use of io.jans.ca.server.service.DiscoveryService 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);
}
}
Aggregations