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:
Phillip Webb
2020-07-26 12:04:13 -07:00
committed by Rob Winch
parent 8866fa6fb0
commit 9e08b51ed3
558 changed files with 1418 additions and 102 deletions

View File

@@ -56,14 +56,17 @@ public class Jsr250MethodSecurityMetadataSource extends AbstractFallbackMethodSe
this.defaultRolePrefix = defaultRolePrefix;
}
@Override
protected Collection<ConfigAttribute> findAttributes(Class<?> clazz) {
return processAnnotations(clazz.getAnnotations());
}
@Override
protected Collection<ConfigAttribute> findAttributes(Method method, Class<?> targetClass) {
return processAnnotations(AnnotationUtils.getAnnotations(method));
}
@Override
public Collection<ConfigAttribute> getAllConfigAttributes() {
return null;
}

View File

@@ -36,6 +36,7 @@ public class Jsr250Voter implements AccessDecisionVoter<Object> {
* @param configAttribute The config attribute.
* @return whether the config attribute is supported.
*/
@Override
public boolean supports(ConfigAttribute configAttribute) {
return configAttribute instanceof Jsr250SecurityConfig;
}
@@ -45,6 +46,7 @@ public class Jsr250Voter implements AccessDecisionVoter<Object> {
* @param clazz the class.
* @return true
*/
@Override
public boolean supports(Class<?> clazz) {
return true;
}
@@ -59,6 +61,7 @@ public class Jsr250Voter implements AccessDecisionVoter<Object> {
* @param definition The configuration definition.
* @return The vote.
*/
@Override
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> definition) {
boolean jsr250AttributeFound = false;

View File

@@ -59,14 +59,17 @@ public class SecuredAnnotationSecurityMetadataSource extends AbstractFallbackMet
+ " must supply a generic parameter for AnnotationMetadataExtractor");
}
@Override
protected Collection<ConfigAttribute> findAttributes(Class<?> clazz) {
return processAnnotation(AnnotationUtils.findAnnotation(clazz, this.annotationType));
}
@Override
protected Collection<ConfigAttribute> findAttributes(Method method, Class<?> targetClass) {
return processAnnotation(AnnotationUtils.findAnnotation(method, this.annotationType));
}
@Override
public Collection<ConfigAttribute> getAllConfigAttributes() {
return null;
}
@@ -83,6 +86,7 @@ public class SecuredAnnotationSecurityMetadataSource extends AbstractFallbackMet
class SecuredAnnotationMetadataExtractor implements AnnotationMetadataExtractor<Secured> {
@Override
public Collection<ConfigAttribute> extractAttributes(Secured secured) {
String[] attributeTokens = secured.value();
List<ConfigAttribute> attributes = new ArrayList<>(attributeTokens.length);

View File

@@ -34,6 +34,7 @@ public class LoggerListener implements ApplicationListener<AbstractAuthorization
private static final Log logger = LogFactory.getLog(LoggerListener.class);
@Override
public void onApplicationEvent(AbstractAuthorizationEvent event) {
if (event instanceof AuthenticationCredentialsNotFoundEvent) {
AuthenticationCredentialsNotFoundEvent authEvent = (AuthenticationCredentialsNotFoundEvent) event;

View File

@@ -47,6 +47,7 @@ public abstract class AbstractSecurityExpressionHandler<T>
private PermissionEvaluator permissionEvaluator = new DenyAllPermissionEvaluator();
@Override
public final ExpressionParser getExpressionParser() {
return this.expressionParser;
}
@@ -64,6 +65,7 @@ public abstract class AbstractSecurityExpressionHandler<T>
* @return the context object for use in evaluating the expression, populated with a
* suitable root object.
*/
@Override
public final EvaluationContext createEvaluationContext(Authentication authentication, T invocation) {
SecurityExpressionOperations root = createSecurityExpressionRoot(authentication, invocation);
StandardEvaluationContext ctx = createEvaluationContextInternal(authentication, invocation);
@@ -114,6 +116,7 @@ public abstract class AbstractSecurityExpressionHandler<T>
this.permissionEvaluator = permissionEvaluator;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.br = new BeanFactoryResolver(applicationContext);
}

View File

@@ -37,6 +37,7 @@ public class DenyAllPermissionEvaluator implements PermissionEvaluator {
/**
* @return false always
*/
@Override
public boolean hasPermission(Authentication authentication, Object target, Object permission) {
this.logger.warn(
"Denying user " + authentication.getName() + " permission '" + permission + "' on object " + target);
@@ -46,6 +47,7 @@ public class DenyAllPermissionEvaluator implements PermissionEvaluator {
/**
* @return false always
*/
@Override
public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType,
Object permission) {
this.logger.warn("Denying user " + authentication.getName() + " permission '" + permission

View File

@@ -73,18 +73,22 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
this.authentication = authentication;
}
@Override
public final boolean hasAuthority(String authority) {
return hasAnyAuthority(authority);
}
@Override
public final boolean hasAnyAuthority(String... authorities) {
return hasAnyAuthorityName(null, authorities);
}
@Override
public final boolean hasRole(String role) {
return hasAnyRole(role);
}
@Override
public final boolean hasAnyRole(String... roles) {
return hasAnyAuthorityName(this.defaultRolePrefix, roles);
}
@@ -102,30 +106,37 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
return false;
}
@Override
public final Authentication getAuthentication() {
return this.authentication;
}
@Override
public final boolean permitAll() {
return true;
}
@Override
public final boolean denyAll() {
return false;
}
@Override
public final boolean isAnonymous() {
return this.trustResolver.isAnonymous(this.authentication);
}
@Override
public final boolean isAuthenticated() {
return !isAnonymous();
}
@Override
public final boolean isRememberMe() {
return this.trustResolver.isRememberMe(this.authentication);
}
@Override
public final boolean isFullyAuthenticated() {
return !this.trustResolver.isAnonymous(this.authentication)
&& !this.trustResolver.isRememberMe(this.authentication);
@@ -179,10 +190,12 @@ public abstract class SecurityExpressionRoot implements SecurityExpressionOperat
return this.roles;
}
@Override
public boolean hasPermission(Object target, Object permission) {
return this.permissionEvaluator.hasPermission(this.authentication, target, permission);
}
@Override
public boolean hasPermission(Object targetId, String targetType, Object permission) {
return this.permissionEvaluator.hasPermission(this.authentication, (Serializable) targetId, targetType,
permission);

View File

@@ -66,6 +66,7 @@ abstract class AbstractExpressionBasedMethodConfigAttribute implements ConfigAtt
return this.authorizeExpression;
}
@Override
public String getAttribute() {
return null;
}

View File

@@ -70,6 +70,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
* Uses a {@link MethodSecurityEvaluationContext} as the <tt>EvaluationContext</tt>
* implementation.
*/
@Override
public StandardEvaluationContext createEvaluationContextInternal(Authentication auth, MethodInvocation mi) {
return new MethodSecurityEvaluationContext(auth, mi, getParameterNameDiscoverer());
}
@@ -77,6 +78,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
/**
* Creates the root object for expression evaluation.
*/
@Override
protected MethodSecurityExpressionOperations createSecurityExpressionRoot(Authentication authentication,
MethodInvocation invocation) {
MethodSecurityExpressionRoot root = new MethodSecurityExpressionRoot(authentication);
@@ -97,6 +99,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
* modified to contain the elements for which the permission expression evaluates to
* {@code true}. For an array, a new array instance will be returned.
*/
@Override
@SuppressWarnings("unchecked")
public Object filter(Object filterTarget, Expression filterExpression, EvaluationContext ctx) {
MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx.getRootObject()
@@ -248,6 +251,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
this.permissionCacheOptimizer = permissionCacheOptimizer;
}
@Override
public void setReturnObject(Object returnObject, EvaluationContext ctx) {
((MethodSecurityExpressionOperations) ctx.getRootObject().getValue()).setReturnObject(returnObject);
}

View File

@@ -42,6 +42,7 @@ public class ExpressionBasedAnnotationAttributeFactory implements PrePostInvocat
this.handler = handler;
}
@Override
public PreInvocationAttribute createPreInvocationAttribute(String preFilterAttribute, String filterObject,
String preAuthorizeAttribute) {
try {
@@ -58,6 +59,7 @@ public class ExpressionBasedAnnotationAttributeFactory implements PrePostInvocat
}
}
@Override
public PostInvocationAttribute createPostInvocationAttribute(String postFilterAttribute,
String postAuthorizeAttribute) {
try {

View File

@@ -41,6 +41,7 @@ public class ExpressionBasedPostInvocationAdvice implements PostInvocationAuthor
this.expressionHandler = expressionHandler;
}
@Override
public Object after(Authentication authentication, MethodInvocation mi, PostInvocationAttribute postAttr,
Object returnedObject) throws AccessDeniedException {
PostInvocationExpressionAttribute pia = (PostInvocationExpressionAttribute) postAttr;

View File

@@ -39,6 +39,7 @@ public class ExpressionBasedPreInvocationAdvice implements PreInvocationAuthoriz
private MethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
@Override
public boolean before(Authentication authentication, MethodInvocation mi, PreInvocationAttribute attr) {
PreInvocationExpressionAttribute preAttr = (PreInvocationExpressionAttribute) attr;
EvaluationContext ctx = this.expressionHandler.createEvaluationContext(authentication, mi);

View File

@@ -36,18 +36,22 @@ class MethodSecurityExpressionRoot extends SecurityExpressionRoot implements Met
super(a);
}
@Override
public void setFilterObject(Object filterObject) {
this.filterObject = filterObject;
}
@Override
public Object getFilterObject() {
return this.filterObject;
}
@Override
public void setReturnObject(Object returnObject) {
this.returnObject = returnObject;
}
@Override
public Object getReturnObject() {
return this.returnObject;
}
@@ -62,6 +66,7 @@ class MethodSecurityExpressionRoot extends SecurityExpressionRoot implements Met
this.target = target;
}
@Override
public Object getThis() {
return this.target;
}

View File

@@ -25,6 +25,7 @@ import org.springframework.security.core.GrantedAuthority;
*/
public final class NullRoleHierarchy implements RoleHierarchy {
@Override
public Collection<? extends GrantedAuthority> getReachableGrantedAuthorities(
Collection<? extends GrantedAuthority> authorities) {
return authorities;

View File

@@ -31,6 +31,7 @@ public class RoleHierarchyAuthoritiesMapper implements GrantedAuthoritiesMapper
this.roleHierarchy = roleHierarchy;
}
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
return this.roleHierarchy.getReachableGrantedAuthorities(authorities);
}

View File

@@ -127,6 +127,7 @@ public abstract class AbstractSecurityInterceptor
private boolean publishAuthorizationSuccess = false;
@Override
public void afterPropertiesSet() {
Assert.notNull(getSecureObjectClass(), "Subclass must provide a non-null response to getSecureObjectClass()");
Assert.notNull(this.messages, "A message source must be set");
@@ -419,6 +420,7 @@ public abstract class AbstractSecurityInterceptor
this.alwaysReauthenticate = alwaysReauthenticate;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.eventPublisher = applicationEventPublisher;
}
@@ -427,6 +429,7 @@ public abstract class AbstractSecurityInterceptor
this.authenticationManager = newManager;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@@ -474,6 +477,7 @@ public abstract class AbstractSecurityInterceptor
private static class NoOpAuthenticationManager implements AuthenticationManager {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
throw new AuthenticationServiceException("Cannot authenticate " + authentication);
}

View File

@@ -52,6 +52,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager, I
private List<AfterInvocationProvider> providers;
@Override
public void afterPropertiesSet() {
checkIfValidList(this.providers);
}
@@ -62,6 +63,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager, I
}
}
@Override
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
Object returnedObject) throws AccessDeniedException {
@@ -89,6 +91,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager, I
}
}
@Override
public boolean supports(ConfigAttribute attribute) {
for (AfterInvocationProvider provider : this.providers) {
if (logger.isDebugEnabled()) {
@@ -114,6 +117,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager, I
* object class, which requires every one of its <code>AfterInvocationProvider</code>s
* to support the secure object class
*/
@Override
public boolean supports(Class<?> clazz) {
for (AfterInvocationProvider provider : this.providers) {
if (!provider.supports(clazz)) {

View File

@@ -49,6 +49,7 @@ public class MethodInvocationPrivilegeEvaluator implements InitializingBean {
private AbstractSecurityInterceptor securityInterceptor;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.securityInterceptor, "SecurityInterceptor required");
}

View File

@@ -31,14 +31,17 @@ import org.springframework.security.core.Authentication;
*/
final class NullRunAsManager implements RunAsManager {
@Override
public Authentication buildRunAs(Authentication authentication, Object object, Collection<ConfigAttribute> config) {
return null;
}
@Override
public boolean supports(ConfigAttribute attribute) {
return false;
}
@Override
public boolean supports(Class<?> clazz) {
return true;
}

View File

@@ -46,10 +46,12 @@ public class RunAsImplAuthenticationProvider implements InitializingBean, Authen
private String key;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.key, "A Key is required and should match that configured for the RunAsManagerImpl");
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
RunAsUserToken token = (RunAsUserToken) authentication;
@@ -70,10 +72,12 @@ public class RunAsImplAuthenticationProvider implements InitializingBean, Authen
this.key = key;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@Override
public boolean supports(Class<?> authentication) {
return RunAsUserToken.class.isAssignableFrom(authentication);
}

View File

@@ -59,11 +59,13 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
private String rolePrefix = "ROLE_";
@Override
public void afterPropertiesSet() {
Assert.notNull(this.key,
"A Key is required and should match that configured for the RunAsImplAuthenticationProvider");
}
@Override
public Authentication buildRunAs(Authentication authentication, Object object,
Collection<ConfigAttribute> attributes) {
List<GrantedAuthority> newAuthorities = new ArrayList<>();
@@ -108,6 +110,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
this.rolePrefix = rolePrefix;
}
@Override
public boolean supports(ConfigAttribute attribute) {
return attribute.getAttribute() != null && attribute.getAttribute().startsWith("RUN_AS_");
}
@@ -118,6 +121,7 @@ public class RunAsManagerImpl implements RunAsManager, InitializingBean {
* @param clazz the secure object
* @return always <code>true</code>
*/
@Override
public boolean supports(Class<?> clazz) {
return true;
}

View File

@@ -41,6 +41,7 @@ public class MethodSecurityInterceptor extends AbstractSecurityInterceptor imple
private MethodSecurityMetadataSource securityMetadataSource;
@Override
public Class<?> getSecureObjectClass() {
return MethodInvocation.class;
}
@@ -52,6 +53,7 @@ public class MethodSecurityInterceptor extends AbstractSecurityInterceptor imple
* {@code AfterInvocationManager}).
* @throws Throwable if any error occurs
*/
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
InterceptorStatusToken token = super.beforeInvocation(mi);
@@ -69,6 +71,7 @@ public class MethodSecurityInterceptor extends AbstractSecurityInterceptor imple
return this.securityMetadataSource;
}
@Override
public SecurityMetadataSource obtainSecurityMetadataSource() {
return this.securityMetadataSource;
}

View File

@@ -91,10 +91,12 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
this.metadataSourceBeanName = attributeSourceBeanName;
}
@Override
public Pointcut getPointcut() {
return this.pointcut;
}
@Override
public Advice getAdvice() {
synchronized (this.adviceMonitor) {
if (this.interceptor == null) {
@@ -106,6 +108,7 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
}
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@@ -119,6 +122,7 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
class MethodSecurityMetadataSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
@Override
@SuppressWarnings("unchecked")
public boolean matches(Method m, Class targetClass) {
Collection attributes = MethodSecurityMetadataSourceAdvisor.this.attributeSource.getAttributes(m,

View File

@@ -78,22 +78,27 @@ public final class MethodInvocationAdapter implements MethodInvocation {
return method;
}
@Override
public Method getMethod() {
return this.method;
}
@Override
public Object[] getArguments() {
return this.jp.getArgs();
}
@Override
public AccessibleObject getStaticPart() {
return this.method;
}
@Override
public Object getThis() {
return this.target;
}
@Override
public Object proceed() throws Throwable {
return this.jp.proceed();
}

View File

@@ -45,6 +45,7 @@ import org.springframework.security.access.ConfigAttribute;
*/
public abstract class AbstractFallbackMethodSecurityMetadataSource extends AbstractMethodSecurityMetadataSource {
@Override
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
// The method may be on an interface, but we need attributes from the target
// class.

View File

@@ -36,6 +36,7 @@ public abstract class AbstractMethodSecurityMetadataSource implements MethodSecu
protected final Log logger = LogFactory.getLog(getClass());
@Override
public final Collection<ConfigAttribute> getAttributes(Object object) {
if (object instanceof MethodInvocation) {
MethodInvocation mi = (MethodInvocation) object;
@@ -59,6 +60,7 @@ public abstract class AbstractMethodSecurityMetadataSource implements MethodSecu
throw new IllegalArgumentException("Object must be a non-null MethodInvocation");
}
@Override
public final boolean supports(Class<?> clazz) {
return (MethodInvocation.class.isAssignableFrom(clazz));
}

View File

@@ -49,6 +49,7 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
this.methodSecurityMetadataSources = methodSecurityMetadataSources;
}
@Override
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
DefaultCacheKey cacheKey = new DefaultCacheKey(method, targetClass);
synchronized (this.attributeCache) {

View File

@@ -45,6 +45,7 @@ public class PostInvocationAdviceProvider implements AfterInvocationProvider {
this.postAdvice = postAdvice;
}
@Override
public Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> config,
Object returnedObject) throws AccessDeniedException {
@@ -67,10 +68,12 @@ public class PostInvocationAdviceProvider implements AfterInvocationProvider {
return null;
}
@Override
public boolean supports(ConfigAttribute attribute) {
return attribute instanceof PostInvocationAttribute;
}
@Override
public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(MethodInvocation.class);
}

View File

@@ -48,14 +48,17 @@ public class PreInvocationAuthorizationAdviceVoter implements AccessDecisionVote
this.preAdvice = pre;
}
@Override
public boolean supports(ConfigAttribute attribute) {
return attribute instanceof PreInvocationAttribute;
}
@Override
public boolean supports(Class<?> clazz) {
return MethodInvocation.class.isAssignableFrom(clazz);
}
@Override
public int vote(Authentication authentication, MethodInvocation method, Collection<ConfigAttribute> attributes) {
// Find prefilter and preauth (or combined) attributes

View File

@@ -92,17 +92,18 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
PostInvocationAttribute attr = findPostInvocationAttribute(attributes);
if (Mono.class.isAssignableFrom(returnType)) {
return toInvoke.flatMap(auth -> this.<Mono<?>>proceed(invocation)
return toInvoke.flatMap(auth -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
}
if (Flux.class.isAssignableFrom(returnType)) {
return toInvoke.flatMapMany(auth -> this.<Flux<?>>proceed(invocation)
return toInvoke.flatMapMany(auth -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
}
return toInvoke.flatMapMany(auth -> Flux.from(this.<Publisher<?>>proceed(invocation))
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
return toInvoke
.flatMapMany(auth -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
.map(r -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
}
private static <T extends Publisher<?>> T proceed(final MethodInvocation invocation) {

View File

@@ -56,6 +56,7 @@ public abstract class AbstractAccessDecisionManager
this.decisionVoters = decisionVoters;
}
@Override
public void afterPropertiesSet() {
Assert.notEmpty(this.decisionVoters, "A list of AccessDecisionVoters is required");
Assert.notNull(this.messages, "A message source must be set");
@@ -80,10 +81,12 @@ public abstract class AbstractAccessDecisionManager
this.allowIfAllAbstainDecisions = allowIfAllAbstainDecisions;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@Override
public boolean supports(ConfigAttribute attribute) {
for (AccessDecisionVoter voter : this.decisionVoters) {
if (voter.supports(attribute)) {
@@ -103,6 +106,7 @@ public abstract class AbstractAccessDecisionManager
* @param clazz the type of secured object being presented
* @return true if this type is supported
*/
@Override
public boolean supports(Class<?> clazz) {
for (AccessDecisionVoter voter : this.decisionVoters) {
if (!voter.supports(clazz)) {

View File

@@ -64,6 +64,7 @@ public abstract class AbstractAclVoter implements AccessDecisionVoter<MethodInvo
* @return <code>true</code> if the secure object is <code>MethodInvocation</code>,
* <code>false</code> otherwise
*/
@Override
public boolean supports(Class<?> clazz) {
return (MethodInvocation.class.isAssignableFrom(clazz));
}

View File

@@ -51,6 +51,7 @@ public class AffirmativeBased extends AbstractAccessDecisionManager {
* being invoked
* @throws AccessDeniedException if access is denied
*/
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)
throws AccessDeniedException {
int deny = 0;

View File

@@ -66,6 +66,7 @@ public class AuthenticatedVoter implements AccessDecisionVoter<Object> {
this.authenticationTrustResolver = authenticationTrustResolver;
}
@Override
public boolean supports(ConfigAttribute attribute) {
if ((attribute.getAttribute() != null) && (IS_AUTHENTICATED_FULLY.equals(attribute.getAttribute())
|| IS_AUTHENTICATED_REMEMBERED.equals(attribute.getAttribute())
@@ -83,10 +84,12 @@ public class AuthenticatedVoter implements AccessDecisionVoter<Object> {
* @param clazz the secure object type
* @return always {@code true}
*/
@Override
public boolean supports(Class<?> clazz) {
return true;
}
@Override
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
int result = ACCESS_ABSTAIN;

View File

@@ -58,6 +58,7 @@ public class ConsensusBased extends AbstractAccessDecisionManager {
* being invoked
* @throws AccessDeniedException if access is denied
*/
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)
throws AccessDeniedException {
int grant = 0;

View File

@@ -66,6 +66,7 @@ public class RoleVoter implements AccessDecisionVoter<Object> {
this.rolePrefix = rolePrefix;
}
@Override
public boolean supports(ConfigAttribute attribute) {
if ((attribute.getAttribute() != null) && attribute.getAttribute().startsWith(getRolePrefix())) {
return true;
@@ -81,10 +82,12 @@ public class RoleVoter implements AccessDecisionVoter<Object> {
* @param clazz the secure object
* @return always <code>true</code>
*/
@Override
public boolean supports(Class<?> clazz) {
return true;
}
@Override
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> attributes) {
if (authentication == null) {
return ACCESS_DENIED;

View File

@@ -55,6 +55,7 @@ public class UnanimousBased extends AbstractAccessDecisionManager {
* invoked
* @throws AccessDeniedException if access is denied
*/
@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> attributes)
throws AccessDeniedException {

View File

@@ -65,10 +65,12 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
this.authorities = Collections.unmodifiableList(temp);
}
@Override
public Collection<GrantedAuthority> getAuthorities() {
return this.authorities;
}
@Override
public String getName() {
if (this.getPrincipal() instanceof UserDetails) {
return ((UserDetails) this.getPrincipal()).getUsername();
@@ -83,14 +85,17 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
}
@Override
public boolean isAuthenticated() {
return this.authenticated;
}
@Override
public void setAuthenticated(boolean authenticated) {
this.authenticated = authenticated;
}
@Override
public Object getDetails() {
return this.details;
}
@@ -104,6 +109,7 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
* invoking the {@code eraseCredentials} method on any which implement
* {@link CredentialsContainer}.
*/
@Override
public void eraseCredentials() {
eraseSecret(getCredentials());
eraseSecret(getPrincipal());

View File

@@ -30,6 +30,7 @@ public class AccountStatusUserDetailsChecker implements UserDetailsChecker, Mess
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
@Override
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
throw new LockedException(

View File

@@ -44,6 +44,7 @@ public class AnonymousAuthenticationProvider implements AuthenticationProvider,
this.key = key;
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
@@ -61,11 +62,13 @@ public class AnonymousAuthenticationProvider implements AuthenticationProvider,
return this.key;
}
@Override
public void setMessageSource(MessageSource messageSource) {
Assert.notNull(messageSource, "messageSource cannot be null");
this.messages = new MessageSourceAccessor(messageSource);
}
@Override
public boolean supports(Class<?> authentication) {
return (AnonymousAuthenticationToken.class.isAssignableFrom(authentication));
}

View File

@@ -43,6 +43,7 @@ public class AuthenticationTrustResolverImpl implements AuthenticationTrustResol
return this.rememberMeClass;
}
@Override
public boolean isAnonymous(Authentication authentication) {
if ((this.anonymousClass == null) || (authentication == null)) {
return false;
@@ -51,6 +52,7 @@ public class AuthenticationTrustResolverImpl implements AuthenticationTrustResol
return this.anonymousClass.isAssignableFrom(authentication.getClass());
}
@Override
public boolean isRememberMe(Authentication authentication) {
if ((this.rememberMeClass == null) || (authentication == null)) {
return false;

View File

@@ -43,6 +43,7 @@ public class CachingUserDetailsService implements UserDetailsService {
this.userCache = userCache;
}
@Override
public UserDetails loadUserByUsername(String username) {
UserDetails user = this.userCache.getUserFromCache(username);

View File

@@ -93,12 +93,14 @@ public class DefaultAuthenticationEventPublisher
AuthenticationFailureBadCredentialsEvent.class);
}
@Override
public void publishAuthenticationSuccess(Authentication authentication) {
if (this.applicationEventPublisher != null) {
this.applicationEventPublisher.publishEvent(new AuthenticationSuccessEvent(authentication));
}
}
@Override
public void publishAuthenticationFailure(AuthenticationException exception, Authentication authentication) {
Constructor<? extends AbstractAuthenticationEvent> constructor = getEventConstructor(exception);
AbstractAuthenticationEvent event = null;
@@ -129,6 +131,7 @@ public class DefaultAuthenticationEventPublisher
return (eventConstructor == null ? this.defaultAuthenticationFailureEventConstructor : eventConstructor);
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}

View File

@@ -46,6 +46,7 @@ public class DelegatingReactiveAuthenticationManager implements ReactiveAuthenti
this.delegates = entryPoints;
}
@Override
public Mono<Authentication> authenticate(Authentication authentication) {
return Flux.fromIterable(this.delegates).concatMap(m -> m.authenticate(authentication)).next();
}

View File

@@ -127,6 +127,7 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
checkState();
}
@Override
public void afterPropertiesSet() {
checkState();
}
@@ -161,6 +162,7 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
* @return a fully authenticated object including credentials.
* @throws AuthenticationException if authentication fails.
*/
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Class<? extends Authentication> toTest = authentication.getClass();
AuthenticationException lastException = null;
@@ -271,6 +273,7 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
return this.providers;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@@ -298,9 +301,11 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
private static final class NullEventPublisher implements AuthenticationEventPublisher {
@Override
public void publishAuthenticationFailure(AuthenticationException exception, Authentication authentication) {
}
@Override
public void publishAuthenticationSuccess(Authentication authentication) {
}

View File

@@ -43,10 +43,12 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider,
this.key = key;
}
@Override
public void afterPropertiesSet() {
Assert.notNull(this.messages, "A message source must be set");
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
if (!supports(authentication.getClass())) {
return null;
@@ -64,10 +66,12 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider,
return this.key;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@Override
public boolean supports(Class<?> authentication) {
return (RememberMeAuthenticationToken.class.isAssignableFrom(authentication));
}

View File

@@ -34,10 +34,12 @@ import org.springframework.security.core.AuthenticationException;
*/
public class TestingAuthenticationProvider implements AuthenticationProvider {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
return authentication;
}
@Override
public boolean supports(Class<?> authentication) {
return TestingAuthenticationToken.class.isAssignableFrom(authentication);
}

View File

@@ -54,10 +54,12 @@ public class TestingAuthenticationToken extends AbstractAuthenticationToken {
setAuthenticated(true);
}
@Override
public Object getCredentials() {
return this.credentials;
}
@Override
public Object getPrincipal() {
return this.principal;
}

View File

@@ -70,14 +70,17 @@ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationT
super.setAuthenticated(true); // must use super, as we override
}
@Override
public Object getCredentials() {
return this.credentials;
}
@Override
public Object getPrincipal() {
return this.principal;
}
@Override
public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
if (isAuthenticated) {
throw new IllegalArgumentException(

View File

@@ -112,12 +112,14 @@ public abstract class AbstractUserDetailsAuthenticationProvider
protected abstract void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException;
@Override
public final void afterPropertiesSet() throws Exception {
Assert.notNull(this.userCache, "A user cache must be set");
Assert.notNull(this.messages, "A message source must be set");
doAfterPropertiesSet();
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication,
() -> this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports",
@@ -286,6 +288,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
this.hideUserNotFoundExceptions = hideUserNotFoundExceptions;
}
@Override
public void setMessageSource(MessageSource messageSource) {
this.messages = new MessageSourceAccessor(messageSource);
}
@@ -294,6 +297,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
this.userCache = userCache;
}
@Override
public boolean supports(Class<?> authentication) {
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}
@@ -325,6 +329,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
private class DefaultPreAuthenticationChecks implements UserDetailsChecker {
@Override
public void check(UserDetails user) {
if (!user.isAccountNonLocked()) {
AbstractUserDetailsAuthenticationProvider.this.logger.debug("User account is locked");
@@ -352,6 +357,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
private class DefaultPostAuthenticationChecks implements UserDetailsChecker {
@Override
public void check(UserDetails user) {
if (!user.isCredentialsNonExpired()) {
AbstractUserDetailsAuthenticationProvider.this.logger.debug("User account credentials have expired");

View File

@@ -63,6 +63,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
setPasswordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder());
}
@Override
@SuppressWarnings("deprecation")
protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
@@ -83,10 +84,12 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
}
}
@Override
protected void doAfterPropertiesSet() {
Assert.notNull(this.userDetailsService, "A UserDetailsService must be set");
}
@Override
protected final UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication)
throws AuthenticationException {
prepareTimingAttackProtection();

View File

@@ -39,6 +39,7 @@ public class LoggerListener implements ApplicationListener<AbstractAuthenticatio
*/
private boolean logInteractiveAuthenticationSuccessEvents = true;
@Override
public void onApplicationEvent(AbstractAuthenticationEvent event) {
if (!this.logInteractiveAuthenticationSuccessEvents && event instanceof InteractiveAuthenticationSuccessEvent) {
return;

View File

@@ -134,6 +134,7 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
* called with valid handlers, initializes to use {@link JaasNameCallbackHandler} and
* {@link JaasPasswordCallbackHandler}.
*/
@Override
public void afterPropertiesSet() throws Exception {
Assert.hasLength(this.loginContextName, "loginContextName cannot be null or empty");
Assert.notEmpty(this.authorityGranters, "authorityGranters cannot be null or empty");
@@ -154,6 +155,7 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
* the message of the LoginException that will be thrown, should the
* loginContext.login() method fail.
*/
@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
if (!(auth instanceof UsernamePasswordAuthenticationToken)) {
return null;
@@ -261,6 +263,7 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
}
}
@Override
public void onApplicationEvent(SessionDestroyedEvent event) {
handleLogout(event);
}
@@ -352,10 +355,12 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
this.loginExceptionResolver = loginExceptionResolver;
}
@Override
public boolean supports(Class<?> aClass) {
return UsernamePasswordAuthenticationToken.class.isAssignableFrom(aClass);
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
@@ -375,6 +380,7 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
this.authentication = authentication;
}
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (JaasAuthenticationCallbackHandler handler : AbstractJaasAuthenticationProvider.this.callbackHandlers) {
for (Callback callback : callbacks) {

View File

@@ -29,6 +29,7 @@ import org.springframework.security.core.AuthenticationException;
*/
public class DefaultLoginExceptionResolver implements LoginExceptionResolver {
@Override
public AuthenticationException resolveException(LoginException e) {
return new AuthenticationServiceException(e.getMessage(), e);
}

View File

@@ -43,6 +43,7 @@ public class JaasNameCallbackHandler implements JaasAuthenticationCallbackHandle
* @param authentication
*
*/
@Override
public void handle(Callback callback, Authentication authentication) {
if (callback instanceof NameCallback) {
NameCallback ncb = (NameCallback) callback;

View File

@@ -44,6 +44,7 @@ public class JaasPasswordCallbackHandler implements JaasAuthenticationCallbackHa
* @param auth
*
*/
@Override
public void handle(Callback callback, Authentication auth) {
if (callback instanceof PasswordCallback) {
PasswordCallback pc = (PasswordCallback) callback;

View File

@@ -68,6 +68,7 @@ public class SecurityContextLoginModule implements LoginModule {
* should be ignored.
* @exception LoginException if the abort fails
*/
@Override
public boolean abort() {
if (this.authen == null) {
return false;
@@ -85,6 +86,7 @@ public class SecurityContextLoginModule implements LoginModule {
* should be ignored.
* @exception LoginException if the commit fails
*/
@Override
public boolean commit() {
if (this.authen == null) {
return false;
@@ -113,6 +115,7 @@ public class SecurityContextLoginModule implements LoginModule {
* @param sharedState is ignored
* @param options are ignored
*/
@Override
@SuppressWarnings("unchecked")
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {
this.subject = subject;
@@ -129,6 +132,7 @@ public class SecurityContextLoginModule implements LoginModule {
* <code>LoginModule</code> should be ignored.
* @throws LoginException if the authentication fails
*/
@Override
public boolean login() throws LoginException {
this.authen = SecurityContextHolder.getContext().getAuthentication();
@@ -154,6 +158,7 @@ public class SecurityContextLoginModule implements LoginModule {
* should be ignored.
* @exception LoginException if the logout fails
*/
@Override
public boolean logout() {
if (this.authen == null) {
return false;

View File

@@ -37,10 +37,12 @@ public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationMana
private AuthenticationManager authenticationManager;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.authenticationManager, "authenticationManager is required");
}
@Override
public Collection<? extends GrantedAuthority> attemptAuthentication(String username, String password)
throws RemoteAuthenticationException {
UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken(username, password);

View File

@@ -54,10 +54,12 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, Ini
private RemoteAuthenticationManager remoteAuthenticationManager;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory");
}
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getPrincipal().toString();
Object credentials = authentication.getCredentials();
@@ -76,6 +78,7 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, Ini
this.remoteAuthenticationManager = remoteAuthenticationManager;
}
@Override
public boolean supports(Class<?> authentication) {
return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication));
}

View File

@@ -56,6 +56,7 @@ public class DelegatingSecurityContextExecutor extends AbstractDelegatingSecurit
this(delegate, null);
}
@Override
public final void execute(Runnable task) {
task = wrap(task);
this.delegate.execute(task);

View File

@@ -62,59 +62,71 @@ public class DelegatingSecurityContextExecutorService extends DelegatingSecurity
this(delegate, null);
}
@Override
public final void shutdown() {
getDelegate().shutdown();
}
@Override
public final List<Runnable> shutdownNow() {
return getDelegate().shutdownNow();
}
@Override
public final boolean isShutdown() {
return getDelegate().isShutdown();
}
@Override
public final boolean isTerminated() {
return getDelegate().isTerminated();
}
@Override
public final boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
return getDelegate().awaitTermination(timeout, unit);
}
@Override
public final <T> Future<T> submit(Callable<T> task) {
task = wrap(task);
return getDelegate().submit(task);
}
@Override
public final <T> Future<T> submit(Runnable task, T result) {
task = wrap(task);
return getDelegate().submit(task, result);
}
@Override
public final Future<?> submit(Runnable task) {
task = wrap(task);
return getDelegate().submit(task);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final List invokeAll(Collection tasks) throws InterruptedException {
tasks = createTasks(tasks);
return getDelegate().invokeAll(tasks);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final List invokeAll(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException {
tasks = createTasks(tasks);
return getDelegate().invokeAll(tasks, timeout, unit);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final Object invokeAny(Collection tasks) throws InterruptedException, ExecutionException {
tasks = createTasks(tasks);
return getDelegate().invokeAny(tasks);
}
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public final Object invokeAny(Collection tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {

View File

@@ -58,21 +58,25 @@ public final class DelegatingSecurityContextScheduledExecutorService extends Del
this(delegate, null);
}
@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
command = wrap(command);
return getDelegate().schedule(command, delay, unit);
}
@Override
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
callable = wrap(callable);
return getDelegate().schedule(callable, delay, unit);
}
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
command = wrap(command);
return getDelegate().scheduleAtFixedRate(command, initialDelay, period, unit);
}
@Override
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
command = wrap(command);
return getDelegate().scheduleWithFixedDelay(command, initialDelay, delay, unit);

View File

@@ -34,6 +34,7 @@ public final class DelegatingApplicationListener implements ApplicationListener<
private List<SmartApplicationListener> listeners = new CopyOnWriteArrayList<>();
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event == null) {
return;

View File

@@ -47,6 +47,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper
private Set<String> mappableAttributes = null;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.attributes2grantedAuthoritiesMap, "attributes2grantedAuthoritiesMap must be set");
}
@@ -54,6 +55,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper
/**
* Map the given array of attributes to Spring Security GrantedAuthorities.
*/
@Override
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) {
ArrayList<GrantedAuthority> gaList = new ArrayList<>();
for (String attribute : attributes) {
@@ -166,6 +168,7 @@ public class MapBasedAttributes2GrantedAuthoritiesMapper
*
* @see org.springframework.security.core.authority.mapping.MappableAttributesRetriever#getMappableAttributes()
*/
@Override
public Set<String> getMappableAttributes() {
return this.mappableAttributes;
}

View File

@@ -24,6 +24,7 @@ import org.springframework.security.core.GrantedAuthority;
*/
public class NullAuthoritiesMapper implements GrantedAuthoritiesMapper {
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
return authorities;
}

View File

@@ -51,6 +51,7 @@ public class SimpleAttributes2GrantedAuthoritiesMapper
/**
* Check whether all properties have been set to correct values.
*/
@Override
public void afterPropertiesSet() {
Assert.isTrue(!(isConvertAttributeToUpperCase() && isConvertAttributeToLowerCase()),
"Either convertAttributeToUpperCase or convertAttributeToLowerCase can be set to true, but not both");
@@ -60,6 +61,7 @@ public class SimpleAttributes2GrantedAuthoritiesMapper
* Map the given list of string attributes one-to-one to Spring Security
* GrantedAuthorities.
*/
@Override
public List<GrantedAuthority> getGrantedAuthorities(Collection<String> attributes) {
List<GrantedAuthority> result = new ArrayList<>(attributes.size());
for (String attribute : attributes) {

View File

@@ -42,6 +42,7 @@ public final class SimpleAuthorityMapper implements GrantedAuthoritiesMapper, In
private boolean convertToLowerCase = false;
@Override
public void afterPropertiesSet() {
Assert.isTrue(!(this.convertToUpperCase && this.convertToLowerCase),
"Either convertToUpperCase or convertToLowerCase can be set to true, but not both");
@@ -55,6 +56,7 @@ public final class SimpleAuthorityMapper implements GrantedAuthoritiesMapper, In
* @param authorities the original authorities
* @return the converted set of authorities
*/
@Override
public Set<GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
HashSet<GrantedAuthority> mapped = new HashSet<>(authorities.size());
for (GrantedAuthority authority : authorities) {

View File

@@ -37,6 +37,7 @@ public class SimpleMappableAttributesRetriever implements MappableAttributesRetr
* org.springframework.security.core.authority.mapping.MappableAttributesRetriever
* #getMappableAttributes()
*/
@Override
public Set<String> getMappableAttributes() {
return this.mappableAttributes;
}

View File

@@ -31,10 +31,12 @@ final class GlobalSecurityContextHolderStrategy implements SecurityContextHolder
private static SecurityContext contextHolder;
@Override
public void clearContext() {
contextHolder = null;
}
@Override
public SecurityContext getContext() {
if (contextHolder == null) {
contextHolder = new SecurityContextImpl();
@@ -43,11 +45,13 @@ final class GlobalSecurityContextHolderStrategy implements SecurityContextHolder
return contextHolder;
}
@Override
public void setContext(SecurityContext context) {
Assert.notNull(context, "Only non-null SecurityContext instances are permitted");
contextHolder = context;
}
@Override
public SecurityContext createEmptyContext() {
return new SecurityContextImpl();
}

View File

@@ -29,10 +29,12 @@ final class InheritableThreadLocalSecurityContextHolderStrategy implements Secur
private static final ThreadLocal<SecurityContext> contextHolder = new InheritableThreadLocal<>();
@Override
public void clearContext() {
contextHolder.remove();
}
@Override
public SecurityContext getContext() {
SecurityContext ctx = contextHolder.get();
@@ -44,11 +46,13 @@ final class InheritableThreadLocalSecurityContextHolderStrategy implements Secur
return ctx;
}
@Override
public void setContext(SecurityContext context) {
Assert.notNull(context, "Only non-null SecurityContext instances are permitted");
contextHolder.set(context);
}
@Override
public SecurityContext createEmptyContext() {
return new SecurityContextImpl();
}

View File

@@ -30,10 +30,12 @@ final class ThreadLocalSecurityContextHolderStrategy implements SecurityContextH
private static final ThreadLocal<SecurityContext> contextHolder = new ThreadLocal<>();
@Override
public void clearContext() {
contextHolder.remove();
}
@Override
public SecurityContext getContext() {
SecurityContext ctx = contextHolder.get();
@@ -45,11 +47,13 @@ final class ThreadLocalSecurityContextHolderStrategy implements SecurityContextH
return ctx;
}
@Override
public void setContext(SecurityContext context) {
Assert.notNull(context, "Only non-null SecurityContext instances are permitted");
contextHolder.set(context);
}
@Override
public SecurityContext createEmptyContext() {
return new SecurityContextImpl();
}

View File

@@ -81,6 +81,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi
private SecureRandom secureRandom;
@Override
public Token allocateToken(String extendedInformation) {
Assert.notNull(extendedInformation, "Must provided non-null extendedInformation (but it can be empty)");
long creationTime = new Date().getTime();
@@ -96,6 +97,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi
return new DefaultToken(key, creationTime, extendedInformation);
}
@Override
public Token verifyToken(String key) {
if (key == null || "".equals(key)) {
return null;
@@ -172,6 +174,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi
this.serverInteger = serverInteger;
}
@Override
public void afterPropertiesSet() {
Assert.hasText(this.serverSecret, "Server secret required");
Assert.notNull(this.serverInteger, "Server integer required");

View File

@@ -35,6 +35,7 @@ public class SecureRandomFactoryBean implements FactoryBean<SecureRandom> {
private Resource seed;
@Override
public SecureRandom getObject() throws Exception {
SecureRandom rnd = SecureRandom.getInstance(this.algorithm);
@@ -51,10 +52,12 @@ public class SecureRandomFactoryBean implements FactoryBean<SecureRandom> {
return rnd;
}
@Override
public Class<SecureRandom> getObjectType() {
return SecureRandom.class;
}
@Override
public boolean isSingleton() {
return false;
}

View File

@@ -121,34 +121,42 @@ public class User implements UserDetails, CredentialsContainer {
this.authorities = Collections.unmodifiableSet(sortAuthorities(authorities));
}
@Override
public Collection<GrantedAuthority> getAuthorities() {
return this.authorities;
}
@Override
public String getPassword() {
return this.password;
}
@Override
public String getUsername() {
return this.username;
}
@Override
public boolean isEnabled() {
return this.enabled;
}
@Override
public boolean isAccountNonExpired() {
return this.accountNonExpired;
}
@Override
public boolean isAccountNonLocked() {
return this.accountNonLocked;
}
@Override
public boolean isCredentialsNonExpired() {
return this.credentialsNonExpired;
}
@Override
public void eraseCredentials() {
this.password = null;
}
@@ -171,6 +179,7 @@ public class User implements UserDetails, CredentialsContainer {
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
@Override
public int compare(GrantedAuthority g1, GrantedAuthority g2) {
// Neither should ever be null as each entry is checked before adding it to
// the set.

View File

@@ -57,6 +57,7 @@ public class UserDetailsByNameServiceWrapper<T extends Authentication>
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() {
Assert.notNull(this.userDetailsService, "UserDetailsService must be set");
}
@@ -64,6 +65,7 @@ public class UserDetailsByNameServiceWrapper<T extends Authentication>
/**
* Get the UserDetails object from the wrapped UserDetailsService implementation
*/
@Override
public UserDetails loadUserDetails(T authentication) throws UsernameNotFoundException {
return this.userDetailsService.loadUserByUsername(authentication.getName());
}

View File

@@ -38,6 +38,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
private Ehcache cache;
@Override
public void afterPropertiesSet() {
Assert.notNull(this.cache, "cache mandatory");
}
@@ -46,6 +47,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
return this.cache;
}
@Override
public UserDetails getUserFromCache(String username) {
Element element = this.cache.get(username);
@@ -61,6 +63,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
}
}
@Override
public void putUserInCache(UserDetails user) {
Element element = new Element(user.getUsername(), user);
@@ -79,6 +82,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
this.removeUserFromCache(user.getUsername());
}
@Override
public void removeUserFromCache(String username) {
this.cache.remove(username);
}

View File

@@ -26,13 +26,16 @@ import org.springframework.security.core.userdetails.UserDetails;
*/
public class NullUserCache implements UserCache {
@Override
public UserDetails getUserFromCache(String username) {
return null;
}
@Override
public void putUserInCache(UserDetails user) {
}
@Override
public void removeUserFromCache(String username) {
}

View File

@@ -40,6 +40,7 @@ public class SpringCacheBasedUserCache implements UserCache {
this.cache = cache;
}
@Override
public UserDetails getUserFromCache(String username) {
Cache.ValueWrapper element = username != null ? this.cache.get(username) : null;
@@ -55,6 +56,7 @@ public class SpringCacheBasedUserCache implements UserCache {
}
}
@Override
public void putUserInCache(UserDetails user) {
if (logger.isDebugEnabled()) {
logger.debug("Cache put: " + user.getUsername());
@@ -70,6 +72,7 @@ public class SpringCacheBasedUserCache implements UserCache {
this.removeUserFromCache(user.getUsername());
}
@Override
public void removeUserFromCache(String username) {
this.cache.evict(username);
}

View File

@@ -30,6 +30,7 @@ import org.springframework.util.StringUtils;
*/
public class UserAttributeEditor extends PropertyEditorSupport {
@Override
public void setAsText(String s) throws IllegalArgumentException {
if (StringUtils.hasText(s)) {
String[] tokens = StringUtils.commaDelimitedListToStringArray(s);

View File

@@ -84,26 +84,31 @@ public class InMemoryUserDetailsManager implements UserDetailsManager, UserDetai
}
}
@Override
public void createUser(UserDetails user) {
Assert.isTrue(!userExists(user.getUsername()), "user should not exist");
this.users.put(user.getUsername().toLowerCase(), new MutableUser(user));
}
@Override
public void deleteUser(String username) {
this.users.remove(username.toLowerCase());
}
@Override
public void updateUser(UserDetails user) {
Assert.isTrue(userExists(user.getUsername()), "user should exist");
this.users.put(user.getUsername().toLowerCase(), new MutableUser(user));
}
@Override
public boolean userExists(String username) {
return this.users.containsKey(username.toLowerCase());
}
@Override
public void changePassword(String oldPassword, String newPassword) {
Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();
@@ -145,6 +150,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager, UserDetai
return mutableUser;
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserDetails user = this.users.get(username.toLowerCase());

View File

@@ -156,6 +156,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
setDataSource(dataSource);
}
@Override
protected void initDao() throws ApplicationContextException {
if (this.authenticationManager == null) {
this.logger.info("No authentication manager set. Reauthentication of users when changing passwords will "
@@ -169,6 +170,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
* Executes the SQL <tt>usersByUsernameQuery</tt> and returns a list of UserDetails
* objects. There should normally only be one matching user.
*/
@Override
protected List<UserDetails> loadUsersByUsername(String username) {
return getJdbcTemplate().query(getUsersByUsernameQuery(), new String[] { username }, (rs, rowNum) -> {
@@ -191,6 +193,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
});
}
@Override
public void createUser(final UserDetails user) {
validateUserDetails(user);
@@ -213,6 +216,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
}
}
@Override
public void updateUser(final UserDetails user) {
validateUserDetails(user);
@@ -249,6 +253,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
}
}
@Override
public void deleteUser(String username) {
if (getEnableAuthorities()) {
deleteUserAuthorities(username);
@@ -261,6 +266,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
getJdbcTemplate().update(this.deleteUserAuthoritiesSql, username);
}
@Override
public void changePassword(String oldPassword, String newPassword) throws AuthenticationException {
Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();
@@ -302,6 +308,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
return newAuthentication;
}
@Override
public boolean userExists(String username) {
List<String> users = getJdbcTemplate().queryForList(this.userExistsSql, new String[] { username },
String.class);
@@ -314,15 +321,18 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
return users.size() == 1;
}
@Override
public List<String> findAllGroups() {
return getJdbcTemplate().queryForList(this.findAllGroupsSql, String.class);
}
@Override
public List<String> findUsersInGroup(String groupName) {
Assert.hasText(groupName, "groupName should have text");
return getJdbcTemplate().queryForList(this.findUsersInGroupSql, new String[] { groupName }, String.class);
}
@Override
public void createGroup(final String groupName, final List<GrantedAuthority> authorities) {
Assert.hasText(groupName, "groupName should have text");
Assert.notNull(authorities, "authorities cannot be null");
@@ -343,6 +353,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
}
}
@Override
public void deleteGroup(String groupName) {
this.logger.debug("Deleting group '" + groupName + "'");
Assert.hasText(groupName, "groupName should have text");
@@ -354,6 +365,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
getJdbcTemplate().update(this.deleteGroupSql, groupIdPSS);
}
@Override
public void renameGroup(String oldName, String newName) {
this.logger.debug("Changing group name from '" + oldName + "' to '" + newName + "'");
Assert.hasText(oldName, "oldName should have text");
@@ -362,6 +374,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
getJdbcTemplate().update(this.renameGroupSql, newName, oldName);
}
@Override
public void addUserToGroup(final String username, final String groupName) {
this.logger.debug("Adding user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username, "username should have text");
@@ -376,6 +389,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
this.userCache.removeUserFromCache(username);
}
@Override
public void removeUserFromGroup(final String username, final String groupName) {
this.logger.debug("Removing user '" + username + "' to group '" + groupName + "'");
Assert.hasText(username, "username should have text");
@@ -391,6 +405,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
this.userCache.removeUserFromCache(username);
}
@Override
public List<GrantedAuthority> findGroupAuthorities(String groupName) {
this.logger.debug("Loading authorities for group '" + groupName + "'");
Assert.hasText(groupName, "groupName should have text");
@@ -402,6 +417,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
});
}
@Override
public void removeGroupAuthority(String groupName, final GrantedAuthority authority) {
this.logger.debug("Removing authority '" + authority + "' from group '" + groupName + "'");
Assert.hasText(groupName, "groupName should have text");
@@ -415,6 +431,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
});
}
@Override
public void addGroupAuthority(final String groupName, final GrantedAuthority authority) {
this.logger.debug("Adding authority '" + authority + "' to group '" + groupName + "'");
Assert.hasText(groupName, "groupName should have text");

View File

@@ -38,34 +38,42 @@ class MutableUser implements MutableUserDetails {
this.password = user.getPassword();
}
@Override
public String getPassword() {
return this.password;
}
@Override
public void setPassword(String password) {
this.password = password;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.delegate.getAuthorities();
}
@Override
public String getUsername() {
return this.delegate.getUsername();
}
@Override
public boolean isAccountNonExpired() {
return this.delegate.isAccountNonExpired();
}
@Override
public boolean isAccountNonLocked() {
return this.delegate.isAccountNonLocked();
}
@Override
public boolean isCredentialsNonExpired() {
return this.delegate.isCredentialsNonExpired();
}
@Override
public boolean isEnabled() {
return this.delegate.isEnabled();
}

View File

@@ -59,6 +59,7 @@ public class DelegatingSecurityContextSchedulingTaskExecutor extends DelegatingS
this(delegateAsyncTaskExecutor, null);
}
@Override
public boolean prefersShortLivedTasks() {
return getDelegate().prefersShortLivedTasks();
}

View File

@@ -58,16 +58,19 @@ public class DelegatingSecurityContextAsyncTaskExecutor extends DelegatingSecuri
this(delegateAsyncTaskExecutor, null);
}
@Override
public final void execute(Runnable task, long startTimeout) {
task = wrap(task);
getDelegate().execute(task, startTimeout);
}
@Override
public final Future<?> submit(Runnable task) {
task = wrap(task);
return getDelegate().submit(task);
}
@Override
public final <T> Future<T> submit(Callable<T> task) {
task = wrap(task);
return getDelegate().submit(task);

View File

@@ -43,22 +43,27 @@ public class SimpleMethodInvocation implements MethodInvocation {
public SimpleMethodInvocation() {
}
@Override
public Object[] getArguments() {
return this.arguments;
}
@Override
public Method getMethod() {
return this.method;
}
@Override
public AccessibleObject getStaticPart() {
throw new UnsupportedOperationException("mock method not implemented");
}
@Override
public Object getThis() {
return this.targetObject;
}
@Override
public Object proceed() {
throw new UnsupportedOperationException("mock method not implemented");
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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");

View File

@@ -88,6 +88,7 @@ public class SecurityConfigTests {
this.attribute = configuration;
}
@Override
public String getAttribute() {
return this.attribute;
}

View File

@@ -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() {
}

View File

@@ -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() {
}

View File

@@ -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() {

View File

@@ -245,6 +245,7 @@ public class Jsr250MethodSecurityMetadataSourceTests {
static class Parent implements IParent {
@Override
public void interfaceMethod() {
}

View File

@@ -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) {
}

View File

@@ -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;
}

View File

@@ -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) {
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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");
}

Some files were not shown because too many files have changed in this diff Show More