web/src/main/java/org/springframework/security/web/authentication/preauth/PreAuthenticatedAuthenticationProvider.java
public Authentication authenticate(Authentication authentication)
			throws AuthenticationException {
		if (!supports(authentication.getClass())) {
			return null;
		}

		if (logger.isDebugEnabled()) {
			logger.debug("PreAuthenticated authentication request: " + authentication);
		}

		if (authentication.getPrincipal() == null) {
			logger.debug("No pre-authenticated principal found in request.");

			if (throwExceptionWhenTokenRejected) {
				throw new BadCredentialsException(
						"No pre-authenticated principal found in request.");
			}
			return null;
		}

		if (authentication.getCredentials() == null) {
			logger.debug("No pre-authenticated credentials found in request.");

			if (throwExceptionWhenTokenRejected) {
				throw new BadCredentialsException(
						"No pre-authenticated credentials found in request.");
			}
			return null;
		}

		UserDetails ud = preAuthenticatedUserDetailsService
				.loadUserDetails((PreAuthenticatedAuthenticationToken) authentication);

		userDetailsChecker.check(ud);

		PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(
				ud, authentication.getCredentials(), ud.getAuthorities());
		result.setDetails(authentication.getDetails());

		return result;
	}
public Authentication authenticate(Authentication authentication)
			throws AuthenticationException {
		if (!supports(authentication.getClass())) {
			return null;
		}

		if (logger.isDebugEnabled()) {
			logger.debug("PreAuthenticated authentication request: " + authentication);
		}

		if (authentication.getPrincipal() == null) {
			logger.debug("No pre-authenticated principal found in request.");

			if (throwExceptionWhenTokenRejected) {
				throw new BadCredentialsException(
						"No pre-authenticated principal found in request.");
			}
			return null;
		}

		if (authentication.getCredentials() == null) {
			logger.debug("No pre-authenticated credentials found in request.");

			if (throwExceptionWhenTokenRejected) {
				throw new BadCredentialsException(
						"No pre-authenticated credentials found in request.");
			}
			return null;
		}

		UserDetails ud = preAuthenticatedUserDetailsService
				.loadUserDetails((PreAuthenticatedAuthenticationToken) authentication);

		userDetailsChecker.check(ud);

		PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken(
				ud, authentication.getCredentials(), ud.getAuthorities());
		result.setDetails(authentication.getDetails());

		return result;
	}
public Authentication authenticate ( Authentication authentication ) throws AuthenticationException { if ( ! supports ( authentication . getClass ( ) ) ) { return null ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "PreAuthenticated authentication request: " + authentication ) ; } if ( authentication . getPrincipal ( ) == null ) { logger . debug ( "No pre-authenticated principal found in request." ) ; if ( throwExceptionWhenTokenRejected ) { throw new BadCredentialsException ( "No pre-authenticated principal found in request." ) ; } return null ; } if ( authentication . getCredentials ( ) == null ) { logger . debug ( "No pre-authenticated credentials found in request." ) ; if ( throwExceptionWhenTokenRejected ) { throw new BadCredentialsException ( "No pre-authenticated credentials found in request." ) ; } return null ; } UserDetails ud = preAuthenticatedUserDetailsService . loadUserDetails ( ( PreAuthenticatedAuthenticationToken ) authentication ) ; userDetailsChecker . check ( ud ) ; PreAuthenticatedAuthenticationToken result = new PreAuthenticatedAuthenticationToken ( ud , authentication . getCredentials ( ) , ud . getAuthorities ( ) ) ; result . setDetails ( authentication . getDetails ( ) ) ; return result ; }
Authenticate the given PreAuthenticatedAuthenticationToken.
<p>
If the principal contained in the authentication object is null, the request will
be ignored to allow other providers to authenticate it.
Authenticate the given PreAuthenticatedAuthenticationToken . <p > If the principal contained in the authentication object is null the request will be ignored to allow other providers to authenticate it .