use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerWellKnownResponseDTO in project carbon-apimgt by wso2.
the class KeyManagerMappingUtil method fromOpenIdConnectConfigurationToKeyManagerConfiguration.
public static KeyManagerWellKnownResponseDTO fromOpenIdConnectConfigurationToKeyManagerConfiguration(OpenIdConnectConfiguration openIdConnectConfiguration) {
KeyManagerWellKnownResponseDTO keyManagerWellKnownResponseDTO = new KeyManagerWellKnownResponseDTO();
if (openIdConnectConfiguration != null) {
keyManagerWellKnownResponseDTO.setValid(true);
KeyManagerDTO keyManagerDto = new KeyManagerDTO();
keyManagerDto.setIssuer(openIdConnectConfiguration.getIssuer());
keyManagerDto.setIntrospectionEndpoint(openIdConnectConfiguration.getIntrospectionEndpoint());
keyManagerDto.setClientRegistrationEndpoint(openIdConnectConfiguration.getRegistrationEndpoint());
keyManagerDto.setAuthorizeEndpoint(openIdConnectConfiguration.getAuthorizeEndpoint());
keyManagerDto.setTokenEndpoint(openIdConnectConfiguration.getTokenEndpoint());
keyManagerDto.setRevokeEndpoint(openIdConnectConfiguration.getRevokeEndpoint());
keyManagerDto.setEnabled(true);
keyManagerDto.setEnableTokenGeneration(true);
keyManagerDto.setEnableMapOAuthConsumerApps(true);
keyManagerDto.setEnableOAuthAppCreation(true);
keyManagerDto.setEnableSelfValidationJWT(true);
keyManagerDto.setAvailableGrantTypes(openIdConnectConfiguration.getGrantTypesSupported());
if (StringUtils.isNotEmpty(openIdConnectConfiguration.getJwksEndpoint())) {
KeyManagerCertificatesDTO keyManagerCertificatesDTO = new KeyManagerCertificatesDTO();
keyManagerCertificatesDTO.setType(KeyManagerCertificatesDTO.TypeEnum.JWKS);
keyManagerCertificatesDTO.setValue(openIdConnectConfiguration.getJwksEndpoint());
keyManagerDto.setCertificates(keyManagerCertificatesDTO);
}
keyManagerWellKnownResponseDTO.setValue(keyManagerDto);
}
return keyManagerWellKnownResponseDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerWellKnownResponseDTO 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();
}
Aggregations