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;
}
Aggregations