use of org.springframework.security.oauth.provider.token.InvalidOAuthTokenException in project spring-security-oauth by spring-projects.
the class UserAuthorizationProcessingFilter method attemptAuthentication.
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
String requestToken = request.getParameter(getTokenParameterName());
if (requestToken == null) {
throw new InvalidOAuthParametersException("An OAuth token id is required.");
}
OAuthProviderToken token = getTokenServices().getToken(requestToken);
if (token == null) {
throw new InvalidOAuthTokenException("No callback value has been provided for request token " + requestToken + ".");
}
String callbackURL = token.getCallbackUrl();
if (isRequire10a() && callbackURL == null) {
throw new InvalidOAuthTokenException("No callback value has been provided for request token " + requestToken + ".");
}
if (callbackURL != null) {
request.setAttribute(CALLBACK_ATTRIBUTE, callbackURL);
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !authentication.isAuthenticated()) {
throw new InsufficientAuthenticationException("User must be authenticated before authorizing a request token.");
}
String verifier = getVerifierServices().createVerifier();
request.setAttribute(VERIFIER_ATTRIBUTE, verifier);
getTokenServices().authorizeRequestToken(requestToken, verifier, authentication);
return authentication;
}
Aggregations