You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2011/03/07 19:59:41 UTC

svn commit: r1078894 - /wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java

Author: mgrigorov
Date: Mon Mar  7 18:59:41 2011
New Revision: 1078894

URL: http://svn.apache.org/viewvc?rev=1078894&view=rev
Log:
WICKET-3514 SimpleTree example not working with CryptoMapper

Make the name of the parameter that brings the encrypted url configurable


Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java

Modified: wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java?rev=1078894&r1=1078893&r2=1078894&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java (original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/mapper/CryptoMapper.java Mon Mar  7 18:59:41 2011
@@ -35,16 +35,19 @@ public class CryptoMapper implements IRe
 {
 	private final IRequestMapper wrappedMapper;
 	private final IProvider<ICrypt> cryptProvider;
+	private final Application application;
 
 	public CryptoMapper(IRequestMapper wrappedMapper, Application application)
 	{
-		this(wrappedMapper, new ApplicationCryptProvider(application));
+		this(wrappedMapper, application, new ApplicationCryptProvider(application));
 	}
 
-	public CryptoMapper(IRequestMapper wrappedMapper, IProvider<ICrypt> cryptProvider)
+	public CryptoMapper(IRequestMapper wrappedMapper, Application application,
+		IProvider<ICrypt> cryptProvider)
 	{
 		this.wrappedMapper = wrappedMapper;
 		this.cryptProvider = cryptProvider;
+		this.application = application;
 	}
 
 	public int getCompatibilityScore(Request request)
@@ -86,7 +89,7 @@ public class CryptoMapper implements IRe
 	{
 		Url encrypted = new Url();
 		String encryptedUrlString = getCrypt().encryptUrlSafe(url.toString());
-		encrypted.addQueryParameter("x", encryptedUrlString);
+		encrypted.addQueryParameter(getCryptParameterName(), encryptedUrlString);
 		return encrypted;
 	}
 
@@ -97,7 +100,8 @@ public class CryptoMapper implements IRe
 			return encryptedUrl;
 		}
 
-		String encryptedUrlString = encryptedUrl.getQueryParameterValue("x").toString();
+		String encryptedUrlString = encryptedUrl.getQueryParameterValue(getCryptParameterName())
+			.toString();
 		if (Strings.isEmpty(encryptedUrlString))
 		{
 			return null;
@@ -117,6 +121,14 @@ public class CryptoMapper implements IRe
 		return url;
 	}
 
+	/**
+	 * @return the name of the parameter that brings the encrypted url
+	 */
+	protected String getCryptParameterName()
+	{
+		return application.getMapperContext().getNamespace();
+	}
+
 	private static class ApplicationCryptProvider implements IProvider<ICrypt>
 	{
 		private final Application application;