Search in sources :

Example 1 with GetIssuerResponse

use of io.jans.ca.common.response.GetIssuerResponse in project jans by JanssenProject.

the class GetIssuerOperation method execute.

public IOpResponse execute(GetIssuerParams params) {
    validateParams(params);
    GetIssuerResponse webfingerResponse = getWebfingerResponse(params.getResource());
    String issuerFromDiscovery = getDiscoveryService().getConnectDiscoveryResponse(params.getOpConfigurationEndpoint(), params.getOpHost(), params.getOpDiscoveryPath()).getIssuer();
    validateIssuer(webfingerResponse, issuerFromDiscovery);
    return webfingerResponse;
}
Also used : GetIssuerResponse(io.jans.ca.common.response.GetIssuerResponse)

Example 2 with GetIssuerResponse

use of io.jans.ca.common.response.GetIssuerResponse in project jans by JanssenProject.

the class GetIssuerTest method hostnameInputTest.

@Parameters({ "host", "opHost", "hostnameWebfingerInput" })
@Test
public void hostnameInputTest(String host, String opHost, String hostnameWebfingerInput) {
    ClientInterface client = Tester.newClient(host);
    final GetIssuerParams params = new GetIssuerParams();
    params.setResource(hostnameWebfingerInput);
    params.setOpHost(opHost);
    final GetIssuerResponse resp = client.getIssuer(params);
    assertNotNull(resp);
    assertEquals(resp.getSubject(), hostnameWebfingerInput);
    resp.getLinks().forEach((link) -> {
        assertEquals(link.getHref(), opHost);
    });
}
Also used : GetIssuerResponse(io.jans.ca.common.response.GetIssuerResponse) GetIssuerParams(io.jans.ca.common.params.GetIssuerParams) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with GetIssuerResponse

use of io.jans.ca.common.response.GetIssuerResponse in project jans by JanssenProject.

the class GetIssuerTest method emailInputTest.

@Parameters({ "host", "opHost", "emailWebfingerInput" })
@Test(enabled = false)
public void emailInputTest(String host, String opHost, String emailWebfingerInput) {
    ClientInterface client = Tester.newClient(host);
    final GetIssuerParams params = new GetIssuerParams();
    params.setResource(emailWebfingerInput);
    params.setOpHost(opHost);
    final GetIssuerResponse resp = client.getIssuer(params);
    assertNotNull(resp);
    assertEquals(resp.getSubject(), emailWebfingerInput);
    resp.getLinks().forEach((link) -> {
        assertEquals(link.getHref(), opHost);
    });
}
Also used : GetIssuerResponse(io.jans.ca.common.response.GetIssuerResponse) GetIssuerParams(io.jans.ca.common.params.GetIssuerParams) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 4 with GetIssuerResponse

use of io.jans.ca.common.response.GetIssuerResponse in project jans by JanssenProject.

the class GetIssuerTest method urlInputTest.

@Parameters({ "host", "opHost", "urlWebfingerInput" })
@Test(enabled = false)
public void urlInputTest(String host, String opHost, String urlWebfingerInput) {
    ClientInterface client = Tester.newClient(host);
    final GetIssuerParams params = new GetIssuerParams();
    params.setResource(urlWebfingerInput);
    params.setOpHost(opHost);
    final GetIssuerResponse resp = client.getIssuer(params);
    assertNotNull(resp);
    assertEquals(resp.getSubject(), urlWebfingerInput);
    resp.getLinks().forEach((link) -> {
        assertEquals(link.getHref(), opHost);
    });
}
Also used : GetIssuerResponse(io.jans.ca.common.response.GetIssuerResponse) GetIssuerParams(io.jans.ca.common.params.GetIssuerParams) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with GetIssuerResponse

use of io.jans.ca.common.response.GetIssuerResponse in project jans by JanssenProject.

the class GetIssuerOperation method getWebfingerResponse.

private static GetIssuerResponse getWebfingerResponse(String resource) {
    try {
        OpenIdConnectDiscoveryClient client = new OpenIdConnectDiscoveryClient(resource);
        OpenIdConnectDiscoveryResponse response = client.exec();
        if (response == null || Strings.isNullOrEmpty(response.getSubject()) || response.getLinks().isEmpty()) {
            LOG.error("Error in fetching op discovery configuration response ");
            throw new HttpException(ErrorResponseCode.FAILED_TO_GET_ISSUER);
        }
        GetIssuerResponse webfingerResponse = new GetIssuerResponse();
        BeanUtils.copyProperties(webfingerResponse, response);
        return webfingerResponse;
    } catch (Exception e) {
        LOG.error("Error in creating op discovery configuration response ", e);
        throw new HttpException(ErrorResponseCode.FAILED_TO_GET_ISSUER);
    }
}
Also used : OpenIdConnectDiscoveryClient(io.jans.as.client.OpenIdConnectDiscoveryClient) GetIssuerResponse(io.jans.ca.common.response.GetIssuerResponse) OpenIdConnectDiscoveryResponse(io.jans.as.client.OpenIdConnectDiscoveryResponse) HttpException(io.jans.ca.server.HttpException) HttpException(io.jans.ca.server.HttpException)

Aggregations

GetIssuerResponse (io.jans.ca.common.response.GetIssuerResponse)5 ClientInterface (io.jans.ca.client.ClientInterface)3 GetIssuerParams (io.jans.ca.common.params.GetIssuerParams)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 OpenIdConnectDiscoveryClient (io.jans.as.client.OpenIdConnectDiscoveryClient)1 OpenIdConnectDiscoveryResponse (io.jans.as.client.OpenIdConnectDiscoveryResponse)1 HttpException (io.jans.ca.server.HttpException)1