use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class APIAdminImpl method encryptKeyManagerConfigurationValues.
private void encryptKeyManagerConfigurationValues(KeyManagerConfigurationDTO retrievedKeyManagerConfigurationDTO, KeyManagerConfigurationDTO updatedKeyManagerConfigurationDto) throws APIManagementException {
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(updatedKeyManagerConfigurationDto.getType());
if (keyManagerConnectorConfiguration != null) {
Map<String, Object> additionalProperties = updatedKeyManagerConfigurationDto.getAdditionalProperties();
for (ConfigurationDto configurationDto : keyManagerConnectorConfiguration.getConnectionConfigurations()) {
if (configurationDto.isMask()) {
String value = (String) additionalProperties.get(configurationDto.getName());
if (APIConstants.DEFAULT_MODIFIED_ENDPOINT_PASSWORD.equals(value)) {
Object unModifiedValue = retrievedKeyManagerConfigurationDTO.getAdditionalProperties().get(configurationDto.getName());
additionalProperties.replace(configurationDto.getName(), unModifiedValue);
} else if (StringUtils.isNotEmpty(value)) {
additionalProperties.replace(configurationDto.getName(), encryptValues(value));
}
}
}
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class APIAdminImpl method maskValues.
private void maskValues(KeyManagerConfigurationDTO keyManagerConfigurationDTO) {
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(keyManagerConfigurationDTO.getType());
Map<String, Object> additionalProperties = keyManagerConfigurationDTO.getAdditionalProperties();
List<ConfigurationDto> connectionConfigurations = keyManagerConnectorConfiguration.getConnectionConfigurations();
for (ConfigurationDto connectionConfiguration : connectionConfigurations) {
if (connectionConfiguration.isMask()) {
additionalProperties.replace(connectionConfiguration.getName(), APIConstants.DEFAULT_MODIFIED_ENDPOINT_PASSWORD);
}
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagerMappingUtil method toKeyManagerConfigurationDTO.
public static KeyManagerConfigurationDTO toKeyManagerConfigurationDTO(String tenantDomain, KeyManagerDTO keyManagerDTO) {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new KeyManagerConfigurationDTO();
Map<String, String> endpoints = new HashMap<>();
keyManagerConfigurationDTO.setName(keyManagerDTO.getName());
keyManagerConfigurationDTO.setDisplayName(keyManagerDTO.getDisplayName());
keyManagerConfigurationDTO.setDescription(keyManagerDTO.getDescription());
keyManagerConfigurationDTO.setEnabled(keyManagerDTO.isEnabled());
keyManagerConfigurationDTO.setType(keyManagerDTO.getType());
keyManagerConfigurationDTO.setOrganization(tenantDomain);
keyManagerConfigurationDTO.setTokenType(keyManagerDTO.getTokenType().toString());
keyManagerConfigurationDTO.setAlias(keyManagerDTO.getAlias());
Map<String, Object> additionalProperties = new HashMap();
if (keyManagerDTO.getAdditionalProperties() != null && keyManagerDTO.getAdditionalProperties() instanceof Map) {
additionalProperties.putAll((Map) keyManagerDTO.getAdditionalProperties());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getClientRegistrationEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.CLIENT_REGISTRATION_ENDPOINT, keyManagerDTO.getClientRegistrationEndpoint());
endpoints.put(APIConstants.KeyManager.CLIENT_REGISTRATION_ENDPOINT, keyManagerDTO.getClientRegistrationEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getIntrospectionEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.INTROSPECTION_ENDPOINT, keyManagerDTO.getIntrospectionEndpoint());
endpoints.put(APIConstants.KeyManager.INTROSPECTION_ENDPOINT, keyManagerDTO.getIntrospectionEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getTokenEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.TOKEN_ENDPOINT, keyManagerDTO.getTokenEndpoint());
endpoints.put(APIConstants.KeyManager.TOKEN_ENDPOINT, keyManagerDTO.getTokenEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getDisplayTokenEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.DISPLAY_TOKEN_ENDPOINT, keyManagerDTO.getDisplayTokenEndpoint());
endpoints.put(APIConstants.KeyManager.DISPLAY_TOKEN_ENDPOINT, keyManagerDTO.getDisplayTokenEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getRevokeEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.REVOKE_ENDPOINT, keyManagerDTO.getRevokeEndpoint());
endpoints.put(APIConstants.KeyManager.REVOKE_ENDPOINT, keyManagerDTO.getRevokeEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getDisplayRevokeEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.DISPLAY_REVOKE_ENDPOINT, keyManagerDTO.getDisplayRevokeEndpoint());
endpoints.put(APIConstants.KeyManager.DISPLAY_REVOKE_ENDPOINT, keyManagerDTO.getDisplayRevokeEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getScopeManagementEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.SCOPE_MANAGEMENT_ENDPOINT, keyManagerDTO.getScopeManagementEndpoint());
endpoints.put(APIConstants.KeyManager.SCOPE_MANAGEMENT_ENDPOINT, keyManagerDTO.getScopeManagementEndpoint());
}
if (keyManagerDTO.getAvailableGrantTypes() != null) {
additionalProperties.put(APIConstants.KeyManager.AVAILABLE_GRANT_TYPE, keyManagerDTO.getAvailableGrantTypes());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getIssuer())) {
additionalProperties.put(APIConstants.KeyManager.ISSUER, keyManagerDTO.getIssuer());
}
if (keyManagerDTO.getCertificates() != null) {
additionalProperties.put(APIConstants.KeyManager.CERTIFICATE_VALUE, keyManagerDTO.getCertificates().getValue());
if (KeyManagerCertificatesDTO.TypeEnum.JWKS.equals(keyManagerDTO.getCertificates().getType())) {
additionalProperties.put(APIConstants.KeyManager.CERTIFICATE_TYPE, APIConstants.KeyManager.CERTIFICATE_TYPE_JWKS_ENDPOINT);
} else if (KeyManagerCertificatesDTO.TypeEnum.PEM.equals(keyManagerDTO.getCertificates().getType())) {
additionalProperties.put(APIConstants.KeyManager.CERTIFICATE_TYPE, APIConstants.KeyManager.CERTIFICATE_TYPE_PEM_FILE);
}
}
if (StringUtils.isNotEmpty(keyManagerDTO.getUserInfoEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.USERINFO_ENDPOINT, keyManagerDTO.getUserInfoEndpoint());
endpoints.put(APIConstants.KeyManager.USERINFO_ENDPOINT, keyManagerDTO.getUserInfoEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getAuthorizeEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.AUTHORIZE_ENDPOINT, keyManagerDTO.getAuthorizeEndpoint());
endpoints.put(APIConstants.KeyManager.AUTHORIZE_ENDPOINT, keyManagerDTO.getAuthorizeEndpoint());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getWellKnownEndpoint())) {
additionalProperties.put(APIConstants.KeyManager.WELL_KNOWN_ENDPOINT, keyManagerDTO.getWellKnownEndpoint());
}
if (keyManagerDTO.getEndpoints() != null) {
for (KeyManagerEndpointDTO endpoint : keyManagerDTO.getEndpoints()) {
endpoints.put(endpoint.getName(), endpoint.getValue());
}
}
keyManagerConfigurationDTO.setEndpoints(endpoints);
additionalProperties.put(APIConstants.KeyManager.ENABLE_OAUTH_APP_CREATION, keyManagerDTO.isEnableOAuthAppCreation());
additionalProperties.put(APIConstants.KeyManager.ENABLE_MAP_OAUTH_CONSUMER_APPS, keyManagerDTO.isEnableMapOAuthConsumerApps());
additionalProperties.put(APIConstants.KeyManager.ENABLE_TOKEN_GENERATION, keyManagerDTO.isEnableTokenGeneration());
additionalProperties.put(APIConstants.KeyManager.ENABLE_TOKEN_HASH, keyManagerDTO.isEnableTokenHashing());
additionalProperties.put(APIConstants.KeyManager.ENABLE_TOKEN_ENCRYPTION, keyManagerDTO.isEnableTokenEncryption());
additionalProperties.put(APIConstants.KeyManager.SELF_VALIDATE_JWT, keyManagerDTO.isEnableSelfValidationJWT());
List<TokenValidationDTO> tokenValidationDTOList = keyManagerDTO.getTokenValidation();
if (tokenValidationDTOList != null && !tokenValidationDTOList.isEmpty()) {
additionalProperties.put(APIConstants.KeyManager.TOKEN_FORMAT_STRING, new Gson().toJson(tokenValidationDTOList));
}
List<ClaimMappingEntryDTO> claimMapping = keyManagerDTO.getClaimMapping();
if (claimMapping != null) {
additionalProperties.put(APIConstants.KeyManager.CLAIM_MAPPING, new Gson().toJsonTree(claimMapping));
}
if (StringUtils.isNotEmpty(keyManagerDTO.getConsumerKeyClaim())) {
additionalProperties.put(APIConstants.KeyManager.CONSUMER_KEY_CLAIM, keyManagerDTO.getConsumerKeyClaim());
}
if (StringUtils.isNotEmpty(keyManagerDTO.getScopesClaim())) {
additionalProperties.put(APIConstants.KeyManager.SCOPES_CLAIM, keyManagerDTO.getScopesClaim());
}
keyManagerConfigurationDTO.setAdditionalProperties(additionalProperties);
return keyManagerConfigurationDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class SettingsMappingUtil method fromKeyManagerConfigurationToSettingsKeyManagerConfigurationDTO.
private static SettingsKeyManagerConfigurationDTO fromKeyManagerConfigurationToSettingsKeyManagerConfigurationDTO(String name, String displayName, String scopesClaim, String consumerKeyClaim, List<ConfigurationDto> connectionConfigurationDtoList, List<ConfigurationDto> endpointConfigurations) {
SettingsKeyManagerConfigurationDTO settingsKeyManagerConfigurationDTO = new SettingsKeyManagerConfigurationDTO();
settingsKeyManagerConfigurationDTO.setDisplayName(displayName);
settingsKeyManagerConfigurationDTO.setType(name);
settingsKeyManagerConfigurationDTO.setDefaultScopesClaim(scopesClaim);
settingsKeyManagerConfigurationDTO.setDefaultConsumerKeyClaim(consumerKeyClaim);
if (connectionConfigurationDtoList != null) {
for (ConfigurationDto configurationDto : connectionConfigurationDtoList) {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new KeyManagerConfigurationDTO();
keyManagerConfigurationDTO.setName(configurationDto.getName());
keyManagerConfigurationDTO.setLabel(configurationDto.getLabel());
keyManagerConfigurationDTO.setType(configurationDto.getType());
keyManagerConfigurationDTO.setRequired(configurationDto.isRequired());
keyManagerConfigurationDTO.setMask(configurationDto.isMask());
keyManagerConfigurationDTO.setMultiple(configurationDto.isMultiple());
keyManagerConfigurationDTO.setTooltip(configurationDto.getTooltip());
keyManagerConfigurationDTO.setDefault(configurationDto.getDefaultValue());
keyManagerConfigurationDTO.setValues(configurationDto.getValues());
settingsKeyManagerConfigurationDTO.getConfigurations().add(keyManagerConfigurationDTO);
}
}
if (endpointConfigurations != null) {
for (ConfigurationDto configurationDto : endpointConfigurations) {
KeyManagerConfigurationDTO keyManagerConfigurationDTO = new KeyManagerConfigurationDTO();
keyManagerConfigurationDTO.setName(configurationDto.getName());
keyManagerConfigurationDTO.setLabel(configurationDto.getLabel());
keyManagerConfigurationDTO.setType(configurationDto.getType());
keyManagerConfigurationDTO.setRequired(configurationDto.isRequired());
keyManagerConfigurationDTO.setMask(configurationDto.isMask());
keyManagerConfigurationDTO.setMultiple(configurationDto.isMultiple());
keyManagerConfigurationDTO.setTooltip(configurationDto.getTooltip());
keyManagerConfigurationDTO.setDefault(configurationDto.getDefaultValue());
keyManagerConfigurationDTO.setValues(configurationDto.getValues());
settingsKeyManagerConfigurationDTO.getEndpointConfigurations().add(keyManagerConfigurationDTO);
}
}
return settingsKeyManagerConfigurationDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.KeyManagerConfigurationDTO in project carbon-apimgt by wso2.
the class KeyManagersApiServiceImpl method keyManagersGet.
public Response keyManagersGet(MessageContext messageContext) throws APIManagementException {
String organization = RestApiUtil.getOrganization(messageContext);
APIAdmin apiAdmin = new APIAdminImpl();
List<KeyManagerConfigurationDTO> keyManagerConfigurationsByOrganization = apiAdmin.getKeyManagerConfigurationsByOrganization(organization);
KeyManagerListDTO keyManagerListDTO = KeyManagerMappingUtil.toKeyManagerListDTO(keyManagerConfigurationsByOrganization);
return Response.ok().entity(keyManagerListDTO).build();
}
Aggregations