Search in sources :

Example 16 with OpenIdConnectDiscoveryRequest

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

the class CanDiscoverIdentifiersUsingUrlSyntax method hostNormalization1.

@Test
public void hostNormalization1() throws Exception {
    String resource = "example.com";
    String expectedHost = "example.com";
    String expectedPath = null;
    OpenIdConnectDiscoveryRequest openIdConnectDiscoveryRequest = new OpenIdConnectDiscoveryRequest(resource);
    assertEquals(openIdConnectDiscoveryRequest.getResource(), resource);
    assertEquals(openIdConnectDiscoveryRequest.getHost(), expectedHost);
    assertEquals(openIdConnectDiscoveryRequest.getPath(), expectedPath);
}
Also used : OpenIdConnectDiscoveryRequest(org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest) Test(org.testng.annotations.Test)

Example 17 with OpenIdConnectDiscoveryRequest

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

the class CanDiscoverIdentifiersUsingUrlSyntax method urlNormalization5.

@Test
public void urlNormalization5() throws Exception {
    String resource = "https://example.com:8080/joe#fragment";
    String expectedHost = "example.com:8080";
    String expectedPath = "/joe";
    OpenIdConnectDiscoveryRequest openIdConnectDiscoveryRequest = new OpenIdConnectDiscoveryRequest(resource);
    assertEquals(openIdConnectDiscoveryRequest.getResource(), resource);
    assertEquals(openIdConnectDiscoveryRequest.getHost(), expectedHost);
    assertEquals(openIdConnectDiscoveryRequest.getPath(), expectedPath);
}
Also used : OpenIdConnectDiscoveryRequest(org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest) Test(org.testng.annotations.Test)

Example 18 with OpenIdConnectDiscoveryRequest

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

the class CanDiscoverIdentifiersUsingUrlSyntax method urlNormalization4.

@Test
public void urlNormalization4() throws Exception {
    String resource = "https://example.com:8080/joe";
    String expectedHost = "example.com:8080";
    String expectedPath = "/joe";
    OpenIdConnectDiscoveryRequest openIdConnectDiscoveryRequest = new OpenIdConnectDiscoveryRequest(resource);
    assertEquals(openIdConnectDiscoveryRequest.getResource(), resource);
    assertEquals(openIdConnectDiscoveryRequest.getHost(), expectedHost);
    assertEquals(openIdConnectDiscoveryRequest.getPath(), expectedPath);
}
Also used : OpenIdConnectDiscoveryRequest(org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest) Test(org.testng.annotations.Test)

Example 19 with OpenIdConnectDiscoveryRequest

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

the class OpenIdConnectDiscoveryAction method exec.

public void exec() {
    try {
        ClientExecutor clientExecutor = null;
        if (acceptUntrustedCertificate) {
            HttpClient httpClient = new SslDefaultHttpClient(new TrustAllTrustManager());
            clientExecutor = new ApacheHttpClient4Executor(httpClient);
        }
        OpenIdConnectDiscoveryRequest openIdConnectDiscoveryRequest = new OpenIdConnectDiscoveryRequest(resource);
        host = openIdConnectDiscoveryRequest.getHost();
        rel = REL_VALUE;
        OpenIdConnectDiscoveryClient openIdConnectDiscoveryClient = new OpenIdConnectDiscoveryClient(resource);
        OpenIdConnectDiscoveryResponse openIdConnectDiscoveryResponse;
        if (clientExecutor == null) {
            openIdConnectDiscoveryResponse = openIdConnectDiscoveryClient.exec();
        } else {
            openIdConnectDiscoveryResponse = openIdConnectDiscoveryClient.exec(clientExecutor);
        }
        showResults = true;
        requestString1 = openIdConnectDiscoveryClient.getRequestAsString();
        responseString1 = openIdConnectDiscoveryClient.getResponseAsString();
        if (openIdConnectDiscoveryResponse.getStatus() == 200) {
            String openIdConfigurationUrl = openIdConnectDiscoveryResponse.getLinks().get(0).getHref() + "/.well-known/openid-configuration";
            OpenIdConfigurationClient openIdConfigurationClient = new OpenIdConfigurationClient(openIdConfigurationUrl);
            OpenIdConfigurationResponse openIdConfigurationResponse;
            if (clientExecutor == null) {
                openIdConfigurationResponse = openIdConfigurationClient.execOpenIdConfiguration();
            } else {
                openIdConfigurationResponse = openIdConfigurationClient.execOpenIdConfiguration(clientExecutor);
            }
            requestString2 = openIdConfigurationClient.getRequestAsString();
            responseString2 = openIdConfigurationClient.getResponseAsString();
            registrationAction.setRegistrationEndpoint(openIdConfigurationResponse.getRegistrationEndpoint());
            authorizationAction.setAuthorizationEndpoint(openIdConfigurationResponse.getAuthorizationEndpoint());
            authorizationAction.setJwksUri(openIdConfigurationResponse.getJwksUri());
            tokenAction.setTokenEndpoint(openIdConfigurationResponse.getTokenEndpoint());
            userInfoAction.setUserInfoEndpoint(openIdConfigurationResponse.getUserInfoEndpoint());
            checkSessionAction.setCheckSessionEndpoint(openIdConfigurationResponse.getCheckSessionIFrame());
            endSessionAction.setEndSessionEndpoint(openIdConfigurationResponse.getEndSessionEndpoint());
        }
    } catch (IllegalArgumentException e) {
        log.error(e.getMessage(), e);
    } catch (URISyntaxException e) {
        log.error(e.getMessage(), e);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : SslDefaultHttpClient(org.xdi.net.SslDefaultHttpClient) ApacheHttpClient4Executor(org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor) OpenIdConnectDiscoveryClient(org.xdi.oxauth.client.OpenIdConnectDiscoveryClient) ClientExecutor(org.jboss.resteasy.client.ClientExecutor) OpenIdConnectDiscoveryResponse(org.xdi.oxauth.client.OpenIdConnectDiscoveryResponse) TrustAllTrustManager(org.xdi.net.TrustAllTrustManager) URISyntaxException(java.net.URISyntaxException) URISyntaxException(java.net.URISyntaxException) OpenIdConnectDiscoveryRequest(org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest) OpenIdConfigurationClient(org.xdi.oxauth.client.OpenIdConfigurationClient) SslDefaultHttpClient(org.xdi.net.SslDefaultHttpClient) HttpClient(org.apache.http.client.HttpClient) OpenIdConfigurationResponse(org.xdi.oxauth.client.OpenIdConfigurationResponse)

Example 20 with OpenIdConnectDiscoveryRequest

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

the class CanDiscoverIdentifiersUsingEMailSyntax method emailNormalization1.

@Test
public void emailNormalization1() throws Exception {
    String resource = "acct:joe@example.com";
    String expectedHost = "example.com";
    String expectedPath = null;
    OpenIdConnectDiscoveryRequest openIdConnectDiscoveryRequest = new OpenIdConnectDiscoveryRequest(resource);
    assertEquals(openIdConnectDiscoveryRequest.getResource(), resource);
    assertEquals(openIdConnectDiscoveryRequest.getHost(), expectedHost);
    assertEquals(openIdConnectDiscoveryRequest.getPath(), expectedPath);
}
Also used : OpenIdConnectDiscoveryRequest(org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest) Test(org.testng.annotations.Test)

Aggregations

OpenIdConnectDiscoveryRequest (org.xdi.oxauth.client.OpenIdConnectDiscoveryRequest)35 Test (org.testng.annotations.Test)34 BaseTest (org.xdi.oxauth.BaseTest)17 URISyntaxException (java.net.URISyntaxException)1 HttpClient (org.apache.http.client.HttpClient)1 ClientExecutor (org.jboss.resteasy.client.ClientExecutor)1 ApacheHttpClient4Executor (org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor)1 SslDefaultHttpClient (org.xdi.net.SslDefaultHttpClient)1 TrustAllTrustManager (org.xdi.net.TrustAllTrustManager)1 OpenIdConfigurationClient (org.xdi.oxauth.client.OpenIdConfigurationClient)1 OpenIdConfigurationResponse (org.xdi.oxauth.client.OpenIdConfigurationResponse)1 OpenIdConnectDiscoveryClient (org.xdi.oxauth.client.OpenIdConnectDiscoveryClient)1 OpenIdConnectDiscoveryResponse (org.xdi.oxauth.client.OpenIdConnectDiscoveryResponse)1