Search in sources :

Example 1 with POJOResponse

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;
}
Also used : POJOResponse(io.jans.ca.common.response.POJOResponse) Command(io.jans.ca.common.Command) IOpResponse(io.jans.ca.common.response.IOpResponse) JSONObject(org.json.JSONObject) ConfigurationService(io.jans.ca.server.service.ConfigurationService)

Example 2 with POJOResponse

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);
}
Also used : CorrectRptIntrospectionResponse(io.jans.ca.common.introspection.CorrectRptIntrospectionResponse) POJOResponse(io.jans.ca.common.response.POJOResponse)

Example 3 with POJOResponse

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);
    }
}
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 4 with POJOResponse

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()));
}
Also used : POJOResponse(io.jans.ca.common.response.POJOResponse) UserInfoRequest(io.jans.as.client.UserInfoRequest) UserInfoResponse(io.jans.as.client.UserInfoResponse) UserInfoClient(io.jans.as.client.UserInfoClient)

Example 5 with POJOResponse

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);
}
Also used : POJOResponse(io.jans.ca.common.response.POJOResponse) IntrospectionResponse(io.jans.as.model.common.IntrospectionResponse) IntrospectionService(io.jans.ca.server.service.IntrospectionService)

Aggregations

POJOResponse (io.jans.ca.common.response.POJOResponse)6 OpenIdConfigurationResponse (io.jans.as.client.OpenIdConfigurationResponse)2 JwkClient (io.jans.as.client.JwkClient)1 JwkResponse (io.jans.as.client.JwkResponse)1 UserInfoClient (io.jans.as.client.UserInfoClient)1 UserInfoRequest (io.jans.as.client.UserInfoRequest)1 UserInfoResponse (io.jans.as.client.UserInfoResponse)1 IntrospectionResponse (io.jans.as.model.common.IntrospectionResponse)1 Jwt (io.jans.as.model.jwt.Jwt)1 Command (io.jans.ca.common.Command)1 CorrectRptIntrospectionResponse (io.jans.ca.common.introspection.CorrectRptIntrospectionResponse)1 GetJwksResponse (io.jans.ca.common.response.GetJwksResponse)1 IOpResponse (io.jans.ca.common.response.IOpResponse)1 HttpException (io.jans.ca.server.HttpException)1 ConfigurationService (io.jans.ca.server.service.ConfigurationService)1 DiscoveryService (io.jans.ca.server.service.DiscoveryService)1 IntrospectionService (io.jans.ca.server.service.IntrospectionService)1 Rp (io.jans.ca.server.service.Rp)1 JSONObject (org.json.JSONObject)1