|
@@ -1,23 +1,29 @@
|
|
|
package org.springframework.security.ui.preauth.j2ee;
|
|
|
|
|
|
import org.springframework.security.ui.preauth.PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails;
|
|
|
-import org.springframework.security.ui.AuthenticationDetailsSourceImpl;
|
|
|
+import org.springframework.security.ui.WebAuthenticationDetailsSource;
|
|
|
import org.springframework.security.providers.preauth.PreAuthenticatedGrantedAuthoritiesSetter;
|
|
|
import org.springframework.security.GrantedAuthority;
|
|
|
import org.springframework.security.authoritymapping.Attributes2GrantedAuthoritiesMapper;
|
|
|
import org.springframework.security.authoritymapping.MappableAttributesRetriever;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
-import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
-public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends AuthenticationDetailsSourceImpl implements InitializingBean {
|
|
|
+/**
|
|
|
+ * Extended AuthenticationDetailsSource which allows
|
|
|
+ *
|
|
|
+ * @author Ruud Senden
|
|
|
+ * @since 2.0
|
|
|
+ */
|
|
|
+public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends WebAuthenticationDetailsSource implements InitializingBean {
|
|
|
private static final Log logger = LogFactory.getLog(J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource.class);
|
|
|
|
|
|
private String[] j2eeMappableRoles;
|
|
@@ -41,18 +47,18 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends Aut
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Build the authentication details object. If the speficied authentication
|
|
|
+ * Build the authentication details object. If the specified authentication
|
|
|
* details class implements the PreAuthenticatedGrantedAuthoritiesSetter, a
|
|
|
* list of pre-authenticated Granted Authorities will be set based on the
|
|
|
* J2EE roles for the current user.
|
|
|
*
|
|
|
- * @see org.springframework.security.ui.AuthenticationDetailsSource#buildDetails(javax.servlet.http.HttpServletRequest)
|
|
|
+ * @see org.springframework.security.ui.AuthenticationDetailsSource#buildDetails(Object)
|
|
|
*/
|
|
|
- public Object buildDetails(HttpServletRequest request) {
|
|
|
- Object result = super.buildDetails(request);
|
|
|
+ public Object buildDetails(Object context) {
|
|
|
+ Object result = super.buildDetails(context);
|
|
|
if (result instanceof PreAuthenticatedGrantedAuthoritiesSetter) {
|
|
|
((PreAuthenticatedGrantedAuthoritiesSetter) result)
|
|
|
- .setPreAuthenticatedGrantedAuthorities(getJ2eeBasedGrantedAuthorities(request));
|
|
|
+ .setPreAuthenticatedGrantedAuthorities(getJ2eeBasedGrantedAuthorities((HttpServletRequest)context));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
@@ -76,8 +82,8 @@ public class J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource extends Aut
|
|
|
j2eeUserRoles = (String[]) j2eeUserRolesList.toArray(j2eeUserRoles);
|
|
|
GrantedAuthority[] userGas = j2eeUserRoles2GrantedAuthoritiesMapper.getGrantedAuthorities(j2eeUserRoles);
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
- logger.debug("J2EE user roles [" + StringUtils.join(j2eeUserRoles) + "] mapped to Granted Authorities: ["
|
|
|
- + StringUtils.join(userGas) + "]");
|
|
|
+ logger.debug("J2EE user roles [" + j2eeUserRolesList + "] mapped to Granted Authorities: ["
|
|
|
+ + Arrays.asList(userGas) + "]");
|
|
|
}
|
|
|
return userGas;
|
|
|
}
|