Use consistent ternary expression style
Update all ternary expressions so that the condition is always in parentheses and "not equals" is used in the test. This helps to bring consistency across the codebase which makes ternary expression easier to scan. For example: `a = (a != null) ? a : b` Issue gh-8945
This commit is contained in:
parent
8d3f039f76
commit
834dcf5bcf
|
@ -125,7 +125,7 @@ public class AccessControlEntryImpl implements AccessControlEntry, AuditableAcce
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = this.permission.hashCode();
|
int result = this.permission.hashCode();
|
||||||
result = 31 * result + (this.id != null ? this.id.hashCode() : 0);
|
result = 31 * result + ((this.id != null) ? this.id.hashCode() : 0);
|
||||||
result = 31 * result + (this.sid.hashCode());
|
result = 31 * result + (this.sid.hashCode());
|
||||||
result = 31 * result + (this.auditFailure ? 1 : 0);
|
result = 31 * result + (this.auditFailure ? 1 : 0);
|
||||||
result = 31 * result + (this.auditSuccess ? 1 : 0);
|
result = 31 * result + (this.auditSuccess ? 1 : 0);
|
||||||
|
|
|
@ -307,15 +307,15 @@ public class AclImpl implements Acl, MutableAcl, AuditableAcl, OwnershipAcl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = this.parentAcl != null ? this.parentAcl.hashCode() : 0;
|
int result = (this.parentAcl != null) ? this.parentAcl.hashCode() : 0;
|
||||||
result = 31 * result + this.aclAuthorizationStrategy.hashCode();
|
result = 31 * result + this.aclAuthorizationStrategy.hashCode();
|
||||||
result = 31 * result
|
result = 31 * result
|
||||||
+ (this.permissionGrantingStrategy != null ? this.permissionGrantingStrategy.hashCode() : 0);
|
+ ((this.permissionGrantingStrategy != null) ? this.permissionGrantingStrategy.hashCode() : 0);
|
||||||
result = 31 * result + (this.aces != null ? this.aces.hashCode() : 0);
|
result = 31 * result + ((this.aces != null) ? this.aces.hashCode() : 0);
|
||||||
result = 31 * result + this.objectIdentity.hashCode();
|
result = 31 * result + this.objectIdentity.hashCode();
|
||||||
result = 31 * result + this.id.hashCode();
|
result = 31 * result + this.id.hashCode();
|
||||||
result = 31 * result + (this.owner != null ? this.owner.hashCode() : 0);
|
result = 31 * result + ((this.owner != null) ? this.owner.hashCode() : 0);
|
||||||
result = 31 * result + (this.loadedSids != null ? this.loadedSids.hashCode() : 0);
|
result = 31 * result + ((this.loadedSids != null) ? this.loadedSids.hashCode() : 0);
|
||||||
result = 31 * result + (this.entriesInheriting ? 1 : 0);
|
result = 31 * result + (this.entriesInheriting ? 1 : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.SpringSecurityCoreVersion;
|
import org.springframework.security.core.SpringSecurityCoreVersion;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a successful CAS <code>Authentication</code>.
|
* Represents a successful CAS <code>Authentication</code>.
|
||||||
|
@ -141,7 +142,7 @@ public class CasAuthenticationToken extends AbstractAuthenticationToken implemen
|
||||||
result = 31 * result + this.principal.hashCode();
|
result = 31 * result + this.principal.hashCode();
|
||||||
result = 31 * result + this.userDetails.hashCode();
|
result = 31 * result + this.userDetails.hashCode();
|
||||||
result = 31 * result + this.keyHash;
|
result = 31 * result + this.keyHash;
|
||||||
result = 31 * result + (this.assertion != null ? this.assertion.hashCode() : 0);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(this.assertion);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
|
||||||
logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
|
logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element == null ? null : (CasAuthenticationToken) element.getValue();
|
return (element != null) ? (CasAuthenticationToken) element.getValue() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ehcache getCache() {
|
public Ehcache getCache() {
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class SpringCacheBasedTicketCache implements StatelessTicketCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CasAuthenticationToken getByTicketId(final String serviceTicket) {
|
public CasAuthenticationToken getByTicketId(final String serviceTicket) {
|
||||||
final Cache.ValueWrapper element = serviceTicket != null ? this.cache.get(serviceTicket) : null;
|
final Cache.ValueWrapper element = (serviceTicket != null) ? this.cache.get(serviceTicket) : null;
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
|
logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element == null ? null : (CasAuthenticationToken) element.get();
|
return (element != null) ? (CasAuthenticationToken) element.get() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -151,7 +151,7 @@ public final class SecurityNamespaceHandler implements NamespaceHandler {
|
||||||
|
|
||||||
private void reportUnsupportedNodeType(String name, ParserContext pc, Node node) {
|
private void reportUnsupportedNodeType(String name, ParserContext pc, Node node) {
|
||||||
pc.getReaderContext().fatal("Security namespace does not support decoration of "
|
pc.getReaderContext().fatal("Security namespace does not support decoration of "
|
||||||
+ (node instanceof Element ? "element" : "attribute") + " [" + name + "]", node);
|
+ ((node instanceof Element) ? "element" : "attribute") + " [" + name + "]", node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportMissingWebClasses(String nodeName, ParserContext pc, Node node) {
|
private void reportMissingWebClasses(String nodeName, ParserContext pc, Node node) {
|
||||||
|
|
|
@ -187,8 +187,8 @@ public class LdapAuthenticationProviderConfigurer<B extends ProviderManagerBuild
|
||||||
* @return the {@link LdapAuthenticator} to use
|
* @return the {@link LdapAuthenticator} to use
|
||||||
*/
|
*/
|
||||||
private LdapAuthenticator createLdapAuthenticator(BaseLdapPathContextSource contextSource) {
|
private LdapAuthenticator createLdapAuthenticator(BaseLdapPathContextSource contextSource) {
|
||||||
AbstractLdapAuthenticator ldapAuthenticator = this.passwordEncoder == null
|
AbstractLdapAuthenticator ldapAuthenticator = (this.passwordEncoder != null)
|
||||||
? createBindAuthenticator(contextSource) : createPasswordCompareAuthenticator(contextSource);
|
? createPasswordCompareAuthenticator(contextSource) : createBindAuthenticator(contextSource);
|
||||||
LdapUserSearch userSearch = createUserSearch();
|
LdapUserSearch userSearch = createUserSearch();
|
||||||
if (userSearch != null) {
|
if (userSearch != null) {
|
||||||
ldapAuthenticator.setUserSearch(userSearch);
|
ldapAuthenticator.setUserSearch(userSearch);
|
||||||
|
|
|
@ -247,7 +247,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||||
* @return a {@link List} of {@link AntPathRequestMatcher} instances
|
* @return a {@link List} of {@link AntPathRequestMatcher} instances
|
||||||
*/
|
*/
|
||||||
static List<RequestMatcher> antMatchers(HttpMethod httpMethod, String... antPatterns) {
|
static List<RequestMatcher> antMatchers(HttpMethod httpMethod, String... antPatterns) {
|
||||||
String method = httpMethod == null ? null : httpMethod.toString();
|
String method = (httpMethod != null) ? httpMethod.toString() : null;
|
||||||
List<RequestMatcher> matchers = new ArrayList<>();
|
List<RequestMatcher> matchers = new ArrayList<>();
|
||||||
for (String pattern : antPatterns) {
|
for (String pattern : antPatterns) {
|
||||||
matchers.add(new AntPathRequestMatcher(pattern, method));
|
matchers.add(new AntPathRequestMatcher(pattern, method));
|
||||||
|
@ -275,7 +275,7 @@ public abstract class AbstractRequestMatcherRegistry<C> {
|
||||||
* @return a {@link List} of {@link RegexRequestMatcher} instances
|
* @return a {@link List} of {@link RegexRequestMatcher} instances
|
||||||
*/
|
*/
|
||||||
static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, String... regexPatterns) {
|
static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, String... regexPatterns) {
|
||||||
String method = httpMethod == null ? null : httpMethod.toString();
|
String method = (httpMethod != null) ? httpMethod.toString() : null;
|
||||||
List<RequestMatcher> matchers = new ArrayList<>();
|
List<RequestMatcher> matchers = new ArrayList<>();
|
||||||
for (String pattern : regexPatterns) {
|
for (String pattern : regexPatterns) {
|
||||||
matchers.add(new RegexRequestMatcher(pattern, method));
|
matchers.add(new RegexRequestMatcher(pattern, method));
|
||||||
|
|
|
@ -242,8 +242,8 @@ public final class WebSecurity extends AbstractConfiguredSecurityBuilder<Filter,
|
||||||
if (this.privilegeEvaluator != null) {
|
if (this.privilegeEvaluator != null) {
|
||||||
return this.privilegeEvaluator;
|
return this.privilegeEvaluator;
|
||||||
}
|
}
|
||||||
return this.filterSecurityInterceptor == null ? null
|
return (this.filterSecurityInterceptor != null)
|
||||||
: new DefaultWebInvocationPrivilegeEvaluator(this.filterSecurityInterceptor);
|
? new DefaultWebInvocationPrivilegeEvaluator(this.filterSecurityInterceptor) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -227,7 +227,7 @@ public class WebSecurityConfiguration implements ImportAware, BeanClassLoaderAwa
|
||||||
return ((Ordered) obj).getOrder();
|
return ((Ordered) obj).getOrder();
|
||||||
}
|
}
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
Class<?> clazz = (obj instanceof Class ? (Class<?>) obj : obj.getClass());
|
Class<?> clazz = ((obj instanceof Class) ? (Class<?>) obj : obj.getClass());
|
||||||
Order order = AnnotationUtils.findAnnotation(clazz, Order.class);
|
Order order = AnnotationUtils.findAnnotation(clazz, Order.class);
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
return order.value();
|
return order.value();
|
||||||
|
|
|
@ -230,7 +230,7 @@ public final class JeeConfigurer<H extends HttpSecurityBuilder<H>> extends Abstr
|
||||||
* @return the {@link AuthenticationUserDetailsService} to use
|
* @return the {@link AuthenticationUserDetailsService} to use
|
||||||
*/
|
*/
|
||||||
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getUserDetailsService() {
|
private AuthenticationUserDetailsService<PreAuthenticatedAuthenticationToken> getUserDetailsService() {
|
||||||
return this.authenticationUserDetailsService == null
|
return (this.authenticationUserDetailsService != null)
|
||||||
? new PreAuthenticatedGrantedAuthoritiesUserDetailsService() : this.authenticationUserDetailsService;
|
? new PreAuthenticatedGrantedAuthoritiesUserDetailsService() : this.authenticationUserDetailsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -369,8 +369,8 @@ public final class RememberMeConfigurer<H extends HttpSecurityBuilder<H>>
|
||||||
* @return the {@link RememberMeServices} to use
|
* @return the {@link RememberMeServices} to use
|
||||||
*/
|
*/
|
||||||
private AbstractRememberMeServices createRememberMeServices(H http, String key) {
|
private AbstractRememberMeServices createRememberMeServices(H http, String key) {
|
||||||
return this.tokenRepository == null ? createTokenBasedRememberMeServices(http, key)
|
return (this.tokenRepository != null) ? createPersistentRememberMeServices(http, key)
|
||||||
: createPersistentRememberMeServices(http, key);
|
: createTokenBasedRememberMeServices(http, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -90,8 +90,8 @@ public final class SecurityContextConfigurer<H extends HttpSecurityBuilder<H>>
|
||||||
SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(
|
SecurityContextPersistenceFilter securityContextFilter = new SecurityContextPersistenceFilter(
|
||||||
securityContextRepository);
|
securityContextRepository);
|
||||||
SessionManagementConfigurer<?> sessionManagement = http.getConfigurer(SessionManagementConfigurer.class);
|
SessionManagementConfigurer<?> sessionManagement = http.getConfigurer(SessionManagementConfigurer.class);
|
||||||
SessionCreationPolicy sessionCreationPolicy = sessionManagement == null ? null
|
SessionCreationPolicy sessionCreationPolicy = (sessionManagement != null)
|
||||||
: sessionManagement.getSessionCreationPolicy();
|
? sessionManagement.getSessionCreationPolicy() : null;
|
||||||
if (SessionCreationPolicy.ALWAYS == sessionCreationPolicy) {
|
if (SessionCreationPolicy.ALWAYS == sessionCreationPolicy) {
|
||||||
securityContextFilter.setForceEagerSessionCreation(true);
|
securityContextFilter.setForceEagerSessionCreation(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,11 +80,11 @@ public final class ServletApiConfigurer<H extends HttpSecurityBuilder<H>>
|
||||||
public void configure(H http) {
|
public void configure(H http) {
|
||||||
this.securityContextRequestFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
this.securityContextRequestFilter.setAuthenticationManager(http.getSharedObject(AuthenticationManager.class));
|
||||||
ExceptionHandlingConfigurer<H> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
|
ExceptionHandlingConfigurer<H> exceptionConf = http.getConfigurer(ExceptionHandlingConfigurer.class);
|
||||||
AuthenticationEntryPoint authenticationEntryPoint = exceptionConf == null ? null
|
AuthenticationEntryPoint authenticationEntryPoint = (exceptionConf != null)
|
||||||
: exceptionConf.getAuthenticationEntryPoint(http);
|
? exceptionConf.getAuthenticationEntryPoint(http) : null;
|
||||||
this.securityContextRequestFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
|
this.securityContextRequestFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
|
||||||
LogoutConfigurer<H> logoutConf = http.getConfigurer(LogoutConfigurer.class);
|
LogoutConfigurer<H> logoutConf = http.getConfigurer(LogoutConfigurer.class);
|
||||||
List<LogoutHandler> logoutHandlers = logoutConf == null ? null : logoutConf.getLogoutHandlers();
|
List<LogoutHandler> logoutHandlers = (logoutConf != null) ? logoutConf.getLogoutHandlers() : null;
|
||||||
this.securityContextRequestFilter.setLogoutHandlers(logoutHandlers);
|
this.securityContextRequestFilter.setLogoutHandlers(logoutHandlers);
|
||||||
AuthenticationTrustResolver trustResolver = http.getSharedObject(AuthenticationTrustResolver.class);
|
AuthenticationTrustResolver trustResolver = http.getSharedObject(AuthenticationTrustResolver.class);
|
||||||
if (trustResolver != null) {
|
if (trustResolver != null) {
|
||||||
|
|
|
@ -451,7 +451,7 @@ public final class SessionManagementConfigurer<H extends HttpSecurityBuilder<H>>
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionCreationPolicy sessionPolicy = getBuilder().getSharedObject(SessionCreationPolicy.class);
|
SessionCreationPolicy sessionPolicy = getBuilder().getSharedObject(SessionCreationPolicy.class);
|
||||||
return sessionPolicy == null ? SessionCreationPolicy.IF_REQUIRED : sessionPolicy;
|
return (sessionPolicy != null) ? sessionPolicy : SessionCreationPolicy.IF_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -98,7 +98,7 @@ public final class ImplicitGrantConfigurer<B extends HttpSecurityBuilder<B>>
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAuthorizationRequestBaseUri() {
|
private String getAuthorizationRequestBaseUri() {
|
||||||
return this.authorizationRequestBaseUri != null ? this.authorizationRequestBaseUri
|
return (this.authorizationRequestBaseUri != null) ? this.authorizationRequestBaseUri
|
||||||
: OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI;
|
: OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -500,7 +500,7 @@ public final class OAuth2LoginConfigurer<B extends HttpSecurityBuilder<B>>
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
String authorizationRequestBaseUri = this.authorizationEndpointConfig.authorizationRequestBaseUri != null
|
String authorizationRequestBaseUri = (this.authorizationEndpointConfig.authorizationRequestBaseUri != null)
|
||||||
? this.authorizationEndpointConfig.authorizationRequestBaseUri
|
? this.authorizationEndpointConfig.authorizationRequestBaseUri
|
||||||
: OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI;
|
: OAuth2AuthorizationRequestRedirectFilter.DEFAULT_AUTHORIZATION_REQUEST_BASE_URI;
|
||||||
Map<String, String> loginUrlToClientName = new HashMap<>();
|
Map<String, String> loginUrlToClientName = new HashMap<>();
|
||||||
|
|
|
@ -107,8 +107,8 @@ public class FilterInvocationSecurityMetadataSourceParser implements BeanDefinit
|
||||||
|
|
||||||
if (useExpressions) {
|
if (useExpressions) {
|
||||||
Element expressionHandlerElt = DomUtils.getChildElementByTagName(httpElt, Elements.EXPRESSION_HANDLER);
|
Element expressionHandlerElt = DomUtils.getChildElementByTagName(httpElt, Elements.EXPRESSION_HANDLER);
|
||||||
String expressionHandlerRef = expressionHandlerElt == null ? null
|
String expressionHandlerRef = (expressionHandlerElt != null) ? expressionHandlerElt.getAttribute("ref")
|
||||||
: expressionHandlerElt.getAttribute("ref");
|
: null;
|
||||||
|
|
||||||
if (StringUtils.hasText(expressionHandlerRef)) {
|
if (StringUtils.hasText(expressionHandlerRef)) {
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class FormLoginBeanDefinitionParser {
|
||||||
BeanDefinitionBuilder entryPointBuilder = BeanDefinitionBuilder
|
BeanDefinitionBuilder entryPointBuilder = BeanDefinitionBuilder
|
||||||
.rootBeanDefinition(LoginUrlAuthenticationEntryPoint.class);
|
.rootBeanDefinition(LoginUrlAuthenticationEntryPoint.class);
|
||||||
entryPointBuilder.getRawBeanDefinition().setSource(source);
|
entryPointBuilder.getRawBeanDefinition().setSource(source);
|
||||||
entryPointBuilder.addConstructorArgValue(this.loginPage != null ? this.loginPage : DEF_LOGIN_PAGE);
|
entryPointBuilder.addConstructorArgValue((this.loginPage != null) ? this.loginPage : DEF_LOGIN_PAGE);
|
||||||
entryPointBuilder.addPropertyValue("portMapper", this.portMapper);
|
entryPointBuilder.addPropertyValue("portMapper", this.portMapper);
|
||||||
entryPointBuilder.addPropertyValue("portResolver", this.portResolver);
|
entryPointBuilder.addPropertyValue("portResolver", this.portResolver);
|
||||||
this.entryPointBean = (RootBeanDefinition) entryPointBuilder.getBeanDefinition();
|
this.entryPointBean = (RootBeanDefinition) entryPointBuilder.getBeanDefinition();
|
||||||
|
|
|
@ -177,8 +177,8 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseCacheControlElement(boolean addIfNotPresent, Element element) {
|
private void parseCacheControlElement(boolean addIfNotPresent, Element element) {
|
||||||
Element cacheControlElement = element == null ? null
|
Element cacheControlElement = (element != null)
|
||||||
: DomUtils.getChildElementByTagName(element, CACHE_CONTROL_ELEMENT);
|
? DomUtils.getChildElementByTagName(element, CACHE_CONTROL_ELEMENT) : null;
|
||||||
boolean disabled = "true".equals(getAttribute(cacheControlElement, ATT_DISABLED, "false"));
|
boolean disabled = "true".equals(getAttribute(cacheControlElement, ATT_DISABLED, "false"));
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -195,7 +195,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHstsElement(boolean addIfNotPresent, Element element, ParserContext context) {
|
private void parseHstsElement(boolean addIfNotPresent, Element element, ParserContext context) {
|
||||||
Element hstsElement = element == null ? null : DomUtils.getChildElementByTagName(element, HSTS_ELEMENT);
|
Element hstsElement = (element != null) ? DomUtils.getChildElementByTagName(element, HSTS_ELEMENT) : null;
|
||||||
if (addIfNotPresent || hstsElement != null) {
|
if (addIfNotPresent || hstsElement != null) {
|
||||||
addHsts(addIfNotPresent, hstsElement, context);
|
addHsts(addIfNotPresent, hstsElement, context);
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHpkpElement(boolean addIfNotPresent, Element element, ParserContext context) {
|
private void parseHpkpElement(boolean addIfNotPresent, Element element, ParserContext context) {
|
||||||
Element hpkpElement = element == null ? null : DomUtils.getChildElementByTagName(element, HPKP_ELEMENT);
|
Element hpkpElement = (element != null) ? DomUtils.getChildElementByTagName(element, HPKP_ELEMENT) : null;
|
||||||
if (addIfNotPresent || hpkpElement != null) {
|
if (addIfNotPresent || hpkpElement != null) {
|
||||||
addHpkp(addIfNotPresent, hpkpElement, context);
|
addHpkp(addIfNotPresent, hpkpElement, context);
|
||||||
}
|
}
|
||||||
|
@ -342,8 +342,8 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseReferrerPolicyElement(Element element, ParserContext context) {
|
private void parseReferrerPolicyElement(Element element, ParserContext context) {
|
||||||
Element referrerPolicyElement = (element == null) ? null
|
Element referrerPolicyElement = (element != null)
|
||||||
: DomUtils.getChildElementByTagName(element, REFERRER_POLICY_ELEMENT);
|
? DomUtils.getChildElementByTagName(element, REFERRER_POLICY_ELEMENT) : null;
|
||||||
if (referrerPolicyElement != null) {
|
if (referrerPolicyElement != null) {
|
||||||
addReferrerPolicy(referrerPolicyElement, context);
|
addReferrerPolicy(referrerPolicyElement, context);
|
||||||
}
|
}
|
||||||
|
@ -361,8 +361,8 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseFeaturePolicyElement(Element element, ParserContext context) {
|
private void parseFeaturePolicyElement(Element element, ParserContext context) {
|
||||||
Element featurePolicyElement = (element == null) ? null
|
Element featurePolicyElement = (element != null)
|
||||||
: DomUtils.getChildElementByTagName(element, FEATURE_POLICY_ELEMENT);
|
? DomUtils.getChildElementByTagName(element, FEATURE_POLICY_ELEMENT) : null;
|
||||||
if (featurePolicyElement != null) {
|
if (featurePolicyElement != null) {
|
||||||
addFeaturePolicy(featurePolicyElement, context);
|
addFeaturePolicy(featurePolicyElement, context);
|
||||||
}
|
}
|
||||||
|
@ -390,8 +390,8 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHeaderElements(Element element) {
|
private void parseHeaderElements(Element element) {
|
||||||
List<Element> headerElts = element == null ? Collections.<Element>emptyList()
|
List<Element> headerElts = (element != null)
|
||||||
: DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT);
|
? DomUtils.getChildElementsByTagName(element, GENERIC_HEADER_ELEMENT) : Collections.emptyList();
|
||||||
for (Element headerElt : headerElts) {
|
for (Element headerElt : headerElts) {
|
||||||
String headerFactoryRef = headerElt.getAttribute(ATT_REF);
|
String headerFactoryRef = headerElt.getAttribute(ATT_REF);
|
||||||
if (StringUtils.hasText(headerFactoryRef)) {
|
if (StringUtils.hasText(headerFactoryRef)) {
|
||||||
|
@ -407,8 +407,8 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseContentTypeOptionsElement(boolean addIfNotPresent, Element element) {
|
private void parseContentTypeOptionsElement(boolean addIfNotPresent, Element element) {
|
||||||
Element contentTypeElt = element == null ? null
|
Element contentTypeElt = (element != null) ? DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT)
|
||||||
: DomUtils.getChildElementByTagName(element, CONTENT_TYPE_ELEMENT);
|
: null;
|
||||||
boolean disabled = "true".equals(getAttribute(contentTypeElt, ATT_DISABLED, "false"));
|
boolean disabled = "true".equals(getAttribute(contentTypeElt, ATT_DISABLED, "false"));
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
return;
|
return;
|
||||||
|
@ -504,7 +504,7 @@ public class HeadersBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseXssElement(boolean addIfNotPresent, Element element, ParserContext parserContext) {
|
private void parseXssElement(boolean addIfNotPresent, Element element, ParserContext parserContext) {
|
||||||
Element xssElt = element == null ? null : DomUtils.getChildElementByTagName(element, XSS_ELEMENT);
|
Element xssElt = (element != null) ? DomUtils.getChildElementByTagName(element, XSS_ELEMENT) : null;
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(XXssProtectionHeaderWriter.class);
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(XXssProtectionHeaderWriter.class);
|
||||||
if (xssElt != null) {
|
if (xssElt != null) {
|
||||||
boolean disabled = "true".equals(getAttribute(xssElt, ATT_DISABLED, "false"));
|
boolean disabled = "true".equals(getAttribute(xssElt, ATT_DISABLED, "false"));
|
||||||
|
|
|
@ -83,7 +83,7 @@ final class OAuth2ClientBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
BeanDefinitionBuilder authorizationRequestRedirectFilterBuilder = BeanDefinitionBuilder
|
BeanDefinitionBuilder authorizationRequestRedirectFilterBuilder = BeanDefinitionBuilder
|
||||||
.rootBeanDefinition(OAuth2AuthorizationRequestRedirectFilter.class);
|
.rootBeanDefinition(OAuth2AuthorizationRequestRedirectFilter.class);
|
||||||
String authorizationRequestResolverRef = authorizationCodeGrantElt != null
|
String authorizationRequestResolverRef = (authorizationCodeGrantElt != null)
|
||||||
? authorizationCodeGrantElt.getAttribute(ATT_AUTHORIZATION_REQUEST_RESOLVER_REF) : null;
|
? authorizationCodeGrantElt.getAttribute(ATT_AUTHORIZATION_REQUEST_RESOLVER_REF) : null;
|
||||||
if (!StringUtils.isEmpty(authorizationRequestResolverRef)) {
|
if (!StringUtils.isEmpty(authorizationRequestResolverRef)) {
|
||||||
authorizationRequestRedirectFilterBuilder.addConstructorArgReference(authorizationRequestResolverRef);
|
authorizationRequestRedirectFilterBuilder.addConstructorArgReference(authorizationRequestResolverRef);
|
||||||
|
@ -112,7 +112,7 @@ final class OAuth2ClientBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
private BeanMetadataElement getAuthorizationRequestRepository(Element element) {
|
private BeanMetadataElement getAuthorizationRequestRepository(Element element) {
|
||||||
BeanMetadataElement authorizationRequestRepository;
|
BeanMetadataElement authorizationRequestRepository;
|
||||||
String authorizationRequestRepositoryRef = element != null
|
String authorizationRequestRepositoryRef = (element != null)
|
||||||
? element.getAttribute(ATT_AUTHORIZATION_REQUEST_REPOSITORY_REF) : null;
|
? element.getAttribute(ATT_AUTHORIZATION_REQUEST_REPOSITORY_REF) : null;
|
||||||
if (!StringUtils.isEmpty(authorizationRequestRepositoryRef)) {
|
if (!StringUtils.isEmpty(authorizationRequestRepositoryRef)) {
|
||||||
authorizationRequestRepository = new RuntimeBeanReference(authorizationRequestRepositoryRef);
|
authorizationRequestRepository = new RuntimeBeanReference(authorizationRequestRepositoryRef);
|
||||||
|
@ -127,7 +127,7 @@ final class OAuth2ClientBeanDefinitionParser implements BeanDefinitionParser {
|
||||||
|
|
||||||
private BeanMetadataElement getAccessTokenResponseClient(Element element) {
|
private BeanMetadataElement getAccessTokenResponseClient(Element element) {
|
||||||
BeanMetadataElement accessTokenResponseClient;
|
BeanMetadataElement accessTokenResponseClient;
|
||||||
String accessTokenResponseClientRef = element != null
|
String accessTokenResponseClientRef = (element != null)
|
||||||
? element.getAttribute(ATT_ACCESS_TOKEN_RESPONSE_CLIENT_REF) : null;
|
? element.getAttribute(ATT_ACCESS_TOKEN_RESPONSE_CLIENT_REF) : null;
|
||||||
if (!StringUtils.isEmpty(accessTokenResponseClientRef)) {
|
if (!StringUtils.isEmpty(accessTokenResponseClientRef)) {
|
||||||
accessTokenResponseClient = new RuntimeBeanReference(accessTokenResponseClientRef);
|
accessTokenResponseClient = new RuntimeBeanReference(accessTokenResponseClientRef);
|
||||||
|
|
|
@ -178,8 +178,8 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The default expression-based system
|
// The default expression-based system
|
||||||
String expressionHandlerRef = expressionHandlerElt == null ? null
|
String expressionHandlerRef = (expressionHandlerElt != null) ? expressionHandlerElt.getAttribute("ref")
|
||||||
: expressionHandlerElt.getAttribute("ref");
|
: null;
|
||||||
|
|
||||||
if (StringUtils.hasText(expressionHandlerRef)) {
|
if (StringUtils.hasText(expressionHandlerRef)) {
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
|
|
|
@ -168,7 +168,7 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini
|
||||||
|
|
||||||
private static ClientRegistration.Builder getBuilderFromIssuerIfPossible(String registrationId,
|
private static ClientRegistration.Builder getBuilderFromIssuerIfPossible(String registrationId,
|
||||||
String configuredProviderId, Map<String, Map<String, String>> providers) {
|
String configuredProviderId, Map<String, Map<String, String>> providers) {
|
||||||
String providerId = configuredProviderId != null ? configuredProviderId : registrationId;
|
String providerId = (configuredProviderId != null) ? configuredProviderId : registrationId;
|
||||||
if (providers.containsKey(providerId)) {
|
if (providers.containsKey(providerId)) {
|
||||||
Map<String, String> provider = providers.get(providerId);
|
Map<String, String> provider = providers.get(providerId);
|
||||||
String issuer = provider.get(ATT_ISSUER_URI);
|
String issuer = provider.get(ATT_ISSUER_URI);
|
||||||
|
@ -188,7 +188,7 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini
|
||||||
if (provider == null && !providers.containsKey(providerId)) {
|
if (provider == null && !providers.containsKey(providerId)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ClientRegistration.Builder builder = provider != null ? provider.getBuilder(registrationId)
|
ClientRegistration.Builder builder = (provider != null) ? provider.getBuilder(registrationId)
|
||||||
: ClientRegistration.withRegistrationId(registrationId);
|
: ClientRegistration.withRegistrationId(registrationId);
|
||||||
if (providers.containsKey(providerId)) {
|
if (providers.containsKey(providerId)) {
|
||||||
return getBuilder(builder, providers.get(providerId));
|
return getBuilder(builder, providers.get(providerId));
|
||||||
|
@ -251,7 +251,7 @@ public final class ClientRegistrationsBeanDefinitionParser implements BeanDefini
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getErrorMessage(String configuredProviderId, String registrationId) {
|
private static String getErrorMessage(String configuredProviderId, String registrationId) {
|
||||||
return configuredProviderId != null ? "Unknown provider ID '" + configuredProviderId + "'"
|
return (configuredProviderId != null) ? "Unknown provider ID '" + configuredProviderId + "'"
|
||||||
: "Provider ID must be specified for client registration '" + registrationId + "'";
|
: "Provider ID must be specified for client registration '" + registrationId + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1467,8 +1467,8 @@ public class ServerHttpSecurity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private WebFilter securityContextRepositoryWebFilter() {
|
private WebFilter securityContextRepositoryWebFilter() {
|
||||||
ServerSecurityContextRepository repository = this.securityContextRepository == null
|
ServerSecurityContextRepository repository = (this.securityContextRepository != null)
|
||||||
? new WebSessionServerSecurityContextRepository() : this.securityContextRepository;
|
? this.securityContextRepository : new WebSessionServerSecurityContextRepository();
|
||||||
WebFilter result = new ReactorContextWebFilter(repository);
|
WebFilter result = new ReactorContextWebFilter(repository);
|
||||||
return new OrderedWebFilter(result, SecurityWebFiltersOrder.REACTOR_CONTEXT.getOrder());
|
return new OrderedWebFilter(result, SecurityWebFiltersOrder.REACTOR_CONTEXT.getOrder());
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
|
||||||
|
|
||||||
String id = element.getAttribute(ID_ATTR);
|
String id = element.getAttribute(ID_ATTR);
|
||||||
Element expressionHandlerElt = DomUtils.getChildElementByTagName(element, Elements.EXPRESSION_HANDLER);
|
Element expressionHandlerElt = DomUtils.getChildElementByTagName(element, Elements.EXPRESSION_HANDLER);
|
||||||
String expressionHandlerRef = expressionHandlerElt == null ? null : expressionHandlerElt.getAttribute("ref");
|
String expressionHandlerRef = (expressionHandlerElt != null) ? expressionHandlerElt.getAttribute("ref") : null;
|
||||||
boolean expressionHandlerDefined = StringUtils.hasText(expressionHandlerRef);
|
boolean expressionHandlerDefined = StringUtils.hasText(expressionHandlerRef);
|
||||||
|
|
||||||
boolean sameOriginDisabled = Boolean.parseBoolean(element.getAttribute(DISABLED_ATTR));
|
boolean sameOriginDisabled = Boolean.parseBoolean(element.getAttribute(DISABLED_ATTR));
|
||||||
|
@ -252,7 +252,7 @@ public final class WebSocketMessageBrokerSecurityBeanDefinitionParser implements
|
||||||
|
|
||||||
if (!registry.containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
|
if (!registry.containsBeanDefinition(PATH_MATCHER_BEAN_NAME)) {
|
||||||
PropertyValue pathMatcherProp = bd.getPropertyValues().getPropertyValue("pathMatcher");
|
PropertyValue pathMatcherProp = bd.getPropertyValues().getPropertyValue("pathMatcher");
|
||||||
Object pathMatcher = pathMatcherProp == null ? null : pathMatcherProp.getValue();
|
Object pathMatcher = (pathMatcherProp != null) ? pathMatcherProp.getValue() : null;
|
||||||
if (pathMatcher instanceof BeanReference) {
|
if (pathMatcher instanceof BeanReference) {
|
||||||
registry.registerAlias(((BeanReference) pathMatcher).getBeanName(), PATH_MATCHER_BEAN_NAME);
|
registry.registerAlias(((BeanReference) pathMatcher).getBeanName(), PATH_MATCHER_BEAN_NAME);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class OAuth2ClientConfigurationTests {
|
||||||
@GetMapping("/authorized-client")
|
@GetMapping("/authorized-client")
|
||||||
String authorizedClient(
|
String authorizedClient(
|
||||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
return (authorizedClient != null) ? "resolved" : "not-resolved";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ public class OAuth2ClientConfigurationTests {
|
||||||
@GetMapping("/authorized-client")
|
@GetMapping("/authorized-client")
|
||||||
String authorizedClient(
|
String authorizedClient(
|
||||||
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
@RegisteredOAuth2AuthorizedClient("client1") OAuth2AuthorizedClient authorizedClient) {
|
||||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
return (authorizedClient != null) ? "resolved" : "not-resolved";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ public class OAuth2ClientBeanDefinitionParserTests {
|
||||||
@GetMapping("/authorized-client")
|
@GetMapping("/authorized-client")
|
||||||
String authorizedClient(Model model,
|
String authorizedClient(Model model,
|
||||||
@RegisteredOAuth2AuthorizedClient("google") OAuth2AuthorizedClient authorizedClient) {
|
@RegisteredOAuth2AuthorizedClient("google") OAuth2AuthorizedClient authorizedClient) {
|
||||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
return (authorizedClient != null) ? "resolved" : "not-resolved";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,7 @@ public class OAuth2LoginBeanDefinitionParserTests {
|
||||||
@GetMapping("/authorized-client")
|
@GetMapping("/authorized-client")
|
||||||
String authorizedClient(Model model,
|
String authorizedClient(Model model,
|
||||||
@RegisteredOAuth2AuthorizedClient("google") OAuth2AuthorizedClient authorizedClient) {
|
@RegisteredOAuth2AuthorizedClient("google") OAuth2AuthorizedClient authorizedClient) {
|
||||||
return authorizedClient != null ? "resolved" : "not-resolved";
|
return (authorizedClient != null) ? "resolved" : "not-resolved";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ final class HtmlUnitWebTestClient {
|
||||||
contentType = encodingType.getName();
|
contentType = encodingType.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MediaType mediaType = contentType == null ? MediaType.ALL : MediaType.parseMediaType(contentType);
|
MediaType mediaType = (contentType != null) ? MediaType.parseMediaType(contentType) : MediaType.ALL;
|
||||||
request.contentType(mediaType);
|
request.contentType(mediaType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,16 +47,16 @@ abstract class AbstractExpressionBasedMethodConfigAttribute implements ConfigAtt
|
||||||
Assert.isTrue(filterExpression != null || authorizeExpression != null,
|
Assert.isTrue(filterExpression != null || authorizeExpression != null,
|
||||||
"Filter and authorization Expressions cannot both be null");
|
"Filter and authorization Expressions cannot both be null");
|
||||||
SpelExpressionParser parser = new SpelExpressionParser();
|
SpelExpressionParser parser = new SpelExpressionParser();
|
||||||
this.filterExpression = filterExpression == null ? null : parser.parseExpression(filterExpression);
|
this.filterExpression = (filterExpression != null) ? parser.parseExpression(filterExpression) : null;
|
||||||
this.authorizeExpression = authorizeExpression == null ? null : parser.parseExpression(authorizeExpression);
|
this.authorizeExpression = (authorizeExpression != null) ? parser.parseExpression(authorizeExpression) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractExpressionBasedMethodConfigAttribute(Expression filterExpression, Expression authorizeExpression)
|
AbstractExpressionBasedMethodConfigAttribute(Expression filterExpression, Expression authorizeExpression)
|
||||||
throws ParseException {
|
throws ParseException {
|
||||||
Assert.isTrue(filterExpression != null || authorizeExpression != null,
|
Assert.isTrue(filterExpression != null || authorizeExpression != null,
|
||||||
"Filter and authorization Expressions cannot both be null");
|
"Filter and authorization Expressions cannot both be null");
|
||||||
this.filterExpression = filterExpression == null ? null : filterExpression;
|
this.filterExpression = (filterExpression != null) ? filterExpression : null;
|
||||||
this.authorizeExpression = authorizeExpression == null ? null : authorizeExpression;
|
this.authorizeExpression = (authorizeExpression != null) ? authorizeExpression : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression getFilterExpression() {
|
Expression getFilterExpression() {
|
||||||
|
|
|
@ -49,10 +49,10 @@ public class ExpressionBasedAnnotationAttributeFactory implements PrePostInvocat
|
||||||
try {
|
try {
|
||||||
// TODO: Optimization of permitAll
|
// TODO: Optimization of permitAll
|
||||||
ExpressionParser parser = getParser();
|
ExpressionParser parser = getParser();
|
||||||
Expression preAuthorizeExpression = preAuthorizeAttribute == null ? parser.parseExpression("permitAll")
|
Expression preAuthorizeExpression = (preAuthorizeAttribute != null)
|
||||||
: parser.parseExpression(preAuthorizeAttribute);
|
? parser.parseExpression(preAuthorizeAttribute) : parser.parseExpression("permitAll");
|
||||||
Expression preFilterExpression = preFilterAttribute == null ? null
|
Expression preFilterExpression = (preFilterAttribute != null) ? parser.parseExpression(preFilterAttribute)
|
||||||
: parser.parseExpression(preFilterAttribute);
|
: null;
|
||||||
return new PreInvocationExpressionAttribute(preFilterExpression, filterObject, preAuthorizeExpression);
|
return new PreInvocationExpressionAttribute(preFilterExpression, filterObject, preAuthorizeExpression);
|
||||||
}
|
}
|
||||||
catch (ParseException ex) {
|
catch (ParseException ex) {
|
||||||
|
@ -65,11 +65,10 @@ public class ExpressionBasedAnnotationAttributeFactory implements PrePostInvocat
|
||||||
String postAuthorizeAttribute) {
|
String postAuthorizeAttribute) {
|
||||||
try {
|
try {
|
||||||
ExpressionParser parser = getParser();
|
ExpressionParser parser = getParser();
|
||||||
Expression postAuthorizeExpression = postAuthorizeAttribute == null ? null
|
Expression postAuthorizeExpression = (postAuthorizeAttribute != null)
|
||||||
: parser.parseExpression(postAuthorizeAttribute);
|
? parser.parseExpression(postAuthorizeAttribute) : null;
|
||||||
Expression postFilterExpression = postFilterAttribute == null ? null
|
Expression postFilterExpression = (postFilterAttribute != null)
|
||||||
: parser.parseExpression(postFilterAttribute);
|
? parser.parseExpression(postFilterAttribute) : null;
|
||||||
|
|
||||||
if (postFilterExpression != null || postAuthorizeExpression != null) {
|
if (postFilterExpression != null || postAuthorizeExpression != null) {
|
||||||
return new PostInvocationExpressionAttribute(postFilterExpression, postAuthorizeExpression);
|
return new PostInvocationExpressionAttribute(postFilterExpression, postAuthorizeExpression);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ class PostInvocationExpressionAttribute extends AbstractExpressionBasedMethodCon
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Expression authorize = getAuthorizeExpression();
|
Expression authorize = getAuthorizeExpression();
|
||||||
Expression filter = getFilterExpression();
|
Expression filter = getFilterExpression();
|
||||||
sb.append("[authorize: '").append(authorize == null ? "null" : authorize.getExpressionString());
|
sb.append("[authorize: '").append((authorize != null) ? authorize.getExpressionString() : "null");
|
||||||
sb.append("', filter: '").append(filter == null ? "null" : filter.getExpressionString()).append("']");
|
sb.append("', filter: '").append((filter != null) ? filter.getExpressionString() : "null").append("']");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ class PreInvocationExpressionAttribute extends AbstractExpressionBasedMethodConf
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Expression authorize = getAuthorizeExpression();
|
Expression authorize = getAuthorizeExpression();
|
||||||
Expression filter = getFilterExpression();
|
Expression filter = getFilterExpression();
|
||||||
sb.append("[authorize: '").append(authorize == null ? "null" : authorize.getExpressionString());
|
sb.append("[authorize: '").append((authorize != null) ? authorize.getExpressionString() : "null");
|
||||||
sb.append("', filter: '").append(filter == null ? "null" : filter.getExpressionString());
|
sb.append("', filter: '").append((filter != null) ? filter.getExpressionString() : "null");
|
||||||
sb.append("', filterTarget: '").append(this.filterTarget).append("']");
|
sb.append("', filterTarget: '").append(this.filterTarget).append("']");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class RunAsUserToken extends AbstractAuthenticationToken {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder(super.toString());
|
StringBuilder sb = new StringBuilder(super.toString());
|
||||||
String className = this.originalAuthentication == null ? null : this.originalAuthentication.getName();
|
String className = (this.originalAuthentication != null) ? this.originalAuthentication.getName() : null;
|
||||||
sb.append("; Original Class: ").append(className);
|
sb.append("; Original Class: ").append(className);
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class AbstractMethodSecurityMetadataSource implements MethodSecu
|
||||||
Class<?> targetClass = null;
|
Class<?> targetClass = null;
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
targetClass = target instanceof Class<?> ? (Class<?>) target
|
targetClass = (target instanceof Class<?>) ? (Class<?>) target
|
||||||
: AopProxyUtils.ultimateTargetClass(target);
|
: AopProxyUtils.ultimateTargetClass(target);
|
||||||
}
|
}
|
||||||
Collection<ConfigAttribute> attrs = getAttributes(mi.getMethod(), targetClass);
|
Collection<ConfigAttribute> attrs = getAttributes(mi.getMethod(), targetClass);
|
||||||
|
|
|
@ -122,12 +122,12 @@ public final class DelegatingMethodSecurityMetadataSource extends AbstractMethod
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return this.method.hashCode() * 21 + (this.targetClass != null ? this.targetClass.hashCode() : 0);
|
return this.method.hashCode() * 21 + ((this.targetClass != null) ? this.targetClass.hashCode() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CacheKey[" + (this.targetClass == null ? "-" : this.targetClass.getName()) + "; " + this.method
|
return "CacheKey[" + ((this.targetClass != null) ? this.targetClass.getName() : "-") + "; " + this.method
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,17 +93,17 @@ public class PrePostAdviceReactiveMethodInterceptor implements MethodInterceptor
|
||||||
|
|
||||||
if (Mono.class.isAssignableFrom(returnType)) {
|
if (Mono.class.isAssignableFrom(returnType)) {
|
||||||
return toInvoke.flatMap((auth) -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
|
return toInvoke.flatMap((auth) -> PrePostAdviceReactiveMethodInterceptor.<Mono<?>>proceed(invocation)
|
||||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Flux.class.isAssignableFrom(returnType)) {
|
if (Flux.class.isAssignableFrom(returnType)) {
|
||||||
return toInvoke.flatMapMany((auth) -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
|
return toInvoke.flatMapMany((auth) -> PrePostAdviceReactiveMethodInterceptor.<Flux<?>>proceed(invocation)
|
||||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||||
}
|
}
|
||||||
|
|
||||||
return toInvoke.flatMapMany(
|
return toInvoke.flatMapMany(
|
||||||
(auth) -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
(auth) -> Flux.from(PrePostAdviceReactiveMethodInterceptor.<Publisher<?>>proceed(invocation))
|
||||||
.map((r) -> attr == null ? r : this.postAdvice.after(auth, invocation, attr, r)));
|
.map((r) -> (attr != null) ? this.postAdvice.after(auth, invocation, attr, r) : r));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends Publisher<?>> T proceed(final MethodInvocation invocation) {
|
private static <T extends Publisher<?>> T proceed(final MethodInvocation invocation) {
|
||||||
|
|
|
@ -76,11 +76,11 @@ public class PrePostAnnotationSecurityMetadataSource extends AbstractMethodSecur
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
String preFilterAttribute = preFilter == null ? null : preFilter.value();
|
String preFilterAttribute = (preFilter != null) ? preFilter.value() : null;
|
||||||
String filterObject = preFilter == null ? null : preFilter.filterTarget();
|
String filterObject = (preFilter != null) ? preFilter.filterTarget() : null;
|
||||||
String preAuthorizeAttribute = preAuthorize == null ? null : preAuthorize.value();
|
String preAuthorizeAttribute = (preAuthorize != null) ? preAuthorize.value() : null;
|
||||||
String postFilterAttribute = postFilter == null ? null : postFilter.value();
|
String postFilterAttribute = (postFilter != null) ? postFilter.value() : null;
|
||||||
String postAuthorizeAttribute = postAuthorize == null ? null : postAuthorize.value();
|
String postAuthorizeAttribute = (postAuthorize != null) ? postAuthorize.value() : null;
|
||||||
|
|
||||||
ArrayList<ConfigAttribute> attrs = new ArrayList<>(2);
|
ArrayList<ConfigAttribute> attrs = new ArrayList<>(2);
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class DefaultAuthenticationEventPublisher
|
||||||
private Constructor<? extends AbstractAuthenticationEvent> getEventConstructor(AuthenticationException exception) {
|
private Constructor<? extends AbstractAuthenticationEvent> getEventConstructor(AuthenticationException exception) {
|
||||||
Constructor<? extends AbstractAuthenticationEvent> eventConstructor = this.exceptionMappings
|
Constructor<? extends AbstractAuthenticationEvent> eventConstructor = this.exceptionMappings
|
||||||
.get(exception.getClass().getName());
|
.get(exception.getClass().getName());
|
||||||
return (eventConstructor == null ? this.defaultAuthenticationFailureEventConstructor : eventConstructor);
|
return (eventConstructor != null) ? eventConstructor : this.defaultAuthenticationFailureEventConstructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class InMemoryConfiguration extends Configuration {
|
||||||
@Override
|
@Override
|
||||||
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
|
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
|
||||||
AppConfigurationEntry[] mappedResult = this.mappedConfigurations.get(name);
|
AppConfigurationEntry[] mappedResult = this.mappedConfigurations.get(name);
|
||||||
return mappedResult == null ? this.defaultConfiguration : mappedResult;
|
return (mappedResult != null) ? mappedResult : this.defaultConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class RemoteAuthenticationProvider implements AuthenticationProvider, Ini
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
String username = authentication.getPrincipal().toString();
|
String username = authentication.getPrincipal().toString();
|
||||||
Object credentials = authentication.getCredentials();
|
Object credentials = authentication.getCredentials();
|
||||||
String password = credentials == null ? null : credentials.toString();
|
String password = (credentials != null) ? credentials.toString() : null;
|
||||||
Collection<? extends GrantedAuthority> authorities = this.remoteAuthenticationManager
|
Collection<? extends GrantedAuthority> authorities = this.remoteAuthenticationManager
|
||||||
.attemptAuthentication(username, password);
|
.attemptAuthentication(username, password);
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@ public final class DelegatingSecurityContextCallable<V> implements Callable<V> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <V> Callable<V> create(Callable<V> delegate, SecurityContext securityContext) {
|
public static <V> Callable<V> create(Callable<V> delegate, SecurityContext securityContext) {
|
||||||
return securityContext == null ? new DelegatingSecurityContextCallable<>(delegate)
|
return (securityContext != null) ? new DelegatingSecurityContextCallable<>(delegate, securityContext)
|
||||||
: new DelegatingSecurityContextCallable<>(delegate, securityContext);
|
: new DelegatingSecurityContextCallable<>(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ public final class DelegatingSecurityContextRunnable implements Runnable {
|
||||||
*/
|
*/
|
||||||
public static Runnable create(Runnable delegate, SecurityContext securityContext) {
|
public static Runnable create(Runnable delegate, SecurityContext securityContext) {
|
||||||
Assert.notNull(delegate, "delegate cannot be null");
|
Assert.notNull(delegate, "delegate cannot be null");
|
||||||
return securityContext == null ? new DelegatingSecurityContextRunnable(delegate)
|
return (securityContext != null) ? new DelegatingSecurityContextRunnable(delegate, securityContext)
|
||||||
: new DelegatingSecurityContextRunnable(delegate, securityContext);
|
: new DelegatingSecurityContextRunnable(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class SpringSecurityCoreVersion {
|
||||||
|
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
Package pkg = SpringSecurityCoreVersion.class.getPackage();
|
Package pkg = SpringSecurityCoreVersion.class.getPackage();
|
||||||
return (pkg != null ? pkg.getImplementationVersion() : null);
|
return (pkg != null) ? pkg.getImplementationVersion() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class SimpleAttributes2GrantedAuthoritiesMapper
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAttributePrefix() {
|
private String getAttributePrefix() {
|
||||||
return this.attributePrefix == null ? "" : this.attributePrefix;
|
return (this.attributePrefix != null) ? this.attributePrefix : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttributePrefix(String string) {
|
public void setAttributePrefix(String string) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class MapReactiveUserDetailsService implements ReactiveUserDetailsService
|
||||||
public Mono<UserDetails> findByUsername(String username) {
|
public Mono<UserDetails> findByUsername(String username) {
|
||||||
String key = getKey(username);
|
String key = getKey(username);
|
||||||
UserDetails result = this.users.get(key);
|
UserDetails result = this.users.get(key);
|
||||||
return result == null ? Mono.empty() : Mono.just(User.withUserDetails(result).build());
|
return (result != null) ? Mono.just(User.withUserDetails(result).build()) : Mono.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SpringCacheBasedUserCache implements UserCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails getUserFromCache(String username) {
|
public UserDetails getUserFromCache(String username) {
|
||||||
Cache.ValueWrapper element = username != null ? this.cache.get(username) : null;
|
Cache.ValueWrapper element = (username != null) ? this.cache.get(username) : null;
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Cache hit: " + (element != null) + "; username: " + username);
|
logger.debug("Cache hit: " + (element != null) + "; username: " + username);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class SimpleMethodInvocation implements MethodInvocation {
|
||||||
public SimpleMethodInvocation(Object targetObject, Method method, Object... arguments) {
|
public SimpleMethodInvocation(Object targetObject, Method method, Object... arguments) {
|
||||||
this.targetObject = targetObject;
|
this.targetObject = targetObject;
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.arguments = arguments == null ? new Object[0] : arguments;
|
this.arguments = (arguments != null) ? arguments : new Object[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleMethodInvocation() {
|
public SimpleMethodInvocation() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class BCryptPasswordEncoder implements PasswordEncoder {
|
||||||
throw new IllegalArgumentException("Bad strength");
|
throw new IllegalArgumentException("Bad strength");
|
||||||
}
|
}
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.strength = strength == -1 ? 10 : strength;
|
this.strength = (strength == -1) ? 10 : strength;
|
||||||
this.random = random;
|
this.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -333,9 +333,9 @@ public final class Base64 {
|
||||||
// significant bytes passed in the array.
|
// significant bytes passed in the array.
|
||||||
// We have to shift left 24 in order to flush out the 1's that appear
|
// We have to shift left 24 in order to flush out the 1's that appear
|
||||||
// when Java treats a value as negative that is cast from a byte to an int.
|
// when Java treats a value as negative that is cast from a byte to an int.
|
||||||
int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)
|
int inBuff = ((numSigBytes > 0) ? ((source[srcOffset] << 24) >>> 8) : 0)
|
||||||
| (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)
|
| ((numSigBytes > 1) ? ((source[srcOffset + 1] << 24) >>> 16) : 0)
|
||||||
| (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);
|
| ((numSigBytes > 2) ? ((source[srcOffset + 2] << 24) >>> 24) : 0);
|
||||||
|
|
||||||
switch (numSigBytes) {
|
switch (numSigBytes) {
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -404,8 +404,10 @@ public final class Base64 {
|
||||||
// Try to determine more precisely how big the array needs to be.
|
// Try to determine more precisely how big the array needs to be.
|
||||||
// If we get it right, we don't have to do an array copy, and
|
// If we get it right, we don't have to do an array copy, and
|
||||||
// we save a bunch of memory.
|
// we save a bunch of memory.
|
||||||
int encLen = (len / 3) * 4 + (len % 3 > 0 ? 4 : 0); // Bytes needed for actual
|
|
||||||
// encoding
|
// Bytes needed for actual encoding
|
||||||
|
int encLen = (len / 3) * 4 + ((len % 3 > 0) ? 4 : 0);
|
||||||
|
|
||||||
if (breakLines) {
|
if (breakLines) {
|
||||||
encLen += encLen / MAX_LINE_LENGTH; // Plus extra newline characters
|
encLen += encLen / MAX_LINE_LENGTH; // Plus extra newline characters
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public final class AesBytesEncryptor implements BytesEncryptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlgorithmParameterSpec getParameterSpec(byte[] iv) {
|
public AlgorithmParameterSpec getParameterSpec(byte[] iv) {
|
||||||
return this == CBC ? new IvParameterSpec(iv) : new GCMParameterSpec(128, iv);
|
return (this != CBC) ? new GCMParameterSpec(128, iv) : new IvParameterSpec(iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cipher createCipher() {
|
public Cipher createCipher() {
|
||||||
|
@ -110,7 +110,7 @@ public final class AesBytesEncryptor implements BytesEncryptor {
|
||||||
this.alg = alg;
|
this.alg = alg;
|
||||||
this.encryptor = alg.createCipher();
|
this.encryptor = alg.createCipher();
|
||||||
this.decryptor = alg.createCipher();
|
this.decryptor = alg.createCipher();
|
||||||
this.ivGenerator = ivGenerator != null ? ivGenerator : alg.defaultIvGenerator();
|
this.ivGenerator = (ivGenerator != null) ? ivGenerator : alg.defaultIvGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,7 +119,7 @@ public final class AesBytesEncryptor implements BytesEncryptor {
|
||||||
byte[] iv = this.ivGenerator.generateKey();
|
byte[] iv = this.ivGenerator.generateKey();
|
||||||
CipherUtils.initCipher(this.encryptor, Cipher.ENCRYPT_MODE, this.secretKey, this.alg.getParameterSpec(iv));
|
CipherUtils.initCipher(this.encryptor, Cipher.ENCRYPT_MODE, this.secretKey, this.alg.getParameterSpec(iv));
|
||||||
byte[] encrypted = CipherUtils.doFinal(this.encryptor, bytes);
|
byte[] encrypted = CipherUtils.doFinal(this.encryptor, bytes);
|
||||||
return this.ivGenerator != NULL_IV_GENERATOR ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
return (this.ivGenerator != NULL_IV_GENERATOR) ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,12 +129,12 @@ public final class AesBytesEncryptor implements BytesEncryptor {
|
||||||
byte[] iv = iv(encryptedBytes);
|
byte[] iv = iv(encryptedBytes);
|
||||||
CipherUtils.initCipher(this.decryptor, Cipher.DECRYPT_MODE, this.secretKey, this.alg.getParameterSpec(iv));
|
CipherUtils.initCipher(this.decryptor, Cipher.DECRYPT_MODE, this.secretKey, this.alg.getParameterSpec(iv));
|
||||||
return CipherUtils.doFinal(this.decryptor,
|
return CipherUtils.doFinal(this.decryptor,
|
||||||
this.ivGenerator != NULL_IV_GENERATOR ? encrypted(encryptedBytes, iv.length) : encryptedBytes);
|
(this.ivGenerator != NULL_IV_GENERATOR) ? encrypted(encryptedBytes, iv.length) : encryptedBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] iv(byte[] encrypted) {
|
private byte[] iv(byte[] encrypted) {
|
||||||
return this.ivGenerator != NULL_IV_GENERATOR
|
return (this.ivGenerator != NULL_IV_GENERATOR)
|
||||||
? EncodingUtils.subArray(encrypted, 0, this.ivGenerator.getKeyLength())
|
? EncodingUtils.subArray(encrypted, 0, this.ivGenerator.getKeyLength())
|
||||||
: NULL_IV_GENERATOR.generateKey();
|
: NULL_IV_GENERATOR.generateKey();
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class BouncyCastleAesCbcBytesEncryptor extends BouncyCastleAesBytesEncryp
|
||||||
new CBCBlockCipher(new org.bouncycastle.crypto.engines.AESFastEngine()), new PKCS7Padding());
|
new CBCBlockCipher(new org.bouncycastle.crypto.engines.AESFastEngine()), new PKCS7Padding());
|
||||||
blockCipher.init(true, new ParametersWithIV(this.secretKey, iv));
|
blockCipher.init(true, new ParametersWithIV(this.secretKey, iv));
|
||||||
byte[] encrypted = process(blockCipher, bytes);
|
byte[] encrypted = process(blockCipher, bytes);
|
||||||
return iv != null ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
return (iv != null) ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class BouncyCastleAesGcmBytesEncryptor extends BouncyCastleAesBytesEncryp
|
||||||
blockCipher.init(true, new AEADParameters(this.secretKey, 128, iv, null));
|
blockCipher.init(true, new AEADParameters(this.secretKey, 128, iv, null));
|
||||||
|
|
||||||
byte[] encrypted = process(blockCipher, bytes);
|
byte[] encrypted = process(blockCipher, bytes);
|
||||||
return iv != null ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
return (iv != null) ? EncodingUtils.concatenate(iv, encrypted) : encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class LdapShaPasswordEncoder implements PasswordEncoder {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
||||||
return matches(rawPassword == null ? null : rawPassword.toString(), encodedPassword);
|
return matches((rawPassword != null) ? rawPassword.toString() : null, encodedPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matches(String rawPassword, String encodedPassword) {
|
private boolean matches(String rawPassword, String encodedPassword) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
|
||||||
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
|
||||||
<suppressions>
|
<suppressions>
|
||||||
<suppress files=".*" checks="SpringTernary" />
|
|
||||||
<suppress files=".*" checks="WhitespaceAfter" />
|
<suppress files=".*" checks="WhitespaceAfter" />
|
||||||
<suppress files=".*" checks="WhitespaceAround" />
|
<suppress files=".*" checks="WhitespaceAround" />
|
||||||
<suppress files=".*" checks="JavadocMethod" />
|
<suppress files=".*" checks="JavadocMethod" />
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class FilterChainPerformanceTests {
|
||||||
public void provideDataOnScalingWithNumberOfAuthoritiesUserHas() throws Exception {
|
public void provideDataOnScalingWithNumberOfAuthoritiesUserHas() throws Exception {
|
||||||
StopWatch sw = new StopWatch("Scaling with nAuthorities");
|
StopWatch sw = new StopWatch("Scaling with nAuthorities");
|
||||||
for (int user = 0; user < N_AUTHORITIES / 10; user++) {
|
for (int user = 0; user < N_AUTHORITIES / 10; user++) {
|
||||||
int nAuthorities = user == 0 ? 1 : user * 10;
|
int nAuthorities = (user != 0) ? user * 10 : 1;
|
||||||
SecurityContextHolder.getContext().setAuthentication(
|
SecurityContextHolder.getContext().setAuthentication(
|
||||||
new UsernamePasswordAuthenticationToken("bob", "bobspassword", createRoles(nAuthorities)));
|
new UsernamePasswordAuthenticationToken("bob", "bobspassword", createRoles(nAuthorities)));
|
||||||
this.session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
this.session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY,
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
|
||||||
|
|
||||||
SearchControls ctls = new SearchControls();
|
SearchControls ctls = new SearchControls();
|
||||||
ctls.setSearchScope(this.searchControls.getSearchScope());
|
ctls.setSearchScope(this.searchControls.getSearchScope());
|
||||||
ctls.setReturningAttributes(attributeNames != null && attributeNames.length > 0 ? attributeNames : null);
|
ctls.setReturningAttributes((attributeNames != null && attributeNames.length > 0) ? attributeNames : null);
|
||||||
|
|
||||||
search(base, formattedFilter, ctls, roleMapper);
|
search(base, formattedFilter, ctls, roleMapper);
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||||
Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
|
Assert.isTrue(StringUtils.hasText(url), "Url cannot be empty");
|
||||||
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
|
this.domain = StringUtils.hasText(domain) ? domain.toLowerCase() : null;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.rootDn = this.domain == null ? null : rootDnFromDomain(this.domain);
|
this.rootDn = (this.domain != null) ? rootDnFromDomain(this.domain) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -336,7 +336,7 @@ public final class ActiveDirectoryLdapAuthenticationProvider extends AbstractLda
|
||||||
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||||
|
|
||||||
String bindPrincipal = createBindPrincipal(username);
|
String bindPrincipal = createBindPrincipal(username);
|
||||||
String searchRoot = this.rootDn != null ? this.rootDn : searchRootFromPrincipal(bindPrincipal);
|
String searchRoot = (this.rootDn != null) ? this.rootDn : searchRootFromPrincipal(bindPrincipal);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(context, searchControls, searchRoot,
|
return SpringSecurityLdapTemplate.searchForSingleEntryInternal(context, searchControls, searchRoot,
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class FilterBasedLdapUserSearch implements LdapUserSearch {
|
||||||
sb.append("[ searchFilter: '").append(this.searchFilter).append("', ");
|
sb.append("[ searchFilter: '").append(this.searchFilter).append("', ");
|
||||||
sb.append("searchBase: '").append(this.searchBase).append("'");
|
sb.append("searchBase: '").append(this.searchBase).append("'");
|
||||||
sb.append(", scope: ").append(
|
sb.append(", scope: ").append(
|
||||||
this.searchControls.getSearchScope() == SearchControls.SUBTREE_SCOPE ? "subtree" : "single-level, ");
|
(this.searchControls.getSearchScope() != SearchControls.SUBTREE_SCOPE) ? "single-level, " : "subtree");
|
||||||
sb.append(", searchTimeLimit: ").append(this.searchControls.getTimeLimit());
|
sb.append(", searchTimeLimit: ").append(this.searchControls.getTimeLimit());
|
||||||
sb.append(", derefLinkFlag: ").append(this.searchControls.getDerefLinkFlag()).append(" ]");
|
sb.append(", derefLinkFlag: ").append(this.searchControls.getDerefLinkFlag()).append(" ]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class LdapAuthority implements GrantedAuthority {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = this.dn.hashCode();
|
int result = this.dn.hashCode();
|
||||||
result = 31 * result + (this.role != null ? this.role.hashCode() : 0);
|
result = 31 * result + ((this.role != null) ? this.role.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
|
||||||
// this prevents a forever loop for a misconfigured ldap directory
|
// this prevents a forever loop for a misconfigured ldap directory
|
||||||
circular = circular | (!authorities.add(new LdapAuthority(role, dn, record)));
|
circular = circular | (!authorities.add(new LdapAuthority(role, dn, record)));
|
||||||
}
|
}
|
||||||
String roleName = roles.size() > 0 ? roles.iterator().next() : dn;
|
String roleName = (roles.size() > 0) ? roles.iterator().next() : dn;
|
||||||
if (!circular) {
|
if (!circular) {
|
||||||
performNestedSearch(dn, roleName, authorities, (depth - 1));
|
performNestedSearch(dn, roleName, authorities, (depth - 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class AuthenticationPrincipalArgumentResolver implements HandlerMethodArg
|
||||||
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap((a) -> {
|
return ReactiveSecurityContextHolder.getContext().map(SecurityContext::getAuthentication).flatMap((a) -> {
|
||||||
Object p = resolvePrincipal(parameter, a.getPrincipal());
|
Object p = resolvePrincipal(parameter, a.getPrincipal());
|
||||||
Mono<Object> principal = Mono.justOrEmpty(p);
|
Mono<Object> principal = Mono.justOrEmpty(p);
|
||||||
return adapter == null ? principal : Mono.just(adapter.fromPublisher(principal));
|
return (adapter != null) ? Mono.just(adapter.fromPublisher(principal)) : principal;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class CurrentSecurityContextArgumentResolver implements HandlerMethodArgu
|
||||||
return ReactiveSecurityContextHolder.getContext().flatMap((securityContext) -> {
|
return ReactiveSecurityContextHolder.getContext().flatMap((securityContext) -> {
|
||||||
Object sc = resolveSecurityContext(parameter, securityContext);
|
Object sc = resolveSecurityContext(parameter, securityContext);
|
||||||
Mono<Object> result = Mono.justOrEmpty(sc);
|
Mono<Object> result = Mono.justOrEmpty(sc);
|
||||||
return adapter == null ? result : Mono.just(adapter.fromPublisher(result));
|
return (adapter != null) ? Mono.just(adapter.fromPublisher(result)) : result;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public final class SimpDestinationMessageMatcher implements MessageMatcher<Objec
|
||||||
}
|
}
|
||||||
|
|
||||||
this.matcher = pathMatcher;
|
this.matcher = pathMatcher;
|
||||||
this.messageTypeMatcher = type == null ? ANY_MESSAGE : new SimpMessageTypeMatcher(type);
|
this.messageTypeMatcher = (type != null) ? new SimpMessageTypeMatcher(type) : ANY_MESSAGE;
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public final class SimpDestinationMessageMatcher implements MessageMatcher<Objec
|
||||||
|
|
||||||
public Map<String, String> extractPathVariables(Message<?> message) {
|
public Map<String, String> extractPathVariables(Message<?> message) {
|
||||||
final String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
|
final String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders());
|
||||||
return destination != null ? this.matcher.extractUriTemplateVariables(this.pattern, destination)
|
return (destination != null) ? this.matcher.extractUriTemplateVariables(this.pattern, destination)
|
||||||
: Collections.emptyMap();
|
: Collections.emptyMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ public final class CsrfChannelInterceptor extends ChannelInterceptorAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(message.getHeaders());
|
Map<String, Object> sessionAttributes = SimpMessageHeaderAccessor.getSessionAttributes(message.getHeaders());
|
||||||
CsrfToken expectedToken = sessionAttributes == null ? null
|
CsrfToken expectedToken = (sessionAttributes != null)
|
||||||
: (CsrfToken) sessionAttributes.get(CsrfToken.class.getName());
|
? (CsrfToken) sessionAttributes.get(CsrfToken.class.getName()) : null;
|
||||||
|
|
||||||
if (expectedToken == null) {
|
if (expectedToken == null) {
|
||||||
throw new MissingCsrfTokenException(null);
|
throw new MissingCsrfTokenException(null);
|
||||||
|
|
|
@ -220,10 +220,10 @@ public final class ResolvableMethod {
|
||||||
|
|
||||||
private String formatParameter(Parameter param) {
|
private String formatParameter(Parameter param) {
|
||||||
Annotation[] anns = param.getAnnotations();
|
Annotation[] anns = param.getAnnotations();
|
||||||
return (anns.length > 0
|
return (anns.length > 0)
|
||||||
? Arrays.stream(anns).map(this::formatAnnotation).collect(Collectors.joining(",", "[", "]")) + " "
|
? Arrays.stream(anns).map(this::formatAnnotation).collect(Collectors.joining(",", "[", "]")) + " "
|
||||||
+ param
|
+ param
|
||||||
: param.toString());
|
: param.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatAnnotation(Annotation annotation) {
|
private String formatAnnotation(Annotation annotation) {
|
||||||
|
@ -591,9 +591,9 @@ public final class ResolvableMethod {
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
|
public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotationTypes) {
|
||||||
this.filters.add((param) -> (annotationTypes.length > 0
|
this.filters.add((param) -> (annotationTypes.length > 0)
|
||||||
? Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation)
|
? Arrays.stream(annotationTypes).noneMatch(param::hasParameterAnnotation)
|
||||||
: param.getParameterAnnotations().length == 0));
|
: param.getParameterAnnotations().length == 0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class OAuth2AuthorizationCodeAuthenticationToken extends AbstractAuthenti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCredentials() {
|
public Object getCredentials() {
|
||||||
return this.accessToken != null ? this.accessToken.getTokenValue()
|
return (this.accessToken != null) ? this.accessToken.getTokenValue()
|
||||||
: this.authorizationExchange.getAuthorizationResponse().getCode();
|
: this.authorizationExchange.getAuthorizationResponse().getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,9 @@ public class NimbusAuthorizationCodeTokenResponseClient
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
oauth2Error = new OAuth2Error(
|
oauth2Error = new OAuth2Error(
|
||||||
errorObject.getCode() != null ? errorObject.getCode() : OAuth2ErrorCodes.SERVER_ERROR,
|
(errorObject.getCode() != null) ? errorObject.getCode() : OAuth2ErrorCodes.SERVER_ERROR,
|
||||||
errorObject.getDescription(),
|
errorObject.getDescription(),
|
||||||
errorObject.getURI() != null ? errorObject.getURI().toString() : null);
|
(errorObject.getURI() != null) ? errorObject.getURI().toString() : null);
|
||||||
}
|
}
|
||||||
throw new OAuth2AuthorizationException(oauth2Error);
|
throw new OAuth2AuthorizationException(oauth2Error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class OAuth2RefreshTokenGrantRequest extends AbstractOAuth2AuthorizationG
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.refreshToken = refreshToken;
|
this.refreshToken = refreshToken;
|
||||||
this.scopes = Collections
|
this.scopes = Collections
|
||||||
.unmodifiableSet(scopes != null ? new LinkedHashSet<>(scopes) : Collections.emptySet());
|
.unmodifiableSet((scopes != null) ? new LinkedHashSet<>(scopes) : Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -80,10 +80,10 @@ public class OAuth2ErrorResponseErrorHandler implements ResponseErrorHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String errorCode = bearerTokenError.getCode() != null ? bearerTokenError.getCode()
|
String errorCode = (bearerTokenError.getCode() != null) ? bearerTokenError.getCode()
|
||||||
: OAuth2ErrorCodes.SERVER_ERROR;
|
: OAuth2ErrorCodes.SERVER_ERROR;
|
||||||
String errorDescription = bearerTokenError.getDescription();
|
String errorDescription = bearerTokenError.getDescription();
|
||||||
String errorUri = bearerTokenError.getURI() != null ? bearerTokenError.getURI().toString() : null;
|
String errorUri = (bearerTokenError.getURI() != null) ? bearerTokenError.getURI().toString() : null;
|
||||||
|
|
||||||
return new OAuth2Error(errorCode, errorDescription, errorUri);
|
return new OAuth2Error(errorCode, errorDescription, errorUri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class OidcReactiveOAuth2UserService implements ReactiveOAuth2UserService<
|
||||||
private Map<String, Object> convertClaims(Map<String, Object> claims, ClientRegistration clientRegistration) {
|
private Map<String, Object> convertClaims(Map<String, Object> claims, ClientRegistration clientRegistration) {
|
||||||
Converter<Map<String, Object>, Map<String, Object>> claimTypeConverter = this.claimTypeConverterFactory
|
Converter<Map<String, Object>, Map<String, Object>> claimTypeConverter = this.claimTypeConverterFactory
|
||||||
.apply(clientRegistration);
|
.apply(clientRegistration);
|
||||||
return claimTypeConverter != null ? claimTypeConverter.convert(claims)
|
return (claimTypeConverter != null) ? claimTypeConverter.convert(claims)
|
||||||
: DEFAULT_CLAIM_TYPE_CONVERTER.convert(claims);
|
: DEFAULT_CLAIM_TYPE_CONVERTER.convert(claims);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,7 +368,7 @@ public final class ClientRegistration implements Serializable {
|
||||||
this.clientAuthenticationMethod = clientRegistration.clientAuthenticationMethod;
|
this.clientAuthenticationMethod = clientRegistration.clientAuthenticationMethod;
|
||||||
this.authorizationGrantType = clientRegistration.authorizationGrantType;
|
this.authorizationGrantType = clientRegistration.authorizationGrantType;
|
||||||
this.redirectUri = clientRegistration.redirectUri;
|
this.redirectUri = clientRegistration.redirectUri;
|
||||||
this.scopes = clientRegistration.scopes == null ? null : new HashSet<>(clientRegistration.scopes);
|
this.scopes = (clientRegistration.scopes != null) ? new HashSet<>(clientRegistration.scopes) : null;
|
||||||
this.authorizationUri = clientRegistration.providerDetails.authorizationUri;
|
this.authorizationUri = clientRegistration.providerDetails.authorizationUri;
|
||||||
this.tokenUri = clientRegistration.providerDetails.tokenUri;
|
this.tokenUri = clientRegistration.providerDetails.tokenUri;
|
||||||
this.userInfoUri = clientRegistration.providerDetails.userInfoEndpoint.uri;
|
this.userInfoUri = clientRegistration.providerDetails.userInfoEndpoint.uri;
|
||||||
|
|
|
@ -224,22 +224,22 @@ public final class DefaultOAuth2AuthorizationRequestResolver implements OAuth2Au
|
||||||
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(UrlUtils.buildFullRequestUrl(request))
|
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(UrlUtils.buildFullRequestUrl(request))
|
||||||
.replacePath(request.getContextPath()).replaceQuery(null).fragment(null).build();
|
.replacePath(request.getContextPath()).replaceQuery(null).fragment(null).build();
|
||||||
String scheme = uriComponents.getScheme();
|
String scheme = uriComponents.getScheme();
|
||||||
uriVariables.put("baseScheme", scheme == null ? "" : scheme);
|
uriVariables.put("baseScheme", (scheme != null) ? scheme : "");
|
||||||
String host = uriComponents.getHost();
|
String host = uriComponents.getHost();
|
||||||
uriVariables.put("baseHost", host == null ? "" : host);
|
uriVariables.put("baseHost", (host != null) ? host : "");
|
||||||
// following logic is based on HierarchicalUriComponents#toUriString()
|
// following logic is based on HierarchicalUriComponents#toUriString()
|
||||||
int port = uriComponents.getPort();
|
int port = uriComponents.getPort();
|
||||||
uriVariables.put("basePort", port == -1 ? "" : ":" + port);
|
uriVariables.put("basePort", (port == -1) ? "" : ":" + port);
|
||||||
String path = uriComponents.getPath();
|
String path = uriComponents.getPath();
|
||||||
if (StringUtils.hasLength(path)) {
|
if (StringUtils.hasLength(path)) {
|
||||||
if (path.charAt(0) != PATH_DELIMITER) {
|
if (path.charAt(0) != PATH_DELIMITER) {
|
||||||
path = PATH_DELIMITER + path;
|
path = PATH_DELIMITER + path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uriVariables.put("basePath", path == null ? "" : path);
|
uriVariables.put("basePath", (path != null) ? path : "");
|
||||||
uriVariables.put("baseUrl", uriComponents.toUriString());
|
uriVariables.put("baseUrl", uriComponents.toUriString());
|
||||||
|
|
||||||
uriVariables.put("action", action == null ? "" : action);
|
uriVariables.put("action", (action != null) ? action : "");
|
||||||
|
|
||||||
return UriComponentsBuilder.fromUriString(clientRegistration.getRedirectUri()).buildAndExpand(uriVariables)
|
return UriComponentsBuilder.fromUriString(clientRegistration.getRedirectUri()).buildAndExpand(uriVariables)
|
||||||
.toUriString();
|
.toUriString();
|
||||||
|
|
|
@ -151,7 +151,7 @@ public final class DefaultReactiveOAuth2AuthorizedClientManager implements React
|
||||||
(authorizationContext) -> authorize(authorizationContext, principal, serverWebExchange))
|
(authorizationContext) -> authorize(authorizationContext, principal, serverWebExchange))
|
||||||
// Default to the existing authorizedClient if the
|
// Default to the existing authorizedClient if the
|
||||||
// client was not re-authorized
|
// client was not re-authorized
|
||||||
.defaultIfEmpty(authorizeRequest.getAuthorizedClient() != null
|
.defaultIfEmpty((authorizeRequest.getAuthorizedClient() != null)
|
||||||
? authorizeRequest.getAuthorizedClient() : authorizedClient))
|
? authorizeRequest.getAuthorizedClient() : authorizedClient))
|
||||||
.switchIfEmpty(Mono.defer(() ->
|
.switchIfEmpty(Mono.defer(() ->
|
||||||
// Authorize
|
// Authorize
|
||||||
|
|
|
@ -115,8 +115,8 @@ public final class HttpSessionOAuth2AuthorizationRequestRepository
|
||||||
*/
|
*/
|
||||||
private Map<String, OAuth2AuthorizationRequest> getAuthorizationRequests(HttpServletRequest request) {
|
private Map<String, OAuth2AuthorizationRequest> getAuthorizationRequests(HttpServletRequest request) {
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
Map<String, OAuth2AuthorizationRequest> authorizationRequests = session == null ? null
|
Map<String, OAuth2AuthorizationRequest> authorizationRequests = (session != null)
|
||||||
: (Map<String, OAuth2AuthorizationRequest>) session.getAttribute(this.sessionAttributeName);
|
? (Map<String, OAuth2AuthorizationRequest>) session.getAttribute(this.sessionAttributeName) : null;
|
||||||
if (authorizationRequests == null) {
|
if (authorizationRequests == null) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,8 @@ public final class HttpSessionOAuth2AuthorizedClientRepository implements OAuth2
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, OAuth2AuthorizedClient> getAuthorizedClients(HttpServletRequest request) {
|
private Map<String, OAuth2AuthorizedClient> getAuthorizedClients(HttpServletRequest request) {
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
Map<String, OAuth2AuthorizedClient> authorizedClients = session == null ? null
|
Map<String, OAuth2AuthorizedClient> authorizedClients = (session != null)
|
||||||
: (Map<String, OAuth2AuthorizedClient>) session.getAttribute(this.sessionAttributeName);
|
? (Map<String, OAuth2AuthorizedClient>) session.getAttribute(this.sessionAttributeName) : null;
|
||||||
if (authorizedClients == null) {
|
if (authorizedClients == null) {
|
||||||
authorizedClients = new HashMap<>();
|
authorizedClients = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class OAuth2AuthorizationCodeGrantFilter extends OncePerRequestFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
String principalName = currentAuthentication != null ? currentAuthentication.getName() : "anonymousUser";
|
String principalName = (currentAuthentication != null) ? currentAuthentication.getName() : "anonymousUser";
|
||||||
|
|
||||||
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(
|
OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient(
|
||||||
authenticationResult.getClientRegistration(), principalName, authenticationResult.getAccessToken(),
|
authenticationResult.getClientRegistration(), principalName, authenticationResult.getAccessToken(),
|
||||||
|
|
|
@ -572,7 +572,7 @@ public final class ServerOAuth2AuthorizedClientExchangeFilterFunction implements
|
||||||
.build()).flatMap((authorizationContext) -> authorize(authorizationContext, principal))
|
.build()).flatMap((authorizationContext) -> authorize(authorizationContext, principal))
|
||||||
// Default to the existing authorizedClient if the client
|
// Default to the existing authorizedClient if the client
|
||||||
// was not re-authorized
|
// was not re-authorized
|
||||||
.defaultIfEmpty(authorizeRequest.getAuthorizedClient() != null
|
.defaultIfEmpty((authorizeRequest.getAuthorizedClient() != null)
|
||||||
? authorizeRequest.getAuthorizedClient() : authorizedClient))
|
? authorizeRequest.getAuthorizedClient() : authorizedClient))
|
||||||
.switchIfEmpty(Mono.defer(() ->
|
.switchIfEmpty(Mono.defer(() ->
|
||||||
// Authorize
|
// Authorize
|
||||||
|
|
|
@ -217,19 +217,19 @@ public class DefaultServerOAuth2AuthorizationRequestResolver implements ServerOA
|
||||||
UriComponents uriComponents = UriComponentsBuilder.fromUri(request.getURI())
|
UriComponents uriComponents = UriComponentsBuilder.fromUri(request.getURI())
|
||||||
.replacePath(request.getPath().contextPath().value()).replaceQuery(null).fragment(null).build();
|
.replacePath(request.getPath().contextPath().value()).replaceQuery(null).fragment(null).build();
|
||||||
String scheme = uriComponents.getScheme();
|
String scheme = uriComponents.getScheme();
|
||||||
uriVariables.put("baseScheme", scheme == null ? "" : scheme);
|
uriVariables.put("baseScheme", (scheme != null) ? scheme : "");
|
||||||
String host = uriComponents.getHost();
|
String host = uriComponents.getHost();
|
||||||
uriVariables.put("baseHost", host == null ? "" : host);
|
uriVariables.put("baseHost", (host != null) ? host : "");
|
||||||
// following logic is based on HierarchicalUriComponents#toUriString()
|
// following logic is based on HierarchicalUriComponents#toUriString()
|
||||||
int port = uriComponents.getPort();
|
int port = uriComponents.getPort();
|
||||||
uriVariables.put("basePort", port == -1 ? "" : ":" + port);
|
uriVariables.put("basePort", (port == -1) ? "" : ":" + port);
|
||||||
String path = uriComponents.getPath();
|
String path = uriComponents.getPath();
|
||||||
if (StringUtils.hasLength(path)) {
|
if (StringUtils.hasLength(path)) {
|
||||||
if (path.charAt(0) != PATH_DELIMITER) {
|
if (path.charAt(0) != PATH_DELIMITER) {
|
||||||
path = PATH_DELIMITER + path;
|
path = PATH_DELIMITER + path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uriVariables.put("basePath", path == null ? "" : path);
|
uriVariables.put("basePath", (path != null) ? path : "");
|
||||||
uriVariables.put("baseUrl", uriComponents.toUriString());
|
uriVariables.put("baseUrl", uriComponents.toUriString());
|
||||||
|
|
||||||
String action = "";
|
String action = "";
|
||||||
|
|
|
@ -85,8 +85,8 @@ public final class WebSessionServerOAuth2AuthorizedClientRepository implements S
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private Map<String, OAuth2AuthorizedClient> getAuthorizedClients(WebSession session) {
|
private Map<String, OAuth2AuthorizedClient> getAuthorizedClients(WebSession session) {
|
||||||
Map<String, OAuth2AuthorizedClient> authorizedClients = session == null ? null
|
Map<String, OAuth2AuthorizedClient> authorizedClients = (session != null)
|
||||||
: (Map<String, OAuth2AuthorizedClient>) session.getAttribute(this.sessionAttributeName);
|
? (Map<String, OAuth2AuthorizedClient>) session.getAttribute(this.sessionAttributeName) : null;
|
||||||
if (authorizedClients == null) {
|
if (authorizedClients == null) {
|
||||||
authorizedClients = new HashMap<>();
|
authorizedClients = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class OAuth2AuthenticationExceptionMixinTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String jsonStringOrNull(String input) {
|
private String jsonStringOrNull(String input) {
|
||||||
return input != null ? "\"" + input + "\"" : "null";
|
return (input != null) ? "\"" + input + "\"" : "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class OAuth2AuthenticationTokenMixinTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String asJson(OAuth2AuthenticationToken authentication) {
|
private static String asJson(OAuth2AuthenticationToken authentication) {
|
||||||
String principalJson = authentication.getPrincipal() instanceof DefaultOidcUser
|
String principalJson = (authentication.getPrincipal() instanceof DefaultOidcUser)
|
||||||
? asJson((DefaultOidcUser) authentication.getPrincipal())
|
? asJson((DefaultOidcUser) authentication.getPrincipal())
|
||||||
: asJson((DefaultOAuth2User) authentication.getPrincipal());
|
: asJson((DefaultOAuth2User) authentication.getPrincipal());
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
@ -224,8 +224,8 @@ public class OAuth2AuthenticationTokenMixinTests {
|
||||||
simpleAuthorities.add((SimpleGrantedAuthority) authority);
|
simpleAuthorities.add((SimpleGrantedAuthority) authority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String authoritiesJson = oidcUserAuthority != null ? asJson(oidcUserAuthority)
|
String authoritiesJson = (oidcUserAuthority != null) ? asJson(oidcUserAuthority)
|
||||||
: oauth2UserAuthority != null ? asJson(oauth2UserAuthority) : "";
|
: (oauth2UserAuthority != null) ? asJson(oauth2UserAuthority) : "";
|
||||||
if (!simpleAuthorities.isEmpty()) {
|
if (!simpleAuthorities.isEmpty()) {
|
||||||
if (!StringUtils.isEmpty(authoritiesJson)) {
|
if (!StringUtils.isEmpty(authoritiesJson)) {
|
||||||
authoritiesJson += ",";
|
authoritiesJson += ",";
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class OAuth2AuthorizationRequestMixinTests {
|
||||||
" \"java.util.Collections$UnmodifiableSet\",\n" +
|
" \"java.util.Collections$UnmodifiableSet\",\n" +
|
||||||
" [" + scopes + "]\n" +
|
" [" + scopes + "]\n" +
|
||||||
" ],\n" +
|
" ],\n" +
|
||||||
" \"state\": " + (authorizationRequest.getState() != null ? "\"" + authorizationRequest.getState() + "\"" : "null") + ",\n" +
|
" \"state\": " + ((authorizationRequest.getState() != null) ? "\"" + authorizationRequest.getState() + "\"" : "null") + ",\n" +
|
||||||
" \"additionalParameters\": {\n" +
|
" \"additionalParameters\": {\n" +
|
||||||
" " + additionalParameters + "\n" +
|
" " + additionalParameters + "\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
|
|
|
@ -241,14 +241,14 @@ public class OAuth2AuthorizedClientMixinTests {
|
||||||
" \"tokenUri\": \"" + providerDetails.getTokenUri() + "\",\n" +
|
" \"tokenUri\": \"" + providerDetails.getTokenUri() + "\",\n" +
|
||||||
" \"userInfoEndpoint\": {\n" +
|
" \"userInfoEndpoint\": {\n" +
|
||||||
" \"@class\": \"org.springframework.security.oauth2.client.registration.ClientRegistration$ProviderDetails$UserInfoEndpoint\",\n" +
|
" \"@class\": \"org.springframework.security.oauth2.client.registration.ClientRegistration$ProviderDetails$UserInfoEndpoint\",\n" +
|
||||||
" \"uri\": " + (userInfoEndpoint.getUri() != null ? "\"" + userInfoEndpoint.getUri() + "\"" : null) + ",\n" +
|
" \"uri\": " + ((userInfoEndpoint.getUri() != null) ? "\"" + userInfoEndpoint.getUri() + "\"" : null) + ",\n" +
|
||||||
" \"authenticationMethod\": {\n" +
|
" \"authenticationMethod\": {\n" +
|
||||||
" \"value\": \"" + userInfoEndpoint.getAuthenticationMethod().getValue() + "\"\n" +
|
" \"value\": \"" + userInfoEndpoint.getAuthenticationMethod().getValue() + "\"\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"userNameAttributeName\": " + (userInfoEndpoint.getUserNameAttributeName() != null ? "\"" + userInfoEndpoint.getUserNameAttributeName() + "\"" : null) + "\n" +
|
" \"userNameAttributeName\": " + ((userInfoEndpoint.getUserNameAttributeName() != null) ? "\"" + userInfoEndpoint.getUserNameAttributeName() + "\"" : null) + "\n" +
|
||||||
" },\n" +
|
" },\n" +
|
||||||
" \"jwkSetUri\": " + (providerDetails.getJwkSetUri() != null ? "\"" + providerDetails.getJwkSetUri() + "\"" : null) + ",\n" +
|
" \"jwkSetUri\": " + ((providerDetails.getJwkSetUri() != null) ? "\"" + providerDetails.getJwkSetUri() + "\"" : null) + ",\n" +
|
||||||
" \"issuerUri\": " + (providerDetails.getIssuerUri() != null ? "\"" + providerDetails.getIssuerUri() + "\"" : null) + ",\n" +
|
" \"issuerUri\": " + ((providerDetails.getIssuerUri() != null) ? "\"" + providerDetails.getIssuerUri() + "\"" : null) + ",\n" +
|
||||||
" \"configurationMetadata\": {\n" +
|
" \"configurationMetadata\": {\n" +
|
||||||
" " + configurationMetadata + "\n" +
|
" " + configurationMetadata + "\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
|
|
|
@ -393,7 +393,7 @@ public class ClientRegistrationsTests {
|
||||||
this.issuer = createIssuerFromServer(path);
|
this.issuer = createIssuerFromServer(path);
|
||||||
this.response.put("issuer", this.issuer);
|
this.response.put("issuer", this.issuer);
|
||||||
this.issuer = this.server.url(path).toString();
|
this.issuer = this.server.url(path).toString();
|
||||||
final String responseBody = body != null ? body : this.mapper.writeValueAsString(this.response);
|
final String responseBody = (body != null) ? body : this.mapper.writeValueAsString(this.response);
|
||||||
|
|
||||||
final Dispatcher dispatcher = new Dispatcher() {
|
final Dispatcher dispatcher = new Dispatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -429,7 +429,7 @@ public class ClientRegistrationsTests {
|
||||||
this.issuer = createIssuerFromServer(path);
|
this.issuer = createIssuerFromServer(path);
|
||||||
this.response.put("issuer", this.issuer);
|
this.response.put("issuer", this.issuer);
|
||||||
|
|
||||||
String responseBody = body != null ? body : this.mapper.writeValueAsString(this.response);
|
String responseBody = (body != null) ? body : this.mapper.writeValueAsString(this.response);
|
||||||
|
|
||||||
final Dispatcher dispatcher = new Dispatcher() {
|
final Dispatcher dispatcher = new Dispatcher() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -175,8 +175,8 @@ public class OAuth2AuthorizedClientArgumentResolverTests {
|
||||||
|
|
||||||
private Object resolveArgument(MethodParameter methodParameter) {
|
private Object resolveArgument(MethodParameter methodParameter) {
|
||||||
return this.argumentResolver.resolveArgument(methodParameter, null, null)
|
return this.argumentResolver.resolveArgument(methodParameter, null, null)
|
||||||
.subscriberContext(this.authentication == null ? Context.empty()
|
.subscriberContext((this.authentication != null)
|
||||||
: ReactiveSecurityContextHolder.withAuthentication(this.authentication))
|
? ReactiveSecurityContextHolder.withAuthentication(this.authentication) : Context.empty())
|
||||||
.subscriberContext(serverWebExchange()).block();
|
.subscriberContext(serverWebExchange()).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,23 +98,24 @@ public abstract class AbstractOAuth2Token implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractOAuth2Token that = (AbstractOAuth2Token) obj;
|
AbstractOAuth2Token other = (AbstractOAuth2Token) obj;
|
||||||
|
|
||||||
if (!this.getTokenValue().equals(that.getTokenValue())) {
|
if (!this.getTokenValue().equals(other.getTokenValue())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.getIssuedAt() != null ? !this.getIssuedAt().equals(that.getIssuedAt()) : that.getIssuedAt() != null) {
|
if ((this.getIssuedAt() != null) ? !this.getIssuedAt().equals(other.getIssuedAt())
|
||||||
|
: other.getIssuedAt() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getExpiresAt() != null ? this.getExpiresAt().equals(that.getExpiresAt())
|
return (this.getExpiresAt() != null) ? this.getExpiresAt().equals(other.getExpiresAt())
|
||||||
: that.getExpiresAt() == null;
|
: other.getExpiresAt() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = this.getTokenValue().hashCode();
|
int result = this.getTokenValue().hashCode();
|
||||||
result = 31 * result + (this.getIssuedAt() != null ? this.getIssuedAt().hashCode() : 0);
|
result = 31 * result + ((this.getIssuedAt() != null) ? this.getIssuedAt().hashCode() : 0);
|
||||||
result = 31 * result + (this.getExpiresAt() != null ? this.getExpiresAt().hashCode() : 0);
|
result = 31 * result + ((this.getExpiresAt() != null) ? this.getExpiresAt().hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ public final class DefaultOAuth2AuthenticatedPrincipal implements OAuth2Authenti
|
||||||
|
|
||||||
Assert.notEmpty(attributes, "attributes cannot be empty");
|
Assert.notEmpty(attributes, "attributes cannot be empty");
|
||||||
this.attributes = Collections.unmodifiableMap(attributes);
|
this.attributes = Collections.unmodifiableMap(attributes);
|
||||||
this.authorities = authorities == null ? AuthorityUtils.NO_AUTHORITIES
|
this.authorities = (authorities != null) ? Collections.unmodifiableCollection(authorities)
|
||||||
: Collections.unmodifiableCollection(authorities);
|
: AuthorityUtils.NO_AUTHORITIES;
|
||||||
this.name = name == null ? (String) this.attributes.get("sub") : name;
|
this.name = (name != null) ? name : (String) this.attributes.get("sub");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class OAuth2AccessToken extends AbstractOAuth2Token {
|
||||||
super(tokenValue, issuedAt, expiresAt);
|
super(tokenValue, issuedAt, expiresAt);
|
||||||
Assert.notNull(tokenType, "tokenType cannot be null");
|
Assert.notNull(tokenType, "tokenType cannot be null");
|
||||||
this.tokenType = tokenType;
|
this.tokenType = tokenType;
|
||||||
this.scopes = Collections.unmodifiableSet(scopes != null ? scopes : Collections.emptySet());
|
this.scopes = Collections.unmodifiableSet((scopes != null) ? scopes : Collections.emptySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class OAuth2Error implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + this.getErrorCode() + "] " + (this.getDescription() != null ? this.getDescription() : "");
|
return "[" + this.getErrorCode() + "] " + ((this.getDescription() != null) ? this.getDescription() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ final class ObjectToStringConverter implements GenericConverter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||||
return source == null ? null : source.toString();
|
return (source != null) ? source.toString() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,8 @@ public final class OAuth2AccessTokenResponse {
|
||||||
this.issuedAt = accessToken.getIssuedAt();
|
this.issuedAt = accessToken.getIssuedAt();
|
||||||
this.expiresAt = accessToken.getExpiresAt();
|
this.expiresAt = accessToken.getExpiresAt();
|
||||||
this.scopes = accessToken.getScopes();
|
this.scopes = accessToken.getScopes();
|
||||||
this.refreshToken = response.getRefreshToken() == null ? null : response.getRefreshToken().getTokenValue();
|
this.refreshToken = (response.getRefreshToken() != null) ? response.getRefreshToken().getTokenValue()
|
||||||
|
: null;
|
||||||
this.additionalParameters = response.getAdditionalParameters();
|
this.additionalParameters = response.getAdditionalParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ public final class OAuth2AccessTokenResponse {
|
||||||
private Instant getExpiresAt() {
|
private Instant getExpiresAt() {
|
||||||
if (this.expiresAt == null) {
|
if (this.expiresAt == null) {
|
||||||
Instant issuedAt = getIssuedAt();
|
Instant issuedAt = getIssuedAt();
|
||||||
this.expiresAt = this.expiresIn > 0 ? issuedAt.plusSeconds(this.expiresIn) : issuedAt.plusSeconds(1);
|
this.expiresAt = (this.expiresIn > 0) ? issuedAt.plusSeconds(this.expiresIn) : issuedAt.plusSeconds(1);
|
||||||
}
|
}
|
||||||
return this.expiresAt;
|
return this.expiresAt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,37 +81,38 @@ public final class DefaultAddressStandardClaim implements AddressStandardClaim {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressStandardClaim that = (AddressStandardClaim) obj;
|
AddressStandardClaim other = (AddressStandardClaim) obj;
|
||||||
|
|
||||||
if (this.getFormatted() != null ? !this.getFormatted().equals(that.getFormatted())
|
if ((this.getFormatted() != null) ? !this.getFormatted().equals(other.getFormatted())
|
||||||
: that.getFormatted() != null) {
|
: other.getFormatted() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.getStreetAddress() != null ? !this.getStreetAddress().equals(that.getStreetAddress())
|
if ((this.getStreetAddress() != null) ? !this.getStreetAddress().equals(other.getStreetAddress())
|
||||||
: that.getStreetAddress() != null) {
|
: other.getStreetAddress() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.getLocality() != null ? !this.getLocality().equals(that.getLocality()) : that.getLocality() != null) {
|
if ((this.getLocality() != null) ? !this.getLocality().equals(other.getLocality())
|
||||||
|
: other.getLocality() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.getRegion() != null ? !this.getRegion().equals(that.getRegion()) : that.getRegion() != null) {
|
if ((this.getRegion() != null) ? !this.getRegion().equals(other.getRegion()) : other.getRegion() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.getPostalCode() != null ? !this.getPostalCode().equals(that.getPostalCode())
|
if ((this.getPostalCode() != null) ? !this.getPostalCode().equals(other.getPostalCode())
|
||||||
: that.getPostalCode() != null) {
|
: other.getPostalCode() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getCountry() != null ? this.getCountry().equals(that.getCountry()) : that.getCountry() == null;
|
return (this.getCountry() != null) ? this.getCountry().equals(other.getCountry()) : other.getCountry() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = this.getFormatted() != null ? this.getFormatted().hashCode() : 0;
|
int result = (this.getFormatted() != null) ? this.getFormatted().hashCode() : 0;
|
||||||
result = 31 * result + (this.getStreetAddress() != null ? this.getStreetAddress().hashCode() : 0);
|
result = 31 * result + ((this.getStreetAddress() != null) ? this.getStreetAddress().hashCode() : 0);
|
||||||
result = 31 * result + (this.getLocality() != null ? this.getLocality().hashCode() : 0);
|
result = 31 * result + ((this.getLocality() != null) ? this.getLocality().hashCode() : 0);
|
||||||
result = 31 * result + (this.getRegion() != null ? this.getRegion().hashCode() : 0);
|
result = 31 * result + ((this.getRegion() != null) ? this.getRegion().hashCode() : 0);
|
||||||
result = 31 * result + (this.getPostalCode() != null ? this.getPostalCode().hashCode() : 0);
|
result = 31 * result + ((this.getPostalCode() != null) ? this.getPostalCode().hashCode() : 0);
|
||||||
result = 31 * result + (this.getCountry() != null ? this.getCountry().hashCode() : 0);
|
result = 31 * result + ((this.getCountry() != null) ? this.getCountry().hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,14 +104,15 @@ public class OidcUserAuthority extends OAuth2UserAuthority {
|
||||||
if (!this.getIdToken().equals(that.getIdToken())) {
|
if (!this.getIdToken().equals(that.getIdToken())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return this.getUserInfo() != null ? this.getUserInfo().equals(that.getUserInfo()) : that.getUserInfo() == null;
|
return (this.getUserInfo() != null) ? this.getUserInfo().equals(that.getUserInfo())
|
||||||
|
: that.getUserInfo() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = 31 * result + this.getIdToken().hashCode();
|
result = 31 * result + this.getIdToken().hashCode();
|
||||||
result = 31 * result + (this.getUserInfo() != null ? this.getUserInfo().hashCode() : 0);
|
result = 31 * result + ((this.getUserInfo() != null) ? this.getUserInfo().hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,9 @@ class OAuth2AccessTokenResponseBodyExtractor
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
oauth2Error = new OAuth2Error(
|
oauth2Error = new OAuth2Error(
|
||||||
errorObject.getCode() != null ? errorObject.getCode() : OAuth2ErrorCodes.SERVER_ERROR,
|
(errorObject.getCode() != null) ? errorObject.getCode() : OAuth2ErrorCodes.SERVER_ERROR,
|
||||||
errorObject.getDescription(),
|
errorObject.getDescription(),
|
||||||
errorObject.getURI() != null ? errorObject.getURI().toString() : null);
|
(errorObject.getURI() != null) ? errorObject.getURI().toString() : null);
|
||||||
}
|
}
|
||||||
return Mono.error(new OAuth2AuthorizationException(oauth2Error));
|
return Mono.error(new OAuth2AuthorizationException(oauth2Error));
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,8 @@ class OAuth2AccessTokenResponseBodyExtractor
|
||||||
}
|
}
|
||||||
long expiresIn = accessToken.getLifetime();
|
long expiresIn = accessToken.getLifetime();
|
||||||
|
|
||||||
Set<String> scopes = accessToken.getScope() == null ? Collections.emptySet()
|
Set<String> scopes = (accessToken.getScope() != null)
|
||||||
: new LinkedHashSet<>(accessToken.getScope().toStringList());
|
? new LinkedHashSet<>(accessToken.getScope().toStringList()) : Collections.emptySet();
|
||||||
|
|
||||||
String refreshToken = null;
|
String refreshToken = null;
|
||||||
if (accessTokenResponse.getTokens().getRefreshToken() != null) {
|
if (accessTokenResponse.getTokens().getRefreshToken() != null) {
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class OpenID4JavaConsumer implements OpenIDConsumer {
|
||||||
if (verified == null) {
|
if (verified == null) {
|
||||||
Identifier id = discovered.getClaimedIdentifier();
|
Identifier id = discovered.getClaimedIdentifier();
|
||||||
return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE,
|
return new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE,
|
||||||
id == null ? "Unknown" : id.getIdentifier(),
|
(id != null) ? id.getIdentifier() : "Unknown",
|
||||||
"Verification status message: [" + verification.getStatusMsg() + "]",
|
"Verification status message: [" + verification.getStatusMsg() + "]",
|
||||||
Collections.<OpenIDAttribute>emptyList());
|
Collections.<OpenIDAttribute>emptyList());
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
|
||||||
if (currentUser != null) {
|
if (currentUser != null) {
|
||||||
this.principal = currentUser.getName();
|
this.principal = currentUser.getName();
|
||||||
Object userCredentials = currentUser.getCredentials();
|
Object userCredentials = currentUser.getCredentials();
|
||||||
this.credentials = userCredentials == null ? null : userCredentials.toString();
|
this.credentials = (userCredentials != null) ? userCredentials.toString() : null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.credentials = null;
|
this.credentials = null;
|
||||||
|
|
|
@ -81,7 +81,9 @@ public interface PayloadExchangeMatcher {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Mono<MatchResult> match(Map<String, ? extends Object> variables) {
|
public static Mono<MatchResult> match(Map<String, ? extends Object> variables) {
|
||||||
return Mono.just(new MatchResult(true, variables == null ? null : new HashMap<String, Object>(variables)));
|
MatchResult result = new MatchResult(true,
|
||||||
|
(variables != null) ? new HashMap<String, Object>(variables) : null);
|
||||||
|
return Mono.just(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class Saml2Error implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[" + this.getErrorCode() + "] " + (this.getDescription() != null ? this.getDescription() : "");
|
return "[" + this.getErrorCode() + "] " + ((this.getDescription() != null) ? this.getDescription() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -536,11 +536,11 @@ public final class OpenSamlAuthenticationProvider implements AuthenticationProvi
|
||||||
}
|
}
|
||||||
if (xmlObject instanceof XSBoolean) {
|
if (xmlObject instanceof XSBoolean) {
|
||||||
XSBooleanValue xsBooleanValue = ((XSBoolean) xmlObject).getValue();
|
XSBooleanValue xsBooleanValue = ((XSBoolean) xmlObject).getValue();
|
||||||
return xsBooleanValue != null ? xsBooleanValue.getValue() : null;
|
return (xsBooleanValue != null) ? xsBooleanValue.getValue() : null;
|
||||||
}
|
}
|
||||||
if (xmlObject instanceof XSDateTime) {
|
if (xmlObject instanceof XSDateTime) {
|
||||||
DateTime dateTime = ((XSDateTime) xmlObject).getValue();
|
DateTime dateTime = ((XSDateTime) xmlObject).getValue();
|
||||||
return dateTime != null ? Instant.ofEpochMilli(dateTime.getMillis()) : null;
|
return (dateTime != null) ? Instant.ofEpochMilli(dateTime.getMillis()) : null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue