Search in sources :

Example 41 with AuthenticationRequest

use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.

the class AuthCodeHandlerTest method generateAuthRequest.

private static AuthenticationRequest generateAuthRequest(SignedJWT signedJWT) {
    Scope scope = new Scope();
    scope.add(OIDCScopeValue.OPENID);
    AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(ResponseType.CODE, scope, CLIENT_ID, REDIRECT_URI).requestObject(signedJWT);
    return builder.build();
}
Also used : Scope(com.nimbusds.oauth2.sdk.Scope) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest)

Example 42 with AuthenticationRequest

use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.

the class IPVCallbackHandlerTest method generateAuthRequest.

public static AuthenticationRequest generateAuthRequest() {
    ResponseType responseType = new ResponseType(ResponseType.Value.CODE);
    Scope scope = new Scope();
    Nonce nonce = new Nonce();
    scope.add(OIDCScopeValue.OPENID);
    scope.add("phone");
    scope.add("email");
    return new AuthenticationRequest.Builder(responseType, scope, CLIENT_ID, REDIRECT_URI).state(RP_STATE).nonce(nonce).build();
}
Also used : Nonce(com.nimbusds.openid.connect.sdk.Nonce) Scope(com.nimbusds.oauth2.sdk.Scope) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest) ResponseType(com.nimbusds.oauth2.sdk.ResponseType)

Example 43 with AuthenticationRequest

use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project di-authentication-api by alphagov.

the class VerifyCodeIntegrationTest method setUpTestWithoutSignUp.

private void setUpTestWithoutSignUp(String sessionId, Scope scope) throws Json.JsonException {
    redis.addEmailToSession(sessionId, EMAIL_ADDRESS);
    AuthenticationRequest authRequest = new AuthenticationRequest.Builder(ResponseType.CODE, scope, new ClientID(CLIENT_ID), URI.create(REDIRECT_URI)).nonce(new Nonce()).state(new State()).build();
    redis.createClientSession(CLIENT_SESSION_ID, authRequest.toParameters());
    clientStore.registerClient(CLIENT_ID, "test-client", singletonList("redirect-url"), singletonList(EMAIL_ADDRESS), List.of("openid", "email", "phone"), "public-key", singletonList("http://localhost/post-redirect-logout"), "http://example.com", String.valueOf(ServiceType.MANDATORY), "https://test.com", "public", true);
}
Also used : Nonce(com.nimbusds.openid.connect.sdk.Nonce) State(com.nimbusds.oauth2.sdk.id.State) ClientID(com.nimbusds.oauth2.sdk.id.ClientID) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest)

Example 44 with AuthenticationRequest

use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project dataverse by IQSS.

the class OIDCAuthProvider method buildAuthzUrl.

/**
 * Create the authz URL for the OIDC provider
 * @param state A randomized state, necessary to secure the authorization flow. @see OAuth2LoginBackingBean.createState()
 * @param callbackUrl URL where the provider should send the browser after authn in code flow
 * @return
 */
@Override
public String buildAuthzUrl(String state, String callbackUrl) {
    State stateObject = new State(state);
    URI callback = URI.create(callbackUrl);
    Nonce nonce = new Nonce();
    AuthenticationRequest req = new AuthenticationRequest.Builder(new ResponseType("code"), Scope.parse(this.scope), this.clientAuth.getClientID(), callback).endpointURI(idpMetadata.getAuthorizationEndpointURI()).state(stateObject).nonce(nonce).build();
    return req.toURI().toString();
}
Also used : Nonce(com.nimbusds.openid.connect.sdk.Nonce) State(com.nimbusds.oauth2.sdk.id.State) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest) URI(java.net.URI) ResponseType(com.nimbusds.oauth2.sdk.ResponseType)

Example 45 with AuthenticationRequest

use of com.nimbusds.openid.connect.sdk.AuthenticationRequest in project Kustvakt by KorAP.

the class OpenIdAuthorizationService method requestAuthorizationCode.

public URI requestAuthorizationCode(MultivaluedMap<String, String> map, String username, boolean isAuthentication, ZonedDateTime authenticationTime) throws KustvaktException, ParseException {
    AuthorizationCode code = new AuthorizationCode();
    URI redirectUri = null;
    if (isAuthentication) {
        AuthenticationRequest authRequest = null;
        authRequest = AuthenticationRequest.parse((Map<String, List<String>>) map);
        redirectUri = handleAuthenticationRequest(authRequest, code, username, authenticationTime);
        return new AuthenticationSuccessResponse(redirectUri, code, null, null, authRequest.getState(), null, null).toURI();
    } else {
        AuthorizationRequest authzRequest = AuthorizationRequest.parse((Map<String, List<String>>) map);
        redirectUri = handleAuthorizationRequest(authzRequest, code, username, authenticationTime, null);
        return new AuthorizationSuccessResponse(redirectUri, code, null, authzRequest.getState(), null).toURI();
    }
}
Also used : AuthorizationCode(com.nimbusds.oauth2.sdk.AuthorizationCode) AuthorizationRequest(com.nimbusds.oauth2.sdk.AuthorizationRequest) List(java.util.List) AuthorizationSuccessResponse(com.nimbusds.oauth2.sdk.AuthorizationSuccessResponse) AuthenticationRequest(com.nimbusds.openid.connect.sdk.AuthenticationRequest) URI(java.net.URI) Map(java.util.Map) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) AuthenticationSuccessResponse(com.nimbusds.openid.connect.sdk.AuthenticationSuccessResponse)

Aggregations

AuthenticationRequest (com.nimbusds.openid.connect.sdk.AuthenticationRequest)73 Scope (com.nimbusds.oauth2.sdk.Scope)44 ResponseType (com.nimbusds.oauth2.sdk.ResponseType)34 State (com.nimbusds.oauth2.sdk.id.State)29 Nonce (com.nimbusds.openid.connect.sdk.Nonce)27 ClientID (com.nimbusds.oauth2.sdk.id.ClientID)24 Test (org.junit.jupiter.api.Test)19 ErrorObject (com.nimbusds.oauth2.sdk.ErrorObject)16 URI (java.net.URI)16 ParseException (com.nimbusds.oauth2.sdk.ParseException)12 ClientSession (uk.gov.di.authentication.shared.entity.ClientSession)12 AuthorizationCode (com.nimbusds.oauth2.sdk.AuthorizationCode)11 VectorOfTrust (uk.gov.di.authentication.shared.entity.VectorOfTrust)10 AuthenticationSuccessResponse (com.nimbusds.openid.connect.sdk.AuthenticationSuccessResponse)8 APIGatewayProxyResponseEvent (com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 SignedJWT (com.nimbusds.jwt.SignedJWT)5 OIDCClaimsRequest (com.nimbusds.openid.connect.sdk.OIDCClaimsRequest)5 HashMap (java.util.HashMap)5