Use Supplier variants of Assert methods
This commit is contained in:
committed by
Rob Winch
parent
7d4e7bf42d
commit
d07cfe655d
+1
-1
@@ -54,7 +54,7 @@ public class SecuredAnnotationSecurityMetadataSource extends
|
||||
annotationType = (Class<? extends Annotation>) GenericTypeResolver
|
||||
.resolveTypeArgument(annotationExtractor.getClass(),
|
||||
AnnotationMetadataExtractor.class);
|
||||
Assert.notNull(annotationType, annotationExtractor.getClass().getName()
|
||||
Assert.notNull(annotationType, () -> annotationExtractor.getClass().getName()
|
||||
+ " must supply a generic parameter for AnnotationMetadataExtractor");
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -136,18 +136,18 @@ public abstract class AbstractSecurityInterceptor implements InitializingBean,
|
||||
"An SecurityMetadataSource is required");
|
||||
Assert.isTrue(this.obtainSecurityMetadataSource()
|
||||
.supports(getSecureObjectClass()),
|
||||
"SecurityMetadataSource does not support secure object class: "
|
||||
() -> "SecurityMetadataSource does not support secure object class: "
|
||||
+ getSecureObjectClass());
|
||||
Assert.isTrue(this.runAsManager.supports(getSecureObjectClass()),
|
||||
"RunAsManager does not support secure object class: "
|
||||
() -> "RunAsManager does not support secure object class: "
|
||||
+ getSecureObjectClass());
|
||||
Assert.isTrue(this.accessDecisionManager.supports(getSecureObjectClass()),
|
||||
"AccessDecisionManager does not support secure object class: "
|
||||
() -> "AccessDecisionManager does not support secure object class: "
|
||||
+ getSecureObjectClass());
|
||||
|
||||
if (this.afterInvocationManager != null) {
|
||||
Assert.isTrue(this.afterInvocationManager.supports(getSecureObjectClass()),
|
||||
"AfterInvocationManager does not support secure object class: "
|
||||
() -> "AfterInvocationManager does not support secure object class: "
|
||||
+ getSecureObjectClass());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ public class AfterInvocationProviderManager implements AfterInvocationManager,
|
||||
|
||||
for (Object currentObject : newList) {
|
||||
Assert.isInstanceOf(AfterInvocationProvider.class, currentObject,
|
||||
"AfterInvocationProvider " + currentObject.getClass().getName()
|
||||
() -> "AfterInvocationProvider " + currentObject.getClass().getName()
|
||||
+ " must implement AfterInvocationProvider");
|
||||
providers.add((AfterInvocationProvider) currentObject);
|
||||
}
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ public class MapBasedMethodSecurityMetadataSource extends
|
||||
}
|
||||
|
||||
String methodName = name.substring(lastDotIndex + 1);
|
||||
Assert.hasText(methodName, "Method not found for '" + name + "'");
|
||||
Assert.hasText(methodName, () -> "Method not found for '" + name + "'");
|
||||
|
||||
String typeName = name.substring(0, lastDotIndex);
|
||||
Class<?> type = ClassUtils.resolveClassName(typeName, this.beanClassLoader);
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ public abstract class AbstractUserDetailsAuthenticationProvider implements
|
||||
public Authentication authenticate(Authentication authentication)
|
||||
throws AuthenticationException {
|
||||
Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication,
|
||||
messages.getMessage(
|
||||
() -> messages.getMessage(
|
||||
"AbstractUserDetailsAuthenticationProvider.onlySupports",
|
||||
"Only UsernamePasswordAuthenticationToken is supported"));
|
||||
|
||||
|
||||
+3
-2
@@ -158,8 +158,9 @@ public class JaasAuthenticationProvider extends AbstractJaasAuthenticationProvid
|
||||
// the superclass is not called because it does additional checks that are
|
||||
// non-passive
|
||||
Assert.hasLength(getLoginContextName(),
|
||||
"loginContextName must be set on " + getClass());
|
||||
Assert.notNull(this.loginConfig, "loginConfig must be set on " + getClass());
|
||||
() -> "loginContextName must be set on " + getClass());
|
||||
Assert.notNull(this.loginConfig,
|
||||
() -> "loginConfig must be set on " + getClass());
|
||||
configureJaas(this.loginConfig);
|
||||
|
||||
Assert.notNull(Configuration.getConfiguration(),
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -100,7 +100,7 @@ public class KeyBasedPersistenceTokenService implements TokenService, Initializi
|
||||
}
|
||||
String[] tokens = StringUtils.delimitedListToStringArray(
|
||||
Utf8.decode(Base64.getDecoder().decode(Utf8.encode(key))), ":");
|
||||
Assert.isTrue(tokens.length >= 4, "Expected 4 or more tokens but found "
|
||||
Assert.isTrue(tokens.length >= 4, () -> "Expected 4 or more tokens but found "
|
||||
+ tokens.length);
|
||||
|
||||
long creationTime;
|
||||
|
||||
@@ -433,7 +433,7 @@ public class User implements UserDetails, CredentialsContainer {
|
||||
List<GrantedAuthority> authorities = new ArrayList<>(
|
||||
roles.length);
|
||||
for (String role : roles) {
|
||||
Assert.isTrue(!role.startsWith("ROLE_"), role
|
||||
Assert.isTrue(!role.startsWith("ROLE_"), () -> role
|
||||
+ " cannot start with ROLE_ (it is automatically added)");
|
||||
authorities.add(new SimpleGrantedAuthority("ROLE_" + role));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user