use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class SecondaryUserStoreConfigurationUtil method triggerListenersOnUserStorePreAdd.
/**
* Trigger the listeners before a userstore is added.
*
* @param userStoreDTO Userstore configuration to be added.
* @throws UserStoreException throws when an error occurred when triggering listeners.
*/
public static void triggerListenersOnUserStorePreAdd(UserStoreDTO userStoreDTO) throws UserStoreException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<UserStoreConfigListener> userStoreConfigListeners = UserStoreConfigListenersHolder.getInstance().getUserStoreConfigListeners();
for (UserStoreConfigListener userStoreConfigListener : userStoreConfigListeners) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Triggering userstore pre add listener: %s for tenant: %s", userStoreConfigListener.getClass().getName(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain()));
}
userStoreConfigListener.onUserStorePreAdd(tenantId, userStoreDTO);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class SecondaryUserStoreConfigurationUtil method triggerListenersOnUserStorePostGet.
/**
* Trigger the listeners after a userstore is retrieved.
*
* @param userStoreDTO Retrieved userstore configuration.
* @throws UserStoreException throws when an error occurred when triggering listeners.
*/
public static void triggerListenersOnUserStorePostGet(UserStoreDTO userStoreDTO) throws UserStoreException {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<UserStoreConfigListener> userStoreConfigListeners = UserStoreConfigListenersHolder.getInstance().getUserStoreConfigListeners();
for (UserStoreConfigListener userStoreConfigListener : userStoreConfigListeners) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Triggering userstore post get listener: %s for tenant: %s", userStoreConfigListener.getClass().getName(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain()));
}
userStoreConfigListener.onUserStorePostGet(tenantId, userStoreDTO);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO 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);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project product-is by wso2.
the class OIDCPasswordGrantTest method addSecondaryUserStore.
private void addSecondaryUserStore() throws Exception {
String jdbcClass = "org.wso2.carbon.user.core.jdbc.UniqueIDJDBCUserStoreManager";
H2DataBaseManager dataBaseManager = new H2DataBaseManager("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME, DB_USER_NAME, DB_USER_PASSWORD);
dataBaseManager.executeUpdate(new File(ServerConfigurationManager.getCarbonHome() + "/dbscripts/h2.sql"));
dataBaseManager.disconnect();
PropertyDTO[] propertyDTOs = new PropertyDTO[10];
for (int i = 0; i < 10; i++) {
propertyDTOs[i] = new PropertyDTO();
}
propertyDTOs[0].setName("driverName");
propertyDTOs[0].setValue("org.h2.Driver");
propertyDTOs[1].setName("url");
propertyDTOs[1].setValue("jdbc:h2:" + ServerConfigurationManager.getCarbonHome() + "/repository/database/" + USER_STORE_DB_NAME);
propertyDTOs[2].setName("userName");
propertyDTOs[2].setValue(DB_USER_NAME);
propertyDTOs[3].setName("password");
propertyDTOs[3].setValue(DB_USER_PASSWORD);
propertyDTOs[4].setName("UserIDEnabled");
propertyDTOs[4].setValue("true");
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(jdbcClass, USER_STORE_DOMAIN, propertyDTOs);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, USER_STORE_DOMAIN);
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project product-is by wso2.
the class SCIMUtils method createSecondaryUserStore.
/**
* Create a secondary user store.
*
* @param userStoreType User store type.
* @param userStoreDomain User store domain.
* @param userStoreProperties Configuration properties for the user store.
* @param backendURL Backend URL of the Identity Server.
* @param sessionCookie Session Cookie.
* @throws Exception Thrown if the user store creation fails.
*/
public static void createSecondaryUserStore(String userStoreType, String userStoreDomain, PropertyDTO[] userStoreProperties, String backendURL, String sessionCookie) throws Exception {
UserStoreConfigAdminServiceClient userStoreConfigAdminServiceClient = new UserStoreConfigAdminServiceClient(backendURL, sessionCookie);
UserStoreDTO userStoreDTO = userStoreConfigAdminServiceClient.createUserStoreDTO(userStoreType, userStoreDomain, userStoreProperties);
userStoreConfigAdminServiceClient.addUserStore(userStoreDTO);
Thread.sleep(5000);
Assert.assertTrue(userStoreConfigUtils.waitForUserStoreDeployment(userStoreConfigAdminServiceClient, userStoreDomain), "Domain addition via DTO has failed.");
}
Aggregations