dev@javaserverfaces.java.net

code review request for spec issue 733

From: Sheetal Vartak <sheetal.vartak_at_oracle.com>
Date: Wed, 21 Jul 2010 15:04:18 -0700

Here's a code review request for spec issue 733. I finally managed to get my hosting machine setup for this issue since I needed JDK 5 (which my macbook pro's Snow Leopard does not support ).

The changed files are :
M jsf-api/src/main/java/javax/faces/context/ExternalContext.java
M jsf-ri/test/com/sun/faces/context/TestExternalContextImpl.java
M jsf-ri/src/main/java/com/sun/faces/context/ExternalContextImpl.java
M lib/jsf-extensions-test-time.jar

Here are the diffs :

Index: src/main/java/com/sun/faces/context/ExternalContextImpl.java
===================================================================
--- src/main/java/com/sun/faces/context/ExternalContextImpl.java (revision 8498)
+++ src/main/java/com/sun/faces/context/ExternalContextImpl.java (working copy)
@@ -900,6 +900,14 @@
 
     }
 
+ /**
+ * @see javax.faces.context.ExternalContext#isSecure()
+ * @return boolean
+ */
+ @Override
+ public boolean isSecure() {
+ return ((HttpServletRequest) request).isSecure();
+ }
 
     @Override
     public String encodeBookmarkableURL(String baseUrl,

Index: test/com/sun/faces/context/TestExternalContextImpl.java
===================================================================
--- test/com/sun/faces/context/TestExternalContextImpl.java (revision 8498)
+++ test/com/sun/faces/context/TestExternalContextImpl.java (working copy)
@@ -253,6 +253,11 @@
         }
     }
 
+ public void testIsSecure() {
+ ExternalContext ctx = getFacesContext().getExternalContext();
+ assertTrue(ctx.isSecure() == request.isSecure());
+ }
+
     public void testRequestScheme() {
         ExternalContext ctx = getFacesContext().getExternalContext();
         assertTrue(ctx.getRequestScheme().equals(request.getScheme()));

Index: src/main/java/javax/faces/context/ExternalContext.java
===================================================================
--- src/main/java/javax/faces/context/ExternalContext.java (revision 8498)
+++ src/main/java/javax/faces/context/ExternalContext.java (working copy)
@@ -1904,4 +1904,28 @@
         throw new UnsupportedOperationException();
     }
 
+ /**
+ * <p class="changed_added_2_1">Returns a boolean indicating whether this request
+ * was made using a secure channel, such as HTTPS.
+ *
+ *
+ * <p><em>Servlet:</em> This must return the result of calling
+ * <code>isSecure</code> on the underlying
+ * <code>javax.servlet.http.HttpServletRequest</code> instance.</p>
+ *
+ * <p>The default implementation throws
+ * <code>UnsupportedOperationException</code> and is provided
+ * for the sole purpose of not breaking existing applications that extend
+ * this class.</p>
+ *
+ * @since 2.1
+ */
+ public boolean isSecure() {
+ if (defaultExternalContext != null) {
+ return defaultExternalContext.isSecure();
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+

Thanks
Sheetal