mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-08 11:32:47 +00:00
Tidying up generics and removing warnings from portlet module.
This commit is contained in:
parent
7edf9635e7
commit
56c9117484
@ -8,9 +8,11 @@ import javax.portlet.PortletRequest;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class PortletAuthenticationDetails implements Serializable {
|
public class PortletAuthenticationDetails implements Serializable {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
protected final Log logger = LogFactory.getLog(PortletAuthenticationDetails.class);
|
protected final Log logger = LogFactory.getLog(PortletAuthenticationDetails.class);
|
||||||
|
|
||||||
protected Map userInfo;
|
protected Map userInfo;
|
||||||
|
|
||||||
//~ Constructors ===================================================================================================
|
//~ Constructors ===================================================================================================
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.springframework.security.portlet;
|
package org.springframework.security.portlet;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class PortletPreAuthenticatedAuthenticationDetails extends PortletAuthent
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append(super.toString() + "; ");
|
sb.append(super.toString() + "; ");
|
||||||
sb.append("preAuthenticatedGrantedAuthorities: " + Arrays.asList(preAuthenticatedGrantedAuthorities));
|
sb.append("preAuthenticatedGrantedAuthorities: " + preAuthenticatedGrantedAuthorities);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,21 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.portlet.*;
|
import javax.portlet.ActionRequest;
|
||||||
|
import javax.portlet.ActionResponse;
|
||||||
|
import javax.portlet.EventRequest;
|
||||||
|
import javax.portlet.EventResponse;
|
||||||
|
import javax.portlet.PortletRequest;
|
||||||
|
import javax.portlet.PortletResponse;
|
||||||
|
import javax.portlet.PortletSession;
|
||||||
|
import javax.portlet.RenderRequest;
|
||||||
|
import javax.portlet.RenderResponse;
|
||||||
|
import javax.portlet.ResourceRequest;
|
||||||
|
import javax.portlet.ResourceResponse;
|
||||||
|
|
||||||
import org.springframework.security.web.authentication.AbstractProcessingFilter;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
||||||
import org.springframework.security.authentication.AuthenticationDetailsSourceImpl;
|
import org.springframework.security.authentication.AuthenticationDetailsSourceImpl;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
@ -34,9 +46,6 @@ import org.springframework.security.core.AuthenticationException;
|
|||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.web.authentication.AbstractProcessingFilter;
|
import org.springframework.security.web.authentication.AbstractProcessingFilter;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.web.portlet.HandlerInterceptor;
|
import org.springframework.web.portlet.HandlerInterceptor;
|
||||||
import org.springframework.web.portlet.ModelAndView;
|
import org.springframework.web.portlet.ModelAndView;
|
||||||
@ -72,6 +81,7 @@ import org.springframework.web.portlet.ModelAndView;
|
|||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public class PortletProcessingInterceptor implements HandlerInterceptor, InitializingBean {
|
public class PortletProcessingInterceptor implements HandlerInterceptor, InitializingBean {
|
||||||
|
|
||||||
//~ Static fields/initializers =====================================================================================
|
//~ Static fields/initializers =====================================================================================
|
||||||
|
@ -20,18 +20,16 @@ import javax.portlet.PortletSession;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.springframework.security.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.authority.GrantedAuthorityImpl;
|
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.security.core.context.SecurityContextImpl;
|
|
||||||
import org.springframework.security.core.userdetails.User;
|
|
||||||
import org.springframework.security.portlet.PortletSessionContextIntegrationInterceptor;
|
|
||||||
import org.springframework.mock.web.portlet.MockActionRequest;
|
import org.springframework.mock.web.portlet.MockActionRequest;
|
||||||
import org.springframework.mock.web.portlet.MockActionResponse;
|
import org.springframework.mock.web.portlet.MockActionResponse;
|
||||||
import org.springframework.mock.web.portlet.MockRenderRequest;
|
import org.springframework.mock.web.portlet.MockRenderRequest;
|
||||||
import org.springframework.mock.web.portlet.MockRenderResponse;
|
import org.springframework.mock.web.portlet.MockRenderResponse;
|
||||||
|
import org.springframework.security.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||||
|
import org.springframework.security.core.authority.AuthorityUtils;
|
||||||
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.core.context.SecurityContextImpl;
|
||||||
|
import org.springframework.security.core.userdetails.User;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link PortletSessionContextIntegrationInterceptor}.
|
* Tests {@link PortletSessionContextIntegrationInterceptor}.
|
||||||
@ -169,10 +167,10 @@ public class PortletSessionContextIntegrationInterceptorTests extends TestCase {
|
|||||||
// Perform updates to principal
|
// Perform updates to principal
|
||||||
sessionPrincipal = PortletTestUtils.createAuthenticatedToken(
|
sessionPrincipal = PortletTestUtils.createAuthenticatedToken(
|
||||||
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
||||||
new GrantedAuthority[] {new GrantedAuthorityImpl("UPDATEDROLE1")}));
|
AuthorityUtils.createAuthorityList("UPDATEDROLE1")));
|
||||||
baselinePrincipal = PortletTestUtils.createAuthenticatedToken(
|
baselinePrincipal = PortletTestUtils.createAuthenticatedToken(
|
||||||
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
||||||
new GrantedAuthority[] {new GrantedAuthorityImpl("UPDATEDROLE1")}));
|
AuthorityUtils.createAuthorityList("UPDATEDROLE1")));
|
||||||
|
|
||||||
// Store updated principal into SecurityContextHolder
|
// Store updated principal into SecurityContextHolder
|
||||||
SecurityContextHolder.getContext().setAuthentication(sessionPrincipal);
|
SecurityContextHolder.getContext().setAuthentication(sessionPrincipal);
|
||||||
@ -323,10 +321,10 @@ public class PortletSessionContextIntegrationInterceptorTests extends TestCase {
|
|||||||
// Perform updates to principal
|
// Perform updates to principal
|
||||||
sessionPrincipal = PortletTestUtils.createAuthenticatedToken(
|
sessionPrincipal = PortletTestUtils.createAuthenticatedToken(
|
||||||
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
||||||
new GrantedAuthority[] {new GrantedAuthorityImpl("UPDATEDROLE1")}));
|
AuthorityUtils.createAuthorityList("UPDATEDROLE1")));
|
||||||
baselinePrincipal = PortletTestUtils.createAuthenticatedToken(
|
baselinePrincipal = PortletTestUtils.createAuthenticatedToken(
|
||||||
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
new User(PortletTestUtils.TESTUSER, PortletTestUtils.TESTCRED, true, true, true, true,
|
||||||
new GrantedAuthority[] {new GrantedAuthorityImpl("UPDATEDROLE1")}));
|
AuthorityUtils.createAuthorityList("UPDATEDROLE1")));
|
||||||
|
|
||||||
// Store updated principal into SecurityContextHolder
|
// Store updated principal into SecurityContextHolder
|
||||||
SecurityContextHolder.getContext().setAuthentication(sessionPrincipal);
|
SecurityContextHolder.getContext().setAuthentication(sessionPrincipal);
|
||||||
|
@ -18,18 +18,16 @@ package org.springframework.security.portlet;
|
|||||||
|
|
||||||
import javax.portlet.PortletRequest;
|
import javax.portlet.PortletRequest;
|
||||||
|
|
||||||
import org.springframework.security.authentication.TestingAuthenticationToken;
|
|
||||||
import org.springframework.security.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.authority.GrantedAuthorityImpl;
|
|
||||||
import org.springframework.security.core.userdetails.User;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.security.portlet.PortletAuthenticationDetails;
|
|
||||||
import org.springframework.mock.web.portlet.MockActionRequest;
|
import org.springframework.mock.web.portlet.MockActionRequest;
|
||||||
import org.springframework.mock.web.portlet.MockActionResponse;
|
import org.springframework.mock.web.portlet.MockActionResponse;
|
||||||
import org.springframework.mock.web.portlet.MockPortletRequest;
|
import org.springframework.mock.web.portlet.MockPortletRequest;
|
||||||
import org.springframework.mock.web.portlet.MockRenderRequest;
|
import org.springframework.mock.web.portlet.MockRenderRequest;
|
||||||
import org.springframework.mock.web.portlet.MockRenderResponse;
|
import org.springframework.mock.web.portlet.MockRenderResponse;
|
||||||
|
import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||||
|
import org.springframework.security.authentication.preauth.PreAuthenticatedAuthenticationToken;
|
||||||
|
import org.springframework.security.core.authority.AuthorityUtils;
|
||||||
|
import org.springframework.security.core.userdetails.User;
|
||||||
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for testing Portlet (JSR 168) based security.
|
* Utilities for testing Portlet (JSR 168) based security.
|
||||||
@ -54,7 +52,7 @@ public class PortletTestUtils {
|
|||||||
|
|
||||||
public static UserDetails createUser() {
|
public static UserDetails createUser() {
|
||||||
return new User(PortletTestUtils.TESTUSER, "dummy", true, true, true, true,
|
return new User(PortletTestUtils.TESTUSER, "dummy", true, true, true, true,
|
||||||
new GrantedAuthority[] {new GrantedAuthorityImpl(TESTROLE1), new GrantedAuthorityImpl(TESTROLE2)});
|
AuthorityUtils.createAuthorityList(TESTROLE1, TESTROLE2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void applyPortletRequestSecurity(MockPortletRequest request) {
|
public static void applyPortletRequestSecurity(MockPortletRequest request) {
|
||||||
@ -100,7 +98,7 @@ public class PortletTestUtils {
|
|||||||
|
|
||||||
public static PreAuthenticatedAuthenticationToken createAuthenticatedToken(UserDetails user) {
|
public static PreAuthenticatedAuthenticationToken createAuthenticatedToken(UserDetails user) {
|
||||||
PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(
|
PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(
|
||||||
user, user.getPassword(), user.getAuthorities().toArray(new GrantedAuthority[0]));
|
user, user.getPassword(), user.getAuthorities());
|
||||||
result.setAuthenticated(true);
|
result.setAuthenticated(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user