Search in sources :

Example 1 with OAuth20AccessTokenFactory

use of org.apereo.cas.ticket.accesstoken.OAuth20AccessTokenFactory in project cas by apereo.

the class OidcDynamicClientRegistrationEndpointController method generateRegistrationAccessToken.

/**
 * Generate registration access token access token.
 *
 * @param request             the request
 * @param response            the response
 * @param registeredService   the registered service
 * @param registrationRequest the registration request
 * @return the access token
 * @throws Exception the exception
 */
protected OAuth20AccessToken generateRegistrationAccessToken(final HttpServletRequest request, final HttpServletResponse response, final OidcRegisteredService registeredService, final OidcClientRegistrationRequest registrationRequest) throws Exception {
    val authn = DefaultAuthenticationBuilder.newInstance().setPrincipal(PrincipalFactoryUtils.newPrincipalFactory().createPrincipal(registeredService.getClientId())).build();
    val clientConfigUri = OidcClientRegistrationUtils.getClientConfigurationUri(registeredService, getConfigurationContext().getCasProperties().getServer().getPrefix());
    val service = getConfigurationContext().getWebApplicationServiceServiceFactory().createService(clientConfigUri);
    val factory = (OAuth20AccessTokenFactory) getConfigurationContext().getTicketFactory().get(OAuth20AccessToken.class);
    val accessToken = factory.create(service, authn, List.of(OidcConstants.CLIENT_REGISTRATION_SCOPE), registeredService.getClientId(), OAuth20ResponseTypes.NONE, OAuth20GrantTypes.NONE);
    getConfigurationContext().getTicketRegistry().addTicket(accessToken);
    return accessToken;
}
Also used : lombok.val(lombok.val) OAuth20AccessToken(org.apereo.cas.ticket.accesstoken.OAuth20AccessToken) OAuth20AccessTokenFactory(org.apereo.cas.ticket.accesstoken.OAuth20AccessTokenFactory)

Aggregations

lombok.val (lombok.val)1 OAuth20AccessToken (org.apereo.cas.ticket.accesstoken.OAuth20AccessToken)1 OAuth20AccessTokenFactory (org.apereo.cas.ticket.accesstoken.OAuth20AccessTokenFactory)1