use of io.jans.ca.common.response.POJOResponse in project jans by JanssenProject.
the class RestResource method getObjectForJsonConversion.
private static <T extends IParams> Object getObjectForJsonConversion(CommandType commandType, String paramsAsString, Class<T> paramsClass, String authorization, String AuthorizationRpId) {
LOG.trace("Command: {}", paramsAsString);
T params = read(safeToJson(paramsAsString), paramsClass);
final RpServerConfiguration conf = ServerLauncher.getInjector().getInstance(ConfigurationService.class).get();
if (commandType.isAuthorizationRequired()) {
validateAuthorizationRpId(conf, AuthorizationRpId);
validateAccessToken(authorization, safeToRpId((HasRpIdParams) params, AuthorizationRpId));
}
Command command = new Command(commandType, params);
final IOpResponse response = ServerLauncher.getInjector().getInstance(Processor.class).process(command);
Object forJsonConversion = response;
if (response instanceof POJOResponse) {
forJsonConversion = ((POJOResponse) response).getNode();
}
return forJsonConversion;
}
use of io.jans.ca.common.response.POJOResponse in project jans by JanssenProject.
the class IntrospectRptOperation method execute.
@Override
public IOpResponse execute(IntrospectRptParams params) {
getValidationService().validate(params);
CorrectRptIntrospectionResponse response = getIntrospectionService().introspectRpt(params.getRpId(), params.getRpt());
return new POJOResponse(response);
}
use of io.jans.ca.common.response.POJOResponse 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);
}
}
use of io.jans.ca.common.response.POJOResponse in project jans by JanssenProject.
the class GetUserInfoOperation method execute.
@Override
public IOpResponse execute(GetUserInfoParams params) throws IOException {
getValidationService().validate(params);
UserInfoClient client = getOpClientFactory().createUserInfoClient(getDiscoveryService().getConnectDiscoveryResponseByRpId(params.getRpId()).getUserInfoEndpoint());
client.setExecutor(getHttpService().getClientEngine());
client.setRequest(new UserInfoRequest(params.getAccessToken()));
final UserInfoResponse response = client.exec();
// validate subject identifier of successful response
if (response.getStatus() == 200) {
validateSubjectIdentifier(params.getIdToken(), response);
}
return new POJOResponse(Jackson2.createJsonMapper().readTree(response.getEntity()));
}
use of io.jans.ca.common.response.POJOResponse in project jans by JanssenProject.
the class IntrospectAccessTokenOperation method execute.
@Override
public IOpResponse execute(IntrospectAccessTokenParams params) {
getValidationService().validate(params);
final IntrospectionService introspectionService = getInstance(IntrospectionService.class);
IntrospectionResponse response = introspectionService.introspectToken(params.getRpId(), params.getAccessToken());
return new POJOResponse(response);
}
Aggregations