Search in sources :

Example 1 with BearerTokenError

use of com.nimbusds.oauth2.sdk.token.BearerTokenError in project spring-security by spring-projects.

the class OAuth2ErrorResponseErrorHandler method readErrorFromWwwAuthenticate.

private OAuth2Error readErrorFromWwwAuthenticate(HttpHeaders headers) {
    String wwwAuthenticateHeader = headers.getFirst(HttpHeaders.WWW_AUTHENTICATE);
    if (!StringUtils.hasText(wwwAuthenticateHeader)) {
        return null;
    }
    BearerTokenError bearerTokenError = getBearerToken(wwwAuthenticateHeader);
    if (bearerTokenError == null) {
        return new OAuth2Error(OAuth2ErrorCodes.SERVER_ERROR, null, null);
    }
    String errorCode = (bearerTokenError.getCode() != null) ? bearerTokenError.getCode() : OAuth2ErrorCodes.SERVER_ERROR;
    String errorDescription = bearerTokenError.getDescription();
    String errorUri = (bearerTokenError.getURI() != null) ? bearerTokenError.getURI().toString() : null;
    return new OAuth2Error(errorCode, errorDescription, errorUri);
}
Also used : OAuth2Error(org.springframework.security.oauth2.core.OAuth2Error) BearerTokenError(com.nimbusds.oauth2.sdk.token.BearerTokenError)

Aggregations

BearerTokenError (com.nimbusds.oauth2.sdk.token.BearerTokenError)1 OAuth2Error (org.springframework.security.oauth2.core.OAuth2Error)1