Authorities authenticate TestingAuthenticationToken

In other extensions of `AbstractAuthenticationToken`, the constructors
that include `authorities` call `setAuthenticated(true)`. This includes
`PreAuthenticated`-, `UsernamePassword`-, and
`RememberMeAuthenticationToken`.

This change brings `TestingAuthenticationToken` in line with that
convention.

Note that this was done once already to one of the constructors
(ee13be4) in `TestingAuthenticationToken` that takes an arity of
`authorities`. It was not propagated to the constructor that takes a
collection, which is what this commit remedies.

Fixes: gh-5097
This commit is contained in:
Josh Cummings
2018-03-07 14:20:14 -07:00
committed by Rob Winch
parent 5854f00977
commit 72080bb5fe
3 changed files with 62 additions and 11 deletions

View File

@@ -16,11 +16,11 @@
package org.springframework.security.authentication;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import java.util.List;
/**
* An {@link org.springframework.security.core.Authentication} implementation that is
* designed for use whilst unit testing.
@@ -49,7 +49,6 @@ public class TestingAuthenticationToken extends AbstractAuthenticationToken {
public TestingAuthenticationToken(Object principal, Object credentials,
String... authorities) {
this(principal, credentials, AuthorityUtils.createAuthorityList(authorities));
setAuthenticated(true);
}
public TestingAuthenticationToken(Object principal, Object credentials,
@@ -57,6 +56,7 @@ public class TestingAuthenticationToken extends AbstractAuthenticationToken {
super(authorities);
this.principal = principal;
this.credentials = credentials;
setAuthenticated(true);
}
// ~ Methods