use of org.pac4j.core.exception.TechnicalException in project pac4j by pac4j.
the class OAuth20RedirectionActionBuilder method getRedirectionAction.
@Override
public Optional<RedirectionAction> getRedirectionAction(final WebContext context, final SessionStore sessionStore) {
try {
final String state;
if (configuration.isWithState()) {
state = this.configuration.getStateGenerator().generateValue(context, sessionStore);
logger.debug("save sessionState: {}", state);
sessionStore.set(context, client.getStateSessionAttributeName(), state);
} else {
state = null;
}
final var service = (OAuth20Service) this.configuration.buildService(context, client);
final var authorizationUrl = new AuthorizationUrlBuilder(service).state(state).additionalParams(this.configuration.getCustomParams()).build();
logger.debug("authorizationUrl: {}", authorizationUrl);
return Optional.of(HttpActionHelper.buildRedirectUrlAction(context, authorizationUrl));
} catch (final OAuthException e) {
throw new TechnicalException(e);
}
}
Aggregations