Fixed sandbox build
This commit is contained in:
parent
fc9a1f0242
commit
6a0da5fe67
|
@ -16,14 +16,21 @@
|
|||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>org.springframework.test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package org.springframework.security.captcha;
|
||||
|
||||
import org.springframework.security.ConfigAttribute;
|
||||
import org.springframework.security.ConfigAttributeDefinition;
|
||||
|
||||
import org.springframework.security.context.SecurityContextHolder;
|
||||
|
||||
|
@ -77,8 +76,7 @@ public abstract class CaptchaChannelProcessorTemplate implements ChannelProcesso
|
|||
Assert.hasLength(keyword, "keyword required");
|
||||
}
|
||||
|
||||
public void decide(FilterInvocation invocation, ConfigAttributeDefinition config)
|
||||
throws IOException, ServletException {
|
||||
public void decide(FilterInvocation invocation, java.util.List<ConfigAttribute> config) throws IOException, ServletException {
|
||||
if ((invocation == null) || (config == null)) {
|
||||
throw new IllegalArgumentException("Nulls cannot be provided");
|
||||
}
|
||||
|
@ -86,7 +84,7 @@ public abstract class CaptchaChannelProcessorTemplate implements ChannelProcesso
|
|||
CaptchaSecurityContext context = null;
|
||||
context = (CaptchaSecurityContext) SecurityContextHolder.getContext();
|
||||
|
||||
Iterator iter = config.getConfigAttributes().iterator();
|
||||
Iterator iter = config.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
ConfigAttribute attribute = (ConfigAttribute) iter.next();
|
||||
|
|
|
@ -181,8 +181,7 @@ public class CaptchaEntryPoint implements ChannelEntryPoint, InitializingBean {
|
|||
}
|
||||
}
|
||||
|
||||
public void commence(ServletRequest request, ServletResponse response)
|
||||
throws IOException, ServletException {
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||
StringBuffer redirectUrl = new StringBuffer();
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.springframework.security.captcha;
|
|||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.security.ConfigAttributeDefinition;
|
||||
import org.springframework.security.ConfigAttribute;
|
||||
import org.springframework.security.SecurityConfig;
|
||||
|
||||
import org.springframework.security.context.SecurityContextHolder;
|
||||
|
@ -28,6 +28,7 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
|||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.FilterChain;
|
||||
|
@ -44,7 +45,7 @@ import javax.servlet.ServletResponse;
|
|||
public class CaptchaChannelProcessorTemplateTests extends TestCase {
|
||||
//~ Methods ========================================================================================================
|
||||
|
||||
private MockHttpServletResponse decideWithNewResponse(ConfigAttributeDefinition cad,
|
||||
private MockHttpServletResponse decideWithNewResponse(List<ConfigAttribute> cad,
|
||||
CaptchaChannelProcessorTemplate processor, MockHttpServletRequest request)
|
||||
throws IOException, ServletException {
|
||||
MockHttpServletResponse response;
|
||||
|
@ -70,7 +71,7 @@ public class CaptchaChannelProcessorTemplateTests extends TestCase {
|
|||
CaptchaChannelProcessorTemplate processor = new TestHumanityCaptchaChannelProcessor();
|
||||
processor.setKeyword("X");
|
||||
|
||||
ConfigAttributeDefinition cad = new ConfigAttributeDefinition("Y");
|
||||
List<ConfigAttribute> cad = SecurityConfig.createList("Y");
|
||||
|
||||
CaptchaSecurityContext context = new CaptchaSecurityContextImpl();
|
||||
SecurityContextHolder.setContext(context);
|
||||
|
@ -136,7 +137,7 @@ public class CaptchaChannelProcessorTemplateTests extends TestCase {
|
|||
CaptchaChannelProcessorTemplate processor = new TestHumanityCaptchaChannelProcessor();
|
||||
processor.setKeyword("X");
|
||||
|
||||
ConfigAttributeDefinition cad = new ConfigAttributeDefinition("X");
|
||||
List<ConfigAttribute> cad = SecurityConfig.createList("X");
|
||||
CaptchaSecurityContext context = new CaptchaSecurityContextImpl();
|
||||
SecurityContextHolder.setContext(context);
|
||||
|
||||
|
@ -224,5 +225,5 @@ public class CaptchaChannelProcessorTemplateTests extends TestCase {
|
|||
public void doFilter(ServletRequest arg0, ServletResponse arg1) throws IOException, ServletException {
|
||||
throw new UnsupportedOperationException("mock method not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.springframework.security.context.SecurityContextHolder;
|
||||
|
||||
import org.springframework.security.util.MockFilter;
|
||||
import org.springframework.security.util.MockFilterChain;
|
||||
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
|
|
@ -17,19 +17,26 @@
|
|||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>org.springframework.test</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>org.springframework.jdbc</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ldap</groupId>
|
||||
<artifactId>spring-ldap</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<artifactId>spring-ldap-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -45,27 +52,26 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<optional>true</optional>
|
||||
<artifactId>com.springsource.org.aspectj.runtime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<artifactId>com.springsource.org.aspectj.weaver</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ldapsdk</groupId>
|
||||
<artifactId>ldapsdk</artifactId>
|
||||
<version>4.1</version>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.samba.jcifs</groupId>
|
||||
<artifactId>jcifs</artifactId>
|
||||
<version>1.2.6</version>
|
||||
<type>jar</type>
|
||||
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
|
|
|
@ -28,8 +28,8 @@ import netscape.ldap.ber.stream.BERSequence;
|
|||
import netscape.ldap.ber.stream.BERTag;
|
||||
import netscape.ldap.ber.stream.BERTagDecoder;
|
||||
|
||||
import org.springframework.security.ldap.LdapDataAccessException;
|
||||
import org.springframework.security.ldap.ppolicy.PasswordPolicyControl;
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -98,7 +98,7 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
|
|||
try {
|
||||
decoder.decode();
|
||||
} catch (IOException e) {
|
||||
throw new LdapDataAccessException("Failed to parse control value", e);
|
||||
throw new DataRetrievalFailureException("Failed to parse control value", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,6 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
|
|||
/**
|
||||
* Returns the unchanged value of the response control. Returns the unchanged value of the response
|
||||
* control as byte array.
|
||||
*
|
||||
* @return DOCUMENT ME!
|
||||
*/
|
||||
public byte[] getEncodedValue() {
|
||||
return encodedValue;
|
||||
|
@ -287,7 +285,7 @@ public class PasswordPolicyResponseControl extends PasswordPolicyControl {
|
|||
}
|
||||
}
|
||||
|
||||
throw new LdapDataAccessException("Unexpected tag " + tag);
|
||||
throw new DataRetrievalFailureException("Unexpected tag " + tag);
|
||||
}
|
||||
|
||||
private void setInChoice(boolean inChoice) {
|
||||
|
|
|
@ -22,6 +22,8 @@ import org.springframework.security.GrantedAuthority;
|
|||
import org.springframework.security.userdetails.UserDetails;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Maps user (loaded from the primary user accounts repository, e.g. LDAP) to username in secondary
|
||||
* user accounts repository. Tries to find user's authority with name starting with
|
||||
|
@ -53,9 +55,9 @@ public class AuthorityByPrefixAccountMapper implements AccountMapper, Initializi
|
|||
}
|
||||
|
||||
// search authorities for authority prefix
|
||||
GrantedAuthority[] authorities = user.getAuthorities();
|
||||
for (int i = 0; i < authorities.length; i++) {
|
||||
String authority = authorities[i].getAuthority();
|
||||
List<GrantedAuthority> authorities = user.getAuthorities();
|
||||
for (int i = 0; i < authorities.size(); i++) {
|
||||
String authority = authorities.get(i).getAuthority();
|
||||
if (authority.startsWith(this.getAuthorityPrefix())) {
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("Authority found=[" + authority + "]");
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.springframework.security.userdetails.UserDetails;
|
|||
import org.springframework.security.userdetails.UserDetailsService;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* The context mapper used by the LDAP authentication provider to create an LDAP user object.
|
||||
* Creates the final <tt>UserDetails</tt> object that will be returned by the provider once the
|
||||
|
@ -95,7 +96,7 @@ public class ReplacingUserDetailsMapper extends LdapUserDetailsMapper implements
|
|||
* the user has been authenticated, replacing the original <tt>UserDetails</tt> object.
|
||||
*/
|
||||
public UserDetails mapUserFromContext(DirContextOperations ctx, String username,
|
||||
GrantedAuthority[] authorities) {
|
||||
List<GrantedAuthority> authorities) {
|
||||
UserDetails userOriginal = super.mapUserFromContext(ctx, username, authorities);
|
||||
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.springframework.security.userdetails.ldap;
|
||||
|
||||
|
@ -10,16 +10,18 @@ import org.springframework.security.GrantedAuthorityImpl;
|
|||
import org.springframework.security.userdetails.User;
|
||||
import org.springframework.security.userdetails.UserDetails;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AuthorityByPrefixAccountMapperTest extends TestCase {
|
||||
AuthorityByPrefixAccountMapper mapper;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -28,7 +30,7 @@ public class AuthorityByPrefixAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -43,7 +45,7 @@ public class AuthorityByPrefixAccountMapperTest extends TestCase {
|
|||
String expectedAuthority = "prefix1_role1";
|
||||
GrantedAuthority[] authorities = { new GrantedAuthorityImpl(expectedAuthority),
|
||||
new GrantedAuthorityImpl("prefix1_role2") };
|
||||
UserDetails user = new User("username1", "password1", false, authorities);
|
||||
UserDetails user = new User("username1", "password1", false, false, false, false, Arrays.asList(authorities));
|
||||
mapper.setAuthorityPrefix("prefix1_");
|
||||
String authority = mapper.map(user);
|
||||
|
||||
|
@ -57,7 +59,7 @@ public class AuthorityByPrefixAccountMapperTest extends TestCase {
|
|||
public final void testAuthorityNotFoundThrowsException() {
|
||||
String expectedAuthority = "prefix1_role1";
|
||||
GrantedAuthority[] authorities = { new GrantedAuthorityImpl(expectedAuthority) };
|
||||
UserDetails user = new User("username1", "password1", false, authorities);
|
||||
UserDetails user = new User("username1", "password1", false, false, false, false, Arrays.asList(authorities));
|
||||
mapper.setAuthorityPrefix("NoMatchPrefix");
|
||||
|
||||
try {
|
||||
|
|
|
@ -23,10 +23,11 @@ import org.springframework.security.userdetails.UsernameNotFoundException;
|
|||
import org.springframework.security.userdetails.memory.InMemoryDaoImpl;
|
||||
import org.springframework.security.userdetails.memory.UserMap;
|
||||
import org.springframework.security.userdetails.memory.UserMapEditor;
|
||||
import org.springframework.security.util.AuthorityUtils;
|
||||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ReplacingUserDetailsMapperTest extends TestCase {
|
||||
|
||||
|
@ -34,7 +35,7 @@ public class ReplacingUserDetailsMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -43,7 +44,7 @@ public class ReplacingUserDetailsMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -118,9 +119,9 @@ public class ReplacingUserDetailsMapperTest extends TestCase {
|
|||
ctx.setAttributeValues("userRole", new String[] { "X", "Y", "Z" });
|
||||
ctx.setAttributeValue("uid", "ani");
|
||||
|
||||
UserDetails userDetails = mapper.mapUserFromContext(ctx, "ani", new GrantedAuthority[0]);
|
||||
UserDetails userDetails = mapper.mapUserFromContext(ctx, "ani", AuthorityUtils.NO_AUTHORITIES);
|
||||
// verify that userDetails came from the secondary repository
|
||||
assertEquals("ROLE_ONE", userDetails.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_ONE", userDetails.getAuthorities().get(0).getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,7 +142,7 @@ public class ReplacingUserDetailsMapperTest extends TestCase {
|
|||
|
||||
UserDetails userDetails = mapper.retrieveUser(username);
|
||||
|
||||
assertEquals("ROLE_ONE", userDetails.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_ONE", userDetails.getAuthorities().get(0).getAuthority());
|
||||
|
||||
try {
|
||||
mapper.retrieveUser("noMatchUsername");
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.springframework.security.userdetails.UserDetails;
|
|||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -39,7 +39,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -52,7 +52,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
*/
|
||||
public final void testNormalOperation() {
|
||||
String usernameExpected = "username1";
|
||||
UserDetails user = new User(usernameExpected, "password1", false, new GrantedAuthority[0]);
|
||||
UserDetails user = new User(usernameExpected, "password1", false, false, false, false, new GrantedAuthority[0]);
|
||||
mapper.setUsername(usernameExpected);
|
||||
String username = mapper.map(user);
|
||||
|
||||
|
|
|
@ -25,26 +25,16 @@ import org.springframework.security.userdetails.memory.UserMapEditor;
|
|||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UserDetailsMappingServiceWrapperTest extends TestCase {
|
||||
|
||||
UserDetailsMappingServiceWrapper service;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
service = new UserDetailsMappingServiceWrapper();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
service = null;
|
||||
}
|
||||
|
@ -84,11 +74,11 @@ public class UserDetailsMappingServiceWrapperTest extends TestCase {
|
|||
service.setUserDetailsService(dao);
|
||||
}
|
||||
|
||||
Authentication authentication = new TestingAuthenticationToken("any", "any", null);
|
||||
Authentication authentication = new TestingAuthenticationToken("any", "any");
|
||||
UserDetails user = service.loadUserDetails(authentication);
|
||||
|
||||
// verify that userDetails came from the secondary repository
|
||||
assertEquals("ROLE_ONE", user.getAuthorities()[0].getAuthority());
|
||||
assertEquals("ROLE_ONE", user.getAuthorities().get(0).getAuthority());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.springframework.security.providers.TestingAuthenticationToken;
|
|||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -38,7 +38,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -51,7 +51,7 @@ public class UsernameFromPropertyAccountMapperTest extends TestCase {
|
|||
*/
|
||||
public final void testNormalOperation() {
|
||||
String usernameExpected = "username1";
|
||||
Authentication authenticationRequest = new TestingAuthenticationToken("any", "any", null);
|
||||
Authentication authenticationRequest = new TestingAuthenticationToken("any", "any");
|
||||
mapper.setUsername(usernameExpected);
|
||||
|
||||
String username = mapper.map(authenticationRequest);
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.springframework.security.providers.TestingAuthenticationToken;
|
|||
|
||||
/**
|
||||
* @author Valery Tydykov
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UsernameFromRequestAccountMapperTest extends TestCase {
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class UsernameFromRequestAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
|
@ -38,7 +38,7 @@ public class UsernameFromRequestAccountMapperTest extends TestCase {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see junit.framework.TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
|
@ -51,8 +51,7 @@ public class UsernameFromRequestAccountMapperTest extends TestCase {
|
|||
*/
|
||||
public final void testNormalOperation() {
|
||||
String usernameExpected = "username1";
|
||||
Authentication authenticationRequest = new TestingAuthenticationToken(usernameExpected,
|
||||
"password1", null);
|
||||
Authentication authenticationRequest = new TestingAuthenticationToken(usernameExpected, "password1");
|
||||
String username = mapper.map(authenticationRequest);
|
||||
|
||||
assertEquals(usernameExpected, username);
|
||||
|
|
|
@ -15,37 +15,37 @@
|
|||
|
||||
package org.springframework.security.vote;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.security.AccessDeniedException;
|
||||
import org.springframework.security.Authentication;
|
||||
import org.springframework.security.ConfigAttributeDefinition;
|
||||
import org.springframework.security.ConfigAttribute;
|
||||
|
||||
/**
|
||||
* AccessDecisionManager which bases its result on the first non-abstention from
|
||||
* its list of voters.
|
||||
*
|
||||
* @author Janning Vygen
|
||||
* its list of voters.
|
||||
*
|
||||
* @author Janning Vygen
|
||||
*/
|
||||
public class FirstDecisionBased extends AbstractAccessDecisionManager {
|
||||
|
||||
public void decide(Authentication authentication, Object object, ConfigAttributeDefinition config ) throws AccessDeniedException {
|
||||
public void decide(Authentication authentication, Object object, List<ConfigAttribute> config ) throws AccessDeniedException {
|
||||
Iterator voters = this.getDecisionVoters().iterator();
|
||||
|
||||
while (voters.hasNext()) {
|
||||
AccessDecisionVoter voter = (AccessDecisionVoter) voters.next();
|
||||
int result = voter.vote(authentication, object, config);
|
||||
|
||||
|
||||
switch (result) {
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
return;
|
||||
|
||||
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
throw new AccessDeniedException(messages.getMessage("AbstractAccessDecisionManager.accessDenied", "Access is denied"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// To get this far, every AccessDecisionVoter abstained
|
||||
checkAllowIfAllAbstainDecisions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue