Search in sources :

Example 6 with RegisterRequest

use of org.gluu.oxauth.client.RegisterRequest in project oxAuth by GluuFederation.

the class RequestObjectSigningAlgRestrictionEmbeddedTest method requestObjectSigningAlgHS512Step1.

/**
 * Read client to check whether it is using the Request Object Signing Alg
 * <code>HS384</code>.
 */
/**
 * Request authorization with Request Object Signing Alg <code>HS384</code>.
 */
/**
 * Fail 1: Request authorization with Request Object Signing Alg
 * <code>NONE</code>.
 */
/**
 * Fail 2: Request authorization with Request Object Signing Alg
 * <code>HS256</code>.
 */
/**
 * Fail 3: Request authorization with Request Object Signing Alg
 * <code>HS512</code>.
 */
/**
 * Fail 4: Request authorization with Request Object Signing Alg
 * <code>RS256</code>.
 */
/**
 * Fail 5: Request authorization with Request Object Signing Alg
 * <code>RS384</code>.
 */
/**
 * Fail 6: Request authorization with Request Object Signing Alg
 * <code>RS512</code>.
 */
/**
 * Fail 7: Request authorization with Request Object Signing Alg
 * <code>ES256</code>.
 */
/**
 * Fail 8: Request authorization with Request Object Signing Alg
 * <code>ES384</code>.
 */
/**
 * Fail 9: Request authorization with Request Object Signing Alg
 * <code>ES512</code>.
 */
/**
 * Register a client with Request Object Signing Alg <code>HS512</code>.
 */
@Parameters({ "registerPath", "redirectUris" })
@Test
public void requestObjectSigningAlgHS512Step1(final String registerPath, final String redirectUris) throws Exception {
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
    String registerRequestContent = null;
    try {
        RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
        registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.HS512);
        registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN));
        registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
        registerRequestContent = ServerUtil.toPrettyJson(registerRequest.getJSONParameters());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Response response = request.post(Entity.json(registerRequestContent));
    String entity = response.readEntity(String.class);
    showResponse("requestObjectSigningAlgHS512Step1", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
    assertNotNull(entity, "Unexpected result: " + entity);
    try {
        JSONObject jsonObj = new JSONObject(entity);
        assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
        assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
        assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
        assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
        clientId5 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
        clientSecret5 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
        registrationAccessToken5 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage() + "\nResponse was: " + entity);
    }
}
Also used : Response(javax.ws.rs.core.Response) RegisterRequest(org.gluu.oxauth.client.RegisterRequest) JSONObject(org.json.JSONObject) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 7 with RegisterRequest

use of org.gluu.oxauth.client.RegisterRequest in project oxAuth by GluuFederation.

the class RequestObjectSigningAlgRestrictionEmbeddedTest method requestObjectSigningAlgRS512Step1.

/**
 * Read client to check whether it is using the Request Object Signing Alg
 * <code>RS384</code>.
 */
/**
 * Request authorization with Request Object Signing Alg <code>RS384</code>.
 */
/**
 * Fail 1: Request authorization with Request Object Signing Alg
 * <code>NONE</code>.
 */
/**
 * Fail 2: Request authorization with Request Object Signing Alg
 * <code>HS256</code>.
 */
/**
 * Fail 3: Request authorization with Request Object Signing Alg
 * <code>HS384</code>.
 */
/**
 * Fail 4: Request authorization with Request Object Signing Alg
 * <code>HS512</code>.
 */
/**
 * Fail 5: Request authorization with Request Object Signing Alg
 * <code>RS256</code>.
 */
/**
 * Fail 6: Request authorization with Request Object Signing Alg
 * <code>RS512</code>.
 */
/**
 * Fail 7: Request authorization with Request Object Signing Alg
 * <code>ES256</code>.
 */
/**
 * Fail 8: Request authorization with Request Object Signing Alg
 * <code>ES384</code>.
 */
/**
 * Fail 9: Request authorization with Request Object Signing Alg
 * <code>ES512</code>.
 */
/**
 * Register a client with Request Object Signing Alg <code>RS512</code>.
 */
@Parameters({ "registerPath", "redirectUris", "clientJwksUri" })
@Test
public void requestObjectSigningAlgRS512Step1(final String registerPath, final String redirectUris, final String jwksUri) throws Exception {
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
    String registerRequestContent = null;
    try {
        RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
        registerRequest.setJwksUri(jwksUri);
        registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS512);
        registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN));
        registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
        registerRequestContent = ServerUtil.toPrettyJson(registerRequest.getJSONParameters());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Response response = request.post(Entity.json(registerRequestContent));
    String entity = response.readEntity(String.class);
    showResponse("requestObjectSigningAlgRS512Step1", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
    assertNotNull(entity, "Unexpected result: " + entity);
    try {
        JSONObject jsonObj = new JSONObject(entity);
        assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
        assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
        assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
        assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
        clientId8 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
        clientSecret8 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
        registrationAccessToken8 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage() + "\nResponse was: " + entity);
    }
}
Also used : Response(javax.ws.rs.core.Response) RegisterRequest(org.gluu.oxauth.client.RegisterRequest) JSONObject(org.json.JSONObject) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 8 with RegisterRequest

use of org.gluu.oxauth.client.RegisterRequest in project oxAuth by GluuFederation.

the class RequestObjectSigningAlgRestrictionEmbeddedTest method requestObjectSigningAlgES256Step1.

/**
 * Read client to check whether it is using the Request Object Signing Alg
 * <code>RS512</code>.
 */
/**
 * Request authorization with Request Object Signing Alg <code>RS512</code>.
 */
/**
 * Fail 1: Request authorization with Request Object Signing Alg
 * <code>NONE</code>.
 */
/**
 * Fail 2: Request authorization with Request Object Signing Alg
 * <code>HS256</code>.
 */
/**
 * Fail 3: Request authorization with Request Object Signing Alg
 * <code>HS384</code>.
 */
/**
 * Fail 4: Request authorization with Request Object Signing Alg
 * <code>HS512</code>.
 */
/**
 * Fail 5: Request authorization with Request Object Signing Alg
 * <code>RS256</code>.
 */
/**
 * Fail 6: Request authorization with Request Object Signing Alg
 * <code>RS384</code>.
 */
/**
 * Fail 7: Request authorization with Request Object Signing Alg
 * <code>ES256</code>.
 */
/**
 * Fail 8: Request authorization with Request Object Signing Alg
 * <code>ES384</code>.
 */
/**
 * Fail 9: Request authorization with Request Object Signing Alg
 * <code>ES512</code>.
 */
/**
 * Register a client with Request Object Signing Alg <code>ES256</code>.
 */
@Parameters({ "registerPath", "redirectUris", "clientJwksUri" })
@Test
public void requestObjectSigningAlgES256Step1(final String registerPath, final String redirectUris, final String jwksUri) throws Exception {
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
    String registerRequestContent = null;
    try {
        RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
        registerRequest.setJwksUri(jwksUri);
        registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.ES256);
        registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN));
        registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
        registerRequestContent = ServerUtil.toPrettyJson(registerRequest.getJSONParameters());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Response response = request.post(Entity.json(registerRequestContent));
    String entity = response.readEntity(String.class);
    showResponse("requestObjectSigningAlgES256Step1", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
    assertNotNull(entity, "Unexpected result: " + entity);
    try {
        JSONObject jsonObj = new JSONObject(entity);
        assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
        assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
        assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
        assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
        clientId9 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
        clientSecret9 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
        registrationAccessToken9 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage() + "\nResponse was: " + entity);
    }
}
Also used : Response(javax.ws.rs.core.Response) RegisterRequest(org.gluu.oxauth.client.RegisterRequest) JSONObject(org.json.JSONObject) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 9 with RegisterRequest

use of org.gluu.oxauth.client.RegisterRequest in project oxAuth by GluuFederation.

the class RequestObjectSigningAlgRestrictionEmbeddedTest method requestObjectSigningAlgHS384Step1.

/**
 * Read client to check whether it is using the Request Object Signing Alg
 * <code>HS256</code>.
 */
/**
 * Request authorization with Request Object Signing Alg <code>HS256</code>.
 */
/**
 * Fail 1: Request authorization with Request Object Signing Alg
 * <code>NONE</code>.
 */
/**
 * Fail 2: Request authorization with Request Object Signing Alg
 * <code>HS384</code>.
 */
/**
 * Fail 3: Request authorization with Request Object Signing Alg
 * <code>HS512</code>.
 */
/**
 * Fail 4: Request authorization with Request Object Signing Alg
 * <code>RS256</code>.
 */
/**
 * Fail 5: Request authorization with Request Object Signing Alg
 * <code>RS384</code>.
 */
/**
 * Fail 6: Request authorization with Request Object Signing Alg
 * <code>RS512</code>.
 */
/**
 * Fail 7: Request authorization with Request Object Signing Alg
 * <code>ES256</code>.
 */
/**
 * Fail 8: Request authorization with Request Object Signing Alg
 * <code>ES384</code>.
 */
/**
 * Fail 9: Request authorization with Request Object Signing Alg
 * <code>ES512</code>.
 */
/**
 * Register a client with Request Object Signing Alg <code>HS384</code>.
 */
@Parameters({ "registerPath", "redirectUris" })
@Test
public void requestObjectSigningAlgHS384Step1(final String registerPath, final String redirectUris) throws Exception {
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
    String registerRequestContent = null;
    try {
        RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
        registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.HS384);
        registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN));
        registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
        registerRequestContent = ServerUtil.toPrettyJson(registerRequest.getJSONParameters());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Response response = request.post(Entity.json(registerRequestContent));
    String entity = response.readEntity(String.class);
    showResponse("requestObjectSigningAlgHS384Step1", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
    assertNotNull(entity, "Unexpected result: " + entity);
    try {
        JSONObject jsonObj = new JSONObject(entity);
        assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
        assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
        assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
        assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
        clientId4 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
        clientSecret4 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
        registrationAccessToken4 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage() + "\nResponse was: " + entity);
    }
}
Also used : Response(javax.ws.rs.core.Response) RegisterRequest(org.gluu.oxauth.client.RegisterRequest) JSONObject(org.json.JSONObject) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Example 10 with RegisterRequest

use of org.gluu.oxauth.client.RegisterRequest in project oxAuth by GluuFederation.

the class RequestObjectSigningAlgRestrictionEmbeddedTest method requestObjectSigningAlgNoneStep1.

/**
 * Register a client with Request Object Signing Alg <code>NONE</code>.
 */
@Parameters({ "registerPath", "redirectUris", "clientJwksUri" })
@Test
public void requestObjectSigningAlgNoneStep1(final String registerPath, final String redirectUris, final String jwksUri) throws Exception {
    Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request();
    String registerRequestContent = null;
    try {
        RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris));
        registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.NONE);
        registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN));
        registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
        registerRequestContent = ServerUtil.toPrettyJson(registerRequest.getJSONParameters());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Response response = request.post(Entity.json(registerRequestContent));
    String entity = response.readEntity(String.class);
    showResponse("requestObjectSigningAlgNoneStep1", response, entity);
    assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity);
    assertNotNull(entity, "Unexpected result: " + entity);
    try {
        JSONObject jsonObj = new JSONObject(entity);
        assertTrue(jsonObj.has(RegisterResponseParam.CLIENT_ID.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET.toString()));
        assertTrue(jsonObj.has(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString()));
        assertTrue(jsonObj.has(REGISTRATION_CLIENT_URI.toString()));
        assertTrue(jsonObj.has(CLIENT_ID_ISSUED_AT.toString()));
        assertTrue(jsonObj.has(CLIENT_SECRET_EXPIRES_AT.toString()));
        clientId2 = jsonObj.getString(RegisterResponseParam.CLIENT_ID.toString());
        clientSecret2 = jsonObj.getString(RegisterResponseParam.CLIENT_SECRET.toString());
        registrationAccessToken2 = jsonObj.getString(RegisterResponseParam.REGISTRATION_ACCESS_TOKEN.toString());
        registrationClientUri2 = jsonObj.getString(RegisterResponseParam.REGISTRATION_CLIENT_URI.toString());
    } catch (JSONException e) {
        e.printStackTrace();
        fail(e.getMessage() + "\nResponse was: " + entity);
    }
}
Also used : Response(javax.ws.rs.core.Response) RegisterRequest(org.gluu.oxauth.client.RegisterRequest) JSONObject(org.json.JSONObject) ResteasyClientBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder) Builder(javax.ws.rs.client.Invocation.Builder) JSONException(org.json.JSONException) Parameters(org.testng.annotations.Parameters) BaseTest(org.gluu.oxauth.BaseTest) Test(org.testng.annotations.Test)

Aggregations

RegisterRequest (org.gluu.oxauth.client.RegisterRequest)824 Test (org.testng.annotations.Test)793 BaseTest (org.gluu.oxauth.BaseTest)789 Parameters (org.testng.annotations.Parameters)781 RegisterResponse (org.gluu.oxauth.client.RegisterResponse)757 RegisterClient (org.gluu.oxauth.client.RegisterClient)753 ResponseType (org.gluu.oxauth.model.common.ResponseType)528 AuthorizationResponse (org.gluu.oxauth.client.AuthorizationResponse)500 AuthorizationRequest (org.gluu.oxauth.client.AuthorizationRequest)483 OxAuthCryptoProvider (org.gluu.oxauth.model.crypto.OxAuthCryptoProvider)313 TokenClient (org.gluu.oxauth.client.TokenClient)222 TokenResponse (org.gluu.oxauth.client.TokenResponse)222 TokenRequest (org.gluu.oxauth.client.TokenRequest)212 AuthorizeClient (org.gluu.oxauth.client.AuthorizeClient)198 UserInfoResponse (org.gluu.oxauth.client.UserInfoResponse)163 UserInfoClient (org.gluu.oxauth.client.UserInfoClient)162 JwtAuthorizationRequest (org.gluu.oxauth.client.model.authorize.JwtAuthorizationRequest)162 Jwt (org.gluu.oxauth.model.jwt.Jwt)156 BackchannelAuthenticationClient (org.gluu.oxauth.client.BackchannelAuthenticationClient)105 BackchannelAuthenticationRequest (org.gluu.oxauth.client.BackchannelAuthenticationRequest)105