Search in sources :

Example 1 with OAuth20AuthorizationResponseBuilder

use of org.apereo.cas.support.oauth.web.response.callback.OAuth20AuthorizationResponseBuilder in project cas by apereo.

the class OAuth20AuthorizeEndpointController method buildAuthorizationForRequest.

/**
 * Build callback url for request string.
 *
 * @param registeredService the registered service
 * @param context           the context
 * @param clientId          the client id
 * @param service           the service
 * @param authentication    the authentication
 * @return the string
 */
protected View buildAuthorizationForRequest(final OAuthRegisteredService registeredService, final J2EContext context, final String clientId, final Service service, final Authentication authentication) {
    final OAuth20AuthorizationResponseBuilder builder = this.oauthAuthorizationResponseBuilders.stream().filter(b -> b.supports(context)).findFirst().orElseThrow(() -> new IllegalArgumentException("Could not build the callback url. Response type likely not supported"));
    final TicketGrantingTicket ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest(ticketGrantingTicketCookieGenerator, this.ticketRegistry, context.getRequest());
    final String grantType = StringUtils.defaultIfEmpty(context.getRequestParameter(OAuth20Constants.GRANT_TYPE), OAuth20GrantTypes.AUTHORIZATION_CODE.getType()).toUpperCase();
    final Set<String> scopes = OAuth20Utils.parseRequestScopes(context);
    final AccessTokenRequestDataHolder holder = new AccessTokenRequestDataHolder(service, authentication, registeredService, ticketGrantingTicket, OAuth20GrantTypes.valueOf(grantType), scopes);
    LOGGER.debug("Building authorization response for grant type [{}] with scopes [{}] for client id [{}]", grantType, scopes, clientId);
    return builder.build(context, clientId, holder);
}
Also used : OAuth20AuthorizationResponseBuilder(org.apereo.cas.support.oauth.web.response.callback.OAuth20AuthorizationResponseBuilder) TicketGrantingTicket(org.apereo.cas.ticket.TicketGrantingTicket) AccessTokenRequestDataHolder(org.apereo.cas.support.oauth.web.response.accesstoken.ext.AccessTokenRequestDataHolder)

Aggregations

AccessTokenRequestDataHolder (org.apereo.cas.support.oauth.web.response.accesstoken.ext.AccessTokenRequestDataHolder)1 OAuth20AuthorizationResponseBuilder (org.apereo.cas.support.oauth.web.response.callback.OAuth20AuthorizationResponseBuilder)1 TicketGrantingTicket (org.apereo.cas.ticket.TicketGrantingTicket)1