Apply updated Code Style
Closes gh-13881
This commit is contained in:
@@ -43,6 +43,7 @@ import java.lang.annotation.Target;
|
||||
* @Secured({ "ROLE_ADMIN" })
|
||||
* public void delete(Contact contact);
|
||||
* </pre>
|
||||
*
|
||||
* @author Mark St.Godard
|
||||
*/
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SecuredAnnotationSecurityMetadataSource extends AbstractFallbackMet
|
||||
Assert.notNull(annotationMetadataExtractor, "annotationMetadataExtractor cannot be null");
|
||||
this.annotationExtractor = annotationMetadataExtractor;
|
||||
this.annotationType = (Class<? extends Annotation>) GenericTypeResolver
|
||||
.resolveTypeArgument(this.annotationExtractor.getClass(), AnnotationMetadataExtractor.class);
|
||||
.resolveTypeArgument(this.annotationExtractor.getClass(), AnnotationMetadataExtractor.class);
|
||||
Assert.notNull(this.annotationType, () -> this.annotationExtractor.getClass().getName()
|
||||
+ " must supply a generic parameter for AnnotationMetadataExtractor");
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public class DefaultMethodSecurityExpressionHandler extends AbstractSecurityExpr
|
||||
@Override
|
||||
public Object filter(Object filterTarget, Expression filterExpression, EvaluationContext ctx) {
|
||||
MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx.getRootObject()
|
||||
.getValue();
|
||||
.getValue();
|
||||
this.logger.debug(LogMessage.format("Filtering with expression: %s", filterExpression.getExpressionString()));
|
||||
if (filterTarget instanceof Collection) {
|
||||
return filterCollection((Collection<?>) filterTarget, filterExpression, ctx, rootObject);
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class AbstractSecurityInterceptor
|
||||
protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
private ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@@ -182,7 +182,7 @@ public abstract class AbstractSecurityInterceptor
|
||||
}
|
||||
if (unsupportedAttrs.size() != 0) {
|
||||
this.logger
|
||||
.trace("Did not validate configuration attributes since validateConfigurationAttributes is false");
|
||||
.trace("Did not validate configuration attributes since validateConfigurationAttributes is false");
|
||||
throw new IllegalArgumentException("Unsupported configuration attributes: " + unsupportedAttrs);
|
||||
}
|
||||
else {
|
||||
@@ -276,8 +276,8 @@ public abstract class AbstractSecurityInterceptor
|
||||
if (token != null && token.isContextHolderRefreshRequired()) {
|
||||
this.securityContextHolderStrategy.setContext(token.getSecurityContext());
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(LogMessage.of(
|
||||
() -> "Reverted to original authentication " + token.getSecurityContext().getAuthentication()));
|
||||
this.logger.debug(LogMessage
|
||||
.of(() -> "Reverted to original authentication " + token.getSecurityContext().getAuthentication()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MethodInvocationPrivilegeEvaluator implements InitializingBean {
|
||||
Assert.notNull(invocation, "MethodInvocation required");
|
||||
Assert.notNull(invocation.getMethod(), "MethodInvocation must provide a non-null getMethod()");
|
||||
Collection<ConfigAttribute> attrs = this.securityInterceptor.obtainSecurityMetadataSource()
|
||||
.getAttributes(invocation);
|
||||
.getAttributes(invocation);
|
||||
if (attrs == null) {
|
||||
return !this.securityInterceptor.isRejectPublicInvocations();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.springframework.security.core.parameters.AnnotationParameterNameDisco
|
||||
* contain the parameter names.
|
||||
*
|
||||
* @see AnnotationParameterNameDiscoverer
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 3.2
|
||||
* @deprecated use @{code org.springframework.security.core.parameters.P}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
|
||||
|
||||
boolean isSuspendingFunction = KotlinDetector.isSuspendingFunction(method);
|
||||
boolean hasFlowReturnType = COROUTINES_FLOW_CLASS_NAME
|
||||
.equals(new MethodParameter(method, RETURN_TYPE_METHOD_PARAMETER_INDEX).getParameterType().getName());
|
||||
.equals(new MethodParameter(method, RETURN_TYPE_METHOD_PARAMETER_INDEX).getParameterType().getName());
|
||||
boolean hasReactiveReturnType = Publisher.class.isAssignableFrom(returnType) || isSuspendingFunction
|
||||
|| hasFlowReturnType;
|
||||
|
||||
@@ -119,41 +119,41 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
|
||||
PostInvocationAttribute attr = findPostInvocationAttribute(attributes);
|
||||
if (Mono.class.isAssignableFrom(returnType)) {
|
||||
return toInvoke.flatMap((auth) -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
}
|
||||
if (Flux.class.isAssignableFrom(returnType)) {
|
||||
return toInvoke.flatMapMany((auth) -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
}
|
||||
if (hasFlowReturnType) {
|
||||
Flux<?> response;
|
||||
if (isSuspendingFunction) {
|
||||
response = toInvoke.flatMapMany((auth) -> Flux
|
||||
.from(CoroutinesUtils.invokeSuspendingFunction(invocation.getMethod(), invocation.getThis(),
|
||||
invocation.getArguments()))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
.from(CoroutinesUtils.invokeSuspendingFunction(invocation.getMethod(), invocation.getThis(),
|
||||
invocation.getArguments()))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
}
|
||||
else {
|
||||
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(returnType);
|
||||
Assert.state(adapter != null, () -> "The returnType " + returnType + " on " + method
|
||||
+ " must have a org.springframework.core.ReactiveAdapter registered");
|
||||
response = toInvoke.flatMapMany((auth) -> Flux
|
||||
.from(adapter.toPublisher(PrePostAdviceReactiveMethodInterceptor.flowProceed(invocation)))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
.from(adapter.toPublisher(PrePostAdviceReactiveMethodInterceptor.flowProceed(invocation)))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
}
|
||||
return KotlinDelegate.asFlow(response);
|
||||
}
|
||||
if (isSuspendingFunction) {
|
||||
Mono<?> response = toInvoke.flatMap((auth) -> Mono
|
||||
.from(CoroutinesUtils.invokeSuspendingFunction(invocation.getMethod(), invocation.getThis(),
|
||||
invocation.getArguments()))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
.from(CoroutinesUtils.invokeSuspendingFunction(invocation.getMethod(), invocation.getThis(),
|
||||
invocation.getArguments()))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
return KotlinDelegate.awaitSingleOrNull(response,
|
||||
invocation.getArguments()[invocation.getArguments().length - 1]);
|
||||
}
|
||||
return toInvoke.flatMapMany(
|
||||
(auth) -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
return toInvoke
|
||||
.flatMapMany((auth) -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
||||
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||
}
|
||||
|
||||
private static <T extends Publisher<?>> T proceed(final MethodInvocation invocation) {
|
||||
|
||||
@@ -130,8 +130,8 @@ public class PrePostAnnotationSecurityMetadataSource extends AbstractMethodSecur
|
||||
// actually implement the method)
|
||||
annotation = AnnotationUtils.findAnnotation(specificMethod.getDeclaringClass(), annotationClass);
|
||||
if (annotation != null) {
|
||||
this.logger.debug(
|
||||
LogMessage.format("%s found on: %s", annotation, specificMethod.getDeclaringClass().getName()));
|
||||
this.logger
|
||||
.debug(LogMessage.format("%s found on: %s", annotation, specificMethod.getDeclaringClass().getName()));
|
||||
return annotation;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -63,13 +63,13 @@ public class AffirmativeBased extends AbstractAccessDecisionManager {
|
||||
for (AccessDecisionVoter voter : getDecisionVoters()) {
|
||||
int result = voter.vote(authentication, object, configAttributes);
|
||||
switch (result) {
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
return;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
deny++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
return;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
deny++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (deny > 0) {
|
||||
|
||||
@@ -71,14 +71,14 @@ public class ConsensusBased extends AbstractAccessDecisionManager {
|
||||
for (AccessDecisionVoter voter : getDecisionVoters()) {
|
||||
int result = voter.vote(authentication, object, configAttributes);
|
||||
switch (result) {
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
grant++;
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
deny++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
grant++;
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
deny++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (grant > deny) {
|
||||
|
||||
@@ -71,14 +71,14 @@ public class UnanimousBased extends AbstractAccessDecisionManager {
|
||||
for (AccessDecisionVoter voter : getDecisionVoters()) {
|
||||
int result = voter.vote(authentication, object, singleAttributeList);
|
||||
switch (result) {
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
grant++;
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
throw new AccessDeniedException(
|
||||
this.messages.getMessage("AbstractAccessDecisionManager.accessDenied", "Access is denied"));
|
||||
default:
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_GRANTED:
|
||||
grant++;
|
||||
break;
|
||||
case AccessDecisionVoter.ACCESS_DENIED:
|
||||
throw new AccessDeniedException(this.messages
|
||||
.getMessage("AbstractAccessDecisionManager.accessDenied", "Access is denied"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractUserDetailsReactiveAuthenticationManager
|
||||
if (!user.isAccountNonExpired()) {
|
||||
this.logger.debug("User account is expired");
|
||||
throw new AccountExpiredException(this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AccountStatusUserDetailsChecker implements UserDetailsChecker, Mess
|
||||
if (!user.isCredentialsNonExpired()) {
|
||||
this.logger.debug("Failed to authenticate since user account credentials have expired");
|
||||
throw new CredentialsExpiredException(this.messages
|
||||
.getMessage("AccountStatusUserDetailsChecker.credentialsExpired", "User credentials have expired"));
|
||||
.getMessage("AccountStatusUserDetailsChecker.credentialsExpired", "User credentials have expired"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ public class DefaultAuthenticationEventPublisher
|
||||
|
||||
private Constructor<? extends AbstractAuthenticationEvent> getEventConstructor(AuthenticationException exception) {
|
||||
Constructor<? extends AbstractAuthenticationEvent> eventConstructor = this.exceptionMappings
|
||||
.get(exception.getClass().getName());
|
||||
.get(exception.getClass().getName());
|
||||
return (eventConstructor != null) ? eventConstructor : this.defaultAuthenticationFailureEventConstructor;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class DefaultAuthenticationEventPublisher
|
||||
Map<Class<? extends AuthenticationException>, Class<? extends AbstractAuthenticationFailureEvent>> mappings) {
|
||||
Assert.notEmpty(mappings, "The mappings Map must not be empty nor null");
|
||||
for (Map.Entry<Class<? extends AuthenticationException>, Class<? extends AbstractAuthenticationFailureEvent>> entry : mappings
|
||||
.entrySet()) {
|
||||
.entrySet()) {
|
||||
Class<?> exceptionClass = entry.getKey();
|
||||
Class<?> eventClass = entry.getValue();
|
||||
Assert.notNull(exceptionClass, "exceptionClass cannot be null");
|
||||
@@ -190,7 +190,7 @@ public class DefaultAuthenticationEventPublisher
|
||||
"defaultAuthenticationFailureEventClass must not be null");
|
||||
try {
|
||||
this.defaultAuthenticationFailureEventConstructor = defaultAuthenticationFailureEventClass
|
||||
.getConstructor(Authentication.class, AuthenticationException.class);
|
||||
.getConstructor(Authentication.class, AuthenticationException.class);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new RuntimeException("Default Authentication Failure event class "
|
||||
@@ -201,7 +201,7 @@ public class DefaultAuthenticationEventPublisher
|
||||
private void addMapping(String exceptionClass, Class<? extends AbstractAuthenticationFailureEvent> eventClass) {
|
||||
try {
|
||||
Constructor<? extends AbstractAuthenticationEvent> constructor = eventClass
|
||||
.getConstructor(Authentication.class, AuthenticationException.class);
|
||||
.getConstructor(Authentication.class, AuthenticationException.class);
|
||||
this.exceptionMappings.put(exceptionClass, constructor);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider
|
||||
throw ex;
|
||||
}
|
||||
throw new BadCredentialsException(this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
}
|
||||
Assert.notNull(user, "retrieveUser returned null - a violation of the interface contract");
|
||||
}
|
||||
@@ -320,21 +320,21 @@ public abstract class AbstractUserDetailsAuthenticationProvider
|
||||
public void check(UserDetails user) {
|
||||
if (!user.isAccountNonLocked()) {
|
||||
AbstractUserDetailsAuthenticationProvider.this.logger
|
||||
.debug("Failed to authenticate since user account is locked");
|
||||
.debug("Failed to authenticate since user account is locked");
|
||||
throw new LockedException(AbstractUserDetailsAuthenticationProvider.this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.locked", "User account is locked"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.locked", "User account is locked"));
|
||||
}
|
||||
if (!user.isEnabled()) {
|
||||
AbstractUserDetailsAuthenticationProvider.this.logger
|
||||
.debug("Failed to authenticate since user account is disabled");
|
||||
.debug("Failed to authenticate since user account is disabled");
|
||||
throw new DisabledException(AbstractUserDetailsAuthenticationProvider.this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.disabled", "User is disabled"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.disabled", "User is disabled"));
|
||||
}
|
||||
if (!user.isAccountNonExpired()) {
|
||||
AbstractUserDetailsAuthenticationProvider.this.logger
|
||||
.debug("Failed to authenticate since user account has expired");
|
||||
.debug("Failed to authenticate since user account has expired");
|
||||
throw new AccountExpiredException(AbstractUserDetailsAuthenticationProvider.this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.expired", "User account has expired"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,10 +346,10 @@ public abstract class AbstractUserDetailsAuthenticationProvider
|
||||
public void check(UserDetails user) {
|
||||
if (!user.isCredentialsNonExpired()) {
|
||||
AbstractUserDetailsAuthenticationProvider.this.logger
|
||||
.debug("Failed to authenticate since user account credentials have expired");
|
||||
.debug("Failed to authenticate since user account credentials have expired");
|
||||
throw new CredentialsExpiredException(AbstractUserDetailsAuthenticationProvider.this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.credentialsExpired",
|
||||
"User credentials have expired"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.credentialsExpired",
|
||||
"User credentials have expired"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
||||
if (authentication.getCredentials() == null) {
|
||||
this.logger.debug("Failed to authenticate since no credentials provided");
|
||||
throw new BadCredentialsException(this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
}
|
||||
String presentedPassword = authentication.getCredentials().toString();
|
||||
if (!this.passwordEncoder.matches(presentedPassword, userDetails.getPassword())) {
|
||||
this.logger.debug("Failed to authenticate since password does not match stored value");
|
||||
throw new BadCredentialsException(this.messages
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,8 +248,8 @@ public abstract class AbstractJaasAuthenticationProvider implements Authenticati
|
||||
|
||||
private void logout(JaasAuthenticationToken token, LoginContext loginContext) throws LoginException {
|
||||
if (loginContext != null) {
|
||||
this.log.debug(
|
||||
LogMessage.of(() -> "Logging principal: [" + token.getPrincipal() + "] out of LoginContext"));
|
||||
this.log
|
||||
.debug(LogMessage.of(() -> "Logging principal: [" + token.getPrincipal() + "] out of LoginContext"));
|
||||
loginContext.logout();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SecurityContextLoginModule implements LoginModule {
|
||||
private static final Log log = LogFactory.getLog(SecurityContextLoginModule.class);
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
private Authentication authen;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, Ini
|
||||
Object credentials = authentication.getCredentials();
|
||||
String password = (credentials != null) ? credentials.toString() : null;
|
||||
Collection<? extends GrantedAuthority> authorities = this.remoteAuthenticationManager
|
||||
.attemptAuthentication(username, password);
|
||||
.attemptAuthentication(username, password);
|
||||
return UsernamePasswordAuthenticationToken.authenticated(username, password, authorities);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,9 @@ public class AuthenticatedReactiveAuthorizationManager<T> implements ReactiveAut
|
||||
|
||||
@Override
|
||||
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, T object) {
|
||||
return authentication.filter(this::isNotAnonymous).map(this::getAuthorizationDecision)
|
||||
.defaultIfEmpty(new AuthorizationDecision(false));
|
||||
return authentication.filter(this::isNotAnonymous)
|
||||
.map(this::getAuthorizationDecision)
|
||||
.defaultIfEmpty(new AuthorizationDecision(false));
|
||||
}
|
||||
|
||||
private AuthorizationDecision getAuthorizationDecision(Authentication authentication) {
|
||||
|
||||
@@ -99,9 +99,12 @@ public final class AuthorizationManagerAfterReactiveMethodInterceptor
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
Method method = mi.getMethod();
|
||||
Class<?> type = method.getReturnType();
|
||||
Assert.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format("The returnType %s on %s must return an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context", type, method));
|
||||
Assert
|
||||
.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format(
|
||||
"The returnType %s on %s must return an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context",
|
||||
type, method));
|
||||
Mono<Authentication> authentication = ReactiveAuthenticationUtils.getAuthentication();
|
||||
Function<Object, Mono<?>> postAuthorize = (result) -> postAuthorize(authentication, mi, result);
|
||||
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(type);
|
||||
@@ -123,7 +126,7 @@ public final class AuthorizationManagerAfterReactiveMethodInterceptor
|
||||
|
||||
private Mono<?> postAuthorize(Mono<Authentication> authentication, MethodInvocation mi, Object result) {
|
||||
return this.authorizationManager.verify(authentication, new MethodInvocationResult(mi, result))
|
||||
.thenReturn(result);
|
||||
.thenReturn(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,9 +99,12 @@ public final class AuthorizationManagerBeforeReactiveMethodInterceptor
|
||||
public Object invoke(MethodInvocation mi) throws Throwable {
|
||||
Method method = mi.getMethod();
|
||||
Class<?> type = method.getReturnType();
|
||||
Assert.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format("The returnType %s on %s must return an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context", type, method));
|
||||
Assert
|
||||
.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format(
|
||||
"The returnType %s on %s must return an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context",
|
||||
type, method));
|
||||
Mono<Authentication> authentication = ReactiveAuthenticationUtils.getAuthentication();
|
||||
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(type);
|
||||
Mono<Void> preAuthorize = this.authorizationManager.verify(authentication, mi);
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class MethodExpressionAuthorizationManager implements Authorization
|
||||
Assert.notNull(expressionHandler, "expressionHandler cannot be null");
|
||||
this.expressionHandler = expressionHandler;
|
||||
this.expression = expressionHandler.getExpressionParser()
|
||||
.parseExpression(this.expression.getExpressionString());
|
||||
.parseExpression(this.expression.getExpressionString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -59,7 +59,7 @@ final class PostAuthorizeExpressionAttributeRegistry extends AbstractExpressionA
|
||||
return ExpressionAttribute.NULL_ATTRIBUTE;
|
||||
}
|
||||
Expression postAuthorizeExpression = this.expressionHandler.getExpressionParser()
|
||||
.parseExpression(postAuthorize.value());
|
||||
.parseExpression(postAuthorize.value());
|
||||
return new ExpressionAttribute(postAuthorizeExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,12 +83,15 @@ public final class PostFilterAuthorizationReactiveMethodInterceptor
|
||||
return ReactiveMethodInvocationUtils.proceed(mi);
|
||||
}
|
||||
Mono<EvaluationContext> toInvoke = ReactiveAuthenticationUtils.getAuthentication()
|
||||
.map((auth) -> this.registry.getExpressionHandler().createEvaluationContext(auth, mi));
|
||||
.map((auth) -> this.registry.getExpressionHandler().createEvaluationContext(auth, mi));
|
||||
Method method = mi.getMethod();
|
||||
Class<?> type = method.getReturnType();
|
||||
Assert.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format("The parameter type %s on %s must be an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context", type, method));
|
||||
Assert
|
||||
.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format(
|
||||
"The parameter type %s on %s must be an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context",
|
||||
type, method));
|
||||
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(type);
|
||||
if (isMultiValue(type, adapter)) {
|
||||
Publisher<?> publisher = Flux.defer(() -> ReactiveMethodInvocationUtils.proceed(mi));
|
||||
@@ -108,13 +111,15 @@ public final class PostFilterAuthorizationReactiveMethodInterceptor
|
||||
}
|
||||
|
||||
private Mono<?> filterSingleValue(Publisher<?> publisher, EvaluationContext ctx, ExpressionAttribute attribute) {
|
||||
return Mono.from(publisher).doOnNext((result) -> setFilterObject(ctx, result))
|
||||
.flatMap((result) -> postFilter(ctx, result, attribute));
|
||||
return Mono.from(publisher)
|
||||
.doOnNext((result) -> setFilterObject(ctx, result))
|
||||
.flatMap((result) -> postFilter(ctx, result, attribute));
|
||||
}
|
||||
|
||||
private Flux<?> filterMultiValue(Publisher<?> publisher, EvaluationContext ctx, ExpressionAttribute attribute) {
|
||||
return Flux.from(publisher).doOnNext((result) -> setFilterObject(ctx, result))
|
||||
.flatMap((result) -> postFilter(ctx, result, attribute));
|
||||
return Flux.from(publisher)
|
||||
.doOnNext((result) -> setFilterObject(ctx, result))
|
||||
.flatMap((result) -> postFilter(ctx, result, attribute));
|
||||
}
|
||||
|
||||
private void setFilterObject(EvaluationContext ctx, Object result) {
|
||||
@@ -123,7 +128,7 @@ public final class PostFilterAuthorizationReactiveMethodInterceptor
|
||||
|
||||
private Mono<?> postFilter(EvaluationContext ctx, Object result, ExpressionAttribute attribute) {
|
||||
return ReactiveExpressionUtils.evaluateAsBoolean(attribute.getExpression(), ctx)
|
||||
.flatMap((granted) -> granted ? Mono.just(result) : Mono.empty());
|
||||
.flatMap((granted) -> granted ? Mono.just(result) : Mono.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -58,7 +58,7 @@ final class PostFilterExpressionAttributeRegistry extends AbstractExpressionAttr
|
||||
return ExpressionAttribute.NULL_ATTRIBUTE;
|
||||
}
|
||||
Expression postFilterExpression = this.expressionHandler.getExpressionParser()
|
||||
.parseExpression(postFilter.value());
|
||||
.parseExpression(postFilter.value());
|
||||
return new ExpressionAttribute(postFilterExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ final class PreAuthorizeExpressionAttributeRegistry extends AbstractExpressionAt
|
||||
return ExpressionAttribute.NULL_ATTRIBUTE;
|
||||
}
|
||||
Expression preAuthorizeExpression = this.expressionHandler.getExpressionParser()
|
||||
.parseExpression(preAuthorize.value());
|
||||
.parseExpression(preAuthorize.value());
|
||||
return new ExpressionAttribute(preAuthorizeExpression);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,21 +96,24 @@ public final class PreFilterAuthorizationReactiveMethodInterceptor
|
||||
}
|
||||
FilterTarget filterTarget = findFilterTarget(attribute.getFilterTarget(), mi);
|
||||
Mono<EvaluationContext> toInvoke = ReactiveAuthenticationUtils.getAuthentication()
|
||||
.map((auth) -> this.registry.getExpressionHandler().createEvaluationContext(auth, mi));
|
||||
.map((auth) -> this.registry.getExpressionHandler().createEvaluationContext(auth, mi));
|
||||
Method method = mi.getMethod();
|
||||
Class<?> type = filterTarget.value.getClass();
|
||||
Assert.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format("The parameter type %s on %s must be an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context", type, method));
|
||||
Assert
|
||||
.state(Publisher.class.isAssignableFrom(type),
|
||||
() -> String.format(
|
||||
"The parameter type %s on %s must be an instance of org.reactivestreams.Publisher "
|
||||
+ "(for example, a Mono or Flux) in order to support Reactor Context",
|
||||
type, method));
|
||||
ReactiveAdapter adapter = ReactiveAdapterRegistry.getSharedInstance().getAdapter(type);
|
||||
if (isMultiValue(type, adapter)) {
|
||||
Flux<?> result = toInvoke
|
||||
.flatMapMany((ctx) -> filterMultiValue(filterTarget.value, attribute.getExpression(), ctx));
|
||||
.flatMapMany((ctx) -> filterMultiValue(filterTarget.value, attribute.getExpression(), ctx));
|
||||
mi.getArguments()[filterTarget.index] = (adapter != null) ? adapter.fromPublisher(result) : result;
|
||||
}
|
||||
else {
|
||||
Mono<?> result = toInvoke
|
||||
.flatMap((ctx) -> filterSingleValue(filterTarget.value, attribute.getExpression(), ctx));
|
||||
.flatMap((ctx) -> filterSingleValue(filterTarget.value, attribute.getExpression(), ctx));
|
||||
mi.getArguments()[filterTarget.index] = (adapter != null) ? adapter.fromPublisher(result) : result;
|
||||
}
|
||||
return ReactiveMethodInvocationUtils.proceed(mi);
|
||||
@@ -157,7 +160,7 @@ public final class PreFilterAuthorizationReactiveMethodInterceptor
|
||||
|
||||
private Mono<?> filterSingleValue(Publisher<?> filterTarget, Expression filterExpression, EvaluationContext ctx) {
|
||||
MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx.getRootObject()
|
||||
.getValue();
|
||||
.getValue();
|
||||
return Mono.from(filterTarget).filterWhen((filterObject) -> {
|
||||
rootObject.setFilterObject(filterObject);
|
||||
return ReactiveExpressionUtils.evaluateAsBoolean(filterExpression, ctx);
|
||||
@@ -166,7 +169,7 @@ public final class PreFilterAuthorizationReactiveMethodInterceptor
|
||||
|
||||
private Flux<?> filterMultiValue(Publisher<?> filterTarget, Expression filterExpression, EvaluationContext ctx) {
|
||||
MethodSecurityExpressionOperations rootObject = (MethodSecurityExpressionOperations) ctx.getRootObject()
|
||||
.getValue();
|
||||
.getValue();
|
||||
return Flux.from(filterTarget).filterWhen((filterObject) -> {
|
||||
rootObject.setFilterObject(filterObject);
|
||||
return ReactiveExpressionUtils.evaluateAsBoolean(filterExpression, ctx);
|
||||
|
||||
@@ -59,7 +59,7 @@ final class PreFilterExpressionAttributeRegistry
|
||||
return PreFilterExpressionAttribute.NULL_ATTRIBUTE;
|
||||
}
|
||||
Expression preFilterExpression = this.expressionHandler.getExpressionParser()
|
||||
.parseExpression(preFilter.value());
|
||||
.parseExpression(preFilter.value());
|
||||
return new PreFilterExpressionAttribute(preFilterExpression, preFilter.filterTarget());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,9 @@ final class ReactiveAuthenticationUtils {
|
||||
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
|
||||
|
||||
static Mono<Authentication> getAuthentication() {
|
||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication)
|
||||
.defaultIfEmpty(ANONYMOUS);
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.map(SecurityContext::getAuthentication)
|
||||
.defaultIfEmpty(ANONYMOUS);
|
||||
}
|
||||
|
||||
private ReactiveAuthenticationUtils() {
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.Assert;
|
||||
abstract class AbstractDelegatingSecurityContextSupport {
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
private final SecurityContext securityContext;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class DelegatingSecurityContextCallable<V> implements Callable<V> {
|
||||
private SecurityContext delegateSecurityContext;
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
/**
|
||||
* The {@link SecurityContext} that was on the {@link SecurityContextHolder} prior to
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class DelegatingSecurityContextRunnable implements Runnable {
|
||||
private final boolean explicitSecurityContextProvided;
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
/**
|
||||
* The {@link SecurityContext} that the delegate {@link Runnable} will be ran as.
|
||||
|
||||
@@ -205,7 +205,7 @@ public final class RsaKeyConverters {
|
||||
byte[] x509 = Base64.getDecoder().decode(base64Encoded.toString());
|
||||
try (InputStream x509CertStream = new ByteArrayInputStream(x509)) {
|
||||
X509Certificate certificate = (X509Certificate) this.certificateFactory
|
||||
.generateCertificate(x509CertStream);
|
||||
.generateCertificate(x509CertStream);
|
||||
return (RSAPublicKey) certificate.getPublicKey();
|
||||
}
|
||||
catch (CertificateException | IOException ex) {
|
||||
|
||||
@@ -131,21 +131,21 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
|
||||
switch (item.getType()) {
|
||||
case INT_ITEM:
|
||||
int itemValue = ((IntItem) item).value;
|
||||
return (value < itemValue) ? -1 : ((value == itemValue) ? 0 : 1);
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
case INT_ITEM:
|
||||
int itemValue = ((IntItem) item).value;
|
||||
return (value < itemValue) ? -1 : ((value == itemValue) ? 0 : 1);
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,22 +205,22 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
|
||||
switch (item.getType()) {
|
||||
case INT_ITEM:
|
||||
return 1;
|
||||
case LONG_ITEM:
|
||||
long itemValue = ((LongItem) item).value;
|
||||
return (value < itemValue) ? -1 : ((value == itemValue) ? 0 : 1);
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
case INT_ITEM:
|
||||
return 1;
|
||||
case LONG_ITEM:
|
||||
long itemValue = ((LongItem) item).value;
|
||||
return (value < itemValue) ? -1 : ((value == itemValue) ? 0 : 1);
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1;
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,21 +279,21 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
}
|
||||
|
||||
switch (item.getType()) {
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
return 1;
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
return 1;
|
||||
|
||||
case BIGINTEGER_ITEM:
|
||||
return value.compareTo(((BigIntegerItem) item).value);
|
||||
case BIGINTEGER_ITEM:
|
||||
return value.compareTo(((BigIntegerItem) item).value);
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
case STRING_ITEM:
|
||||
return 1; // 1.1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
case LIST_ITEM:
|
||||
return 1; // 1.1 > 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,16 +352,16 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
if (followedByDigit && value.length() == 1) {
|
||||
// a1 = alpha-1, b1 = beta-1, m1 = milestone-1
|
||||
switch (value.charAt(0)) {
|
||||
case 'a':
|
||||
value = "alpha";
|
||||
break;
|
||||
case 'b':
|
||||
value = "beta";
|
||||
break;
|
||||
case 'm':
|
||||
value = "milestone";
|
||||
break;
|
||||
default:
|
||||
case 'a':
|
||||
value = "alpha";
|
||||
break;
|
||||
case 'b':
|
||||
value = "beta";
|
||||
break;
|
||||
case 'm':
|
||||
value = "milestone";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
this.value = ALIASES.getProperty(value, value);
|
||||
@@ -403,19 +403,19 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX);
|
||||
}
|
||||
switch (item.getType()) {
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1.any < 1.1 ?
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1.any < 1.1 ?
|
||||
|
||||
case STRING_ITEM:
|
||||
return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value));
|
||||
case STRING_ITEM:
|
||||
return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value));
|
||||
|
||||
case LIST_ITEM:
|
||||
return -1; // 1.any < 1-1
|
||||
case LIST_ITEM:
|
||||
return -1; // 1.any < 1-1
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,34 +485,34 @@ class ComparableVersion implements Comparable<ComparableVersion> {
|
||||
return first.compareTo(null);
|
||||
}
|
||||
switch (item.getType()) {
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1-1 < 1.0.x
|
||||
case INT_ITEM:
|
||||
case LONG_ITEM:
|
||||
case BIGINTEGER_ITEM:
|
||||
return -1; // 1-1 < 1.0.x
|
||||
|
||||
case STRING_ITEM:
|
||||
return 1; // 1-1 > 1-sp
|
||||
case STRING_ITEM:
|
||||
return 1; // 1-1 > 1-sp
|
||||
|
||||
case LIST_ITEM:
|
||||
Iterator<Item> left = iterator();
|
||||
Iterator<Item> right = ((ListItem) item).iterator();
|
||||
case LIST_ITEM:
|
||||
Iterator<Item> left = iterator();
|
||||
Iterator<Item> right = ((ListItem) item).iterator();
|
||||
|
||||
while (left.hasNext() || right.hasNext()) {
|
||||
Item l = left.hasNext() ? left.next() : null;
|
||||
Item r = right.hasNext() ? right.next() : null;
|
||||
while (left.hasNext() || right.hasNext()) {
|
||||
Item l = left.hasNext() ? left.next() : null;
|
||||
Item r = right.hasNext() ? right.next() : null;
|
||||
|
||||
// if this is shorter, then invert the compare and mul with -1
|
||||
int result = l == null ? (r == null ? 0 : -1 * r.compareTo(l)) : l.compareTo(r);
|
||||
// if this is shorter, then invert the compare and mul with -1
|
||||
int result = l == null ? (r == null ? 0 : -1 * r.compareTo(l)) : l.compareTo(r);
|
||||
|
||||
if (result != 0) {
|
||||
return result;
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
default:
|
||||
throw new IllegalStateException("invalid item: " + item.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public final class SpringSecurityCoreVersion {
|
||||
private static String getSpringVersion() {
|
||||
Properties properties = new Properties();
|
||||
try (InputStream is = SpringSecurityCoreVersion.class.getClassLoader()
|
||||
.getResourceAsStream("META-INF/spring-security.versions")) {
|
||||
.getResourceAsStream("META-INF/spring-security.versions")) {
|
||||
properties.load(is);
|
||||
}
|
||||
catch (IOException | NullPointerException ex) {
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.springframework.security.core.Authentication;
|
||||
* @since 4.0
|
||||
*
|
||||
* See: <a href=
|
||||
* "{@docRoot}/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.html"
|
||||
* > AuthenticationPrincipalArgumentResolver </a>
|
||||
* "{@docRoot}/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolver.html" >
|
||||
* AuthenticationPrincipalArgumentResolver </a>
|
||||
*/
|
||||
@Target({ ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -31,14 +31,14 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "{@docRoot}/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.html"
|
||||
* > CurrentSecurityContextArgumentResolver</a> For Servlet
|
||||
* "{@docRoot}/org/springframework/security/web/bind/support/CurrentSecurityContextArgumentResolver.html" >
|
||||
* CurrentSecurityContextArgumentResolver</a> For Servlet
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "{@docRoot}/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolver.html"
|
||||
* > CurrentSecurityContextArgumentResolver</a> For WebFlux
|
||||
* "{@docRoot}/org/springframework/security/web/reactive/result/method/annotation/CurrentSecurityContextArgumentResolver.html" >
|
||||
* CurrentSecurityContextArgumentResolver</a> For WebFlux
|
||||
* </p>
|
||||
*/
|
||||
@Target({ ElementType.PARAMETER, ElementType.ANNOTATION_TYPE })
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.lang.annotation.Target;
|
||||
* contain the parameter names.
|
||||
*
|
||||
* @see AnnotationParameterNameDiscoverer
|
||||
*
|
||||
* @author Rob Winch
|
||||
* @since 5.0
|
||||
*/
|
||||
|
||||
@@ -41,8 +41,8 @@ import org.springframework.util.Assert;
|
||||
* <p>
|
||||
* For this class to function correctly in a web application, it is important that you
|
||||
* register an <a href="
|
||||
* {@docRoot}/org/springframework/security/web/session/HttpSessionEventPublisher.html">HttpSessionEventPublisher</a>
|
||||
* in the <tt>web.xml</tt> file so that this class is notified of sessions that expire.
|
||||
* {@docRoot}/org/springframework/security/web/session/HttpSessionEventPublisher.html">HttpSessionEventPublisher</a> in
|
||||
* the <tt>web.xml</tt> file so that this class is notified of sessions that expire.
|
||||
*
|
||||
* @author Ben Alex
|
||||
* @author Luke Taylor
|
||||
@@ -158,16 +158,16 @@ public class SessionRegistryImpl implements SessionRegistry, ApplicationListener
|
||||
}
|
||||
this.sessionIds.remove(sessionId);
|
||||
this.principals.computeIfPresent(info.getPrincipal(), (key, sessionsUsedByPrincipal) -> {
|
||||
this.logger.debug(
|
||||
LogMessage.format("Removing session %s from principal's set of registered sessions", sessionId));
|
||||
this.logger
|
||||
.debug(LogMessage.format("Removing session %s from principal's set of registered sessions", sessionId));
|
||||
sessionsUsedByPrincipal.remove(sessionId);
|
||||
if (sessionsUsedByPrincipal.isEmpty()) {
|
||||
// No need to keep object in principals Map anymore
|
||||
this.logger.debug(LogMessage.format("Removing principal %s from registry", info.getPrincipal()));
|
||||
sessionsUsedByPrincipal = null;
|
||||
}
|
||||
this.logger.trace(
|
||||
LogMessage.format("Sessions used by '%s' : %s", info.getPrincipal(), sessionsUsedByPrincipal));
|
||||
this.logger
|
||||
.trace(LogMessage.format("Sessions used by '%s' : %s", info.getPrincipal(), sessionsUsedByPrincipal));
|
||||
return sessionsUsedByPrincipal;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi
|
||||
return null;
|
||||
}
|
||||
String[] tokens = StringUtils
|
||||
.delimitedListToStringArray(Utf8.decode(Base64.getDecoder().decode(Utf8.encode(key))), ":");
|
||||
.delimitedListToStringArray(Utf8.decode(Base64.getDecoder().decode(Utf8.encode(key))), ":");
|
||||
Assert.isTrue(tokens.length >= 4, () -> "Expected 4 or more tokens but found " + tokens.length);
|
||||
long creationTime;
|
||||
try {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager, UserDetai
|
||||
private final Map<String, MutableUserDetails> users = new HashMap<>();
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@@ -130,7 +130,7 @@ public class InMemoryUserDetailsManager implements UserDetailsManager, UserDetai
|
||||
if (this.authenticationManager != null) {
|
||||
this.logger.debug(LogMessage.format("Reauthenticating user '%s' for password change request.", username));
|
||||
this.authenticationManager
|
||||
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated(username, oldPassword));
|
||||
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated(username, oldPassword));
|
||||
}
|
||||
else {
|
||||
this.logger.debug("No authentication manager set. Password won't be re-checked.");
|
||||
|
||||
@@ -110,7 +110,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SecurityContextHolderStrategy securityContextHolderStrategy = SecurityContextHolder
|
||||
.getContextHolderStrategy();
|
||||
.getContextHolderStrategy();
|
||||
|
||||
private String createUserSql = DEF_CREATE_USER_SQL;
|
||||
|
||||
@@ -276,7 +276,7 @@ public class JdbcUserDetailsManager extends JdbcDaoImpl implements UserDetailsMa
|
||||
if (this.authenticationManager != null) {
|
||||
this.logger.debug(LogMessage.format("Reauthenticating user '%s' for password change request.", username));
|
||||
this.authenticationManager
|
||||
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated(username, oldPassword));
|
||||
.authenticate(UsernamePasswordAuthenticationToken.unauthenticated(username, oldPassword));
|
||||
}
|
||||
else {
|
||||
this.logger.debug("No authentication manager set. Password won't be re-checked.");
|
||||
|
||||
Reference in New Issue
Block a user