Polish
This commit is contained in:
parent
13d9601799
commit
877e6e034c
|
@ -32,7 +32,6 @@ public interface AuthoritiesExtractor {
|
|||
|
||||
/**
|
||||
* Extract the authorities from the resource server's response.
|
||||
*
|
||||
* @param map the response
|
||||
* @return the extracted authorities
|
||||
*/
|
||||
|
|
|
@ -41,19 +41,19 @@ public class FixedAuthoritiesExtractor implements AuthoritiesExtractor {
|
|||
public List<GrantedAuthority> extractAuthorities(Map<String, Object> map) {
|
||||
String authorities = "ROLE_USER";
|
||||
if (map.containsKey(AUTHORITIES)) {
|
||||
Object object = map.get(AUTHORITIES);
|
||||
if (object instanceof Collection) {
|
||||
authorities = StringUtils
|
||||
.collectionToCommaDelimitedString((Collection<?>) object);
|
||||
}
|
||||
else if (ObjectUtils.isArray(object)) {
|
||||
authorities = StringUtils.arrayToCommaDelimitedString((Object[]) object);
|
||||
}
|
||||
else if (object != null) {
|
||||
authorities = object.toString();
|
||||
}
|
||||
authorities = asAuthorities(map.get(AUTHORITIES));
|
||||
}
|
||||
return AuthorityUtils.commaSeparatedStringToAuthorityList(authorities);
|
||||
}
|
||||
|
||||
private String asAuthorities(Object object) {
|
||||
if (object instanceof Collection) {
|
||||
return StringUtils.collectionToCommaDelimitedString((Collection<?>) object);
|
||||
}
|
||||
if (ObjectUtils.isArray(object)) {
|
||||
return StringUtils.arrayToCommaDelimitedString((Object[]) object);
|
||||
}
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.junit.Test;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests for {@link FixedAuthoritiesExtractor}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class FixedAuthoritiesExtractorTests {
|
||||
|
|
|
@ -204,8 +204,10 @@ public class ResourceServerTokenServicesConfigurationTests {
|
|||
return AuthorityUtils
|
||||
.commaSeparatedStringToAuthorityList("ROLE_ADMIN");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Import({ OAuth2RestOperationsConfiguration.class })
|
||||
|
|
|
@ -96,7 +96,6 @@ public abstract class LoggingSystem {
|
|||
* Returns a {@link Runnable} that can handle shutdown of this logging system when the
|
||||
* JVM exits. The default implementation returns {@code null}, indicating that no
|
||||
* shutdown is required.
|
||||
*
|
||||
* @return the shutdown handler, or {@code null}
|
||||
*/
|
||||
public Runnable getShutdownHandler() {
|
||||
|
|
|
@ -414,4 +414,5 @@ public class LoggingApplicationListenerTests {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue