use of org.wso2.carbon.apimgt.api.model.ConfigurationDto in project carbon-apimgt by wso2.
the class AbstractKeyManager method validateOAuthAppCreationProperties.
protected void validateOAuthAppCreationProperties(OAuthApplicationInfo oAuthApplicationInfo) throws APIManagementException {
String type = getType();
List<String> missedRequiredValues = new ArrayList<>();
KeyManagerConnectorConfiguration keyManagerConnectorConfiguration = ServiceReferenceHolder.getInstance().getKeyManagerConnectorConfiguration(type);
if (keyManagerConnectorConfiguration != null) {
List<ConfigurationDto> applicationConfigurationDtoList = keyManagerConnectorConfiguration.getApplicationConfigurations();
Object additionalProperties = oAuthApplicationInfo.getParameter(APIConstants.JSON_ADDITIONAL_PROPERTIES);
try {
if (additionalProperties != null) {
JSONObject additionalPropertiesJson;
if (additionalProperties instanceof JSONObject) {
additionalPropertiesJson = (JSONObject) additionalProperties;
} else {
additionalPropertiesJson = (JSONObject) new JSONParser().parse((String) additionalProperties);
}
for (ConfigurationDto configurationDto : applicationConfigurationDtoList) {
Object value = additionalPropertiesJson.get(configurationDto.getName());
if (value == null) {
if (configurationDto.isRequired()) {
missedRequiredValues.add(configurationDto.getName());
}
}
}
if (!missedRequiredValues.isEmpty()) {
throw new APIManagementException("Missing required properties to create/update oauth " + "application", ExceptionCodes.KEY_MANAGER_MISSING_REQUIRED_PROPERTIES_IN_APPLICATION);
}
}
} catch (ParseException e) {
throw new APIManagementException("Error while parsing the addition properties of OAuth " + "application");
}
} else {
throw new APIManagementException("Invalid Key Manager Type " + type, ExceptionCodes.KEY_MANAGER_NOT_REGISTERED);
}
}
use of org.wso2.carbon.apimgt.api.model.ConfigurationDto in project carbon-apimgt by wso2.
the class KeyManagerMappingUtil method fromKeyManagerConfigurationDtoToKeyManagerInfoDto.
private static KeyManagerInfoDTO fromKeyManagerConfigurationDtoToKeyManagerInfoDto(KeyManagerConfigurationDTO configurationDto) {
KeyManagerInfoDTO keyManagerInfoDTO = new KeyManagerInfoDTO();
keyManagerInfoDTO.setName(configurationDto.getName());
keyManagerInfoDTO.setDisplayName(configurationDto.getDisplayName());
keyManagerInfoDTO.setDescription(configurationDto.getDescription());
keyManagerInfoDTO.setId(configurationDto.getUuid());
keyManagerInfoDTO.setEnabled(configurationDto.isEnabled());
keyManagerInfoDTO.setType(configurationDto.getType());
return keyManagerInfoDTO;
}
use of org.wso2.carbon.apimgt.api.model.ConfigurationDto in project carbon-apimgt by wso2.
the class AbstractKeyManagerConnectorConfiguration method convertJsonToConnectorConfiguration.
private void convertJsonToConnectorConfiguration() {
configListMap.put(CONNECTOR_CONFIGURATION, Collections.emptyList());
configListMap.put(APPLICATION_CONFIGURATIONS, Collections.EMPTY_LIST);
String connectorConfigPath = CarbonBaseUtils.getCarbonHome() + File.separator + "repository" + File.separator + "resources" + File.separator + "keyManager-extensions" + File.separator + getType() + ".json";
File file = new File(connectorConfigPath);
if (file.exists()) {
try (FileInputStream fileInputStream = new FileInputStream(file)) {
String content = IOUtils.toString(fileInputStream);
Gson gson = new Gson();
Type configurationDtoType = new TypeToken<Map<String, List<ConfigurationDto>>>() {
}.getType();
configListMap = gson.fromJson(content, configurationDtoType);
} catch (IOException e) {
log.error("Error while reading connector configuration", e);
}
}
}
use of org.wso2.carbon.apimgt.api.model.ConfigurationDto in project carbon-apimgt by wso2.
the class DefaultKeyManagerConnectorConfiguration method getApplicationConfigurations.
@Override
public List<ConfigurationDto> getApplicationConfigurations() {
List<ConfigurationDto> applicationConfigurationsList = new ArrayList();
applicationConfigurationsList.add(new ConfigurationDto(APIConstants.KeyManager.APPLICATION_ACCESS_TOKEN_EXPIRY_TIME, "Application Access Token Expiry Time ", "input", "Type Application Access Token Expiry Time " + "in seconds ", APIConstants.KeyManager.NOT_APPLICABLE_VALUE, false, false, Collections.EMPTY_LIST, false));
applicationConfigurationsList.add(new ConfigurationDto(APIConstants.KeyManager.USER_ACCESS_TOKEN_EXPIRY_TIME, "User Access Token Expiry Time ", "input", "Type User Access Token Expiry Time " + "in seconds ", APIConstants.KeyManager.NOT_APPLICABLE_VALUE, false, false, Collections.EMPTY_LIST, false));
applicationConfigurationsList.add(new ConfigurationDto(APIConstants.KeyManager.REFRESH_TOKEN_EXPIRY_TIME, "Refresh Token Expiry Time ", "input", "Type Refresh Token Expiry Time " + "in seconds ", APIConstants.KeyManager.NOT_APPLICABLE_VALUE, false, false, Collections.EMPTY_LIST, false));
applicationConfigurationsList.add(new ConfigurationDto(APIConstants.KeyManager.ID_TOKEN_EXPIRY_TIME, "Id Token Expiry Time", "input", "Type ID Token Expiry Time " + "in seconds ", APIConstants.KeyManager.NOT_APPLICABLE_VALUE, false, false, Collections.EMPTY_LIST, false));
ConfigurationDto configurationDtoPkceMandatory = new ConfigurationDto(APIConstants.KeyManager.PKCE_MANDATORY, "Enable PKCE", "checkbox", "Enable PKCE", String.valueOf(false), false, false, Collections.EMPTY_LIST, false);
applicationConfigurationsList.add(configurationDtoPkceMandatory);
ConfigurationDto configurationDtoPkcePlainText = new ConfigurationDto(APIConstants.KeyManager.PKCE_SUPPORT_PLAIN, "Support PKCE Plain text", "checkbox", "S256 is recommended, plain text too can be used.", String.valueOf(false), false, false, Collections.EMPTY_LIST, false);
applicationConfigurationsList.add(configurationDtoPkcePlainText);
ConfigurationDto configurationDtoBypassClientCredentials = new ConfigurationDto(APIConstants.KeyManager.BYPASS_CLIENT_CREDENTIALS, "Public client", "checkbox", "Allow authentication without the client secret.", String.valueOf(false), false, false, Collections.EMPTY_LIST, false);
applicationConfigurationsList.add(configurationDtoBypassClientCredentials);
return applicationConfigurationsList;
}
use of org.wso2.carbon.apimgt.api.model.ConfigurationDto 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));
}
}
}
}
}
Aggregations