You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2006/06/03 06:08:52 UTC
svn commit: r411376 -
/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java
Author: dennisbyrne
Date: Fri Jun 2 21:08:52 2006
New Revision: 411376
URL: http://svn.apache.org/viewvc?rev=411376&view=rev
Log:
MYFACES-1318 & MYFACES-1319
compression is now optional and moved *before* encryption
Modified:
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java?rev=411376&r1=411375&r2=411376&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/StateUtils.java Fri Jun 2 21:08:52 2006
@@ -104,6 +104,8 @@
public static final String SERIAL_FACTORY = INIT_PREFIX + "SERIAL_FACTORY";
+ private static final String COMPRESS_STATE_IN_CLIENT = INIT_PREFIX + "COMPRESS_STATE_IN_CLIENT";
+
/** Utility class, do not instatiate */
private StateUtils()
{
@@ -123,6 +125,14 @@
}
+ public static boolean enableCompression(ExternalContext ctx)
+ {
+ if(ctx == null)
+ throw new NullPointerException("ExternalContext ctx");
+
+ return "true".equals(ctx.getInitParameter(COMPRESS_STATE_IN_CLIENT));
+ }
+
public static boolean isSecure(ExternalContext ctx)
{
@@ -138,9 +148,10 @@
public static final String construct(Object object, ExternalContext ctx){
byte[] bytes = getAsByteArray(object, ctx);
+ if( enableCompression(ctx) )
+ bytes = compress(bytes);
if(isSecure(ctx))
bytes = encrypt(bytes, ctx);
- bytes = compress(bytes);
bytes = encode(bytes);
try
{
@@ -223,9 +234,10 @@
{
bytes = string.getBytes(ZIP_CHARSET);
bytes = decode(bytes);
- bytes = decompress(bytes);
if(isSecure(ctx))
bytes = decrypt(bytes, ctx);
+ if( enableCompression(ctx) )
+ bytes = decompress(bytes);
return getAsObject(bytes, ctx);
}
catch (UnsupportedEncodingException e)