myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sobr...@apache.org
Subject svn commit: r1335837 - in /myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src: main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ main/java/org/apache/myfaces/trinidadinternal/style/ main/java/org/apache/myfaces/trinidadinternal/styl...
Date Tue, 08 May 2012 23:52:46 GMT
Author: sobryan
Date: Tue May  8 23:52:45 2012
New Revision: 1335837

URL: http://svn.apache.org/viewvc?rev=1335837&view=rev
Log:
TRINIDAD-2130 Skinning: support separate style sheets for secure + non-secure pages (backport)

Modified:
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
    myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MFacesContext.java

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java?rev=1335837&r1=1335836&r2=1335837&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/StyleContextImpl.java
Tue May  8 23:52:45 2012
@@ -198,6 +198,17 @@ class StyleContextImpl implements StyleC
   {
     return CoreRenderKit.OUTPUT_MODE_PORTLET.equals(_arc.getOutputMode());
   }
+  
+  @Override
+  public boolean isRequestSecure()
+  {
+    if (_isRequestSecure == null) 
+    {
+      String scheme = FacesContext.getCurrentInstance().getExternalContext().getRequestScheme();
+      _isRequestSecure =  "https".equals(scheme);
+    }
+    return _isRequestSecure;
+  }
 
   /**
    *
@@ -333,6 +344,7 @@ class StyleContextImpl implements StyleC
   private StyleProvider _styleProvider;
   private Styles _styles;
   private Boolean  _isDisableStyleCompression;
+  private Boolean _isRequestSecure;
   static private final String _SKIN_DIRTY_PARAM =
     "org.apache.myfaces.trinidad.skin.dirty";
 

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java?rev=1335837&r1=1335836&r2=1335837&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/StyleContext.java
Tue May  8 23:52:45 2012
@@ -54,4 +54,9 @@ public interface StyleContext
   public boolean isPortletMode();
   public boolean isDisableStyleCompression();
   public boolean isDirty();
+  
+  /**
+   * @return true if the current request is secure (an https request), false otherwise
+   */
+  public boolean isRequestSecure();
 }

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java?rev=1335837&r1=1335836&r2=1335837&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
Tue May  8 23:52:45 2012
@@ -274,6 +274,12 @@ public class FileSystemStyleCache implem
 
       buffer.append(_PORTLET);
     }
+    
+    if (context.isRequestSecure())
+    {
+      buffer.append(_NAME_SEPARATOR);
+      buffer.append(_SECURE);
+    }
 
     buffer.append(_CSS_EXTENSION);
 
@@ -1194,7 +1200,8 @@ public class FileSystemStyleCache implem
        agent.getAgentOS(),
        !context.isDisableStyleCompression(),
        accProfile,
-       context.isPortletMode());
+       context.isPortletMode(),
+       context.isRequestSecure());
     }
 
     @Override
@@ -1207,7 +1214,8 @@ public class FileSystemStyleCache implem
                        (_browser.ordinal() << 2)   ^
                        (_platform << 8)            ^
                        (_short ? 1 : 0)            ^
-                       (_portlet ? 1:0);
+                       ((_portlet ? 1:0) << 1)     ^
+                       ((_secureRequest ? 1: 0) << 3);
 
         if (_locale != null)     _hashCode ^= _locale.hashCode();
         if (_accProfile != null) _hashCode ^= _accProfile.hashCode();
@@ -1234,7 +1242,8 @@ public class FileSystemStyleCache implem
              (_portlet == key._portlet)         &&
              (_direction == key._direction)     &&
              (_browser == key._browser)         &&
-             (_platform == key._platform))
+             (_platform == key._platform)       &&
+             (_secureRequest == key._secureRequest))
         {
           // now check the optional objects
           if ((_version == null) || _version.equals(key._version))
@@ -1254,7 +1263,8 @@ public class FileSystemStyleCache implem
       int platform,
       boolean useShort,
       AccessibilityProfile accessibilityProfile,
-      boolean portlet
+      boolean portlet,
+      boolean secure
       )
     {
       // Make sure direction is non-null
@@ -1272,6 +1282,7 @@ public class FileSystemStyleCache implem
       _short = useShort;
       _accProfile = accessibilityProfile;
       _portlet     = portlet;
+      _secureRequest = secure;
     }
 
     //is immutable, we should cache this, will make things faster in the long run
@@ -1286,6 +1297,7 @@ public class FileSystemStyleCache implem
     private boolean        _short;  // Do we use short style classes?
     private AccessibilityProfile _accProfile;
     private boolean        _portlet; //kind of a hack but tells whether this was created
in portal mode
+    private boolean        _secureRequest;
   }
 
   /**
@@ -1327,6 +1339,7 @@ public class FileSystemStyleCache implem
       System.arraycopy(styleSheets, 0, _styleSheets, 0, styleSheets.length);
       _short = true;
       _portlet = context.isPortletMode();
+      _secureRequest = context.isRequestSecure();
     }
 
     @Override
@@ -1341,6 +1354,7 @@ public class FileSystemStyleCache implem
 
         if ((_short != key._short) ||
             (_portlet != key._portlet) ||
+            (_secureRequest != key._secureRequest) ||
             (_styleSheets.length != key._styleSheets.length))
           return false;
 
@@ -1367,7 +1381,8 @@ public class FileSystemStyleCache implem
       {
         _hashCode = Arrays.hashCode(_styleSheets) ^
                     (_short ? 1 : 0)              ^
-                    (_portlet ? 1 : 0);
+                    (_portlet ? 1 : 0)            ^
+                    ((_secureRequest ? 1: 0) << 3);
         _noHash = false;
       }
 
@@ -1381,6 +1396,7 @@ public class FileSystemStyleCache implem
     private StyleSheetNode[] _styleSheets;
     private boolean _portlet;
     private boolean _short;   // Do we use short style classes?
+    private boolean _secureRequest;
   }
 
   /**
@@ -1566,6 +1582,7 @@ public class FileSystemStyleCache implem
   private static final char _NAME_SEPARATOR = '-';
   private static final String _COMPRESSED = "cmp";
   private static final String _PORTLET = "prtl";
+  private static final String _SECURE = "s";
 
   /** Extension for CSS files */
   private static final String _CSS_EXTENSION = ".css";

Modified: myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MFacesContext.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MFacesContext.java?rev=1335837&r1=1335836&r2=1335837&view=diff
==============================================================================
--- myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MFacesContext.java
(original)
+++ myfaces/trinidad/branches/2.0.0.x-branch/trinidad-impl/src/test/java/org/apache/myfaces/trinidadinternal/renderkit/MFacesContext.java
Tue May  8 23:52:45 2012
@@ -362,6 +362,12 @@ public class MFacesContext extends MockF
       // implementations as those expect a specific number of calls:
       return _requestMap;
     }
+    
+    @Override
+    public String getRequestScheme()
+    {
+      return "http";
+    }
 
     private final Object _contextObject;
     private final Object _requestObject = new String("request object");



Mime
View raw message