signature:
public class CsrfConfigurer { /** * Allows specifying { @ link HttpServletRequest } that should not use CSRF Protection
 * even if they match the { @ link # requireCsrfProtectionMatcher ( RequestMatcher ) } .
 * For example , the following configuration will ensure CSRF protection ignores :
 * < ul >
 * < li > Any GET , HEAD , TRACE , OPTIONS ( this is the default ) < / li >
 * < li > We also explicitly state to ignore any request that starts with " / sockjs / " < / li >
 * < / ul >
 * < pre >
 * http
 * . csrf ( )
 * . ignoringAntMatchers ( " / sockjs / * * " )
 * . and ( )
 * < / pre >
 * @ since 4.0 */
public CsrfConfigurer < H > ignoringAntMatchers ( String ... antPatterns ) { } }

implementation: return new IgnoreCsrfProtectionRegistry ( this . context ) . antMatchers ( antPatterns ) . and ( ) ;


signature:
public class CsrfConfigurer { /** * Allows specifying { @ link HttpServletRequest } s that should not use CSRF Protection
 * even if they match the { @ link # requireCsrfProtectionMatcher ( RequestMatcher ) } .
 * For example , the following configuration will ensure CSRF protection ignores :
 * < ul >
 * < li > Any GET , HEAD , TRACE , OPTIONS ( this is the default ) < / li >
 * < li > We also explicitly state to ignore any request that has a " X - Requested - With : XMLHttpRequest " header < / li >
 * < / ul >
 * < pre >
 * http
 * . csrf ( )
 * . ignoringRequestMatchers ( request - > " XMLHttpRequest " . equals ( request . getHeader ( " X - Requested - With " ) ) )
 * . and ( )
 * < / pre >
 * @ since 5.1 */
public CsrfConfigurer < H > ignoringRequestMatchers ( RequestMatcher ... requestMatchers ) { } }

implementation: return new IgnoreCsrfProtectionRegistry ( this . context ) . requestMatchers ( requestMatchers ) . and ( ) ;


signature:
public class CsrfConfigurer { /** * Gets the final { @ link RequestMatcher } to use by combining the
 * { @ link # requireCsrfProtectionMatcher ( RequestMatcher ) } and any { @ link # ignore ( ) } .
 * @ return the { @ link RequestMatcher } to use */
private RequestMatcher getRequireCsrfProtectionMatcher ( ) { } }

implementation: if ( this . ignoredCsrfProtectionMatchers . isEmpty ( ) ) { return this . requireCsrfProtectionMatcher ; } return new AndRequestMatcher ( this . requireCsrfProtectionMatcher , new NegatedRequestMatcher ( new OrRequestMatcher ( this . ignoredCsrfProtectionMatchers ) ) ) ;


signature:
public class CsrfConfigurer { /** * Gets the default { @ link AccessDeniedHandler } from the
 * { @ link ExceptionHandlingConfigurer # getAccessDeniedHandler ( ) } or create a
 * { @ link AccessDeniedHandlerImpl } if not available .
 * @ param http the { @ link HttpSecurityBuilder }
 * @ return the { @ link AccessDeniedHandler } */
@ SuppressWarnings ( "unchecked" ) private AccessDeniedHandler getDefaultAccessDeniedHandler ( H http ) { } }

implementation: ExceptionHandlingConfigurer < H > exceptionConfig = http . getConfigurer ( ExceptionHandlingConfigurer . class ) ; AccessDeniedHandler handler = null ; if ( exceptionConfig != null ) { handler = exceptionConfig . getAccessDeniedHandler ( ) ; } if ( handler == null ) { handler = new AccessDeniedHandlerImpl ( ) ; } return handler ;


signature:
public class CsrfConfigurer { /** * Gets the default { @ link InvalidSessionStrategy } from the
 * { @ link SessionManagementConfigurer # getInvalidSessionStrategy ( ) } or null if not
 * available .
 * @ param http the { @ link HttpSecurityBuilder }
 * @ return the { @ link InvalidSessionStrategy } */
@ SuppressWarnings ( "unchecked" ) private InvalidSessionStrategy getInvalidSessionStrategy ( H http ) { } }

implementation: SessionManagementConfigurer < H > sessionManagement = http . getConfigurer ( SessionManagementConfigurer . class ) ; if ( sessionManagement == null ) { return null ; } return sessionManagement . getInvalidSessionStrategy ( ) ;


signature:
public class CsrfConfigurer { /** * Creates the { @ link AccessDeniedHandler } from the result of
 * { @ link # getDefaultAccessDeniedHandler ( HttpSecurityBuilder ) } and
 * { @ link # getInvalidSessionStrategy ( HttpSecurityBuilder ) } . If
 * { @ link # getInvalidSessionStrategy ( HttpSecurityBuilder ) } is non - null , then a
 * { @ link DelegatingAccessDeniedHandler } is used in combination with
 * { @ link InvalidSessionAccessDeniedHandler } and the
 * { @ link # getDefaultAccessDeniedHandler ( HttpSecurityBuilder ) } . Otherwise , only
 * { @ link # getDefaultAccessDeniedHandler ( HttpSecurityBuilder ) } is used .
 * @ param http the { @ link HttpSecurityBuilder }
 * @ return the { @ link AccessDeniedHandler } */
private AccessDeniedHandler createAccessDeniedHandler ( H http ) { } }

implementation: InvalidSessionStrategy invalidSessionStrategy = getInvalidSessionStrategy ( http ) ; AccessDeniedHandler defaultAccessDeniedHandler = getDefaultAccessDeniedHandler ( http ) ; if ( invalidSessionStrategy == null ) { return defaultAccessDeniedHandler ; } InvalidSessionAccessDeniedHandler invalidSessionDeniedHandler = new InvalidSessionAccessDeniedHandler ( invalidSessionStrategy ) ; LinkedHashMap < Class < ? extends AccessDeniedException > , AccessDeniedHandler > handlers = new LinkedHashMap < Class < ? extends AccessDeniedException > , AccessDeniedHandler > ( ) ; handlers . put ( MissingCsrfTokenException . class , invalidSessionDeniedHandler ) ; return new DelegatingAccessDeniedHandler ( handlers , defaultAccessDeniedHandler ) ;


signature:
public class AbstractAuthenticationTargetUrlRequestHandler { /** * Invokes the configured { @ code RedirectStrategy } with the URL returned by the
 * { @ code determineTargetUrl } method .
 * The redirect will not be performed if the response has already been committed . */
protected void handle ( HttpServletRequest request , HttpServletResponse response , Authentication authentication ) throws IOException , ServletException { } }

implementation: String targetUrl = determineTargetUrl ( request , response , authentication ) ; if ( response . isCommitted ( ) ) { logger . debug ( "Response has already been committed. Unable to redirect to " + targetUrl ) ; return ; } redirectStrategy . sendRedirect ( request , response , targetUrl ) ;


signature:
public class AbstractAuthenticationTargetUrlRequestHandler { /** * Builds the target URL according to the logic defined in the main class Javadoc
 * @ since 5.2 */
protected String determineTargetUrl ( HttpServletRequest request , HttpServletResponse response , Authentication authentication ) { } }

implementation: return determineTargetUrl ( request , response ) ;


signature:
public class AbstractAuthenticationTargetUrlRequestHandler { /** * Builds the target URL according to the logic defined in the main class Javadoc . */
protected String determineTargetUrl ( HttpServletRequest request , HttpServletResponse response ) { } }

implementation:
if ( isAlwaysUseDefaultTargetUrl ( ) ) { return defaultTargetUrl ; } // Check for the parameter and use that if available
String targetUrl = null ; if ( targetUrlParameter != null ) { targetUrl = request . getParameter ( targetUrlParameter ) ; if ( StringUtils . hasText ( targetUrl ) ) { logger . debug ( "Found targetUrlParameter in request: " + targetUrl ) ; return targetUrl ; } } if ( useReferer && ! StringUtils . hasLength ( targetUrl ) ) { targetUrl = request . getHeader ( "Referer" ) ; logger . debug ( "Using Referer header: " + targetUrl ) ; } if ( ! StringUtils . hasText ( targetUrl ) ) { targetUrl = defaultTargetUrl ; logger . debug ( "Using default Url: " + targetUrl ) ; } return targetUrl ;


signature:
public class AbstractAuthenticationTargetUrlRequestHandler { /** * Supplies the default target Url that will be used if no saved request is found in
 * the session , or the { @ code alwaysUseDefaultTargetUrl } property is set to true . If
 * not set , defaults to { @ code / } . It will be treated as relative to the web - app ' s
 * context path , and should include the leading < code > / < / code > . Alternatively ,
 * inclusion of a scheme name ( such as " http : / / " or " https : / / " ) as the prefix will
 * denote a fully - qualified URL and this is also supported .
 * @ param defaultTargetUrl */
public void setDefaultTargetUrl ( String defaultTargetUrl ) { } }

implementation: Assert . isTrue ( UrlUtils . isValidRedirectUrl ( defaultTargetUrl ) , "defaultTarget must start with '/' or with 'http(s)'" ) ; this . defaultTargetUrl = defaultTargetUrl ;


signature:
public class AbstractAuthenticationTargetUrlRequestHandler { /** * If this property is set , the current request will be checked for this a parameter
 * with this name and the value used as the target URL if present .
 * @ param targetUrlParameter the name of the parameter containing the encoded target
 * URL . Defaults to null . */
public void setTargetUrlParameter ( String targetUrlParameter ) { } }

implementation: if ( targetUrlParameter != null ) { Assert . hasText ( targetUrlParameter , "targetUrlParameter cannot be empty" ) ; } this . targetUrlParameter = targetUrlParameter ;


signature:
public class DocumentDaoImpl { /** * Executes recursive SQL as needed to build a full Directory hierarchy of objects */
private Directory getDirectoryWithImmediateParentPopulated ( final Long id ) { } }

implementation:
return getJdbcTemplate ( ) . queryForObject ( SELECT_FROM_DIRECTORY_SINGLE , new Object [ ] { id } , new RowMapper < Directory > ( ) { public Directory mapRow ( ResultSet rs , int rowNumber ) throws SQLException { Long parentDirectoryId = new Long ( rs . getLong ( "parent_directory_id" ) ) ; Directory parentDirectory = Directory . ROOT_DIRECTORY ; if ( parentDirectoryId != null && ! parentDirectoryId . equals ( new Long ( - 1 ) ) ) { // Need to go and lookup the parent , so do that first
parentDirectory = getDirectoryWithImmediateParentPopulated ( parentDirectoryId ) ; } Directory directory = new Directory ( rs . getString ( "directory_name" ) , parentDirectory ) ; FieldUtils . setProtectedFieldValue ( "id" , directory , new Long ( rs . getLong ( "id" ) ) ) ; return directory ; } } ) ;


signature:
public class RequestHeaderAuthenticationFilter { /** * Read and returns the header named by { @ code principalRequestHeader } from the
 * request .
 * @ throws PreAuthenticatedCredentialsNotFoundException if the header is missing and
 * { @ code exceptionIfHeaderMissing } is set to { @ code true } . */
protected Object getPreAuthenticatedPrincipal ( HttpServletRequest request ) { } }

implementation: String principal = request . getHeader ( principalRequestHeader ) ; if ( principal == null && exceptionIfHeaderMissing ) { throw new PreAuthenticatedCredentialsNotFoundException ( principalRequestHeader + " header not found in request." ) ; } return principal ;


signature: public class ClientApplication { public void invokeContactManager ( Authentication authentication , int nrOfCalls ) { } }

implementation: StopWatch stopWatch = new StopWatch ( nrOfCalls + " ContactManager call(s)" ) ; Map < String , ContactManager > contactServices = this . beanFactory . getBeansOfType ( ContactManager . class , true , true ) ; SecurityContextHolder . getContext ( ) . setAuthentication ( authentication ) ; for ( Map . Entry < String , ContactManager > entry : contactServices . entrySet ( ) ) { String beanName = entry . getKey ( ) ; ContactManager remoteContactManager = entry . getValue ( ) ; Object object = this . beanFactory . getBean ( "&" + beanName ) ; try { System . out . println ( "Trying to find setUsername(String) method on: " + object . getClass ( ) . getName ( ) ) ; Method method = object . getClass ( ) . getMethod ( "setUsername" , new Class [ ] { String . class } ) ; System . out . println ( "Found; Trying to setUsername(String) to " + authentication . getPrincipal ( ) ) ; method . invoke ( object , authentication . getPrincipal ( ) ) ; } catch ( NoSuchMethodException ignored ) { System . out . println ( "This client proxy factory does not have a setUsername(String) method" ) ; } catch ( IllegalAccessException ignored ) { ignored . printStackTrace ( ) ; } catch ( InvocationTargetException ignored ) { ignored . printStackTrace ( ) ; } try { System . out . println ( "Trying to find setPassword(String) method on: " + object . getClass ( ) . getName ( ) ) ; Method method = object . getClass ( ) . getMethod ( "setPassword" , new Class [ ] { String . class } ) ; method . invoke ( object , authentication . getCredentials ( ) ) ; System . out . println ( "Found; Trying to setPassword(String) to " + authentication . getCredentials ( ) ) ; } catch ( NoSuchMethodException ignored ) { System . out . println ( "This client proxy factory does not have a setPassword(String) method" ) ; } catch ( IllegalAccessException ignored ) { } catch ( InvocationTargetException ignored ) { } System . out . println ( "Calling ContactManager '" + beanName + "'" ) ; stopWatch . start ( beanName ) ; List < Contact > contacts = null ; for ( int i = 0 ; i < nrOfCalls ; i ++ ) { contacts = remoteContactManager . getAll ( ) ; } stopWatch . stop ( ) ; if ( contacts . size ( ) != 0 ) { for ( Contact contact : contacts ) { System . out . println ( "Contact: " + contact ) ; } } else { System . out . println ( "No contacts found which this user has permission to" ) ; } System . out . println ( ) ; System . out . println ( stopWatch . prettyPrint ( ) ) ; } SecurityContextHolder . clearContext ( ) ;


signature:
public class DefaultLdapUsernameToDnMapper { /** * Assembles the Distinguished Name that should be used the given username . */
public DistinguishedName buildDn ( String username ) { } }

implementation: DistinguishedName dn = new DistinguishedName ( userDnBase ) ; dn . add ( usernameAttribute , username ) ; return dn ;


signature:
public class OAuth2AuthorizationRequest { /** * Returns a new { @ link Builder } , initialized with the values
 * from the provided { @ code authorizationRequest } .
 * @ since 5.1
 * @ param authorizationRequest the authorization request used for initializing the { @ link Builder }
 * @ return the { @ link Builder } */
public static Builder from ( OAuth2AuthorizationRequest authorizationRequest ) { } }

implementation: Assert . notNull ( authorizationRequest , "authorizationRequest cannot be null" ) ; return new Builder ( authorizationRequest . getGrantType ( ) ) . authorizationUri ( authorizationRequest . getAuthorizationUri ( ) ) . clientId ( authorizationRequest . getClientId ( ) ) . redirectUri ( authorizationRequest . getRedirectUri ( ) ) . scopes ( authorizationRequest . getScopes ( ) ) . state ( authorizationRequest . getState ( ) ) . additionalParameters ( authorizationRequest . getAdditionalParameters ( ) ) . attributes ( authorizationRequest . getAttributes ( ) ) ;


signature:
public class NimbusOAuth2TokenIntrospectionClient { /** * { @ inheritDoc } */
@ Override public Map < String , Object > introspect ( String token ) { } }

implementation:
TokenIntrospectionSuccessResponse response = Optional . of ( token ) . map ( this :: buildRequest ) . map ( this :: makeRequest ) . map ( this :: adaptToNimbusResponse ) . map ( this :: parseNimbusResponse ) . map ( this :: castToNimbusSuccess ) // relying solely on the authorization server to validate this token ( not checking ' exp ' , for example )
. filter ( TokenIntrospectionSuccessResponse :: isActive ) . orElseThrow ( ( ) -> new OAuth2IntrospectionException ( "Provided token [" + token + "] isn't active" ) ) ; return convertClaimsSet ( response ) ;


signature:
public class WebSecurityConfigurerAdapter { /** * Creates the { @ link HttpSecurity } or returns the current instance
 * ] * @ return the { @ link HttpSecurity }
 * @ throws Exception */
@ SuppressWarnings ( { } }

implementation:
"rawtypes" , "unchecked" } ) protected final HttpSecurity getHttp ( ) throws Exception { if ( http != null ) { return http ; } DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor . postProcess ( new DefaultAuthenticationEventPublisher ( ) ) ; localConfigureAuthenticationBldr . authenticationEventPublisher ( eventPublisher ) ; AuthenticationManager authenticationManager = authenticationManager ( ) ; authenticationBuilder . parentAuthenticationManager ( authenticationManager ) ; authenticationBuilder . authenticationEventPublisher ( eventPublisher ) ; Map < Class < ? extends Object > , Object > sharedObjects = createSharedObjects ( ) ; http = new HttpSecurity ( objectPostProcessor , authenticationBuilder , sharedObjects ) ; if ( ! disableDefaults ) { // @ formatter : off
http . csrf ( ) . and ( ) . addFilter ( new WebAsyncManagerIntegrationFilter ( ) ) . exceptionHandling ( ) . and ( ) . headers ( ) . and ( ) . sessionManagement ( ) . and ( ) . securityContext ( ) . and ( ) . requestCache ( ) . and ( ) . anonymous ( ) . and ( ) . servletApi ( ) . and ( ) . apply ( new DefaultLoginPageConfigurer < > ( ) ) . and ( ) . logout ( ) ; // @ formatter : on
ClassLoader classLoader = this . context . getClassLoader ( ) ; List < AbstractHttpConfigurer > defaultHttpConfigurers = SpringFactoriesLoader . loadFactories ( AbstractHttpConfigurer . class , classLoader ) ; for ( AbstractHttpConfigurer configurer : defaultHttpConfigurers ) { http . apply ( configurer ) ; } } configure ( http ) ; return http ;


signature:
public class WebSecurityConfigurerAdapter { /** * Gets the { @ link AuthenticationManager } to use . The default strategy is if
 * { @ link # configure ( AuthenticationManagerBuilder ) } method is overridden to use the
 * { @ link AuthenticationManagerBuilder } that was passed in . Otherwise , autowire the
 * { @ link AuthenticationManager } by type .
 * @ return the { @ link AuthenticationManager } to use
 * @ throws Exception */
protected AuthenticationManager authenticationManager ( ) throws Exception { } }

implementation: if ( ! authenticationManagerInitialized ) { configure ( localConfigureAuthenticationBldr ) ; if ( disableLocalConfigureAuthenticationBldr ) { authenticationManager = authenticationConfiguration . getAuthenticationManager ( ) ; } else { authenticationManager = localConfigureAuthenticationBldr . build ( ) ; } authenticationManagerInitialized = true ; } return authenticationManager ;


signature:
public class WebSecurityConfigurerAdapter { /** * Override this method to expose a { @ link UserDetailsService } created from
 * { @ link # configure ( AuthenticationManagerBuilder ) } as a bean . In general only the
 * following override should be done of this method :
 * < pre >
 * & # 064 ; Bean ( name = & quot ; myUserDetailsService & quot ; )
 * / / any or no name specified is allowed
 * & # 064 ; Override
 * public UserDetailsService userDetailsServiceBean ( ) throws Exception {
 * return super . userDetailsServiceBean ( ) ;
 * < / pre >
 * To change the instance returned , developers should change
 * { @ link # userDetailsService ( ) } instead
 * @ return the { @ link UserDetailsService }
 * @ throws Exception
 * @ see # userDetailsService ( ) */
public UserDetailsService userDetailsServiceBean ( ) throws Exception { } }

implementation: AuthenticationManagerBuilder globalAuthBuilder = context . getBean ( AuthenticationManagerBuilder . class ) ; return new UserDetailsServiceDelegator ( Arrays . asList ( localConfigureAuthenticationBldr , globalAuthBuilder ) ) ;


signature:
public class WebSecurityConfigurerAdapter { /** * Allows modifying and accessing the { @ link UserDetailsService } from
 * { @ link # userDetailsServiceBean ( ) } without interacting with the
 * { @ link ApplicationContext } . Developers should override this method when changing
 * the instance of { @ link # userDetailsServiceBean ( ) } .
 * @ return the { @ link UserDetailsService } to use */
protected UserDetailsService userDetailsService ( ) { } }


signature:
public class WebSecurityConfigurerAdapter { /** * Creates the shared objects
 * @ return the shared Objects */
private Map < Class < ? extends Object > , Object > createSharedObjects ( ) { } }

implementation: Map < Class < ? extends Object > , Object > sharedObjects = new HashMap < Class < ? extends Object > , Object > ( ) ; sharedObjects . putAll ( localConfigureAuthenticationBldr . getSharedObjects ( ) ) ; sharedObjects . put ( UserDetailsService . class , userDetailsService ( ) ) ; sharedObjects . put ( ApplicationContext . class , context ) ; sharedObjects . put ( ContentNegotiationStrategy . class , contentNegotiationStrategy ) ; sharedObjects . put ( AuthenticationTrustResolver . class , trustResolver ) ; return sharedObjects ;


signature: public class JaasAuthenticationProvider { @ Override public void afterPropertiesSet ( ) throws Exception { } }

implementation:
// the superclass is not called because it does additional checks that are
// non - passive
Assert . hasLength ( getLoginContextName ( ) , ( ) -> "loginContextName must be set on " + getClass ( ) ) ; Assert . notNull ( this . loginConfig , ( ) -> "loginConfig must be set on " + getClass ( ) ) ; configureJaas ( this . loginConfig ) ; Assert . notNull ( Configuration . getConfiguration ( ) , "As per https://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html " + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is " + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to " + "Configuration.getConfiguration()." ) ;


signature:
public class JaasAuthenticationProvider { /** * Loops through the login . config . url . 1 , login . config . url . 2 properties looking for the
 * login configuration . If it is not set , it will be set to the last available
 * login . config . url . X property . */
private void configureJaasUsingLoop ( ) throws IOException { } }

implementation: String loginConfigUrl = convertLoginConfigToUrl ( ) ; boolean alreadySet = false ; int n = 1 ; final String prefix = "login.config.url." ; String existing ; while ( ( existing = Security . getProperty ( prefix + n ) ) != null ) { alreadySet = existing . equals ( loginConfigUrl ) ; if ( alreadySet ) { break ; } n ++ ; } if ( ! alreadySet ) { String key = prefix + n ; log . debug ( "Setting security property [" + key + "] to: " + loginConfigUrl ) ; Security . setProperty ( key , loginConfigUrl ) ; }


signature:
public class JaasAuthenticationProvider { /** * Publishes the { @ link JaasAuthenticationFailedEvent } . Can be overridden by
 * subclasses for different functionality
 * @ param token The authentication token being processed
 * @ param ase The excetion that caused the authentication failure */
@ Override protected void publishFailureEvent ( UsernamePasswordAuthenticationToken token , AuthenticationException ase ) { } }

implementation:
// exists for passivity ( the superclass does a null check before publishing )
getApplicationEventPublisher ( ) . publishEvent ( new JaasAuthenticationFailedEvent ( token , ase ) ) ;


signature:
public class AbstractSecurityExpressionHandler { /** * Invokes the internal template methods to create { @ code StandardEvaluationContext }
 * and { @ code SecurityExpressionRoot } objects .
 * @ param authentication the current authentication object
 * @ param invocation the invocation ( filter , method , channel )
 * @ return the context object for use in evaluating the expression , populated with a
 * suitable root object . */
public final EvaluationContext createEvaluationContext ( Authentication authentication , T invocation ) { } }

implementation: SecurityExpressionOperations root = createSecurityExpressionRoot ( authentication , invocation ) ; StandardEvaluationContext ctx = createEvaluationContextInternal ( authentication , invocation ) ; ctx . setBeanResolver ( br ) ; ctx . setRootObject ( root ) ; return ctx ;


signature:
public class JndiDnsResolver { /** * ( non - Javadoc )
 * @ see
 * org . springframework . security . remoting . dns . DnsResolver # resolveServiceEntry ( java .
 * lang . String , java . lang . String ) */
public String resolveServiceEntry ( String serviceType , String domain ) { } }

implementation: return resolveServiceEntry ( serviceType , domain , this . ctxFactory . getCtx ( ) ) ;


signature:
public class JndiDnsResolver { /** * ( non - Javadoc )
 * @ see
 * org . springframework . security . remoting . dns . DnsResolver # resolveServiceIpAddress ( java
 * . lang . String , java . lang . String ) */
public String resolveServiceIpAddress ( String serviceType , String domain ) { } }

implementation: DirContext ctx = this . ctxFactory . getCtx ( ) ; String hostname = resolveServiceEntry ( serviceType , domain , ctx ) ; return resolveIpAddress ( hostname , ctx ) ;


signature:
public class JndiDnsResolver { /** * resolveServiceIpAddress ( ) . */
private String resolveIpAddress ( String hostname , DirContext ctx ) { } }

implementation:
try { Attribute dnsRecord = lookup ( hostname , ctx , "A" ) ; // There should be only one A record , therefore it is save to return
// only the first .
return dnsRecord . get ( ) . toString ( ) ; } catch ( NamingException e ) { throw new DnsLookupException ( "DNS lookup failed for: " + hostname , e ) ; }


signature:
public class JndiDnsResolver { /** * resolveServiceIpAddress ( ) . */
private String resolveServiceEntry ( String serviceType , String domain , DirContext ctx ) { } }

implementation:
String result = null ; try { String query = new StringBuilder ( "_" ) . append ( serviceType ) . append ( "._tcp." ) . append ( domain ) . toString ( ) ; Attribute dnsRecord = lookup ( query , ctx , "SRV" ) ; // There are maybe more records defined , we will return the one
// with the highest priority ( lowest number ) and the highest weight
// ( highest number )
int highestPriority = - 1 ; int highestWeight = - 1 ; for ( NamingEnumeration < ? > recordEnum = dnsRecord . getAll ( ) ; recordEnum . hasMoreElements ( ) ; ) { String [ ] record = recordEnum . next ( ) . toString ( ) . split ( " " ) ; if ( record . length != 4 ) { throw new DnsLookupException ( "Wrong service record for query " + query + ": [" + Arrays . toString ( record ) + "]" ) ; } int priority = Integer . parseInt ( record [ 0 ] ) ; int weight = Integer . parseInt ( record [ 1 ] ) ; // we have a new highest Priority , so forget also the highest weight
if ( priority < highestPriority || highestPriority == - 1 ) { highestPriority = priority ; highestWeight = weight ; result = record [ 3 ] . trim ( ) ; } // same priority , but higher weight
if ( priority == highestPriority && weight > highestWeight ) { highestWeight = weight ; result = record [ 3 ] . trim ( ) ; } } } catch ( NamingException e ) { throw new DnsLookupException ( "DNS lookup failed for service " + serviceType + " at " + domain , e ) ; } // remove the " . " at the end
if ( result . endsWith ( "." ) ) { result = result . substring ( 0 , result . length ( ) - 1 ) ; } return result ;


signature:
public class AuthenticationSimpleHttpInvokerRequestExecutor { /** * Called every time a HTTP invocation is made .
 * Simply allows the parent to setup the connection , and then adds an
 * < code > Authorization < / code > HTTP header property that will be used for BASIC
 * authentication .
 * The < code > SecurityContextHolder < / code > is used to obtain the relevant principal and
 * credentials .
 * @ param con the HTTP connection to prepare
 * @ param contentLength the length of the content to send
 * @ throws IOException if thrown by HttpURLConnection methods */
protected void prepareConnection ( HttpURLConnection con , int contentLength ) throws IOException { } }

implementation: super . prepareConnection ( con , contentLength ) ; Authentication auth = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( ( auth != null ) && ( auth . getName ( ) != null ) && ( auth . getCredentials ( ) != null ) && ! trustResolver . isAnonymous ( auth ) ) { String base64 = auth . getName ( ) + ":" + auth . getCredentials ( ) . toString ( ) ; con . setRequestProperty ( "Authorization" , "Basic " + new String ( Base64 . getEncoder ( ) . encode ( base64 . getBytes ( ) ) ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "HttpInvocation now presenting via BASIC authentication SecurityContextHolder-derived: " + auth . toString ( ) ) ; } } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Unable to set BASIC authentication header as SecurityContext did not provide " + "valid Authentication: " + auth ) ; } } doPrepareConnection ( con , contentLength ) ;


signature:
public class ReactiveSecurityContextHolder { /** * Gets the { @ code Mono < SecurityContext > } from Reactor { @ link Context }
 * @ return the { @ code Mono < SecurityContext > } */
public static Mono < SecurityContext > getContext ( ) { } }

implementation: return Mono . subscriberContext ( ) . filter ( c -> c . hasKey ( SECURITY_CONTEXT_KEY ) ) . flatMap ( c -> c . < Mono < SecurityContext > > get ( SECURITY_CONTEXT_KEY ) ) ;


signature:
public class AutowireBeanFactoryObjectPostProcessor { /** * ( non - Javadoc )
 * @ see
 * org . springframework . security . config . annotation . web . Initializer # initialize ( java .
 * lang . Object ) */
@ SuppressWarnings ( "unchecked" ) public < T > T postProcess ( T object ) { } }

implementation: if ( object == null ) { return null ; } T result = null ; try { result = ( T ) this . autowireBeanFactory . initializeBean ( object , object . toString ( ) ) ; } catch ( RuntimeException e ) { Class < ? > type = object . getClass ( ) ; throw new RuntimeException ( "Could not postProcess " + object + " of type " + type , e ) ; } this . autowireBeanFactory . autowireBean ( object ) ; if ( result instanceof DisposableBean ) { this . disposableBeans . add ( ( DisposableBean ) result ) ; } if ( result instanceof SmartInitializingSingleton ) { this . smartSingletons . add ( ( SmartInitializingSingleton ) result ) ; } return result ;


signature:
public class AutowireBeanFactoryObjectPostProcessor { /** * ( non - Javadoc )
 * @ see org . springframework . beans . factory . DisposableBean # destroy ( ) */
public void destroy ( ) throws Exception { } }

implementation: for ( DisposableBean disposable : this . disposableBeans ) { try { disposable . destroy ( ) ; } catch ( Exception error ) { this . logger . error ( error ) ; } }


signature: public class UserAttributeEditor { public void setAsText ( String s ) throws IllegalArgumentException { } }

implementation: if ( StringUtils . hasText ( s ) ) { String [ ] tokens = StringUtils . commaDelimitedListToStringArray ( s ) ; UserAttribute userAttrib = new UserAttribute ( ) ; List < String > authoritiesAsStrings = new ArrayList < > ( ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { String currentToken = tokens [ i ] . trim ( ) ; if ( i == 0 ) { userAttrib . setPassword ( currentToken ) ; } else { if ( currentToken . toLowerCase ( ) . equals ( "enabled" ) ) { userAttrib . setEnabled ( true ) ; } else if ( currentToken . toLowerCase ( ) . equals ( "disabled" ) ) { userAttrib . setEnabled ( false ) ; } else { authoritiesAsStrings . add ( currentToken ) ; } } } userAttrib . setAuthoritiesAsString ( authoritiesAsStrings ) ; if ( userAttrib . isValid ( ) ) { setValue ( userAttrib ) ; } else { setValue ( null ) ; } } else { setValue ( null ) ; }


signature:
public class OidcUserService { /** * Sets the { @ link OAuth2UserService } used when requesting the user info resource .
 * @ since 5.1
 * @ param oauth2UserService the { @ link OAuth2UserService } used when requesting the user info resource . */
public final void setOauth2UserService ( OAuth2UserService < OAuth2UserRequest , OAuth2User > oauth2UserService ) { } }

implementation: Assert . notNull ( oauth2UserService , "oauth2UserService cannot be null" ) ; this . oauth2UserService = oauth2UserService ;


signature:
public class FastHttpDateFormat { /** * Formats a specified date to HTTP format . If local format is not < code > null < / code > ,
 * it ' s used instead .
 * @ param value Date value to format
 * @ param threadLocalformat The format to use ( or < code > null < / code > - - then HTTP
 * format will be used )
 * @ return Formatted date */
public static String formatDate ( long value , DateFormat threadLocalformat ) { } }

implementation: String cachedDate = null ; Long longValue = Long . valueOf ( value ) ; try { cachedDate = formatCache . get ( longValue ) ; } catch ( Exception ignored ) { } if ( cachedDate != null ) { return cachedDate ; } String newDate ; Date dateValue = new Date ( value ) ; if ( threadLocalformat != null ) { newDate = threadLocalformat . format ( dateValue ) ; synchronized ( formatCache ) { updateCache ( formatCache , longValue , newDate ) ; } } else { synchronized ( formatCache ) { newDate = format . format ( dateValue ) ; updateCache ( formatCache , longValue , newDate ) ; } } return newDate ;


signature:
public class FastHttpDateFormat { /** * Gets the current date in HTTP format .
 * @ return Current date in HTTP format */
public static String getCurrentDate ( ) { } }

implementation: long now = System . currentTimeMillis ( ) ; if ( ( now - currentDateGenerated ) > 1000 ) { synchronized ( format ) { if ( ( now - currentDateGenerated ) > 1000 ) { currentDateGenerated = now ; currentDate = format . format ( new Date ( now ) ) ; } } } return currentDate ;


signature:
public class FastHttpDateFormat { /** * Parses date with given formatters .
 * @ param value The string to parse
 * @ param formats Array of formats to use
 * @ return Parsed date ( or < code > null < / code > if no formatter mached ) */
private static Long internalParseDate ( String value , DateFormat [ ] formats ) { } }

implementation: Date date = null ; for ( int i = 0 ; ( date == null ) && ( i < formats . length ) ; i ++ ) { try { date = formats [ i ] . parse ( value ) ; } catch ( ParseException ignored ) { } } if ( date == null ) { return null ; } return new Long ( date . getTime ( ) ) ;


signature:
public class FastHttpDateFormat { /** * Tries to parse the given date as an HTTP date . If local format list is not
 * < code > null < / code > , it ' s used instead .
 * @ param value The string to parse
 * @ param threadLocalformats Array of formats to use for parsing . If < code > null < / code >
 * , HTTP formats are used .
 * @ return Parsed date ( or - 1 if error occurred ) */
public static long parseDate ( String value , DateFormat [ ] threadLocalformats ) { } }

implementation: Long cachedDate = null ; try { cachedDate = ( Long ) parseCache . get ( value ) ; } catch ( Exception ignored ) { } if ( cachedDate != null ) { return cachedDate . longValue ( ) ; } Long date ; if ( threadLocalformats != null ) { date = internalParseDate ( value , threadLocalformats ) ; synchronized ( parseCache ) { updateCache ( parseCache , value , date ) ; } } else { synchronized ( parseCache ) { date = internalParseDate ( value , formats ) ; updateCache ( parseCache , value , date ) ; } } if ( date == null ) { return ( - 1L ) ; } else { return date . longValue ( ) ; }


signature:
public class FastHttpDateFormat { /** * Updates cache .
 * @ param cache Cache to be updated
 * @ param key Key to be updated
 * @ param value New value */
@ SuppressWarnings ( "unchecked" ) private static void updateCache ( HashMap cache , Object key , Object value ) { } }

implementation: if ( value == null ) { return ; } if ( cache . size ( ) > 1000 ) { cache . clear ( ) ; } cache . put ( key , value ) ;


signature:
public class MethodInvocationUtils { /** * Generates a < code > MethodInvocation < / code > for specified < code > methodName < / code > on
 * the passed object , using the < code > args < / code > to locate the method .
 * @ param object the object that will be used to find the relevant < code > Method < / code >
 * @ param methodName the name of the method to find
 * @ param args arguments that are required as part of the method signature ( can be
 * empty )
 * @ return a < code > MethodInvocation < / code > , or < code > null < / code > if there was a
 * problem */
public static MethodInvocation create ( Object object , String methodName , Object ... args ) { } }

implementation:
Assert . notNull ( object , "Object required" ) ; Class < ? > [ ] classArgs = null ; if ( args != null ) { classArgs = new Class < ? > [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { classArgs [ i ] = args [ i ] . getClass ( ) ; } } // Determine the type that declares the requested method , taking into account
// proxies
Class < ? > target = AopUtils . getTargetClass ( object ) ; if ( object instanceof Advised ) { Advised a = ( Advised ) object ; if ( ! a . isProxyTargetClass ( ) ) { Class < ? > [ ] possibleInterfaces = a . getProxiedInterfaces ( ) ; for ( Class < ? > possibleInterface : possibleInterfaces ) { try { possibleInterface . getMethod ( methodName , classArgs ) ; // to get here means no exception happened
target = possibleInterface ; break ; } catch ( Exception ignored ) { // try the next one
} } } } return createFromClass ( object , target , methodName , classArgs , args ) ;


signature:
public class MethodInvocationUtils { /** * Generates a < code > MethodInvocation < / code > for the specified < code > methodName < / code >
 * on the passed class .
 * If a method with this name , taking no arguments does not exist , it will check
 * through the declared methods on the class , until one is found matching the supplied
 * name . If more than one method name matches , an < tt > IllegalArgumentException < / tt >
 * will be raised .
 * @ param clazz the class of object that will be used to find the relevant
 * < code > Method < / code >
 * @ param methodName the name of the method to find
 * @ return a < code > MethodInvocation < / code > , or < code > null < / code > if there was a
 * problem */
public static MethodInvocation createFromClass ( Class < ? > clazz , String methodName ) { } }

implementation: MethodInvocation mi = createFromClass ( null , clazz , methodName , null , null ) ; if ( mi == null ) { for ( Method m : clazz . getDeclaredMethods ( ) ) { if ( m . getName ( ) . equals ( methodName ) ) { if ( mi != null ) { throw new IllegalArgumentException ( "The class " + clazz + " has more than one method named" + " '" + methodName + "'" ) ; } mi = new SimpleMethodInvocation ( null , m ) ; } } } return mi ;


signature:
public class MethodInvocationUtils { /** * Generates a < code > MethodInvocation < / code > for specified < code > methodName < / code > on
 * the passed class , using the < code > args < / code > to locate the method .
 * @ param targetObject the object being invoked
 * @ param clazz the class of object that will be used to find the relevant
 * < code > Method < / code >
 * @ param methodName the name of the method to find
 * @ param classArgs arguments that are required to locate the relevant method
 * signature
 * @ param args the actual arguments that should be passed to SimpleMethodInvocation
 * @ return a < code > MethodInvocation < / code > , or < code > null < / code > if there was a
 * problem */
public static MethodInvocation createFromClass ( Object targetObject , Class < ? > clazz , String methodName , Class < ? > [ ] classArgs , Object [ ] args ) { } }

implementation: Assert . notNull ( clazz , "Class required" ) ; Assert . hasText ( methodName , "MethodName required" ) ; Method method ; try { method = clazz . getMethod ( methodName , classArgs ) ; } catch ( NoSuchMethodException e ) { return null ; } return new SimpleMethodInvocation ( targetObject , method , args ) ;


signature: public class UsernamePasswordAuthenticationFilter { public Authentication attemptAuthentication ( HttpServletRequest request , HttpServletResponse response ) throws AuthenticationException { } }

implementation:
if ( postOnly && ! request . getMethod ( ) . equals ( "POST" ) ) { throw new AuthenticationServiceException ( "Authentication method not supported: " + request . getMethod ( ) ) ; } String username = obtainUsername ( request ) ; String password = obtainPassword ( request ) ; if ( username == null ) { username = "" ; } if ( password == null ) { password = "" ; } username = username . trim ( ) ; UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken ( username , password ) ; // Allow subclasses to set the " details " property
setDetails ( request , authRequest ) ; return this . getAuthenticationManager ( ) . authenticate ( authRequest ) ;


signature:
public class UsernamePasswordAuthenticationFilter { /** * Provided so that subclasses may configure what is put into the authentication
 * request ' s details property .
 * @ param request that an authentication request is being created for
 * @ param authRequest the authentication request object that should have its details
 * set */
protected void setDetails ( HttpServletRequest request , UsernamePasswordAuthenticationToken authRequest ) { } }

implementation: authRequest . setDetails ( authenticationDetailsSource . buildDetails ( request ) ) ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * Maps a { @ link List } of { @ link SimpDestinationMessageMatcher } instances .
 * @ param typesToMatch the { @ link SimpMessageType } instance to match on
 * @ return the { @ link Constraint } associated to the matchers . */
public Constraint simpTypeMatchers ( SimpMessageType ... typesToMatch ) { } }

implementation: MessageMatcher < ? > [ ] typeMatchers = new MessageMatcher < ? > [ typesToMatch . length ] ; for ( int i = 0 ; i < typesToMatch . length ; i ++ ) { SimpMessageType typeToMatch = typesToMatch [ i ] ; typeMatchers [ i ] = new SimpMessageTypeMatcher ( typeToMatch ) ; } return matchers ( typeMatchers ) ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * Maps a { @ link List } of { @ link SimpDestinationMessageMatcher } instances . If no
 * destination is found on the Message , then the Matcher returns false .
 * @ param type the { @ link SimpMessageType } to match on . If null , the
 * { @ link SimpMessageType } is not considered for matching .
 * @ param patterns the patterns to create
 * { @ link org . springframework . security . messaging . util . matcher . SimpDestinationMessageMatcher }
 * from . Uses
 * { @ link MessageSecurityMetadataSourceRegistry # simpDestPathMatcher ( PathMatcher ) } .
 * @ return the { @ link Constraint } that is associated to the { @ link MessageMatcher }
 * @ see { @ link MessageSecurityMetadataSourceRegistry # simpDestPathMatcher ( PathMatcher ) } */
private Constraint simpDestMatchers ( SimpMessageType type , String ... patterns ) { } }

implementation: List < MatcherBuilder > matchers = new ArrayList < > ( patterns . length ) ; for ( String pattern : patterns ) { matchers . add ( new PathMatcherMessageMatcherBuilder ( pattern , type ) ) ; } return new Constraint ( matchers ) ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * The { @ link PathMatcher } to be used with the
 * { @ link MessageSecurityMetadataSourceRegistry # simpDestMatchers ( String . . . ) } . The
 * default is to use the default constructor of { @ link AntPathMatcher } .
 * @ param pathMatcher the { @ link PathMatcher } to use . Cannot be null .
 * @ return the { @ link MessageSecurityMetadataSourceRegistry } for further
 * customization . */
public MessageSecurityMetadataSourceRegistry simpDestPathMatcher ( PathMatcher pathMatcher ) { } }

implementation: Assert . notNull ( pathMatcher , "pathMatcher cannot be null" ) ; this . pathMatcher . setPathMatcher ( pathMatcher ) ; this . defaultPathMatcher = false ; return this ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * Maps a { @ link List } of { @ link MessageMatcher } instances to a security expression .
 * @ param matchers the { @ link MessageMatcher } instances to map .
 * @ return The { @ link Constraint } that is associated to the { @ link MessageMatcher }
 * instances */
public Constraint matchers ( MessageMatcher < ? > ... matchers ) { } }

implementation: List < MatcherBuilder > builders = new ArrayList < > ( matchers . length ) ; for ( MessageMatcher < ? > matcher : matchers ) { builders . add ( new PreBuiltMatcherBuilder ( matcher ) ) ; } return new Constraint ( builders ) ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * The { @ link SecurityExpressionHandler } to be used . The
 * default is to use { @ link DefaultMessageSecurityExpressionHandler } .
 * @ param expressionHandler the { @ link SecurityExpressionHandler } to use . Cannot be null .
 * @ return the { @ link MessageSecurityMetadataSourceRegistry } for further
 * customization . */
public MessageSecurityMetadataSourceRegistry expressionHandler ( SecurityExpressionHandler < Message < Object > > expressionHandler ) { } }

implementation: Assert . notNull ( expressionHandler , "expressionHandler cannot be null" ) ; this . expressionHandler = expressionHandler ; return this ;


signature:
public class MessageSecurityMetadataSourceRegistry { /** * Allows subclasses to create creating a { @ link MessageSecurityMetadataSource } .
 * This is not exposed so as not to confuse users of the API , which should never
 * invoke this method .
 * @ return the { @ link MessageSecurityMetadataSource } to use */
protected MessageSecurityMetadataSource createMetadataSource ( ) { } }

implementation: LinkedHashMap < MessageMatcher < ? > , String > matcherToExpression = new LinkedHashMap < MessageMatcher < ? > , String > ( ) ; for ( Map . Entry < MatcherBuilder , String > entry : this . matcherToExpression . entrySet ( ) ) { matcherToExpression . put ( entry . getKey ( ) . build ( ) , entry . getValue ( ) ) ; } return ExpressionBasedMessageSecurityMetadataSourceFactory . createExpressionMessageMetadataSource ( matcherToExpression , expressionHandler ) ;


signature:
public class AbstractUserDetailsAuthenticationProvider { /** * Creates a successful { @ link Authentication } object .
 * Protected so subclasses can override .
 * Subclasses will usually store the original credentials the user supplied ( not
 * salted or encoded passwords ) in the returned < code > Authentication < / code > object .
 * @ param principal that should be the principal in the returned object ( defined by
 * the { @ link # isForcePrincipalAsString ( ) } method )
 * @ param authentication that was presented to the provider for validation
 * @ param user that was loaded by the implementation
 * @ return the successful authentication token */
protected Authentication createSuccessAuthentication ( Object principal , Authentication authentication , UserDetails user ) { } }

implementation:
// Ensure we return the original credentials the user supplied ,
// so subsequent attempts are successful even with encoded passwords .
// Also ensure we return the original getDetails ( ) , so that future
// authentication events after cache expiry contain the details
UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken ( principal , authentication . getCredentials ( ) , authoritiesMapper . mapAuthorities ( user . getAuthorities ( ) ) ) ; result . setDetails ( authentication . getDetails ( ) ) ; return result ;


signature:
public class HttpBasicConfigurer { /** * Allows easily changing the realm , but leaving the remaining defaults in place . If
 * { @ link # authenticationEntryPoint ( AuthenticationEntryPoint ) } has been invoked ,
 * invoking this method will result in an error .
 * @ param realmName the HTTP Basic realm to use
 * @ return { @ link HttpBasicConfigurer } for additional customization
 * @ throws Exception */
public HttpBasicConfigurer < B > realmName ( String realmName ) throws Exception { } }

implementation: this . basicAuthEntryPoint . setRealmName ( realmName ) ; this . basicAuthEntryPoint . afterPropertiesSet ( ) ; return this ;


signature:
public class JdbcUserDetailsManagerConfigurer { /** * Populates the { @ link DataSource } to be used . This is the only required attribute .
 * @ param dataSource the { @ link DataSource } to be used . Cannot be null .
 * @ return The { @ link JdbcUserDetailsManagerConfigurer } used for additional customizations
 * @ throws Exception */
public JdbcUserDetailsManagerConfigurer < B > dataSource ( DataSource dataSource ) throws Exception { } }

implementation: this . dataSource = dataSource ; getUserDetailsService ( ) . setDataSource ( dataSource ) ; return this ;


signature:
public class JdbcUserDetailsManagerConfigurer { /** * An SQL statement to query user ' s group authorities given a username . For example :
 * < code >
 * select
 * g . id , g . group _ name , ga . authority
 * from
 * groups g , group _ members gm , group _ authorities ga
 * where
 * gm . username = ? and g . id = ga . group _ id and g . id = gm . group _ id
 * < / code >
 * @ param query The query to use for selecting the authorities by group . Must contain
 * a single parameter for the username .
 * @ return The { @ link JdbcUserDetailsManagerConfigurer } used for additional
 * customizations
 * @ throws Exception */
public JdbcUserDetailsManagerConfigurer < B > groupAuthoritiesByUsername ( String query ) throws Exception { } }

implementation: JdbcUserDetailsManager userDetailsService = getUserDetailsService ( ) ; userDetailsService . setEnableGroups ( true ) ; userDetailsService . setGroupAuthoritiesByUsernameQuery ( query ) ; return this ;


signature:
public class ApacheDSContainer { /** * The keyStore must not be null and must be a valid file . Will set the keyStore file on the underlying { @ link LdapServer } .
 * @ param keyStoreFile Mandatory if LDAPs is enabled */
public void setKeyStoreFile ( File keyStoreFile ) { } }

implementation: Assert . notNull ( keyStoreFile , "The keyStoreFile must not be null." ) ; Assert . isTrue ( keyStoreFile . isFile ( ) , "The keyStoreFile must be a file." ) ; this . keyStoreFile = keyStoreFile ;


signature: public class DaoAuthenticationProvider { @ SuppressWarnings ( "deprecation" ) protected void additionalAuthenticationChecks ( UserDetails userDetails , UsernamePasswordAuthenticationToken authentication ) throws AuthenticationException { } }

implementation: if ( authentication . getCredentials ( ) == null ) { logger . debug ( "Authentication failed: no credentials provided" ) ; throw new BadCredentialsException ( messages . getMessage ( "AbstractUserDetailsAuthenticationProvider.badCredentials" , "Bad credentials" ) ) ; } String presentedPassword = authentication . getCredentials ( ) . toString ( ) ; if ( ! passwordEncoder . matches ( presentedPassword , userDetails . getPassword ( ) ) ) { logger . debug ( "Authentication failed: password does not match stored value" ) ; throw new BadCredentialsException ( messages . getMessage ( "AbstractUserDetailsAuthenticationProvider.badCredentials" , "Bad credentials" ) ) ; }


signature:
public class DaoAuthenticationProvider { /** * Sets the PasswordEncoder instance to be used to encode and validate passwords . If
 * not set , the password will be compared using { @ link PasswordEncoderFactories # createDelegatingPasswordEncoder ( ) }
 * @ param passwordEncoder must be an instance of one of the { @ code PasswordEncoder }
 * types . */
public void setPasswordEncoder ( PasswordEncoder passwordEncoder ) { } }

implementation: Assert . notNull ( passwordEncoder , "passwordEncoder cannot be null" ) ; this . passwordEncoder = passwordEncoder ; this . userNotFoundEncodedPassword = null ;


signature:
public class SecurityContextLoginModule { /** * Authenticate the < code > Subject < / code > ( phase two ) by adding the Spring Security
 * < code > Authentication < / code > to the < code > Subject < / code > ' s principals .
 * @ return true if this method succeeded , or false if this < code > LoginModule < / code >
 * should be ignored .
 * @ exception LoginException if the commit fails */
public boolean commit ( ) throws LoginException { } }

implementation: if ( authen == null ) { return false ; } subject . getPrincipals ( ) . add ( authen ) ; return true ;


signature:
public class SecurityContextLoginModule { /** * Initialize this < code > LoginModule < / code > . Ignores the callback handler , since the
 * code establishing the < code > LoginContext < / code > likely won ' t provide one that
 * understands Spring Security . Also ignores the < code > sharedState < / code > and
 * < code > options < / code > parameters , since none are recognized .
 * @ param subject the < code > Subject < / code > to be authenticated .
 * @ param callbackHandler is ignored
 * @ param sharedState is ignored
 * @ param options are ignored */
@ SuppressWarnings ( "unchecked" ) public void initialize ( Subject subject , CallbackHandler callbackHandler , Map sharedState , Map options ) { } }

implementation: this . subject = subject ; if ( options != null ) { ignoreMissingAuthentication = "true" . equals ( options . get ( "ignoreMissingAuthentication" ) ) ; }


signature:
public class SecurityContextLoginModule { /** * Authenticate the < code > Subject < / code > ( phase one ) by extracting the Spring Security
 * < code > Authentication < / code > from the current < code > SecurityContext < / code > .
 * @ return true if the authentication succeeded , or false if this
 * < code > LoginModule < / code > should be ignored .
 * @ throws LoginException if the authentication fails */
public boolean login ( ) throws LoginException { } }

implementation: authen = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authen == null ) { String msg = "Login cannot complete, authentication not found in security context" ; if ( ignoreMissingAuthentication ) { log . warn ( msg ) ; return false ; } else { throw new LoginException ( msg ) ; } } return true ;


signature:
public class SecurityContextLoginModule { /** * Log out the < code > Subject < / code > .
 * @ return true if this method succeeded , or false if this < code > LoginModule < / code >
 * should be ignored .
 * @ exception LoginException if the logout fails */
public boolean logout ( ) throws LoginException { } }

implementation: if ( authen == null ) { return false ; } subject . getPrincipals ( ) . remove ( authen ) ; authen = null ; return true ;


signature:
public class UserDetailsManagerResourceFactoryBean { /** * Create a UserDetailsManagerResourceFactoryBean with the location of a Resource that is a Properties file in the
 * format defined in { @ link UserDetailsResourceFactoryBean } .
 * @ param resourceLocation the location of the properties file that contains the users ( i . e . " classpath : users . properties " )
 * @ return the UserDetailsManagerResourceFactoryBean */
public static UserDetailsManagerResourceFactoryBean fromResourceLocation ( String resourceLocation ) { } }

implementation: UserDetailsManagerResourceFactoryBean result = new UserDetailsManagerResourceFactoryBean ( ) ; result . setResourceLocation ( resourceLocation ) ; return result ;


signature:
public class UserDetailsManagerResourceFactoryBean { /** * Create a UserDetailsManagerResourceFactoryBean with a Resource that is a Properties file in the
 * format defined in { @ link UserDetailsResourceFactoryBean } .
 * @ param resource the Resource that is a properties file that contains the users
 * @ return the UserDetailsManagerResourceFactoryBean */
public static UserDetailsManagerResourceFactoryBean fromResource ( Resource resource ) { } }

implementation: UserDetailsManagerResourceFactoryBean result = new UserDetailsManagerResourceFactoryBean ( ) ; result . setResource ( resource ) ; return result ;


signature:
public class UserDetailsManagerResourceFactoryBean { /** * Create a UserDetailsManagerResourceFactoryBean with a String that is in the
 * format defined in { @ link UserDetailsResourceFactoryBean } .
 * @ param users the users in the format defined in { @ link UserDetailsResourceFactoryBean }
 * @ return the UserDetailsManagerResourceFactoryBean */
public static UserDetailsManagerResourceFactoryBean fromString ( String users ) { } }

implementation: UserDetailsManagerResourceFactoryBean result = new UserDetailsManagerResourceFactoryBean ( ) ; result . setResource ( new InMemoryResource ( users ) ) ; return result ;


signature: public class AclImpl { @ Override public void deleteAce ( int aceIndex ) throws NotFoundException { } }

implementation: aclAuthorizationStrategy . securityCheck ( this , AclAuthorizationStrategy . CHANGE_GENERAL ) ; verifyAceIndexExists ( aceIndex ) ; synchronized ( aces ) { this . aces . remove ( aceIndex ) ; }


signature:
public class AclImpl { /** * Delegates to the { @ link PermissionGrantingStrategy } .
 * @ throws UnloadedSidException if the passed SIDs are unknown to this ACL because the
 * ACL was only loaded for a subset of SIDs
 * @ see DefaultPermissionGrantingStrategy */
@ Override public boolean isGranted ( List < Permission > permission , List < Sid > sids , boolean administrativeMode ) throws NotFoundException , UnloadedSidException { } }

implementation: Assert . notEmpty ( permission , "Permissions required" ) ; Assert . notEmpty ( sids , "SIDs required" ) ; if ( ! this . isSidLoaded ( sids ) ) { throw new UnloadedSidException ( "ACL was not loaded for one or more SID" ) ; } return permissionGrantingStrategy . isGranted ( this , permission , sids , administrativeMode ) ;


signature:
public class PrePostAnnotationSecurityMetadataSource { /** * See
 * { @ link org . springframework . security . access . method . AbstractFallbackMethodSecurityMetadataSource # getAttributes ( Method , Class ) }
 * for the logic of this method . The ordering here is slightly different in that we
 * consider method - specific annotations on an interface before class - level ones . */
private < A extends Annotation > A findAnnotation ( Method method , Class < ? > targetClass , Class < A > annotationClass ) { } }

implementation:
// The method may be on an interface , but we need attributes from the target
// class .
// If the target class is null , the method will be unchanged .
Method specificMethod = ClassUtils . getMostSpecificMethod ( method , targetClass ) ; A annotation = AnnotationUtils . findAnnotation ( specificMethod , annotationClass ) ; if ( annotation != null ) { logger . debug ( annotation + " found on specific method: " + specificMethod ) ; return annotation ; } // Check the original ( e . g . interface ) method
if ( specificMethod != method ) { annotation = AnnotationUtils . findAnnotation ( method , annotationClass ) ; if ( annotation != null ) { logger . debug ( annotation + " found on: " + method ) ; return annotation ; } } // Check the class - level ( note declaringClass , not targetClass , which may not
// actually implement the method )
annotation = AnnotationUtils . findAnnotation ( specificMethod . getDeclaringClass ( ) , annotationClass ) ; if ( annotation != null ) { logger . debug ( annotation + " found on: " + specificMethod . getDeclaringClass ( ) . getName ( ) ) ; return annotation ; } return null ;


signature:
public class DefaultWASUsernameAndGroupsExtractor { /** * Get the security name for the given subject .
 * @ param subject The subject for which to retrieve the security name
 * @ return String the security name for the given subject */
private static String getSecurityName ( final Subject subject ) { } }

implementation:
if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Determining Websphere security name for subject " + subject ) ; } String userSecurityName = null ; if ( subject != null ) { // SEC - 803
Object credential = subject . getPublicCredentials ( getWSCredentialClass ( ) ) . iterator ( ) . next ( ) ; if ( credential != null ) { userSecurityName = ( String ) invokeMethod ( getSecurityNameMethod ( ) , credential ) ; } } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Websphere security name is " + userSecurityName + " for subject " + subject ) ; } return userSecurityName ;


signature:
public class DefaultWASUsernameAndGroupsExtractor { /** * Get the WebSphere group names for the given security name .
 * @ param securityName The security name for which to retrieve the WebSphere group
 * names
 * @ return the WebSphere group names for the given security name */
@ SuppressWarnings ( "unchecked" ) private static List < String > getWebSphereGroups ( final String securityName ) { } }

implementation:
Context ic = null ; try { // TODO : Cache UserRegistry object
ic = new InitialContext ( ) ; Object objRef = ic . lookup ( USER_REGISTRY ) ; Object userReg = invokeMethod ( getNarrowMethod ( ) , null , objRef , Class . forName ( "com.ibm.websphere.security.UserRegistry" ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Determining WebSphere groups for user " + securityName + " using WebSphere UserRegistry " + userReg ) ; } final Collection groups = ( Collection ) invokeMethod ( getGroupsForUserMethod ( ) , userReg , new Object [ ] { securityName } ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Groups for user " + securityName + ": " + groups . toString ( ) ) ; } return new ArrayList ( groups ) ; } catch ( Exception e ) { logger . error ( "Exception occured while looking up groups for user" , e ) ; throw new RuntimeException ( "Exception occured while looking up groups for user" , e ) ; } finally { try { if ( ic != null ) { ic . close ( ) ; } } catch ( NamingException e ) { logger . debug ( "Exception occured while closing context" , e ) ; } }


signature:
public class LdapUserDetailsManager { /** * Changes the password for the current user . The username is obtained from the
 * security context .
 * There are two supported strategies for modifying the user ' s password depending on
 * the capabilities of the corresponding LDAP server .
 * Configured one way , this method will modify the user ' s password via the
 * < a target = " _ blank " href = " https : / / tools . ietf . org / html / rfc3062 " >
 * LDAP Password Modify Extended Operation
 * See { @ link LdapUserDetailsManager # setUsePasswordModifyExtensionOperation ( boolean ) } for details .
 * By default , though , if the old password is supplied , the update will be made by rebinding as the user ,
 * thus modifying the password using the user ' s permissions . If
 * < code > oldPassword < / code > is null , the update will be attempted using a standard
 * read / write context supplied by the context source .
 * @ param oldPassword the old password
 * @ param newPassword the new value of the password . */
public void changePassword ( final String oldPassword , final String newPassword ) { } }

implementation: Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; Assert . notNull ( authentication , "No authentication object found in security context. Can't change current user's password!" ) ; String username = authentication . getName ( ) ; logger . debug ( "Changing password for user '" + username ) ; DistinguishedName userDn = usernameMapper . buildDn ( username ) ; if ( usePasswordModifyExtensionOperation ) { changePasswordUsingExtensionOperation ( userDn , oldPassword , newPassword ) ; } else { changePasswordUsingAttributeModification ( userDn , oldPassword , newPassword ) ; }


signature:
public class LdapUserDetailsManager { /** * Creates a DN from a group name .
 * @ param group the name of the group
 * @ return the DN of the corresponding group , including the groupSearchBase */
protected DistinguishedName buildGroupDn ( String group ) { } }

implementation: DistinguishedName dn = new DistinguishedName ( groupSearchBase ) ; dn . add ( groupRoleAttributeName , group . toLowerCase ( ) ) ; return dn ;


signature:
public class LdapUserDetailsManager { /** * Sets the name of the multi - valued attribute which holds the DNs of users who are
 * members of a group .
 * Usually this will be < tt > uniquemember < / tt > ( the default value ) or < tt > member < / tt > .
 * @ param groupMemberAttributeName the name of the attribute used to store group
 * members . */
public void setGroupMemberAttributeName ( String groupMemberAttributeName ) { } }

implementation: Assert . hasText ( groupMemberAttributeName , "groupMemberAttributeName should have text" ) ; this . groupMemberAttributeName = groupMemberAttributeName ; this . groupSearchFilter = "(" + groupMemberAttributeName + "={0})" ;


signature: public class JdbcAclService { public List < ObjectIdentity > findChildren ( ObjectIdentity parentIdentity ) { } }

implementation: Object [ ] args = { parentIdentity . getIdentifier ( ) . toString ( ) , parentIdentity . getType ( ) } ; List < ObjectIdentity > objects = jdbcOperations . query ( findChildrenSql , args , new RowMapper < ObjectIdentity > ( ) { public ObjectIdentity mapRow ( ResultSet rs , int rowNum ) throws SQLException { String javaType = rs . getString ( "class" ) ; Serializable identifier = ( Serializable ) rs . getObject ( "obj_id" ) ; identifier = aclClassIdUtils . identifierFrom ( identifier , rs ) ; return new ObjectIdentityImpl ( javaType , identifier ) ; } } ) ; if ( objects . size ( ) == 0 ) { return null ; } return objects ;


signature: public class AclEntryAfterInvocationProvider { public Object decide ( Authentication authentication , Object object , Collection < ConfigAttribute > config , Object returnedObject ) throws AccessDeniedException { } }

implementation:
if ( returnedObject == null ) { // AclManager interface contract prohibits nulls
// As they have permission to null / nothing , grant access
logger . debug ( "Return object is null, skipping" ) ; return null ; } if ( ! getProcessDomainObjectClass ( ) . isAssignableFrom ( returnedObject . getClass ( ) ) ) { logger . debug ( "Return object is not applicable for this provider, skipping" ) ; return returnedObject ; } for ( ConfigAttribute attr : config ) { if ( ! this . supports ( attr ) ) { continue ; } // Need to make an access decision on this invocation
if ( hasPermission ( authentication , returnedObject ) ) { return returnedObject ; } logger . debug ( "Denying access" ) ; throw new AccessDeniedException ( messages . getMessage ( "AclEntryAfterInvocationProvider.noPermission" , new Object [ ] { authentication . getName ( ) , returnedObject } , "Authentication {0} has NO permissions to the domain object {1}" ) ) ; } return returnedObject ;


signature:
public class ConcurrentSessionControlAuthenticationStrategy { /** * In addition to the steps from the superclass , the sessionRegistry will be updated
 * with the new session information . */
public void onAuthentication ( Authentication authentication , HttpServletRequest request , HttpServletResponse response ) { } }

implementation:
final List < SessionInformation > sessions = sessionRegistry . getAllSessions ( authentication . getPrincipal ( ) , false ) ; int sessionCount = sessions . size ( ) ; int allowedSessions = getMaximumSessionsForThisUser ( authentication ) ; if ( sessionCount < allowedSessions ) { // They haven ' t got too many login sessions running at present
return ; } if ( allowedSessions == - 1 ) { // We permit unlimited logins
return ; } if ( sessionCount == allowedSessions ) { HttpSession session = request . getSession ( false ) ; if ( session != null ) { // Only permit it though if this request is associated with one of the
// already registered sessions
for ( SessionInformation si : sessions ) { if ( si . getSessionId ( ) . equals ( session . getId ( ) ) ) { return ; } } } // If the session is null , a new one will be created by the parent class ,
// exceeding the allowed number
} allowableSessionsExceeded ( sessions , allowedSessions , sessionRegistry ) ;


signature:
public class ConcurrentSessionControlAuthenticationStrategy { /** * Allows subclasses to customise behaviour when too many sessions are detected .
 * @ param sessions either < code > null < / code > or all unexpired sessions associated with
 * the principal
 * @ param allowableSessions the number of concurrent sessions the user is allowed to
 * have
 * @ param registry an instance of the < code > SessionRegistry < / code > for subclass use */
protected void allowableSessionsExceeded ( List < SessionInformation > sessions , int allowableSessions , SessionRegistry registry ) throws SessionAuthenticationException { } }

implementation:
if ( exceptionIfMaximumExceeded || ( sessions == null ) ) { throw new SessionAuthenticationException ( messages . getMessage ( "ConcurrentSessionControlAuthenticationStrategy.exceededAllowed" , new Object [ ] { Integer . valueOf ( allowableSessions ) } , "Maximum sessions of {0} for this principal exceeded" ) ) ; } // Determine least recently used session , and mark it for invalidation
SessionInformation leastRecentlyUsed = null ; for ( SessionInformation session : sessions ) { if ( ( leastRecentlyUsed == null ) || session . getLastRequest ( ) . before ( leastRecentlyUsed . getLastRequest ( ) ) ) { leastRecentlyUsed = session ; } } leastRecentlyUsed . expireNow ( ) ;


signature:
public class BearerTokenAuthenticationEntryPoint { /** * Collect error details from the provided parameters and format according to
 * RFC 6750 , specifically { @ code error } , { @ code error _ description } , { @ code error _ uri } , and { @ scope scope } .
 * @ param request that resulted in an < code > AuthenticationException < / code >
 * @ param response so that the user agent can begin authentication
 * @ param authException that caused the invocation */
@ Override public void commence ( HttpServletRequest request , HttpServletResponse response , AuthenticationException authException ) throws IOException , ServletException { } }

implementation: HttpStatus status = HttpStatus . UNAUTHORIZED ; Map < String , String > parameters = new LinkedHashMap < > ( ) ; if ( this . realmName != null ) { parameters . put ( "realm" , this . realmName ) ; } if ( authException instanceof OAuth2AuthenticationException ) { OAuth2Error error = ( ( OAuth2AuthenticationException ) authException ) . getError ( ) ; parameters . put ( "error" , error . getErrorCode ( ) ) ; if ( StringUtils . hasText ( error . getDescription ( ) ) ) { parameters . put ( "error_description" , error . getDescription ( ) ) ; } if ( StringUtils . hasText ( error . getUri ( ) ) ) { parameters . put ( "error_uri" , error . getUri ( ) ) ; } if ( error instanceof BearerTokenError ) { BearerTokenError bearerTokenError = ( BearerTokenError ) error ; if ( StringUtils . hasText ( bearerTokenError . getScope ( ) ) ) { parameters . put ( "scope" , bearerTokenError . getScope ( ) ) ; } status = ( ( BearerTokenError ) error ) . getHttpStatus ( ) ; } } String wwwAuthenticate = computeWWWAuthenticateHeaderValue ( parameters ) ; response . addHeader ( HttpHeaders . WWW_AUTHENTICATE , wwwAuthenticate ) ; response . setStatus ( status . value ( ) ) ;


signature:
public class JwtAuthenticationProvider { /** * Decode and validate the
 * < a href = " https : / / tools . ietf . org / html / rfc6750 # section - 1.2 " target = " _ blank " > Bearer Token < / a > .
 * @ param authentication the authentication request object .
 * @ return A successful authentication
 * @ throws AuthenticationException if authentication failed for some reason */
@ Override public Authentication authenticate ( Authentication authentication ) throws AuthenticationException { } }

implementation: BearerTokenAuthenticationToken bearer = ( BearerTokenAuthenticationToken ) authentication ; Jwt jwt ; try { jwt = this . jwtDecoder . decode ( bearer . getToken ( ) ) ; } catch ( JwtException failed ) { OAuth2Error invalidToken = invalidToken ( failed . getMessage ( ) ) ; throw new OAuth2AuthenticationException ( invalidToken , invalidToken . getDescription ( ) , failed ) ; } AbstractAuthenticationToken token = this . jwtAuthenticationConverter . convert ( jwt ) ; token . setDetails ( bearer . getDetails ( ) ) ; return token ;


signature:
public class OAuth2ClientCredentialsGrantRequestEntityConverter { /** * Returns a { @ link MultiValueMap } of the form parameters used for the Access Token Request body .
 * @ param clientCredentialsGrantRequest the client credentials grant request
 * @ return a { @ link MultiValueMap } of the form parameters used for the Access Token Request body */
private MultiValueMap < String , String > buildFormParameters ( OAuth2ClientCredentialsGrantRequest clientCredentialsGrantRequest ) { } }

implementation: ClientRegistration clientRegistration = clientCredentialsGrantRequest . getClientRegistration ( ) ; MultiValueMap < String , String > formParameters = new LinkedMultiValueMap < > ( ) ; formParameters . add ( OAuth2ParameterNames . GRANT_TYPE , clientCredentialsGrantRequest . getGrantType ( ) . getValue ( ) ) ; if ( ! CollectionUtils . isEmpty ( clientRegistration . getScopes ( ) ) ) { formParameters . add ( OAuth2ParameterNames . SCOPE , StringUtils . collectionToDelimitedString ( clientRegistration . getScopes ( ) , " " ) ) ; } if ( ClientAuthenticationMethod . POST . equals ( clientRegistration . getClientAuthenticationMethod ( ) ) ) { formParameters . add ( OAuth2ParameterNames . CLIENT_ID , clientRegistration . getClientId ( ) ) ; formParameters . add ( OAuth2ParameterNames . CLIENT_SECRET , clientRegistration . getClientSecret ( ) ) ; } return formParameters ;


signature:
public class ProviderManager { /** * Attempts to authenticate the passed { @ link Authentication } object .
 * The list of { @ link AuthenticationProvider } s will be successively tried until an
 * < code > AuthenticationProvider < / code > indicates it is capable of authenticating the
 * type of < code > Authentication < / code > object passed . Authentication will then be
 * attempted with that < code > AuthenticationProvider < / code > .
 * If more than one < code > AuthenticationProvider < / code > supports the passed
 * < code > Authentication < / code > object , the first one able to successfully
 * authenticate the < code > Authentication < / code > object determines the
 * < code > result < / code > , overriding any possible < code > AuthenticationException < / code >
 * thrown by earlier supporting < code > AuthenticationProvider < / code > s .
 * On successful authentication , no subsequent < code > AuthenticationProvider < / code > s
 * will be tried .
 * If authentication was not successful by any supporting
 * < code > AuthenticationProvider < / code > the last thrown
 * < code > AuthenticationException < / code > will be rethrown .
 * @ param authentication the authentication request object .
 * @ return a fully authenticated object including credentials .
 * @ throws AuthenticationException if authentication fails . */
public Authentication authenticate ( Authentication authentication ) throws AuthenticationException { } }

implementation:
Class < ? extends Authentication > toTest = authentication . getClass ( ) ; AuthenticationException lastException = null ; AuthenticationException parentException = null ; Authentication result = null ; Authentication parentResult = null ; boolean debug = logger . isDebugEnabled ( ) ; for ( AuthenticationProvider provider : getProviders ( ) ) { if ( ! provider . supports ( toTest ) ) { continue ; } if ( debug ) { logger . debug ( "Authentication attempt using " + provider . getClass ( ) . getName ( ) ) ; } try { result = provider . authenticate ( authentication ) ; if ( result != null ) { copyDetails ( authentication , result ) ; break ; } } catch ( AccountStatusException e ) { prepareException ( e , authentication ) ; // SEC - 546 : Avoid polling additional providers if auth failure is due to
// invalid account status
throw e ; } catch ( InternalAuthenticationServiceException e ) { prepareException ( e , authentication ) ; throw e ; } catch ( AuthenticationException e ) { lastException = e ; } } if ( result == null && parent != null ) { // Allow the parent to try .
try { result = parentResult = parent . authenticate ( authentication ) ; } catch ( ProviderNotFoundException e ) { // ignore as we will throw below if no other exception occurred prior to
// calling parent and the parent
// may throw ProviderNotFound even though a provider in the child already
// handled the request
} catch ( AuthenticationException e ) { lastException = parentException = e ; } } if ( result != null ) { if ( eraseCredentialsAfterAuthentication && ( result instanceof CredentialsContainer ) ) { // Authentication is complete . Remove credentials and other secret data
// from authentication
( ( CredentialsContainer ) result ) . eraseCredentials ( ) ; } // If the parent AuthenticationManager was attempted and successful than it will publish an AuthenticationSuccessEvent
// This check prevents a duplicate AuthenticationSuccessEvent if the parent AuthenticationManager already published it
if ( parentResult == null ) { eventPublisher . publishAuthenticationSuccess ( result ) ; } return result ; } // Parent was null , or didn ' t authenticate ( or throw an exception ) .
if ( lastException == null ) { lastException = new ProviderNotFoundException ( messages . getMessage ( "ProviderManager.providerNotFound" , new Object [ ] { toTest . getName ( ) } , "No AuthenticationProvider found for {0}" ) ) ; } // If the parent AuthenticationManager was attempted and failed than it will publish an AbstractAuthenticationFailureEvent
// This check prevents a duplicate AbstractAuthenticationFailureEvent if the parent AuthenticationManager already published it
if ( parentException == null ) { prepareException ( lastException , authentication ) ; } throw lastException ;


signature:
public class ProviderManager { /** * Copies the authentication details from a source Authentication object to a
 * destination one , provided the latter does not already have one set .
 * @ param source source authentication
 * @ param dest the destination authentication object */
private void copyDetails ( Authentication source , Authentication dest ) { } }

implementation: if ( ( dest instanceof AbstractAuthenticationToken ) && ( dest . getDetails ( ) == null ) ) { AbstractAuthenticationToken token = ( AbstractAuthenticationToken ) dest ; token . setDetails ( source . getDetails ( ) ) ; }


signature:
public class AbstractSessionFixationProtectionStrategy { /** * Called when a user is newly authenticated .
 * If a session already exists , and matches the session Id from the client , a new
 * session will be created , and the session attributes copied to it ( if
 * { @ code migrateSessionAttributes } is set ) . If the client ' s requested session Id is
 * invalid , nothing will be done , since there is no need to change the session Id if
 * it doesn ' t match the current session .
 * If there is no session , no action is taken unless the { @ code alwaysCreateSession }
 * property is set , in which case a session will be created if one doesn ' t already
 * exist . */
public void onAuthentication ( Authentication authentication , HttpServletRequest request , HttpServletResponse response ) { } }

implementation:
boolean hadSessionAlready = request . getSession ( false ) != null ; if ( ! hadSessionAlready && ! alwaysCreateSession ) { // Session fixation isn ' t a problem if there ' s no session
return ; } // Create new session if necessary
HttpSession session = request . getSession ( ) ; if ( hadSessionAlready && request . isRequestedSessionIdValid ( ) ) { String originalSessionId ; String newSessionId ; Object mutex = WebUtils . getSessionMutex ( session ) ; synchronized ( mutex ) { // We need to migrate to a new session
originalSessionId = session . getId ( ) ; session = applySessionFixation ( request ) ; newSessionId = session . getId ( ) ; } if ( originalSessionId . equals ( newSessionId ) ) { logger . warn ( "Your servlet container did not change the session ID when a new session was created. You will" + " not be adequately protected against session-fixation attacks" ) ; } onSessionChange ( originalSessionId , session , authentication ) ; }


signature:
public class AbstractSessionFixationProtectionStrategy { /** * Called when the session has been changed and the old attributes have been migrated
 * to the new session . Only called if a session existed to start with . Allows
 * subclasses to plug in additional behaviour . *
 * The default implementation of this method publishes a
 * { @ link SessionFixationProtectionEvent } to notify the application that the session
 * ID has changed . If you override this method and still wish these events to be
 * published , you should call { @ code super . onSessionChange ( ) } within your overriding
 * method .
 * @ param originalSessionId the original session identifier
 * @ param newSession the newly created session
 * @ param auth the token for the newly authenticated principal */
protected void onSessionChange ( String originalSessionId , HttpSession newSession , Authentication auth ) { } }

implementation: applicationEventPublisher . publishEvent ( new SessionFixationProtectionEvent ( auth , originalSessionId , newSession . getId ( ) ) ) ;


signature:
public class RoleHierarchyVoter { /** * Calls the < tt > RoleHierarchy < / tt > to obtain the complete set of user authorities . */
@ Override Collection < ? extends GrantedAuthority > extractAuthorities ( Authentication authentication ) { } }

implementation: return roleHierarchy . getReachableGrantedAuthorities ( authentication . getAuthorities ( ) ) ;


signature:
public class FilterChainProxy { /** * Returns the first filter chain matching the supplied URL .
 * @ param request the request to match
 * @ return an ordered array of Filters defining the filter chain */
private List < Filter > getFilters ( HttpServletRequest request ) { } }

implementation: for ( SecurityFilterChain chain : filterChains ) { if ( chain . matches ( request ) ) { return chain . getFilters ( ) ; } } return null ;


signature:
public class FilterChainProxy { /** * Convenience method , mainly for testing .
 * @ param url the URL
 * @ return matching filter list */
public List < Filter > getFilters ( String url ) { } }

implementation: return getFilters ( firewall . getFirewalledRequest ( ( new FilterInvocation ( url , "GET" ) . getRequest ( ) ) ) ) ;


signature: public class AccessControlListTag { public int doStartTag ( ) throws JspException { } }

implementation:
if ( ( null == hasPermission ) || "" . equals ( hasPermission ) ) { return skipBody ( ) ; } initializeIfRequired ( ) ; if ( domainObject == null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "domainObject resolved to null, so including tag body" ) ; } // Of course they have access to a null object !
return evalBody ( ) ; } Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; if ( authentication == null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "SecurityContextHolder did not return a non-null Authentication object, so skipping tag body" ) ; } return skipBody ( ) ; } List < Object > requiredPermissions = parseHasPermission ( hasPermission ) ; for ( Object requiredPermission : requiredPermissions ) { if ( ! permissionEvaluator . hasPermission ( authentication , domainObject , requiredPermission ) ) { return skipBody ( ) ; } } return evalBody ( ) ;


signature:
public class AccessControlListTag { /** * Allows test cases to override where application context obtained from .
 * @ param pageContext so the < code > ServletContext < / code > can be accessed as required
 * by Spring ' s < code > WebApplicationContextUtils < / code >
 * @ return the Spring application context ( never < code > null < / code > ) */
protected ApplicationContext getContext ( PageContext pageContext ) { } }

implementation: ServletContext servletContext = pageContext . getServletContext ( ) ; return SecurityWebApplicationContextUtils . findRequiredWebApplicationContext ( servletContext ) ;


signature:
public class AbstractLdapAuthenticationProvider { /** * Creates the final { @ code Authentication } object which will be returned from the
 * { @ code authenticate } method .
 * @ param authentication the original authentication request token
 * @ param user the < tt > UserDetails < / tt > instance returned by the configured
 * < tt > UserDetailsContextMapper < / tt > .
 * @ return the Authentication object for the fully authenticated user . */
protected Authentication createSuccessfulAuthentication ( UsernamePasswordAuthenticationToken authentication , UserDetails user ) { } }

implementation: Object password = this . useAuthenticationRequestCredentials ? authentication . getCredentials ( ) : user . getPassword ( ) ; UsernamePasswordAuthenticationToken result = new UsernamePasswordAuthenticationToken ( user , password , this . authoritiesMapper . mapAuthorities ( user . getAuthorities ( ) ) ) ; result . setDetails ( authentication . getDetails ( ) ) ; return result ;


signature: public class AclAuthorizationStrategyImpl { public void securityCheck ( Acl acl , int changeType ) { } }

implementation:
if ( ( SecurityContextHolder . getContext ( ) == null ) || ( SecurityContextHolder . getContext ( ) . getAuthentication ( ) == null ) || ! SecurityContextHolder . getContext ( ) . getAuthentication ( ) . isAuthenticated ( ) ) { throw new AccessDeniedException ( "Authenticated principal required to operate with ACLs" ) ; } Authentication authentication = SecurityContextHolder . getContext ( ) . getAuthentication ( ) ; // Check if authorized by virtue of ACL ownership
Sid currentUser = createCurrentUser ( authentication ) ; if ( currentUser . equals ( acl . getOwner ( ) ) && ( ( changeType == CHANGE_GENERAL ) || ( changeType == CHANGE_OWNERSHIP ) ) ) { return ; } // Not authorized by ACL ownership ; try via adminstrative permissions
GrantedAuthority requiredAuthority ; if ( changeType == CHANGE_AUDITING ) { requiredAuthority = this . gaModifyAuditing ; } else if ( changeType == CHANGE_GENERAL ) { requiredAuthority = this . gaGeneralChanges ; } else if ( changeType == CHANGE_OWNERSHIP ) { requiredAuthority = this . gaTakeOwnership ; } else { throw new IllegalArgumentException ( "Unknown change type" ) ; } // Iterate this principal ' s authorities to determine right
Set < String > authorities = AuthorityUtils . authorityListToSet ( authentication . getAuthorities ( ) ) ; if ( authorities . contains ( requiredAuthority . getAuthority ( ) ) ) { return ; } // Try to get permission via ACEs within the ACL
List < Sid > sids = sidRetrievalStrategy . getSids ( authentication ) ; if ( acl . isGranted ( Arrays . asList ( BasePermission . ADMINISTRATION ) , sids , false ) ) { return ; } throw new AccessDeniedException ( "Principal does not have required ACL permissions to perform requested operation" ) ;


signature:
public class MethodSecurityMetadataSourceAdvisorRegistrar { /** * Register , escalate , and configure the AspectJ auto proxy creator based on the value
 * of the @ { @ link EnableGlobalMethodSecurity # proxyTargetClass ( ) } attribute on the
 * importing { @ code @ Configuration } class . */
public void registerBeanDefinitions ( AnnotationMetadata importingClassMetadata , BeanDefinitionRegistry registry ) { } }

implementation: BeanDefinitionBuilder advisor = BeanDefinitionBuilder . rootBeanDefinition ( MethodSecurityMetadataSourceAdvisor . class ) ; advisor . setRole ( BeanDefinition . ROLE_INFRASTRUCTURE ) ; advisor . addConstructorArgValue ( "methodSecurityInterceptor" ) ; advisor . addConstructorArgReference ( "methodSecurityMetadataSource" ) ; advisor . addConstructorArgValue ( "methodSecurityMetadataSource" ) ; MultiValueMap < String , Object > attributes = importingClassMetadata . getAllAnnotationAttributes ( EnableGlobalMethodSecurity . class . getName ( ) ) ; Integer order = ( Integer ) attributes . getFirst ( "order" ) ; if ( order != null ) { advisor . addPropertyValue ( "order" , order ) ; } registry . registerBeanDefinition ( "metaDataSourceAdvisor" , advisor . getBeanDefinition ( ) ) ;


signature: public class LdapUtils { public static void closeContext ( Context ctx ) { } }

implementation: if ( ctx instanceof DirContextAdapter ) { return ; } try { if ( ctx != null ) { ctx . close ( ) ; } } catch ( NamingException e ) { logger . error ( "Failed to close context." , e ) ; }


signature:
public class LdapUtils { /** * Obtains the part of a DN relative to a supplied base context .
 * If the DN is " cn = bob , ou = people , dc = springframework , dc = org " and the base context name
 * is " ou = people , dc = springframework , dc = org " it would return " cn = bob " .
 * @ param fullDn the DN
 * @ param baseCtx the context to work out the name relative to .
 * @ return the
 * @ throws NamingException any exceptions thrown by the context are propagated . */
public static String getRelativeName ( String fullDn , Context baseCtx ) throws NamingException { } }

implementation: String baseDn = baseCtx . getNameInNamespace ( ) ; if ( baseDn . length ( ) == 0 ) { return fullDn ; } DistinguishedName base = new DistinguishedName ( baseDn ) ; DistinguishedName full = new DistinguishedName ( fullDn ) ; if ( base . equals ( full ) ) { return "" ; } Assert . isTrue ( full . startsWith ( base ) , "Full DN does not start with base DN" ) ; full . removeFirst ( base ) ; return full . toString ( ) ;


signature:
public class LdapUtils { /** * Gets the full dn of a name by prepending the name of the context it is relative to .
 * If the name already contains the base name , it is returned unaltered . */
public static DistinguishedName getFullDn ( DistinguishedName dn , Context baseCtx ) throws NamingException { } }

implementation: DistinguishedName baseDn = new DistinguishedName ( baseCtx . getNameInNamespace ( ) ) ; if ( dn . contains ( baseDn ) ) { return dn ; } baseDn . append ( dn ) ; return baseDn ;


signature:
public class ReactiveJwtAuthenticationConverter { /** * Sets the { @ link Converter Converter & lt ; Jwt , Flux & lt ; GrantedAuthority & gt ; & gt ; } to use .
 * Defaults to a reactive { @ link JwtGrantedAuthoritiesConverter } .
 * @ param jwtGrantedAuthoritiesConverter The converter
 * @ see JwtGrantedAuthoritiesConverter */
public void setJwtGrantedAuthoritiesConverter ( Converter < Jwt , Flux < GrantedAuthority > > jwtGrantedAuthoritiesConverter ) { } }

implementation: Assert . notNull ( jwtGrantedAuthoritiesConverter , "jwtGrantedAuthoritiesConverter cannot be null" ) ; this . jwtGrantedAuthoritiesConverter = jwtGrantedAuthoritiesConverter ;


signature:
public class HttpsRedirectWebFilter { /** * { @ inheritDoc } */
@ Override public Mono < Void > filter ( ServerWebExchange exchange , WebFilterChain chain ) { } }

implementation: return Mono . just ( exchange ) . filter ( this :: isInsecure ) . flatMap ( this . requiresHttpsRedirectMatcher :: matches ) . filter ( matchResult -> matchResult . isMatch ( ) ) . switchIfEmpty ( chain . filter ( exchange ) . then ( Mono . empty ( ) ) ) . map ( matchResult -> createRedirectUri ( exchange ) ) . flatMap ( uri -> this . redirectStrategy . sendRedirect ( exchange , uri ) ) ;


signature:
public class MockMvcRequestSpecificationImpl { /** * Set session attributes .
 * @ param sessionAttributes the session attributes */
public MockMvcRequestSpecification sessionAttrs ( Map < String , Object > sessionAttributes ) { } }

implementation: notNull ( sessionAttributes , "sessionAttributes" ) ; parameterUpdater . updateParameters ( convert ( cfg . getMockMvcParamConfig ( ) . sessionAttributesUpdateStrategy ( ) ) , sessionAttributes , this . sessionAttributes ) ; return this ;


signature:
public class MockMvcRequestSpecificationImpl { /** * Set a session attribute .
 * @ param name the session attribute name
 * @ param value the session attribute value */
public MockMvcRequestSpecification sessionAttr ( String name , Object value ) { } }

implementation: notNull ( name , "Session attribute name" ) ; parameterUpdater . updateZeroToManyParameters ( convert ( cfg . getMockMvcParamConfig ( ) . sessionAttributesUpdateStrategy ( ) ) , sessionAttributes , name , value ) ; return this ;


signature:
public class FormAuthConfig { /** * Enable Cross - site request forgery ( csrf ) support when using form authentication by including the csrf value of the input field with the specified name .
 * For example if the login page looks like this :
 * < pre >
 * & lt ; html & gt ;
 * & lt ; head & gt ;
 * & lt ; title & gt ; Login & lt ; / title & gt ;
 * & lt ; / head & gt ;
 * & lt ; body & gt ;
 * & lt ; form action = & quot ; j _ spring _ security _ check _ with _ csrf & quot ; method = & quot ; POST & quot ; & gt ;
 * & lt ; table & gt ;
 * & lt ; tr & gt ;
 * & lt ; td & gt ; User : & amp ; nbsp ; & lt ; / td & gt ;
 * & lt ; td & gt ; & lt ; input type = & quot ; text & quot ; name = & quot ; j _ username & quot ; & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; tr & gt ;
 * & lt ; td & gt ; Password : & lt ; / td & gt ;
 * & lt ; td & gt ; & lt ; input type = & quot ; password & quot ; name = & quot ; j _ password & quot ; & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; tr & gt ;
 * & lt ; td colspan = & quot ; 2 & quot ; & gt ; & lt ; input name = & quot ; submit & quot ; type = & quot ; submit & quot ; / & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; / table & gt ;
 * & lt ; input type = & quot ; hidden & quot ; name = & quot ; _ csrf & quot ; value = & quot ; 8adf2ea1 - b246-40aa - 8e13 - a85fb7914341 & quot ; / & gt ;
 * & lt ; / form & gt ;
 * & lt ; / body & gt ;
 * & lt ; / html & gt ;
 * < / pre >
 * The csrf field name is called < code > _ csrf < / code > .
 * < b > Important : < / b > When enabling csrf support then REST Assured < b > must always < / b > make an additional request to the server in order to
 * be able to include in the csrf value which will slow down the tests .
 * @ param fieldName The name of the input field
 * @ return A new FormAuthConfig instance .
 * @ see # withAutoDetectionOfCsrf ( ) */
public FormAuthConfig withCsrfFieldName ( String fieldName ) { } }

implementation: notNull ( fieldName , "CSRF field name" ) ; if ( autoDetectCsrfFieldName ) { throw new IllegalStateException ( "Cannot defined a CSRF field name since the CSRF field name has been marked as auto-detected." ) ; } return new FormAuthConfig ( formAction , userInputTagName , passwordInputTagName , logDetail , logConfig , fieldName , false , sendCsrfTokenAsFormParam , additionalInputFieldNames ) ;


signature:
public class FormAuthConfig { /** * Include additional field when using form authentication by including input field value with the specified name .
 * For example if the login page looks like this :
 * < pre >
 * & lt ; html & gt ;
 * & lt ; head & gt ;
 * & lt ; title & gt ; Login & lt ; / title & gt ;
 * & lt ; / head & gt ;
 * & lt ; body & gt ;
 * & lt ; form action = & quot ; j _ spring _ security _ check _ with _ csrf & quot ; method = & quot ; POST & quot ; & gt ;
 * & lt ; table & gt ;
 * & lt ; tr & gt ;
 * & lt ; td & gt ; User : & amp ; nbsp ; & lt ; / td & gt ;
 * & lt ; td & gt ; & lt ; input type = & quot ; text & quot ; name = & quot ; j _ username & quot ; & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; tr & gt ;
 * & lt ; td & gt ; Password : & lt ; / td & gt ;
 * & lt ; td & gt ; & lt ; input type = & quot ; password & quot ; name = & quot ; j _ password & quot ; & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; tr & gt ;
 * & lt ; td colspan = & quot ; 2 & quot ; & gt ; & lt ; input name = & quot ; submit & quot ; type = & quot ; submit & quot ; / & gt ; & lt ; / td & gt ;
 * & lt ; / tr & gt ;
 * & lt ; / table & gt ;
 * & lt ; input type = & quot ; hidden & quot ; name = & quot ; something & quot ; value = & quot ; 8adf2ea1 - b246-40aa - 8e13 - a85fb7914341 & quot ; / & gt ;
 * & lt ; / form & gt ;
 * & lt ; / body & gt ;
 * & lt ; / html & gt ;
 * < / pre >
 * and you ' d like to include the field named < code > something < / code > as an additional form parameter in the request you can do like this :
 * < pre >
 * given ( ) . auth ( ) . form ( . . . , new FormAuthConfig ( . . ) . withAdditionalField ( " something " ) . . .
 * < / pre >
 * and then REST Assured will send the form parameter < code > something = 8adf2ea1 - b246-40aa - 8e13 - a85fb7914341 < / code >
 * < b > Important : < / b > When including an additional field without specifying a value then REST Assured < b > must always < / b > make an additional request to the server in order to
 * be able to figure out the field value . This will slow down the tests .
 * @ param fieldName The first field name to include
 * @ return A new FormAuthConfig instance . */
public FormAuthConfig withAdditionalField ( String fieldName ) { } }

implementation: notNull ( fieldName , "Additional field name" ) ; List < String > list = new ArrayList < String > ( additionalInputFieldNames ) ; list . add ( fieldName ) ; return new FormAuthConfig ( formAction , userInputTagName , passwordInputTagName , logDetail , logConfig , csrfFieldName , autoDetectCsrfFieldName , sendCsrfTokenAsFormParam , list ) ;


signature:
public class FormAuthConfig { /** * Include multiple additional fields when using form authentication by including input field values with the specified name .
 * This is the same as { @ link # withAdditionalField ( String ) } but for multiple fields .
 * < b > Important : < / b > When including an additional field without specifying a value then REST Assured < b > must always < / b > make an additional request to the server in order to
 * be able to figure out the field value . This will slow down the tests .
 * @ param firstFieldName The first additional input field to include
 * @ param secondFieldName The second additional input field to include
 * @ param additionalFieldNames Additional field name to include ( optional )
 * @ return A new FormAuthConfig instance . */
public FormAuthConfig withAdditionalFields ( String firstFieldName , String secondFieldName , String ... additionalFieldNames ) { } }

implementation: notNull ( firstFieldName , "First additional field name" ) ; notNull ( secondFieldName , "Second additional field name" ) ; List < String > list = new ArrayList < String > ( additionalInputFieldNames ) ; list . add ( firstFieldName ) ; list . add ( secondFieldName ) ; if ( additionalFieldNames != null && additionalFieldNames . length > 0 ) { list . addAll ( Arrays . asList ( additionalFieldNames ) ) ; } return new FormAuthConfig ( formAction , userInputTagName , passwordInputTagName , logDetail , logConfig , csrfFieldName , autoDetectCsrfFieldName , sendCsrfTokenAsFormParam , list ) ;