Author: etnu
Date: Tue Jan 13 14:45:38 2009
New Revision: 734266
URL: http://svn.apache.org/viewvc?rev=734266&view=rev
Log:
Applied patch for SHINDIG-792 from Henning Schmiedehausen.
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/UrlParameterAuthenticationHandler.java
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/UrlParameterAuthenticationHandler.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/UrlParameterAuthenticationHandler.java?rev=734266&r1=734265&r2=734266&view=diff
==============================================================================
---
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/UrlParameterAuthenticationHandler.java
(original)
+++
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/UrlParameterAuthenticationHandler.java
Tue Jan 13 14:45:38 2009
@@ -17,8 +17,6 @@
*/
package org.apache.shindig.auth;
-import com.google.inject.Inject;
-
import java.util.Collections;
import java.util.Map;
import java.util.logging.Level;
@@ -26,6 +24,8 @@
import javax.servlet.http.HttpServletRequest;
+import com.google.inject.Inject;
+
/**
* Produces security tokens by extracting the "st" parameter from the request
url or post body.
*/
@@ -34,13 +34,14 @@
private static final String TOKEN_PARAM = "st";
- private static final Logger logger = Logger.getLogger(
- UrlParameterAuthenticationHandler.class.getName());
+ private static final Logger logger = Logger
+ .getLogger(UrlParameterAuthenticationHandler.class.getName());
private final SecurityTokenDecoder securityTokenDecoder;
@Inject
- public UrlParameterAuthenticationHandler(SecurityTokenDecoder
securityTokenDecoder) {
+ public UrlParameterAuthenticationHandler(
+ SecurityTokenDecoder securityTokenDecoder) {
this.securityTokenDecoder = securityTokenDecoder;
}
@@ -50,14 +51,26 @@
public SecurityToken getSecurityTokenFromRequest(HttpServletRequest request)
{
try {
- String token = request.getParameter(TOKEN_PARAM);
- if (token == null) return null;
- Map<String, String> parameters
- = Collections.singletonMap(SecurityTokenDecoder.SECURITY_TOKEN_NAME,
token);
+ Map<String, String> parameters = getMappedParameters(request);
+ if (parameters.get(SecurityTokenDecoder.SECURITY_TOKEN_NAME) == null) {
+ return null;
+ }
return securityTokenDecoder.createToken(parameters);
} catch (SecurityTokenException e) {
logger.log(Level.INFO, "Valid security token not found.", e);
return null;
}
}
+
+ protected SecurityTokenDecoder getSecurityTokenDecoder() {
+ return this.securityTokenDecoder;
+ }
+
+ protected Map<String, String> getMappedParameters(
+ final HttpServletRequest request) {
+ String token = request.getParameter(TOKEN_PARAM);
+ return Collections.singletonMap(SecurityTokenDecoder.SECURITY_TOKEN_NAME,
+ token);
+ }
+
}