Apply code cleanup rules to projects
Apply automated cleanup rules to add `@Override` and `@Deprecated` annotations and to fix class references used with static methods. Issue gh-8945
This commit is contained in:
@@ -35,14 +35,17 @@ package org.springframework.security;
|
||||
*/
|
||||
public class OtherTargetObject extends TargetObject implements ITargetObject {
|
||||
|
||||
@Override
|
||||
public String makeLowerCase(String input) {
|
||||
return super.makeLowerCase(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String makeUpperCase(String input) {
|
||||
return super.makeUpperCase(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String publicMakeLowerCase(String input) {
|
||||
return super.publicMakeLowerCase(input);
|
||||
}
|
||||
|
||||
@@ -26,10 +26,12 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
*/
|
||||
public class TargetObject implements ITargetObject {
|
||||
|
||||
@Override
|
||||
public Integer computeHashCode(String input) {
|
||||
return input.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countLength(String input) {
|
||||
return input.length();
|
||||
}
|
||||
@@ -42,6 +44,7 @@ public class TargetObject implements ITargetObject {
|
||||
* boolean indicating if the <code>Authentication</code> object is authenticated or
|
||||
* not
|
||||
*/
|
||||
@Override
|
||||
public String makeLowerCase(String input) {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
@@ -61,6 +64,7 @@ public class TargetObject implements ITargetObject {
|
||||
* boolean indicating if the <code>Authentication</code> object is authenticated or
|
||||
* not
|
||||
*/
|
||||
@Override
|
||||
public String makeUpperCase(String input) {
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
@@ -71,6 +75,7 @@ public class TargetObject implements ITargetObject {
|
||||
* Delegates through to the {@link #makeLowerCase(String)} method.
|
||||
* @param input the message to be made lower-case
|
||||
*/
|
||||
@Override
|
||||
public String publicMakeLowerCase(String input) {
|
||||
return this.makeLowerCase(input);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TestDataSource extends DriverManagerDataSource implements Disposabl
|
||||
setPassword("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
System.out.println("Shutting down database: " + this.name);
|
||||
new JdbcTemplate(this).execute("SHUTDOWN");
|
||||
|
||||
@@ -88,6 +88,7 @@ public class SecurityConfigTests {
|
||||
this.attribute = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute() {
|
||||
return this.attribute;
|
||||
}
|
||||
|
||||
@@ -23,18 +23,22 @@ import java.util.List;
|
||||
*/
|
||||
public class BusinessServiceImpl<E extends Entity> implements BusinessService {
|
||||
|
||||
@Override
|
||||
@Secured({ "ROLE_USER" })
|
||||
public void someUserMethod1() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Secured({ "ROLE_USER" })
|
||||
public void someUserMethod2() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
|
||||
public void someUserAndAdminMethod() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Secured({ "ROLE_ADMIN" })
|
||||
public void someAdminMethod() {
|
||||
}
|
||||
@@ -43,26 +47,32 @@ public class BusinessServiceImpl<E extends Entity> implements BusinessService {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(int input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> methodReturningAList(List<?> someList) {
|
||||
return someList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> methodReturningAList(String userName, String arg2) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] methodReturningAnArray(Object[] someArray) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rolesAllowedUser() {
|
||||
|
||||
}
|
||||
|
||||
@@ -24,36 +24,45 @@ import org.springframework.security.access.prepost.PreFilter;
|
||||
|
||||
public class ExpressionProtectedBusinessServiceImpl implements BusinessService {
|
||||
|
||||
@Override
|
||||
public void someAdminMethod() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(String s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(int input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void someUserAndAdminMethod() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void someUserMethod1() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void someUserMethod2() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreFilter(filterTarget = "someList", value = "filterObject == authentication.name or filterObject == 'sam'")
|
||||
@PostFilter("filterObject == 'bob'")
|
||||
public List<?> methodReturningAList(List<?> someList) {
|
||||
return someList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Object> methodReturningAList(String userName, String arg2) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostFilter("filterObject == 'bob'")
|
||||
public Object[] methodReturningAnArray(Object[] someArray) {
|
||||
return someArray;
|
||||
@@ -64,6 +73,7 @@ public class ExpressionProtectedBusinessServiceImpl implements BusinessService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rolesAllowedUser() {
|
||||
|
||||
}
|
||||
|
||||
@@ -27,42 +27,52 @@ import javax.annotation.security.RolesAllowed;
|
||||
@PermitAll
|
||||
public class Jsr250BusinessServiceImpl implements BusinessService {
|
||||
|
||||
@Override
|
||||
@RolesAllowed("ROLE_USER")
|
||||
public void someUserMethod1() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@RolesAllowed("ROLE_USER")
|
||||
public void someUserMethod2() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@RolesAllowed({ "ROLE_USER", "ROLE_ADMIN" })
|
||||
public void someUserAndAdminMethod() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@RolesAllowed("ROLE_ADMIN")
|
||||
public void someAdminMethod() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(String input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int someOther(int input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> methodReturningAList(List<?> someList) {
|
||||
return someList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> methodReturningAList(String userName, String arg2) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] methodReturningAnArray(Object[] someArray) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RolesAllowed({ "USER" })
|
||||
public void rolesAllowedUser() {
|
||||
|
||||
|
||||
@@ -245,6 +245,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
|
||||
|
||||
static class Parent implements IParent {
|
||||
|
||||
@Override
|
||||
public void interfaceMethod() {
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
@SuppressWarnings("serial")
|
||||
class DepartmentServiceImpl extends BusinessServiceImpl<Department> implements DepartmentService {
|
||||
|
||||
@Override
|
||||
@Secured({ "ROLE_ADMIN" })
|
||||
public Department someUserMethod3(final Department dept) {
|
||||
return super.someUserMethod3(dept);
|
||||
@@ -236,10 +237,12 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
ADMIN, USER;
|
||||
|
||||
@Override
|
||||
public String getAttribute() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthority() {
|
||||
return toString();
|
||||
}
|
||||
@@ -256,6 +259,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
class CustomSecurityAnnotationMetadataExtractor implements AnnotationMetadataExtractor<CustomSecurityAnnotation> {
|
||||
|
||||
@Override
|
||||
public Collection<? extends ConfigAttribute> extractAttributes(CustomSecurityAnnotation securityAnnotation) {
|
||||
SecurityEnum[] values = securityAnnotation.value();
|
||||
|
||||
@@ -288,6 +292,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
@AnnotatedAnnotation
|
||||
public static class AnnotatedAnnotationAtClassLevel implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -295,6 +300,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class AnnotatedAnnotationAtInterfaceLevel implements ReturnVoid2 {
|
||||
|
||||
@Override
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -302,6 +308,7 @@ public class SecuredAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class AnnotatedAnnotationAtMethodLevel implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
@AnnotatedAnnotation
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -159,12 +159,15 @@ public class MethodExpressionVoterTests {
|
||||
|
||||
private static class TargetImpl implements Target {
|
||||
|
||||
@Override
|
||||
public void methodTakingAnArray(Object[] args) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void methodTakingAString(String argument) {
|
||||
};
|
||||
|
||||
@Override
|
||||
public Collection methodTakingACollection(Collection collection) {
|
||||
return collection;
|
||||
}
|
||||
|
||||
@@ -216,6 +216,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
@PreAuthorize("someExpression")
|
||||
public static class ReturnVoidImpl1 implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -224,6 +225,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
@PreAuthorize("someExpression")
|
||||
public static class ReturnVoidImpl2 implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
@PreFilter(filterTarget = "param", value = "somePreFilterExpression")
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
@@ -232,6 +234,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class ReturnVoidImpl3 implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
@PreFilter(filterTarget = "param", value = "somePreFilterExpression")
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
@@ -240,6 +243,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class ReturnAListImpl1 implements ReturnAList {
|
||||
|
||||
@Override
|
||||
@PostFilter("somePostFilterExpression")
|
||||
public List<?> doSomething(List<?> param) {
|
||||
return param;
|
||||
@@ -249,6 +253,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class ReturnAListImpl2 implements ReturnAList {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("someExpression")
|
||||
@PreFilter(filterTarget = "param", value = "somePreFilterExpression")
|
||||
@PostFilter("somePostFilterExpression")
|
||||
@@ -261,6 +266,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class ReturnAnotherListImpl1 implements ReturnAnotherList {
|
||||
|
||||
@Override
|
||||
public List<?> doSomething(List<?> param) {
|
||||
return param;
|
||||
}
|
||||
@@ -269,6 +275,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class ReturnAnotherListImpl2 implements ReturnAnotherList {
|
||||
|
||||
@Override
|
||||
@PreFilter(filterTarget = "param", value = "classMethodPreFilterExpression")
|
||||
public List<?> doSomething(List<?> param) {
|
||||
return param;
|
||||
@@ -294,6 +301,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
@CustomAnnotation
|
||||
public static class CustomAnnotationAtClassLevel implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -301,6 +309,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class CustomAnnotationAtInterfaceLevel implements ReturnVoid2 {
|
||||
|
||||
@Override
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -308,6 +317,7 @@ public class PrePostAnnotationSecurityMetadataSourceTests {
|
||||
|
||||
public static class CustomAnnotationAtMethodLevel implements ReturnVoid {
|
||||
|
||||
@Override
|
||||
@CustomAnnotation
|
||||
public void doSomething(List<?> param) {
|
||||
}
|
||||
|
||||
@@ -60,10 +60,12 @@ public class AbstractSecurityInterceptorTests {
|
||||
|
||||
private SecurityMetadataSource securityMetadataSource;
|
||||
|
||||
@Override
|
||||
public Class<?> getSecureObjectClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMetadataSource obtainSecurityMetadataSource() {
|
||||
return this.securityMetadataSource;
|
||||
}
|
||||
@@ -78,10 +80,12 @@ public class AbstractSecurityInterceptorTests {
|
||||
|
||||
private SecurityMetadataSource securityMetadataSource;
|
||||
|
||||
@Override
|
||||
public Class<?> getSecureObjectClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityMetadataSource obtainSecurityMetadataSource() {
|
||||
return this.securityMetadataSource;
|
||||
}
|
||||
|
||||
@@ -165,6 +165,7 @@ public class AfterInvocationProviderManagerTests {
|
||||
this.configAttribute = configAttribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
|
||||
Object returnedObject) throws AccessDeniedException {
|
||||
if (config.contains(this.configAttribute)) {
|
||||
@@ -174,10 +175,12 @@ public class AfterInvocationProviderManagerTests {
|
||||
return returnedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return this.secureObject.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
return attribute.equals(this.configAttribute);
|
||||
}
|
||||
|
||||
@@ -41,22 +41,27 @@ public class MockMethodInvocation implements MethodInvocation {
|
||||
this.targetObject = targetObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return this.arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return this.targetObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,7 @@ public class AbstractAccessDecisionManagerTests {
|
||||
super(decisionVoters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) {
|
||||
}
|
||||
|
||||
@@ -143,14 +144,17 @@ public class AbstractAccessDecisionManagerTests {
|
||||
|
||||
private class MockStringOnlyVoter implements AccessDecisionVoter<Object> {
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return String.class.isAssignableFrom(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
throw new UnsupportedOperationException("mock method not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
|
||||
throw new UnsupportedOperationException("mock method not implemented");
|
||||
}
|
||||
|
||||
@@ -33,10 +33,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class AbstractAclVoterTests {
|
||||
|
||||
private AbstractAclVoter voter = new AbstractAclVoter() {
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int vote(Authentication authentication, MethodInvocation object,
|
||||
Collection<ConfigAttribute> attributes) {
|
||||
return 0;
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class DenyAgainVoter implements AccessDecisionVoter<Object> {
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
if ("DENY_AGAIN_FOR_SURE".equals(attribute.getAttribute())) {
|
||||
return true;
|
||||
@@ -44,10 +45,12 @@ public class DenyAgainVoter implements AccessDecisionVoter<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
|
||||
Iterator<ConfigAttribute> iter = attributes.iterator();
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class DenyVoter implements AccessDecisionVoter<Object> {
|
||||
|
||||
@Override
|
||||
public boolean supports(ConfigAttribute attribute) {
|
||||
if ("DENY_FOR_SURE".equals(attribute.getAttribute())) {
|
||||
return true;
|
||||
@@ -46,10 +47,12 @@ public class DenyVoter implements AccessDecisionVoter<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
|
||||
Iterator<ConfigAttribute> iter = attributes.iterator();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.security.access.vote;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.security.access.AccessDecisionVoter;
|
||||
import org.springframework.security.access.SecurityConfig;
|
||||
import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
|
||||
import org.springframework.security.authentication.TestingAuthenticationToken;
|
||||
@@ -35,7 +36,7 @@ public class RoleHierarchyVoterTests {
|
||||
RoleHierarchyVoter voter = new RoleHierarchyVoter(roleHierarchyImpl);
|
||||
|
||||
assertThat(voter.vote(auth, new Object(), SecurityConfig.createList("ROLE_B")))
|
||||
.isEqualTo(RoleHierarchyVoter.ACCESS_GRANTED);
|
||||
.isEqualTo(AccessDecisionVoter.ACCESS_GRANTED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,10 +147,12 @@ public class AbstractAuthenticationTokenTests {
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCredentials() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrincipal() {
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@ public class ProviderManagerTests {
|
||||
@Test(expected = ProviderNotFoundException.class)
|
||||
public void authenticationFailsWithUnsupportedToken() {
|
||||
Authentication token = new AbstractAuthenticationToken(null) {
|
||||
@Override
|
||||
public Object getCredentials() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPrincipal() {
|
||||
return "";
|
||||
}
|
||||
@@ -131,11 +133,13 @@ public class ProviderManagerTests {
|
||||
|
||||
// A provider which sets the details object
|
||||
AuthenticationProvider provider = new AuthenticationProvider() {
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
((TestingAuthenticationToken) authentication).setDetails(resultDetails);
|
||||
return authentication;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return true;
|
||||
}
|
||||
@@ -360,6 +364,7 @@ public class ProviderManagerTests {
|
||||
|
||||
private static class MockProvider implements AuthenticationProvider {
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
if (supports(authentication.getClass())) {
|
||||
return authentication;
|
||||
@@ -369,6 +374,7 @@ public class ProviderManagerTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> authentication) {
|
||||
return TestingAuthenticationToken.class.isAssignableFrom(authentication)
|
||||
|| UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication);
|
||||
|
||||
@@ -685,6 +685,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceReturnsNull implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
return null;
|
||||
}
|
||||
@@ -693,6 +694,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceSimulateBackendError implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
throw new DataRetrievalFailureException("This mock simulator is designed to fail");
|
||||
}
|
||||
@@ -703,6 +705,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private String password = "koala";
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if ("rod".equals(username)) {
|
||||
return new User("rod", this.password, true, true, true, true, ROLES_12);
|
||||
@@ -718,6 +721,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceUserPeter implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if ("peter".equals(username)) {
|
||||
return new User("peter", "opal", false, true, true, true, ROLES_12);
|
||||
@@ -729,6 +733,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceUserPeterAccountExpired implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if ("peter".equals(username)) {
|
||||
return new User("peter", "opal", true, false, true, true, ROLES_12);
|
||||
@@ -740,6 +745,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceUserPeterAccountLocked implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if ("peter".equals(username)) {
|
||||
return new User("peter", "opal", true, true, true, false, ROLES_12);
|
||||
@@ -751,6 +757,7 @@ public class DaoAuthenticationProviderTests {
|
||||
|
||||
private class MockUserDetailsServiceUserPeterCredentialsExpired implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if ("peter".equals(username)) {
|
||||
return new User("peter", "opal", true, true, false, true, ROLES_12);
|
||||
|
||||
@@ -28,14 +28,17 @@ public class MockUserCache implements UserCache {
|
||||
|
||||
private Map<String, UserDetails> cache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public UserDetails getUserFromCache(String username) {
|
||||
return this.cache.get(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putUserInCache(UserDetails user) {
|
||||
this.cache.put(user.getUsername(), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserFromCache(String username) {
|
||||
this.cache.remove(username);
|
||||
}
|
||||
|
||||
@@ -290,6 +290,7 @@ public class JaasAuthenticationProviderTests {
|
||||
super(loginModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout() {
|
||||
this.loggedOut = true;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class JaasEventCheck implements ApplicationListener<JaasAuthenticationEve
|
||||
|
||||
JaasAuthenticationSuccessEvent successEvent;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(JaasAuthenticationEvent event) {
|
||||
if (event instanceof JaasAuthenticationFailedEvent) {
|
||||
this.failedEvent = (JaasAuthenticationFailedEvent) event;
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class TestAuthorityGranter implements AuthorityGranter {
|
||||
|
||||
@Override
|
||||
public Set<String> grant(Principal principal) {
|
||||
Set<String> rtnSet = new HashSet<>();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class TestCallbackHandler implements JaasAuthenticationCallbackHandler {
|
||||
|
||||
@Override
|
||||
public void handle(Callback callback, Authentication auth) {
|
||||
if (callback instanceof TextInputCallback) {
|
||||
TextInputCallback tic = (TextInputCallback) callback;
|
||||
|
||||
@@ -38,14 +38,17 @@ public class TestLoginModule implements LoginModule {
|
||||
|
||||
private Subject subject;
|
||||
|
||||
@Override
|
||||
public boolean abort() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
|
||||
this.subject = subject;
|
||||
@@ -65,6 +68,7 @@ public class TestLoginModule implements LoginModule {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws LoginException {
|
||||
if (!this.user.equals("user")) {
|
||||
throw new LoginException("Bad User");
|
||||
@@ -81,6 +85,7 @@ public class TestLoginModule implements LoginModule {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean logout() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ public class RemoteAuthenticationProviderTests {
|
||||
this.grantAccess = grantAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> attemptAuthentication(String username, String password)
|
||||
throws RemoteAuthenticationException {
|
||||
if (this.grantAccess) {
|
||||
|
||||
@@ -55,6 +55,7 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests
|
||||
this.executor = create();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void constructorNullDelegate() {
|
||||
new DelegatingSecurityContextExecutorService(null);
|
||||
@@ -163,6 +164,7 @@ public abstract class AbstractDelegatingSecurityContextExecutorServiceTests
|
||||
assertThat(result).isEqualTo(exectedResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract DelegatingSecurityContextExecutorService create();
|
||||
|
||||
}
|
||||
|
||||
@@ -135,10 +135,12 @@ public class AnnotationParameterNameDiscovererTests {
|
||||
|
||||
static class DaoImpl extends BaseDaoImpl implements Dao {
|
||||
|
||||
@Override
|
||||
public String findMessageByTo(String to) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findMessageByToAndFrom(@P("to") String to, @P("from") String from) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class MockUserDetailsService implements UserDetailsService {
|
||||
this.users.put("expired", new User("expired", "", true, false, true, true, this.auths));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
if (this.users.get(username) == null) {
|
||||
throw new UsernameNotFoundException("User not found: " + username);
|
||||
|
||||
@@ -403,14 +403,17 @@ public class JdbcUserDetailsManagerTests {
|
||||
|
||||
private Map<String, UserDetails> cache = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public UserDetails getUserFromCache(String username) {
|
||||
return this.cache.get(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putUserInCache(UserDetails user) {
|
||||
this.cache.put(user.getUsername(), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserFromCache(String username) {
|
||||
this.cache.remove(username);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@ public abstract class AbstractSecurityContextSchedulingTaskExecutorTests
|
||||
verify(this.taskExecutorDelegate).prefersShortLivedTasks();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SchedulingTaskExecutor getExecutor() {
|
||||
return this.taskExecutorDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract DelegatingSecurityContextSchedulingTaskExecutor create();
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class CurrentSecurityContextSchedulingTaskExecutorTests
|
||||
currentSecurityContextPowermockSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DelegatingSecurityContextSchedulingTaskExecutor create() {
|
||||
return new DelegatingSecurityContextSchedulingTaskExecutor(this.taskExecutorDelegate);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public class ExplicitSecurityContextSchedulingTaskExecutorTests
|
||||
explicitSecurityContextPowermockSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DelegatingSecurityContextSchedulingTaskExecutor create() {
|
||||
return new DelegatingSecurityContextSchedulingTaskExecutor(this.taskExecutorDelegate, this.securityContext);
|
||||
}
|
||||
|
||||
@@ -65,10 +65,12 @@ public abstract class AbstractDelegatingSecurityContextAsyncTaskExecutorTests
|
||||
verify(getExecutor()).submit(this.wrappedCallable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AsyncTaskExecutor getExecutor() {
|
||||
return this.taskExecutorDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected abstract DelegatingSecurityContextAsyncTaskExecutor create();
|
||||
|
||||
}
|
||||
|
||||
@@ -43,10 +43,12 @@ public class CurrentDelegatingSecurityContextTaskExecutorTests extends AbstractD
|
||||
currentSecurityContextPowermockSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Executor getExecutor() {
|
||||
return this.taskExecutorDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DelegatingSecurityContextExecutor create() {
|
||||
return new DelegatingSecurityContextTaskExecutor(this.taskExecutorDelegate);
|
||||
}
|
||||
|
||||
@@ -43,10 +43,12 @@ public class ExplicitDelegatingSecurityContextTaskExecutorTests extends Abstract
|
||||
explicitSecurityContextPowermockSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Executor getExecutor() {
|
||||
return this.taskExecutorDelegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DelegatingSecurityContextExecutor create() {
|
||||
return new DelegatingSecurityContextTaskExecutor(this.taskExecutorDelegate, this.securityContext);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public class MethodInvocationUtilsTests {
|
||||
|
||||
class AdvisedTarget extends AdvisedSupport implements Blah {
|
||||
|
||||
@Override
|
||||
public void blah() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user