org.springframework.security.oauth2.provider.authentication.TokenExtractor Java Examples

The following examples show how to use org.springframework.security.oauth2.provider.authentication.TokenExtractor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuth2Utils.java    From onetwo with Apache License 2.0 5 votes vote down vote up
public static Optional<String> getAccessTokenValue(TokenExtractor tokenExtractor,  HttpServletRequest request){
	String accessToken = (String)request.getAttribute(OAuth2AuthenticationDetails.ACCESS_TOKEN_VALUE);
	if(accessToken==null){
		Authentication authentication = tokenExtractor.extract(request);
		accessToken = authentication==null?null:(String)authentication.getPrincipal();
	}
	return Optional.ofNullable(accessToken);
}
 
Example #2
Source File: PoPTokenExtractor.java    From OAuth-2.0-Cookbook with MIT License 4 votes vote down vote up
public PoPTokenExtractor(TokenExtractor delegate) {
    this.delegate = delegate;
}
 
Example #3
Source File: OAuth2AuthenticationConfiguration.java    From cubeai with Apache License 2.0 2 votes vote down vote up
/**
 * The new TokenExtractor can extract tokens from Cookies and Authorization headers.
 *
 * @return the CookieTokenExtractor bean.
 */
@Bean
public TokenExtractor tokenExtractor() {
    return new CookieTokenExtractor();
}
 
Example #4
Source File: OAuth2AuthenticationConfiguration.java    From tutorials with MIT License 2 votes vote down vote up
/**
 * The new TokenExtractor can extract tokens from Cookies and Authorization headers.
 *
 * @return the CookieTokenExtractor bean.
 */
@Bean
public TokenExtractor tokenExtractor() {
    return new CookieTokenExtractor();
}