Remove superfluous comments
Use '^\s+//\ \~\ .*$' and '^\s+//\ ============+$' regular expression searches to remove superfluous comments. Prior to this commit, many classes would have comments to indicate blocks of code (such as constructors/methods/instance fields). These added a lot of noise and weren't all that helpful, especially given the outline views available in most modern IDEs. Issue gh-8945
This commit is contained in:
@@ -28,9 +28,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface AccessDecisionManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Resolves an access control decision for the passed parameters.
|
||||
* @param authentication the caller invoking the method (not null)
|
||||
|
||||
@@ -31,18 +31,12 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface AccessDecisionVoter<S> {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
int ACCESS_GRANTED = 1;
|
||||
|
||||
int ACCESS_ABSTAIN = 0;
|
||||
|
||||
int ACCESS_DENIED = -1;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Indicates whether this {@code AccessDecisionVoter} is able to vote on the passed
|
||||
* {@code ConfigAttribute}.
|
||||
|
||||
@@ -24,9 +24,6 @@ package org.springframework.security.access;
|
||||
*/
|
||||
public class AccessDeniedException extends RuntimeException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an <code>AccessDeniedException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface AfterInvocationProvider {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
Object decide(Authentication authentication, Object object, Collection<ConfigAttribute> attributes,
|
||||
Object returnedObject) throws AccessDeniedException;
|
||||
|
||||
|
||||
-3
@@ -26,9 +26,6 @@ package org.springframework.security.access;
|
||||
*/
|
||||
public class AuthorizationServiceException extends AccessDeniedException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an <code>AuthorizationServiceException</code> with the specified
|
||||
* message.
|
||||
|
||||
@@ -38,9 +38,6 @@ import org.springframework.security.access.intercept.RunAsManager;
|
||||
*/
|
||||
public interface ConfigAttribute extends Serializable {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* If the <code>ConfigAttribute</code> can be represented as a <code>String</code> and
|
||||
* that <code>String</code> is sufficient in precision to be relied upon as a
|
||||
|
||||
@@ -29,22 +29,13 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SecurityConfig implements ConfigAttribute {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final String attrib;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public SecurityConfig(String config) {
|
||||
Assert.hasText(config, "You must provide a configuration attribute");
|
||||
this.attrib = config;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ConfigAttribute) {
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.springframework.security.access.intercept.AbstractSecurityInterceptor
|
||||
*/
|
||||
public interface SecurityMetadataSource extends AopInfrastructureBean {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Accesses the {@code ConfigAttribute}s that apply to a given secure object.
|
||||
* @param object the object being secured
|
||||
|
||||
-3
@@ -25,9 +25,6 @@ import org.springframework.context.ApplicationEvent;
|
||||
*/
|
||||
public abstract class AbstractAuthorizationEvent extends ApplicationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Construct the event, passing in the secure object being intercepted.
|
||||
* @param secureObject the secure object
|
||||
|
||||
-9
@@ -29,16 +29,10 @@ import org.springframework.security.authentication.AuthenticationCredentialsNotF
|
||||
*/
|
||||
public class AuthenticationCredentialsNotFoundEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AuthenticationCredentialsNotFoundException credentialsNotFoundException;
|
||||
|
||||
private Collection<ConfigAttribute> configAttribs;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Construct the event.
|
||||
* @param secureObject the secure object
|
||||
@@ -59,9 +53,6 @@ public class AuthenticationCredentialsNotFoundEvent extends AbstractAuthorizatio
|
||||
this.credentialsNotFoundException = credentialsNotFoundException;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Collection<ConfigAttribute> getConfigAttributes() {
|
||||
return configAttribs;
|
||||
}
|
||||
|
||||
-9
@@ -36,18 +36,12 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class AuthorizationFailureEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AccessDeniedException accessDeniedException;
|
||||
|
||||
private Authentication authentication;
|
||||
|
||||
private Collection<ConfigAttribute> configAttributes;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Construct the event.
|
||||
* @param secureObject the secure object
|
||||
@@ -70,9 +64,6 @@ public class AuthorizationFailureEvent extends AbstractAuthorizationEvent {
|
||||
this.accessDeniedException = accessDeniedException;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public AccessDeniedException getAccessDeniedException() {
|
||||
return accessDeniedException;
|
||||
}
|
||||
|
||||
@@ -31,16 +31,10 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class AuthorizedEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Authentication authentication;
|
||||
|
||||
private Collection<ConfigAttribute> configAttributes;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Construct the event.
|
||||
* @param secureObject the secure object
|
||||
@@ -59,9 +53,6 @@ public class AuthorizedEvent extends AbstractAuthorizationEvent {
|
||||
this.authentication = authentication;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Authentication getAuthentication() {
|
||||
return authentication;
|
||||
}
|
||||
|
||||
@@ -31,14 +31,8 @@ import org.springframework.context.ApplicationListener;
|
||||
*/
|
||||
public class LoggerListener implements ApplicationListener<AbstractAuthorizationEvent> {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static final Log logger = LogFactory.getLog(LoggerListener.class);
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void onApplicationEvent(AbstractAuthorizationEvent event) {
|
||||
if (event instanceof AuthenticationCredentialsNotFoundEvent) {
|
||||
AuthenticationCredentialsNotFoundEvent authEvent = (AuthenticationCredentialsNotFoundEvent) event;
|
||||
|
||||
-3
@@ -31,9 +31,6 @@ package org.springframework.security.access.event;
|
||||
*/
|
||||
public class PublicInvocationEvent extends AbstractAuthorizationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Construct the event, passing in the public secure object.
|
||||
* @param secureObject the public secure object
|
||||
|
||||
-9
@@ -104,14 +104,8 @@ import org.springframework.util.Assert;
|
||||
public abstract class AbstractSecurityInterceptor
|
||||
implements InitializingBean, ApplicationEventPublisherAware, MessageSourceAware {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
@@ -132,9 +126,6 @@ public abstract class AbstractSecurityInterceptor
|
||||
|
||||
private boolean publishAuthorizationSuccess = false;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
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");
|
||||
|
||||
-3
@@ -44,9 +44,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface AfterInvocationManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Given the details of a secure object invocation including its returned
|
||||
* <code>Object</code>, make an access control decision or optionally modify the
|
||||
|
||||
-9
@@ -47,19 +47,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AfterInvocationProviderManager implements AfterInvocationManager, InitializingBean {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(AfterInvocationProviderManager.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private List<AfterInvocationProvider> providers;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
checkIfValidList(this.providers);
|
||||
}
|
||||
|
||||
-9
@@ -32,9 +32,6 @@ import org.springframework.security.core.context.SecurityContext;
|
||||
*/
|
||||
public class InterceptorStatusToken {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private SecurityContext securityContext;
|
||||
|
||||
private Collection<ConfigAttribute> attr;
|
||||
@@ -43,9 +40,6 @@ public class InterceptorStatusToken {
|
||||
|
||||
private boolean contextHolderRefreshRequired;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public InterceptorStatusToken(SecurityContext securityContext, boolean contextHolderRefreshRequired,
|
||||
Collection<ConfigAttribute> attributes, Object secureObject) {
|
||||
this.securityContext = securityContext;
|
||||
@@ -54,9 +48,6 @@ public class InterceptorStatusToken {
|
||||
this.secureObject = secureObject;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Collection<ConfigAttribute> getAttributes() {
|
||||
return attr;
|
||||
}
|
||||
|
||||
-9
@@ -44,19 +44,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MethodInvocationPrivilegeEvaluator implements InitializingBean {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(MethodInvocationPrivilegeEvaluator.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AbstractSecurityInterceptor securityInterceptor;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(securityInterceptor, "SecurityInterceptor required");
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
final class NullRunAsManager implements RunAsManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Authentication buildRunAs(Authentication authentication, Object object, Collection<ConfigAttribute> config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
-6
@@ -45,16 +45,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class RunAsImplAuthenticationProvider implements InitializingBean, AuthenticationProvider, MessageSourceAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private String key;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(key, "A Key is required and should match that configured for the RunAsManagerImpl");
|
||||
}
|
||||
|
||||
@@ -60,9 +60,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface RunAsManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Returns a replacement <code>Authentication</code> object for the current secure
|
||||
* object invocation, or <code>null</code> if replacement not required.
|
||||
|
||||
@@ -55,16 +55,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class RunAsManagerImpl implements RunAsManager, InitializingBean {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private String key;
|
||||
|
||||
private String rolePrefix = "ROLE_";
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(key,
|
||||
"A Key is required and should match that configured for the RunAsImplAuthenticationProvider");
|
||||
|
||||
@@ -33,9 +33,6 @@ public class RunAsUserToken extends AbstractAuthenticationToken {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Class<? extends Authentication> originalAuthentication;
|
||||
|
||||
private final Object credentials;
|
||||
@@ -44,9 +41,6 @@ public class RunAsUserToken extends AbstractAuthenticationToken {
|
||||
|
||||
private final int keyHash;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public RunAsUserToken(String key, Object principal, Object credentials,
|
||||
Collection<? extends GrantedAuthority> authorities,
|
||||
Class<? extends Authentication> originalAuthentication) {
|
||||
@@ -58,9 +52,6 @@ public class RunAsUserToken extends AbstractAuthenticationToken {
|
||||
setAuthenticated(true);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@Override
|
||||
public Object getCredentials() {
|
||||
return this.credentials;
|
||||
|
||||
-6
@@ -39,14 +39,8 @@ import org.aopalliance.intercept.MethodInvocation;
|
||||
*/
|
||||
public class MethodSecurityInterceptor extends AbstractSecurityInterceptor implements MethodInterceptor {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private MethodSecurityMetadataSource securityMetadataSource;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Class<?> getSecureObjectClass() {
|
||||
return MethodInvocation.class;
|
||||
}
|
||||
|
||||
-12
@@ -53,9 +53,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor implements BeanFactoryAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private transient MethodSecurityMetadataSource attributeSource;
|
||||
|
||||
private transient MethodInterceptor interceptor;
|
||||
@@ -70,9 +67,6 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
|
||||
|
||||
private transient volatile Object adviceMonitor = new Object();
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Alternative constructor for situations where we want the advisor decoupled from the
|
||||
* advice. Instead the advice bean name should be set. This prevents eager
|
||||
@@ -96,9 +90,6 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
|
||||
this.metadataSourceBeanName = attributeSourceBeanName;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Pointcut getPointcut() {
|
||||
return pointcut;
|
||||
}
|
||||
@@ -124,9 +115,6 @@ public class MethodSecurityMetadataSourceAdvisor extends AbstractPointcutAdvisor
|
||||
attributeSource = beanFactory.getBean(metadataSourceBeanName, MethodSecurityMetadataSource.class);
|
||||
}
|
||||
|
||||
// ~ Inner Classes
|
||||
// ==================================================================================================
|
||||
|
||||
class MethodSecurityMetadataSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
-3
@@ -25,9 +25,6 @@ package org.springframework.security.access.intercept.aspectj;
|
||||
*/
|
||||
public interface AspectJCallback {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
Object proceedWithObject();
|
||||
|
||||
}
|
||||
|
||||
-3
@@ -35,9 +35,6 @@ public abstract class AbstractMethodSecurityMetadataSource implements MethodSecu
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public final Collection<ConfigAttribute> getAttributes(Object object) {
|
||||
if (object instanceof MethodInvocation) {
|
||||
MethodInvocation mi = (MethodInvocation) object;
|
||||
|
||||
-9
@@ -44,17 +44,11 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
|
||||
|
||||
private final Map<DefaultCacheKey, Collection<ConfigAttribute>> attributeCache = new HashMap<>();
|
||||
|
||||
// ~ Constructor
|
||||
// ====================================================================================================
|
||||
|
||||
public DelegatingMethodSecurityMetadataSource(List<MethodSecurityMetadataSource> methodSecurityMetadataSources) {
|
||||
Assert.notNull(methodSecurityMetadataSources, "MethodSecurityMetadataSources cannot be null");
|
||||
this.methodSecurityMetadataSources = methodSecurityMetadataSources;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
|
||||
DefaultCacheKey cacheKey = new DefaultCacheKey(method, targetClass);
|
||||
synchronized (attributeCache) {
|
||||
@@ -106,9 +100,6 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
|
||||
return methodSecurityMetadataSources;
|
||||
}
|
||||
|
||||
// ~ Inner Classes
|
||||
// ==================================================================================================
|
||||
|
||||
private static class DefaultCacheKey {
|
||||
|
||||
private final Method method;
|
||||
|
||||
-5
@@ -45,8 +45,6 @@ import org.springframework.util.ClassUtils;
|
||||
public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethodSecurityMetadataSource
|
||||
implements BeanClassLoaderAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
|
||||
|
||||
/** Map from RegisteredMethod to ConfigAttribute list */
|
||||
@@ -55,9 +53,6 @@ public class MapBasedMethodSecurityMetadataSource extends AbstractFallbackMethod
|
||||
/** Map from RegisteredMethod to name pattern used for registration */
|
||||
private final Map<RegisteredMethod, String> nameMap = new HashMap<>();
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public MapBasedMethodSecurityMetadataSource() {
|
||||
}
|
||||
|
||||
|
||||
-5
@@ -42,8 +42,6 @@ import org.springframework.util.Assert;
|
||||
public abstract class AbstractAccessDecisionManager
|
||||
implements AccessDecisionManager, InitializingBean, MessageSourceAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private List<AccessDecisionVoter<?>> decisionVoters;
|
||||
@@ -57,9 +55,6 @@ public abstract class AbstractAccessDecisionManager
|
||||
this.decisionVoters = decisionVoters;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notEmpty(this.decisionVoters, "A list of AccessDecisionVoters is required");
|
||||
Assert.notNull(this.messages, "A message source must be set");
|
||||
|
||||
@@ -28,14 +28,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractAclVoter implements AccessDecisionVoter<MethodInvocation> {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Class<?> processDomainObjectClass;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
protected Object getDomainObjectInstance(MethodInvocation invocation) {
|
||||
Object[] args;
|
||||
Class<?>[] params;
|
||||
|
||||
@@ -34,9 +34,6 @@ public class AffirmativeBased extends AbstractAccessDecisionManager {
|
||||
super(decisionVoters);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* This concrete implementation simply polls all configured
|
||||
* {@link AccessDecisionVoter}s and grants access if any
|
||||
|
||||
@@ -48,23 +48,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AuthenticatedVoter implements AccessDecisionVoter<Object> {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
public static final String IS_AUTHENTICATED_FULLY = "IS_AUTHENTICATED_FULLY";
|
||||
|
||||
public static final String IS_AUTHENTICATED_REMEMBERED = "IS_AUTHENTICATED_REMEMBERED";
|
||||
|
||||
public static final String IS_AUTHENTICATED_ANONYMOUSLY = "IS_AUTHENTICATED_ANONYMOUSLY";
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AuthenticationTrustResolver authenticationTrustResolver = new AuthenticationTrustResolverImpl();
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
private boolean isFullyAuthenticated(Authentication authentication) {
|
||||
return (!authenticationTrustResolver.isAnonymous(authentication)
|
||||
&& !authenticationTrustResolver.isRememberMe(authentication));
|
||||
|
||||
@@ -34,18 +34,12 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class ConsensusBased extends AbstractAccessDecisionManager {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private boolean allowIfEqualGrantedDeniedDecisions = true;
|
||||
|
||||
public ConsensusBased(List<AccessDecisionVoter<?>> decisionVoters) {
|
||||
super(decisionVoters);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* This concrete implementation simply polls all configured
|
||||
* {@link AccessDecisionVoter}s and upon completion determines the consensus of
|
||||
|
||||
@@ -51,14 +51,8 @@ import org.springframework.security.core.GrantedAuthority;
|
||||
*/
|
||||
public class RoleVoter implements AccessDecisionVoter<Object> {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private String rolePrefix = "ROLE_";
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public String getRolePrefix() {
|
||||
return rolePrefix;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,6 @@ public class UnanimousBased extends AbstractAccessDecisionManager {
|
||||
super(decisionVoters);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* This concrete implementation polls all configured {@link AccessDecisionVoter}s for
|
||||
* each {@link ConfigAttribute} and grants access if <b>only</b> grant (or abstain)
|
||||
|
||||
-9
@@ -38,18 +38,12 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||
*/
|
||||
public abstract class AbstractAuthenticationToken implements Authentication, CredentialsContainer {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Collection<GrantedAuthority> authorities;
|
||||
|
||||
private Object details;
|
||||
|
||||
private boolean authenticated = false;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Creates a token with the supplied array of authorities.
|
||||
* @param authorities the collection of <tt>GrantedAuthority</tt>s for the principal
|
||||
@@ -71,9 +65,6 @@ public abstract class AbstractAuthenticationToken implements Authentication, Cre
|
||||
this.authorities = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Collection<GrantedAuthority> getAuthorities() {
|
||||
return authorities;
|
||||
}
|
||||
|
||||
-3
@@ -24,9 +24,6 @@ package org.springframework.security.authentication;
|
||||
*/
|
||||
public class AccountExpiredException extends AccountStatusException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>AccountExpiredException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
-6
@@ -35,9 +35,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AnonymousAuthenticationProvider implements AuthenticationProvider, MessageSourceAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private String key;
|
||||
@@ -47,9 +44,6 @@ public class AnonymousAuthenticationProvider implements AuthenticationProvider,
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
if (!supports(authentication.getClass())) {
|
||||
return null;
|
||||
|
||||
-9
@@ -29,18 +29,12 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AnonymousAuthenticationToken extends AbstractAuthenticationToken implements Serializable {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Object principal;
|
||||
|
||||
private final int keyHash;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param key to identify if this object made by an authorised client
|
||||
@@ -74,9 +68,6 @@ public class AnonymousAuthenticationToken extends AbstractAuthenticationToken im
|
||||
setAuthenticated(true);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
private static Integer extractKeyHash(String key) {
|
||||
Assert.hasLength(key, "key cannot be empty or null");
|
||||
return key.hashCode();
|
||||
|
||||
-3
@@ -28,9 +28,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationCredentialsNotFoundException extends AuthenticationException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an <code>AuthenticationCredentialsNotFoundException</code> with the
|
||||
* specified message.
|
||||
|
||||
-3
@@ -24,9 +24,6 @@ package org.springframework.security.authentication;
|
||||
*/
|
||||
public interface AuthenticationDetailsSource<C, T> {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Called by a class when it wishes a new authentication details instance to be
|
||||
* created.
|
||||
|
||||
-3
@@ -26,9 +26,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public interface AuthenticationManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Attempts to authenticate the passed {@link Authentication} object, returning a
|
||||
* fully populated <code>Authentication</code> object (including granted authorities)
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public interface AuthenticationProvider {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Performs authentication with the same contract as
|
||||
* {@link org.springframework.security.authentication.AuthenticationManager#authenticate(Authentication)}
|
||||
|
||||
-3
@@ -29,9 +29,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationServiceException extends AuthenticationException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an <code>AuthenticationServiceException</code> with the specified
|
||||
* message.
|
||||
|
||||
-3
@@ -25,9 +25,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface AuthenticationTrustResolver {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Indicates whether the passed <code>Authentication</code> token represents an
|
||||
* anonymous user. Typically the framework will call this method if it is trying to
|
||||
|
||||
-6
@@ -31,16 +31,10 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class AuthenticationTrustResolverImpl implements AuthenticationTrustResolver {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Class<? extends Authentication> anonymousClass = AnonymousAuthenticationToken.class;
|
||||
|
||||
private Class<? extends Authentication> rememberMeClass = RememberMeAuthenticationToken.class;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
Class<? extends Authentication> getAnonymousClass() {
|
||||
return anonymousClass;
|
||||
}
|
||||
|
||||
-3
@@ -26,9 +26,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class BadCredentialsException extends AuthenticationException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>BadCredentialsException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
-3
@@ -24,9 +24,6 @@ package org.springframework.security.authentication;
|
||||
*/
|
||||
public class CredentialsExpiredException extends AccountStatusException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>CredentialsExpiredException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
@@ -24,9 +24,6 @@ package org.springframework.security.authentication;
|
||||
*/
|
||||
public class DisabledException extends AccountStatusException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>DisabledException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
-3
@@ -33,9 +33,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class InsufficientAuthenticationException extends AuthenticationException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an <code>InsufficientAuthenticationException</code> with the specified
|
||||
* message.
|
||||
|
||||
@@ -24,9 +24,6 @@ package org.springframework.security.authentication;
|
||||
*/
|
||||
public class LockedException extends AccountStatusException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>LockedException</code> with the specified message.
|
||||
* @param msg the detail message.
|
||||
|
||||
@@ -86,14 +86,8 @@ import org.springframework.util.CollectionUtils;
|
||||
*/
|
||||
public class ProviderManager implements AuthenticationManager, MessageSourceAware, InitializingBean {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ProviderManager.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AuthenticationEventPublisher eventPublisher = new NullEventPublisher();
|
||||
|
||||
private List<AuthenticationProvider> providers = Collections.emptyList();
|
||||
@@ -132,9 +126,6 @@ public class ProviderManager implements AuthenticationManager, MessageSourceAwar
|
||||
checkState();
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
checkState();
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class ProviderNotFoundException extends AuthenticationException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>ProviderNotFoundException</code> with the specified message.
|
||||
* @param msg the detail message
|
||||
|
||||
-6
@@ -34,9 +34,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class RememberMeAuthenticationProvider implements AuthenticationProvider, InitializingBean, MessageSourceAware {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private String key;
|
||||
@@ -46,9 +43,6 @@ public class RememberMeAuthenticationProvider implements AuthenticationProvider,
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.messages, "A message source must be set");
|
||||
}
|
||||
|
||||
-9
@@ -34,16 +34,10 @@ public class RememberMeAuthenticationToken extends AbstractAuthenticationToken {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Object principal;
|
||||
|
||||
private final int keyHash;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param key to identify if this object made by an authorised client
|
||||
@@ -80,9 +74,6 @@ public class RememberMeAuthenticationToken extends AbstractAuthenticationToken {
|
||||
setAuthenticated(true);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Always returns an empty <code>String</code>
|
||||
* @return an empty String
|
||||
|
||||
-3
@@ -34,9 +34,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class TestingAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
return authentication;
|
||||
}
|
||||
|
||||
-9
@@ -31,18 +31,12 @@ import java.util.List;
|
||||
*/
|
||||
public class TestingAuthenticationToken extends AbstractAuthenticationToken {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Object credentials;
|
||||
|
||||
private final Object principal;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public TestingAuthenticationToken(Object principal, Object credentials) {
|
||||
super(null);
|
||||
this.principal = principal;
|
||||
@@ -60,9 +54,6 @@ public class TestingAuthenticationToken extends AbstractAuthenticationToken {
|
||||
setAuthenticated(true);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Object getCredentials() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
-9
@@ -36,16 +36,10 @@ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationT
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Object principal;
|
||||
|
||||
private Object credentials;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* This constructor can be safely used by any code that wishes to create a
|
||||
* <code>UsernamePasswordAuthenticationToken</code>, as the {@link #isAuthenticated()}
|
||||
@@ -76,9 +70,6 @@ public class UsernamePasswordAuthenticationToken extends AbstractAuthenticationT
|
||||
super.setAuthenticated(true); // must use super, as we override
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Object getCredentials() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
-6
@@ -81,9 +81,6 @@ public abstract class AbstractUserDetailsAuthenticationProvider
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private UserCache userCache = new NullUserCache();
|
||||
@@ -98,9 +95,6 @@ public abstract class AbstractUserDetailsAuthenticationProvider
|
||||
|
||||
private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper();
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Allows subclasses to perform any additional checks of a returned (or cached)
|
||||
* <code>UserDetails</code> for a given authentication request. Generally a subclass
|
||||
|
||||
-9
@@ -39,18 +39,12 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
/**
|
||||
* The plaintext password used to perform PasswordEncoder#matches(CharSequence,
|
||||
* String)} on when the user is not found to avoid SEC-2056.
|
||||
*/
|
||||
private static final String USER_NOT_FOUND_PASSWORD = "userNotFoundPassword";
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
/**
|
||||
@@ -69,9 +63,6 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
||||
setPasswordEncoder(PasswordEncoderFactories.createDelegatingPasswordEncoder());
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void additionalAuthenticationChecks(UserDetails userDetails,
|
||||
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
|
||||
|
||||
-6
@@ -31,16 +31,10 @@ import org.springframework.context.ApplicationEvent;
|
||||
*/
|
||||
public abstract class AbstractAuthenticationEvent extends ApplicationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AbstractAuthenticationEvent(Authentication authentication) {
|
||||
super(authentication);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Getters for the <code>Authentication</code> request that caused the event. Also
|
||||
* available from <code>super.getSource()</code>.
|
||||
|
||||
-9
@@ -28,23 +28,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractAuthenticationFailureEvent extends AbstractAuthenticationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final AuthenticationException exception;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AbstractAuthenticationFailureEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication);
|
||||
Assert.notNull(exception, "AuthenticationException is required");
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public AuthenticationException getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureBadCredentialsEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureBadCredentialsEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureCredentialsExpiredEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureCredentialsExpiredEvent(Authentication authentication,
|
||||
AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureDisabledEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureDisabledEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureExpiredEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureExpiredEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureLockedEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureLockedEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureProviderNotFoundEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureProviderNotFoundEvent(Authentication authentication,
|
||||
AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureProxyUntrustedEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureProxyUntrustedEvent(Authentication authentication, AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
}
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.AuthenticationException;
|
||||
*/
|
||||
public class AuthenticationFailureServiceExceptionEvent extends AbstractAuthenticationFailureEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationFailureServiceExceptionEvent(Authentication authentication,
|
||||
AuthenticationException exception) {
|
||||
super(authentication, exception);
|
||||
|
||||
-3
@@ -25,9 +25,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class AuthenticationSuccessEvent extends AbstractAuthenticationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public AuthenticationSuccessEvent(Authentication authentication) {
|
||||
super(authentication);
|
||||
}
|
||||
|
||||
-9
@@ -35,23 +35,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class InteractiveAuthenticationSuccessEvent extends AbstractAuthenticationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Class<?> generatedBy;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public InteractiveAuthenticationSuccessEvent(Authentication authentication, Class<?> generatedBy) {
|
||||
super(authentication);
|
||||
Assert.notNull(generatedBy, "generatedBy cannot be null");
|
||||
this.generatedBy = generatedBy;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Getter for the <code>Class</code> that generated this event. This can be useful for
|
||||
* generating additional logging information.
|
||||
|
||||
-6
@@ -30,9 +30,6 @@ import org.springframework.util.ClassUtils;
|
||||
*/
|
||||
public class LoggerListener implements ApplicationListener<AbstractAuthenticationEvent> {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static final Log logger = LogFactory.getLog(LoggerListener.class);
|
||||
|
||||
/**
|
||||
@@ -41,9 +38,6 @@ public class LoggerListener implements ApplicationListener<AbstractAuthenticatio
|
||||
*/
|
||||
private boolean logInteractiveAuthenticationSuccessEvents = true;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void onApplicationEvent(AbstractAuthenticationEvent event) {
|
||||
if (!logInteractiveAuthenticationSuccessEvents && event instanceof InteractiveAuthenticationSuccessEvent) {
|
||||
return;
|
||||
|
||||
-9
@@ -116,9 +116,6 @@ import org.springframework.util.ObjectUtils;
|
||||
public abstract class AbstractJaasAuthenticationProvider implements AuthenticationProvider,
|
||||
ApplicationEventPublisherAware, InitializingBean, ApplicationListener<SessionDestroyedEvent> {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
private AuthorityGranter[] authorityGranters;
|
||||
@@ -131,9 +128,6 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
|
||||
|
||||
private String loginContextName = "SPRINGSECURITY";
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Validates the required properties are set. In addition, if
|
||||
* {@link #setCallbackHandlers(JaasAuthenticationCallbackHandler[])} has not been
|
||||
@@ -370,9 +364,6 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
|
||||
return this.applicationEventPublisher;
|
||||
}
|
||||
|
||||
// ~ Inner Classes
|
||||
// ==================================================================================================
|
||||
|
||||
/**
|
||||
* Wrapper class for JAASAuthenticationCallbackHandlers
|
||||
*/
|
||||
|
||||
-3
@@ -31,9 +31,6 @@ import java.util.Set;
|
||||
*/
|
||||
public interface AuthorityGranter {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* The grant method is called for each principal returned from the LoginContext
|
||||
* subject. If the AuthorityGranter wishes to grant any authorities, it should return
|
||||
|
||||
-6
@@ -86,14 +86,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class DefaultJaasAuthenticationProvider extends AbstractJaasAuthenticationProvider {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.afterPropertiesSet();
|
||||
|
||||
-3
@@ -29,9 +29,6 @@ import javax.security.auth.login.LoginException;
|
||||
*/
|
||||
public class DefaultLoginExceptionResolver implements LoginExceptionResolver {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public AuthenticationException resolveException(LoginException e) {
|
||||
return new AuthenticationServiceException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
-3
@@ -46,9 +46,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public interface JaasAuthenticationCallbackHandler {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Handle the <a href=
|
||||
* "https://java.sun.com/j2se/1.4.2/docs/api/javax/security/auth/callback/Callback.html"
|
||||
|
||||
-9
@@ -139,22 +139,13 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JaasAuthenticationProvider extends AbstractJaasAuthenticationProvider {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
// exists for passivity
|
||||
protected static final Log log = LogFactory.getLog(JaasAuthenticationProvider.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Resource loginConfig;
|
||||
|
||||
private boolean refreshConfigurationOnStartup = true;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
// the superclass is not called because it does additional checks that are
|
||||
|
||||
-9
@@ -34,14 +34,8 @@ public class JaasAuthenticationToken extends UsernamePasswordAuthenticationToken
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final transient LoginContext loginContext;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public JaasAuthenticationToken(Object principal, Object credentials, LoginContext loginContext) {
|
||||
super(principal, credentials);
|
||||
this.loginContext = loginContext;
|
||||
@@ -53,9 +47,6 @@ public class JaasAuthenticationToken extends UsernamePasswordAuthenticationToken
|
||||
this.loginContext = loginContext;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public LoginContext getLoginContext() {
|
||||
return loginContext;
|
||||
}
|
||||
|
||||
-3
@@ -44,9 +44,6 @@ public final class JaasGrantedAuthority implements GrantedAuthority {
|
||||
this.principal = principal;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Principal getPrincipal() {
|
||||
return principal;
|
||||
}
|
||||
|
||||
-3
@@ -35,9 +35,6 @@ import javax.security.auth.callback.NameCallback;
|
||||
*/
|
||||
public class JaasNameCallbackHandler implements JaasAuthenticationCallbackHandler {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* If the callback passed to the 'handle' method is an instance of NameCallback, the
|
||||
* JaasNameCallbackHandler will call,
|
||||
|
||||
-3
@@ -36,9 +36,6 @@ import javax.security.auth.callback.PasswordCallback;
|
||||
*/
|
||||
public class JaasPasswordCallbackHandler implements JaasAuthenticationCallbackHandler {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* If the callback passed to the 'handle' method is an instance of PasswordCallback,
|
||||
* the JaasPasswordCallbackHandler will call,
|
||||
|
||||
-3
@@ -32,9 +32,6 @@ import javax.security.auth.login.LoginException;
|
||||
*/
|
||||
public interface LoginExceptionResolver {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Translates a Jaas LoginException to an SpringSecurityException.
|
||||
* @param e The LoginException thrown by the configured LoginModule.
|
||||
|
||||
-9
@@ -53,23 +53,14 @@ import javax.security.auth.spi.LoginModule;
|
||||
*/
|
||||
public class SecurityContextLoginModule implements LoginModule {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static final Log log = LogFactory.getLog(SecurityContextLoginModule.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private Authentication authen;
|
||||
|
||||
private Subject subject;
|
||||
|
||||
private boolean ignoreMissingAuthentication = false;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Abort the authentication process by forgetting the Spring Security
|
||||
* <code>Authentication</code>.
|
||||
|
||||
-6
@@ -29,9 +29,6 @@ import org.springframework.context.ApplicationEvent;
|
||||
*/
|
||||
public abstract class JaasAuthenticationEvent extends ApplicationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* The Authentication object is stored as the ApplicationEvent 'source'.
|
||||
* @param auth
|
||||
@@ -40,9 +37,6 @@ public abstract class JaasAuthenticationEvent extends ApplicationEvent {
|
||||
super(auth);
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Pre-casted method that returns the 'source' of the event.
|
||||
* @return the Authentication
|
||||
|
||||
-9
@@ -26,22 +26,13 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class JaasAuthenticationFailedEvent extends JaasAuthenticationEvent {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final Exception exception;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public JaasAuthenticationFailedEvent(Authentication auth, Exception exception) {
|
||||
super(auth);
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
-3
@@ -28,9 +28,6 @@ import org.springframework.security.core.Authentication;
|
||||
*/
|
||||
public class JaasAuthenticationSuccessEvent extends JaasAuthenticationEvent {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public JaasAuthenticationSuccessEvent(Authentication auth) {
|
||||
super(auth);
|
||||
}
|
||||
|
||||
-9
@@ -36,16 +36,10 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class InMemoryConfiguration extends Configuration {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final AppConfigurationEntry[] defaultConfiguration;
|
||||
|
||||
private final Map<String, AppConfigurationEntry[]> mappedConfigurations;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Creates a new instance with only a defaultConfiguration. Any configuration name
|
||||
* will result in defaultConfiguration being returned.
|
||||
@@ -82,9 +76,6 @@ public class InMemoryConfiguration extends Configuration {
|
||||
this.defaultConfiguration = defaultConfiguration;
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
@Override
|
||||
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
|
||||
AppConfigurationEntry[] mappedResult = this.mappedConfigurations.get(name);
|
||||
|
||||
-3
@@ -33,9 +33,6 @@ public class RemoteAuthenticationException extends NestedRuntimeException {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs a <code>RemoteAuthenticationException</code> with the specified message
|
||||
* and no root cause.
|
||||
|
||||
-3
@@ -27,9 +27,6 @@ import org.springframework.security.core.GrantedAuthority;
|
||||
*/
|
||||
public interface RemoteAuthenticationManager {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Attempts to authenticate the remote client using the presented username and
|
||||
* password. If authentication is successful, a collection of {@code GrantedAuthority}
|
||||
|
||||
-6
@@ -35,14 +35,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationManager, InitializingBean {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.authenticationManager, "authenticationManager is required");
|
||||
}
|
||||
|
||||
-6
@@ -52,14 +52,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class RemoteAuthenticationProvider implements AuthenticationProvider, InitializingBean {
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private RemoteAuthenticationManager remoteAuthenticationManager;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() {
|
||||
Assert.notNull(this.remoteAuthenticationManager, "remoteAuthenticationManager is mandatory");
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
*/
|
||||
public interface Authentication extends Principal, Serializable {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* Set by an <code>AuthenticationManager</code> to indicate the authorities that the
|
||||
* principal has been granted. Note that classes should not rely on this value as
|
||||
|
||||
@@ -24,9 +24,6 @@ package org.springframework.security.core;
|
||||
*/
|
||||
public abstract class AuthenticationException extends RuntimeException {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
/**
|
||||
* Constructs an {@code AuthenticationException} with the specified message and root
|
||||
* cause.
|
||||
|
||||
@@ -31,9 +31,6 @@ import org.springframework.security.access.AccessDecisionManager;
|
||||
*/
|
||||
public interface GrantedAuthority extends Serializable {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
/**
|
||||
* If the <code>GrantedAuthority</code> can be represented as a <code>String</code>
|
||||
* and that <code>String</code> is sufficient in precision to be relied upon for an
|
||||
|
||||
@@ -33,16 +33,10 @@ import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
*/
|
||||
public class SpringSecurityMessageSource extends ResourceBundleMessageSource {
|
||||
|
||||
// ~ Constructors
|
||||
// ===================================================================================================
|
||||
|
||||
public SpringSecurityMessageSource() {
|
||||
setBasename("org.springframework.security.messages");
|
||||
}
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public static MessageSourceAccessor getAccessor() {
|
||||
return new MessageSourceAccessor(new SpringSecurityMessageSource());
|
||||
}
|
||||
|
||||
-6
@@ -29,14 +29,8 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
final class GlobalSecurityContextHolderStrategy implements SecurityContextHolderStrategy {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static SecurityContext contextHolder;
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public void clearContext() {
|
||||
contextHolder = null;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user