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;
}
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);
});
}
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);
});
}
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);
});
}
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);
}
}
Aggregations