use of org.wso2.carbon.user.core.exceptions.HashProviderException in project carbon-identity-framework by wso2.
the class UserStoreHashProviderConfigListenerImpl method validateHashProviderParams.
/**
* Derive the userStoreProperties from UserStoreDTO and Validating HashProvider params.
*
* @param userStoreDTO Data transfer object of userStore properties.
* @throws UserStoreException The exception thrown at validating the hashProvider params.
*/
private void validateHashProviderParams(UserStoreDTO userStoreDTO) throws UserStoreException {
PropertyDTO[] userStoreProperty = userStoreDTO.getProperties();
String userstoreDomainId = userStoreDTO.getDomainId();
String digestFunction = null;
String hashProviderParamsJSON = null;
if (ArrayUtils.isEmpty(userStoreProperty)) {
if (LOG.isDebugEnabled()) {
LOG.debug("No userstore properties found for userstore: " + userstoreDomainId);
}
return;
}
for (PropertyDTO propertyDTO : userStoreProperty) {
if (DIGEST_FUNCTION.equals(propertyDTO.getName())) {
digestFunction = propertyDTO.getValue();
}
if (HASH_PROVIDER_PARAMS_JSON.equals(propertyDTO.getName())) {
hashProviderParamsJSON = propertyDTO.getValue();
}
}
if (StringUtils.isBlank(hashProviderParamsJSON)) {
if (LOG.isDebugEnabled()) {
LOG.debug("No hash provider configurations found for: " + userstoreDomainId);
}
return;
}
// Retrieve the corresponding HashProviderFactory for the defined hashing function.
HashProviderFactory hashProviderFactory = UserStoreConfigListenersHolder.getInstance().getHashProviderFactory(digestFunction);
if (hashProviderFactory == null) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("No HashProviderFactory found digest function : %s for userstore: %s", digestFunction, userstoreDomainId));
}
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("HashProviderFactory: %s found for digest function: %s for userstore: %s", hashProviderFactory.getAlgorithm(), digestFunction, userstoreDomainId));
}
Set<String> hashProviderMetaProperties = hashProviderFactory.getHashProviderConfigProperties();
validateParams(hashProviderParamsJSON, hashProviderMetaProperties);
Map<String, Object> hashProviderPropertiesMap = getHashProviderInitConfigs(hashProviderParamsJSON);
try {
hashProviderFactory.getHashProvider(hashProviderPropertiesMap);
} catch (HashProviderException e) {
throw new UserStoreException("Error occurred while initializing the hashProvider.", e);
}
}
Aggregations