Search in sources :

Example 81 with TechnicalException

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);
    }
}
Also used : TechnicalException(org.pac4j.core.exception.TechnicalException) OAuthException(com.github.scribejava.core.exceptions.OAuthException) AuthorizationUrlBuilder(com.github.scribejava.core.oauth.AuthorizationUrlBuilder) OAuth20Service(com.github.scribejava.core.oauth.OAuth20Service)

Aggregations

TechnicalException (org.pac4j.core.exception.TechnicalException)81 IOException (java.io.IOException)26 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7 HashMap (java.util.HashMap)7 OAuthException (com.github.scribejava.core.exceptions.OAuthException)6 JWT (com.nimbusds.jwt.JWT)6 ParseException (com.nimbusds.oauth2.sdk.ParseException)6 HttpURLConnection (java.net.HttpURLConnection)6 Test (org.junit.Test)6 OidcCredentials (org.pac4j.oidc.credentials.OidcCredentials)6 JWTClaimsSet (com.nimbusds.jwt.JWTClaimsSet)5 SignedJWT (com.nimbusds.jwt.SignedJWT)5 ArrayList (java.util.ArrayList)5 ComponentInitializationException (net.shibboleth.utilities.java.support.component.ComponentInitializationException)5 JOSEException (com.nimbusds.jose.JOSEException)4 URL (java.net.URL)4 HTTPRequest (com.nimbusds.oauth2.sdk.http.HTTPRequest)3 HTTPResponse (com.nimbusds.oauth2.sdk.http.HTTPResponse)3 AccessToken (com.nimbusds.oauth2.sdk.token.AccessToken)3