Search in sources :

Example 26 with RegisterClient

use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.

the class RegistrationRestWebServiceHttpTest method requestClientRegistrationFail3.

@Test
public void requestClientRegistrationFail3() throws Exception {
    showTitle("requestClientRegistrationFail3");
    RegisterClient registerClient = new RegisterClient(registrationEndpoint);
    RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", Arrays.asList("https://client.example.com/cb#fail_fragment"));
    showClient(registerClient);
    assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity());
    assertNotNull(response.getEntity(), "The entity is null");
    assertNotNull(response.getErrorType(), "The error type is null");
    assertNotNull(response.getErrorDescription(), "The error description is null");
}
Also used : RegisterResponse(org.xdi.oxauth.client.RegisterResponse) RegisterClient(org.xdi.oxauth.client.RegisterClient) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 27 with RegisterClient

use of org.xdi.oxauth.client.RegisterClient in project oxAuth by GluuFederation.

the class RegistrationRestWebServiceHttpTest method requestClientRegistrationFail2.

@Test
public void requestClientRegistrationFail2() throws Exception {
    showTitle("requestClientRegistrationFail2");
    RegisterClient registerClient = new RegisterClient(registrationEndpoint);
    // Missing redirect URIs
    RegisterResponse response = registerClient.execRegister(ApplicationType.WEB, "oxAuth test app", null);
    showClient(registerClient);
    assertEquals(response.getStatus(), 400, "Unexpected response code: " + response.getEntity());
    assertNotNull(response.getEntity(), "The entity is null");
    assertNotNull(response.getErrorType(), "The error type is null");
    assertNotNull(response.getErrorDescription(), "The error description is null");
}
Also used : RegisterResponse(org.xdi.oxauth.client.RegisterResponse) RegisterClient(org.xdi.oxauth.client.RegisterClient) Test(org.testng.annotations.Test) BaseTest(org.xdi.oxauth.BaseTest)

Example 28 with RegisterClient

use of org.xdi.oxauth.client.RegisterClient in project oxTrust by GluuFederation.

the class OpenIdClient method registerOpenIdClient.

private RegisterResponse registerOpenIdClient() {
    logger.info("Registering OpenId client");
    String clientName = this.appConfiguration.getApplicationName() + " client";
    RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, clientName, Arrays.asList(this.appConfiguration.getOpenIdRedirectUrl()));
    registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256);
    registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_BASIC);
    RegisterClient registerClient = new RegisterClient(openIdConfiguration.getRegistrationEndpoint());
    registerClient.setRequest(registerRequest);
    RegisterResponse response = registerClient.exec();
    if ((response == null) || (response.getStatus() != 200)) {
        throw new ConfigurationException("Failed to register new client");
    }
    return response;
}
Also used : RegisterRequest(org.xdi.oxauth.client.RegisterRequest) RegisterResponse(org.xdi.oxauth.client.RegisterResponse) ConfigurationException(org.xdi.util.exception.ConfigurationException) RegisterClient(org.xdi.oxauth.client.RegisterClient)

Aggregations

RegisterClient (org.xdi.oxauth.client.RegisterClient)28 RegisterResponse (org.xdi.oxauth.client.RegisterResponse)27 Test (org.testng.annotations.Test)24 BaseTest (org.xdi.oxauth.BaseTest)24 RegisterRequest (org.xdi.oxauth.client.RegisterRequest)24 Parameters (org.testng.annotations.Parameters)18 ResponseType (org.xdi.oxauth.model.common.ResponseType)5 ArrayList (java.util.ArrayList)2 JSONArray (org.codehaus.jettison.json.JSONArray)1 BeforeClass (org.testng.annotations.BeforeClass)1 AuthorizationRequest (org.xdi.oxauth.client.AuthorizationRequest)1 AuthorizationResponse (org.xdi.oxauth.client.AuthorizationResponse)1 AuthorizeClient (org.xdi.oxauth.client.AuthorizeClient)1 TokenClient (org.xdi.oxauth.client.TokenClient)1 TokenRequest (org.xdi.oxauth.client.TokenRequest)1 TokenResponse (org.xdi.oxauth.client.TokenResponse)1 ConfigurationException (org.xdi.util.exception.ConfigurationException)1