SEC-1183: Modified Attributes2GrantedAuthoritiesMapper to return Collection<? extends GrantedAuthority>.

This commit is contained in:
Luke Taylor
2010-11-02 14:02:55 +00:00
parent 84efffb937
commit 43ec2beec0
14 changed files with 63 additions and 96 deletions

View File

@@ -1,7 +1,7 @@
package org.springframework.security.core.authority;
import java.io.Serializable;
import java.util.List;
import java.util.*;
import org.springframework.security.core.GrantedAuthority;
@@ -16,5 +16,5 @@ import org.springframework.security.core.GrantedAuthority;
* @since 2.0
*/
public interface GrantedAuthoritiesContainer extends Serializable {
List<GrantedAuthority> getGrantedAuthorities();
Collection<? extends GrantedAuthority> getGrantedAuthorities();
}

View File

@@ -1,7 +1,6 @@
package org.springframework.security.core.authority;
import java.util.Collections;
import java.util.List;
import java.util.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.util.Assert;
@@ -10,8 +9,10 @@ import org.springframework.util.Assert;
public class GrantedAuthoritiesContainerImpl implements MutableGrantedAuthoritiesContainer {
private List<GrantedAuthority> authorities;
public void setGrantedAuthorities(List<GrantedAuthority> newAuthorities) {
authorities = Collections.unmodifiableList(newAuthorities);
public void setGrantedAuthorities(Collection<? extends GrantedAuthority> newAuthorities) {
ArrayList<GrantedAuthority> temp = new ArrayList<GrantedAuthority>(newAuthorities.size());
temp.addAll(newAuthorities);
authorities = Collections.unmodifiableList(temp);
}
public List<GrantedAuthority> getGrantedAuthorities() {

View File

@@ -1,9 +1,9 @@
package org.springframework.security.core.authority;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import java.util.*;
/**
* Indicates that a object can be used to store and retrieve GrantedAuthority objects.
* <p>
@@ -19,5 +19,5 @@ public interface MutableGrantedAuthoritiesContainer extends GrantedAuthoritiesCo
/**
* Used to store authorities in the containing object.
*/
void setGrantedAuthorities(List<GrantedAuthority> authorities);
void setGrantedAuthorities(Collection<? extends GrantedAuthority> authorities);
}

View File

@@ -7,21 +7,21 @@ import org.springframework.security.core.GrantedAuthority;
/**
* Interface to be implemented by classes that can map a list of security attributes (such as roles or
* group names) to a list of Spring Security GrantedAuthorities.
* group names) to a collection of Spring Security {@code GrantedAuthority}s.
*
* @author Ruud Senden
* @since 2.0
*/
public interface Attributes2GrantedAuthoritiesMapper {
/**
* Implementations of this method should map the given list of attributes to a
* list of Spring Security GrantedAuthorities. There are no restrictions for the
* Implementations of this method should map the given collection of attributes to a
* collection of Spring Security GrantedAuthorities. There are no restrictions for the
* mapping process; a single attribute can be mapped to multiple Spring Security
* GrantedAuthorities, all attributes can be mapped to a single Spring Security
* GrantedAuthority, some attributes may not be mapped, etc.
* {@code GrantedAuthority}, some attributes may not be mapped, etc.
*
* @param attributes the attributes to be mapped
* @return the list of mapped GrantedAuthorities
* @return the collection of authorities created from the attributes
*/
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes);
public Collection<? extends GrantedAuthority> getGrantedAuthorities(Collection<String> attributes);
}

View File

@@ -1,13 +1,6 @@
package org.springframework.security.core.authority.mapping;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.*;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.security.core.GrantedAuthority;