Search in sources :

Example 1 with OpenIDConnectDiscoveryClient

use of org.wso2.carbon.apimgt.impl.kmclient.model.OpenIDConnectDiscoveryClient in project carbon-apimgt by wso2.

the class KeyManagersApiServiceImpl method keyManagersDiscoverPost.

@Override
public Response keyManagersDiscoverPost(String url, String type, MessageContext messageContext) throws APIManagementException {
    if (StringUtils.isNotEmpty(url)) {
        Gson gson = new GsonBuilder().serializeNulls().create();
        OpenIDConnectDiscoveryClient openIDConnectDiscoveryClient = Feign.builder().client(new ApacheFeignHttpClient(APIUtil.getHttpClient(url))).encoder(new GsonEncoder(gson)).decoder(new GsonDecoder(gson)).errorDecoder(new KMClientErrorDecoder()).target(OpenIDConnectDiscoveryClient.class, url);
        OpenIdConnectConfiguration openIdConnectConfiguration = openIDConnectDiscoveryClient.getOpenIdConnectConfiguration();
        if (openIdConnectConfiguration != null) {
            KeyManagerWellKnownResponseDTO keyManagerWellKnownResponseDTO = KeyManagerMappingUtil.fromOpenIdConnectConfigurationToKeyManagerConfiguration(openIdConnectConfiguration);
            keyManagerWellKnownResponseDTO.getValue().setWellKnownEndpoint(url);
            keyManagerWellKnownResponseDTO.getValue().setType(type);
            return Response.ok().entity(keyManagerWellKnownResponseDTO).build();
        }
    }
    return Response.ok(new KeyManagerWellKnownResponseDTO()).build();
}
Also used : KMClientErrorDecoder(org.wso2.carbon.apimgt.impl.kmclient.KMClientErrorDecoder) GsonEncoder(feign.gson.GsonEncoder) OpenIdConnectConfiguration(org.wso2.carbon.apimgt.impl.kmclient.model.OpenIdConnectConfiguration) OpenIDConnectDiscoveryClient(org.wso2.carbon.apimgt.impl.kmclient.model.OpenIDConnectDiscoveryClient) GsonBuilder(com.google.gson.GsonBuilder) KeyManagerWellKnownResponseDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerWellKnownResponseDTO) GsonDecoder(feign.gson.GsonDecoder) Gson(com.google.gson.Gson) ApacheFeignHttpClient(org.wso2.carbon.apimgt.impl.kmclient.ApacheFeignHttpClient)

Aggregations

Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 GsonDecoder (feign.gson.GsonDecoder)1 GsonEncoder (feign.gson.GsonEncoder)1 ApacheFeignHttpClient (org.wso2.carbon.apimgt.impl.kmclient.ApacheFeignHttpClient)1 KMClientErrorDecoder (org.wso2.carbon.apimgt.impl.kmclient.KMClientErrorDecoder)1 OpenIDConnectDiscoveryClient (org.wso2.carbon.apimgt.impl.kmclient.model.OpenIDConnectDiscoveryClient)1 OpenIdConnectConfiguration (org.wso2.carbon.apimgt.impl.kmclient.model.OpenIdConnectConfiguration)1 KeyManagerWellKnownResponseDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerWellKnownResponseDTO)1