Search in sources :

Example 1 with GetJwksResponse

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

the class GetJwksOperation method execute.

@Override
public IOpResponse execute(GetJwksParams params) {
    if (StringUtils.isEmpty(params.getOpHost()) && StringUtils.isEmpty(params.getOpConfigurationEndpoint())) {
        throw new HttpException(ErrorResponseCode.INVALID_OP_HOST_AND_CONFIGURATION_ENDPOINT);
    }
    try {
        final DiscoveryService discoveryService = getDiscoveryService();
        final OpenIdConfigurationResponse openIdConfigurationResponse = discoveryService.getConnectDiscoveryResponse(params.getOpConfigurationEndpoint(), params.getOpHost(), params.getOpDiscoveryPath());
        final String jwksUri = openIdConfigurationResponse.getJwksUri();
        final JwkClient jwkClient = new JwkClient(jwksUri);
        jwkClient.setExecutor(getHttpService().getClientEngine());
        final JwkResponse serverResponse = jwkClient.exec();
        final GetJwksResponse response = new GetJwksResponse();
        response.setKeys(serverResponse.getJwks().getKeys());
        return new POJOResponse(response);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : JwkResponse(io.jans.as.client.JwkResponse) POJOResponse(io.jans.ca.common.response.POJOResponse) GetJwksResponse(io.jans.ca.common.response.GetJwksResponse) HttpException(io.jans.ca.server.HttpException) OpenIdConfigurationResponse(io.jans.as.client.OpenIdConfigurationResponse) DiscoveryService(io.jans.ca.server.service.DiscoveryService) HttpException(io.jans.ca.server.HttpException) JwkClient(io.jans.as.client.JwkClient)

Example 2 with GetJwksResponse

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

the class GetJwksTest method test.

@Test(enabled = false)
@Parameters({ "host", "opHost", "opDiscoveryPath" })
public void test(String host, String opHost, @Optional String opDiscoveryPath) {
    final ClientInterface client = Tester.newClient(host);
    final GetJwksParams params = new GetJwksParams();
    params.setOpHost(opHost);
    params.setOpDiscoveryPath(opDiscoveryPath);
    final GetJwksResponse response = client.getJwks(Tester.getAuthorization(), null, params);
    assertNotNull(response);
    assertNotNull(response.getKeys());
    assertFalse(response.getKeys().isEmpty());
}
Also used : GetJwksParams(io.jans.ca.common.params.GetJwksParams) GetJwksResponse(io.jans.ca.common.response.GetJwksResponse) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 3 with GetJwksResponse

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

the class GetJwksTest method test_withOpConfigurationEndpoint.

@Test
@Parameters({ "host", "opConfigurationEndpoint" })
public void test_withOpConfigurationEndpoint(String host, String opConfigurationEndpoint) {
    final ClientInterface client = Tester.newClient(host);
    final GetJwksParams params = new GetJwksParams();
    params.setOpConfigurationEndpoint(opConfigurationEndpoint);
    final GetJwksResponse response = client.getJwks(Tester.getAuthorization(), null, params);
    assertNotNull(response);
    assertNotNull(response.getKeys());
    assertFalse(response.getKeys().isEmpty());
}
Also used : GetJwksParams(io.jans.ca.common.params.GetJwksParams) GetJwksResponse(io.jans.ca.common.response.GetJwksResponse) ClientInterface(io.jans.ca.client.ClientInterface) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

GetJwksResponse (io.jans.ca.common.response.GetJwksResponse)3 ClientInterface (io.jans.ca.client.ClientInterface)2 GetJwksParams (io.jans.ca.common.params.GetJwksParams)2 Parameters (org.testng.annotations.Parameters)2 Test (org.testng.annotations.Test)2 JwkClient (io.jans.as.client.JwkClient)1 JwkResponse (io.jans.as.client.JwkResponse)1 OpenIdConfigurationResponse (io.jans.as.client.OpenIdConfigurationResponse)1 POJOResponse (io.jans.ca.common.response.POJOResponse)1 HttpException (io.jans.ca.server.HttpException)1 DiscoveryService (io.jans.ca.server.service.DiscoveryService)1