use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.
the class CodeAuthorizeHandler method handleResponse.
@Override
protected void handleResponse() throws OAuthSystemException, IOException {
final ClientDetails clientDetails = clientDetails();
final String authCode = oauthService.retrieveAuthCode(clientDetails);
final OAuthResponse oAuthResponse = OAuthASResponse.authorizationResponse(oauthRequest.request(), HttpServletResponse.SC_OK).location(clientDetails.getRedirectUri()).setCode(authCode).buildQueryMessage();
LOG.debug(" 'code' response: {}", oAuthResponse);
WebUtils.writeOAuthQueryResponse(response, oAuthResponse);
}
use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.
the class AbstractOAuthTokenHandler method validateFailed.
protected boolean validateFailed() throws OAuthSystemException {
AbstractClientDetailsValidator validator = getValidator();
LOG.debug("Use [{}] validate client: {}", validator, tokenRequest.getClientId());
final OAuthResponse oAuthResponse = validator.validate();
return checkAndResponseValidateFailed(oAuthResponse);
}
use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.
the class ClientCredentialsTokenHandler method handleAfterValidation.
@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
AccessToken accessToken = oauthService.retrieveClientCredentialsAccessToken(clientDetails(), tokenRequest.getScopes());
final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
LOG.debug("'client_credentials' response: {}", tokenResponse);
WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.
the class PasswordTokenHandler method handleAfterValidation.
@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
AccessToken accessToken = oauthService.retrievePasswordAccessToken(clientDetails(), tokenRequest.getScopes(), tokenRequest.getUsername());
final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
LOG.debug("'password' response: {}", tokenResponse);
WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project irida by phac-nml.
the class OltuAuthorizationController method authenticate.
/**
* Begin authentication procedure by redirecting to remote authorization
* location
*
* @param remoteAPI
* The API we need to authenticate with
* @param redirect
* The location to redirect back to after authentication is
* complete
* @return A ModelAndView beginning the authentication procedure
* @throws OAuthSystemException
*/
/**
* Begin authentication procedure by redirecting to remote authorization
* location
*
* @param serviceURI
* The base URI of the rest api service
* @param clientID
* The Client ID to connect with
* @param clientSecret
* The client secret to connect with
* @param redirect
* Page to redirect to after auth is complete
* @return ModelAndView redirecting to the authorization location
* @throws OAuthSystemException
*/
public ModelAndView authenticate(String serviceURI, String clientID, String clientSecret, String redirect) throws OAuthSystemException {
// save the client credentials and information
this.clientId = clientID;
this.clientSecret = clientSecret;
this.serviceURI = serviceURI;
// build the authorization path
URI serviceAuthLocation = UriBuilder.fromUri(serviceURI).path("oauth").path("authorize").build();
logger.debug("redirect: " + redirect);
// build a redirect URI to redirect to after auth flow is completed
String tokenRedirect = buildRedirectURI(redirect);
// build the redirect query to request an authorization code from the
// remote API
OAuthClientRequest request = OAuthClientRequest.authorizationLocation(serviceAuthLocation.toString()).setClientId(clientID).setRedirectURI(tokenRedirect).setResponseType(ResponseType.CODE.toString()).setScope("read").buildQueryMessage();
String locURI = request.getLocationUri();
logger.debug("authorization request location:" + locURI);
// create the redirection
ModelAndView modelAndView = new ModelAndView(new RedirectView(locURI));
return modelAndView;
}
Aggregations