use of de.ids_mannheim.korap.oauth2.oltu.OAuth2AuthorizationRequest in project Kustvakt by KorAP.
the class OAuth2Controller method requestAuthorizationCode.
/**
* Requests an authorization code.
*
* Kustvakt supports authorization only with Kalamar as the
* authorization web-frontend or user interface. Thus
* authorization code request requires user authentication
* using authorization header.
*
* <br /><br />
* RFC 6749:
* If the client omits the scope parameter when requesting
* authorization, the authorization server MUST either process the
* request using a pre-defined default value or fail the request
* indicating an invalid scope.
*
* @param request
* HttpServletRequest
* @param form
* form parameters
* @return a redirect URL
*/
@POST
@Path("authorize")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response requestAuthorizationCode(@Context HttpServletRequest request, @Context SecurityContext context, @FormParam("state") String state, MultivaluedMap<String, String> form) {
TokenContext tokenContext = (TokenContext) context.getUserPrincipal();
String username = tokenContext.getUsername();
ZonedDateTime authTime = tokenContext.getAuthenticationTime();
try {
scopeService.verifyScope(tokenContext, OAuth2Scope.AUTHORIZE);
HttpServletRequest requestWithForm = new FormRequestWrapper(request, form);
OAuth2AuthorizationRequest authzRequest = new OAuth2AuthorizationRequest(requestWithForm);
String uri = authorizationService.requestAuthorizationCode(requestWithForm, authzRequest, username, authTime);
return responseHandler.sendRedirect(uri);
} catch (OAuthSystemException e) {
throw responseHandler.throwit(e, state);
} catch (OAuthProblemException e) {
throw responseHandler.throwit(e, state);
} catch (KustvaktException e) {
throw responseHandler.throwit(e, state);
}
}
Aggregations