Search in sources :

Example 91 with ResponseType

use of io.jans.as.model.common.ResponseType in project jans by JanssenProject.

the class AuthorizationResponseModeJwtResponseTypeTokenIdTokenSignedHttpTest method authorizationRequestObjectES384.

@Parameters({ "userId", "userSecret", "redirectUri", "redirectUris", "clientJwksUri", "ES384_keyId", "dnName", "keyStoreFile", "keyStoreSecret", "sectorIdentifierUri" })
@Test
public void authorizationRequestObjectES384(final String userId, final String userSecret, final String redirectUri, final String redirectUris, final String clientJwksUri, final String keyId, final String dnName, final String keyStoreFile, final String keyStoreSecret, final String sectorIdentifierUri) throws Exception {
    showTitle("requestParameterMethodES384");
    List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
    // 1. Dynamic Client Registration
    RegisterResponse registerResponse = registerClient(redirectUris, responseTypes, sectorIdentifierUri, clientJwksUri, SignatureAlgorithm.ES384, null, null);
    String clientId = registerResponse.getClientId();
    // 2. Request authorization
    AuthCryptoProvider cryptoProvider = new AuthCryptoProvider(keyStoreFile, keyStoreSecret, dnName);
    List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    AuthorizationRequest request = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, nonce);
    request.setResponseMode(ResponseMode.JWT);
    request.setState(state);
    JwtAuthorizationRequest jwtAuthorizationRequest = new JwtAuthorizationRequest(request, SignatureAlgorithm.ES384, cryptoProvider);
    jwtAuthorizationRequest.setKeyId(keyId);
    jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NAME, ClaimValue.createNull()));
    jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.NICKNAME, ClaimValue.createEssential(false)));
    jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL, ClaimValue.createNull()));
    jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.EMAIL_VERIFIED, ClaimValue.createNull()));
    jwtAuthorizationRequest.addUserInfoClaim(new Claim(JwtClaimName.PICTURE, ClaimValue.createEssential(false)));
    jwtAuthorizationRequest.addIdTokenClaim(new Claim(JwtClaimName.AUTHENTICATION_TIME, ClaimValue.createNull()));
    jwtAuthorizationRequest.getIdTokenMember().setMaxAge(86400);
    String authJwt = jwtAuthorizationRequest.getEncodedJwt();
    request.setRequest(authJwt);
    AuthorizationResponse authorizationResponse = authorizationRequest(request, ResponseMode.FRAGMENT_JWT, userId, userSecret);
    String accessToken = authorizationResponse.getAccessToken();
    // 3. Request user info
    UserInfoRequest userInfoRequest = new UserInfoRequest(accessToken);
    UserInfoClient userInfoClient = new UserInfoClient(userInfoEndpoint);
    userInfoClient.setRequest(userInfoRequest);
    userInfoClient.setJwksUri(jwksUri);
    UserInfoResponse userInfoResponse = userInfoClient.exec();
    showClient(userInfoClient);
    assertUserInfoBasicResponseOk(userInfoResponse, 200);
    assertUserInfoPersonalDataNotNull(userInfoResponse);
}
Also used : AuthorizationRequest(io.jans.as.client.AuthorizationRequest) JwtAuthorizationRequest(io.jans.as.client.model.authorize.JwtAuthorizationRequest) UserInfoRequest(io.jans.as.client.UserInfoRequest) UserInfoClient(io.jans.as.client.UserInfoClient) ResponseType(io.jans.as.model.common.ResponseType) AuthorizationResponse(io.jans.as.client.AuthorizationResponse) RegisterResponse(io.jans.as.client.RegisterResponse) JwtAuthorizationRequest(io.jans.as.client.model.authorize.JwtAuthorizationRequest) UserInfoResponse(io.jans.as.client.UserInfoResponse) AuthCryptoProvider(io.jans.as.model.crypto.AuthCryptoProvider) Claim(io.jans.as.client.model.authorize.Claim) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 92 with ResponseType

use of io.jans.as.model.common.ResponseType in project jans by JanssenProject.

the class AuthorizationResponseModeJwtResponseTypeTokenIdTokenSignedHttpTest method testRS256.

@Parameters({ "userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri" })
@Test
public void testRS256(final String userId, final String userSecret, final String redirectUris, final String redirectUri, final String sectorIdentifierUri) throws Exception {
    showTitle("testRS256");
    List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
    // 1. Register client
    RegisterResponse registerResponse = registerClient(redirectUris, responseTypes, sectorIdentifierUri, null, SignatureAlgorithm.RS256, null, null);
    String clientId = registerResponse.getClientId();
    sharedKey = registerResponse.getClientSecret();
    // 2. Request authorization
    List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    authorizationRequest(responseTypes, ResponseMode.JWT, ResponseMode.FRAGMENT_JWT, clientId, scopes, redirectUri, nonce, state, userId, userSecret);
}
Also used : RegisterResponse(io.jans.as.client.RegisterResponse) ResponseType(io.jans.as.model.common.ResponseType) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 93 with ResponseType

use of io.jans.as.model.common.ResponseType in project jans by JanssenProject.

the class AuthorizationResponseModeJwtResponseTypeTokenIdTokenSignedHttpTest method testRS384.

@Parameters({ "userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri" })
@Test
public void testRS384(final String userId, final String userSecret, final String redirectUris, final String redirectUri, final String sectorIdentifierUri) throws Exception {
    showTitle("testRS384");
    List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
    // 1. Register client
    RegisterResponse registerResponse = registerClient(redirectUris, responseTypes, sectorIdentifierUri, null, SignatureAlgorithm.RS384, null, null);
    String clientId = registerResponse.getClientId();
    sharedKey = registerResponse.getClientSecret();
    // 2. Request authorization
    List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    authorizationRequest(responseTypes, ResponseMode.JWT, ResponseMode.FRAGMENT_JWT, clientId, scopes, redirectUri, nonce, state, userId, userSecret);
}
Also used : RegisterResponse(io.jans.as.client.RegisterResponse) ResponseType(io.jans.as.model.common.ResponseType) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 94 with ResponseType

use of io.jans.as.model.common.ResponseType in project jans by JanssenProject.

the class AuthorizationResponseModeJwtResponseTypeTokenIdTokenSignedHttpTest method testHS512.

@Parameters({ "userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri" })
@Test
public void testHS512(final String userId, final String userSecret, final String redirectUris, final String redirectUri, final String sectorIdentifierUri) throws Exception {
    showTitle("testHS512");
    List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
    // 1. Register client
    RegisterResponse registerResponse = registerClient(redirectUris, responseTypes, sectorIdentifierUri, null, SignatureAlgorithm.HS512, null, null);
    String clientId = registerResponse.getClientId();
    sharedKey = registerResponse.getClientSecret();
    // 2. Request authorization
    List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    authorizationRequest(responseTypes, ResponseMode.JWT, ResponseMode.FRAGMENT_JWT, clientId, scopes, redirectUri, nonce, state, userId, userSecret);
}
Also used : RegisterResponse(io.jans.as.client.RegisterResponse) ResponseType(io.jans.as.model.common.ResponseType) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Example 95 with ResponseType

use of io.jans.as.model.common.ResponseType in project jans by JanssenProject.

the class AuthorizationResponseModeJwtResponseTypeTokenIdTokenSignedHttpTest method testES256.

@Parameters({ "userId", "userSecret", "redirectUris", "redirectUri", "sectorIdentifierUri" })
@Test
public void testES256(final String userId, final String userSecret, final String redirectUris, final String redirectUri, final String sectorIdentifierUri) throws Exception {
    showTitle("testES256");
    List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN);
    // 1. Register client
    RegisterResponse registerResponse = registerClient(redirectUris, responseTypes, sectorIdentifierUri, null, SignatureAlgorithm.ES256, null, null);
    String clientId = registerResponse.getClientId();
    sharedKey = registerResponse.getClientSecret();
    // 2. Request authorization
    List<String> scopes = Arrays.asList("openid", "profile", "address", "email");
    String nonce = UUID.randomUUID().toString();
    String state = UUID.randomUUID().toString();
    authorizationRequest(responseTypes, ResponseMode.JWT, ResponseMode.FRAGMENT_JWT, clientId, scopes, redirectUri, nonce, state, userId, userSecret);
}
Also used : RegisterResponse(io.jans.as.client.RegisterResponse) ResponseType(io.jans.as.model.common.ResponseType) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.client.BaseTest) Test(org.testng.annotations.Test)

Aggregations

ResponseType (io.jans.as.model.common.ResponseType)1468 Test (org.testng.annotations.Test)1448 Parameters (org.testng.annotations.Parameters)1447 BaseTest (io.jans.as.client.BaseTest)1314 RegisterResponse (io.jans.as.client.RegisterResponse)1309 AuthorizationRequest (io.jans.as.client.AuthorizationRequest)972 AuthorizationResponse (io.jans.as.client.AuthorizationResponse)726 JwtAuthorizationRequest (io.jans.as.client.model.authorize.JwtAuthorizationRequest)667 AuthCryptoProvider (io.jans.as.model.crypto.AuthCryptoProvider)661 RegisterRequest (io.jans.as.client.RegisterRequest)537 RegisterClient (io.jans.as.client.RegisterClient)507 Claim (io.jans.as.client.model.authorize.Claim)470 AuthorizeClient (io.jans.as.client.AuthorizeClient)198 Jwt (io.jans.as.model.jwt.Jwt)189 UserInfoResponse (io.jans.as.client.UserInfoResponse)188 UserInfoClient (io.jans.as.client.UserInfoClient)187 TokenResponse (io.jans.as.client.TokenResponse)185 TokenClient (io.jans.as.client.TokenClient)176 TokenRequest (io.jans.as.client.TokenRequest)165 JSONObject (org.json.JSONObject)138