use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class SecondaryUserStoreConfigurationUtil method triggerListenersOnUserStorePreUpdate.
/**
* Trigger the listeners before a userstore is updated.
*
* @param userStoreDTO Userstore configuration to be updated.
* @param isStateChange Boolean flag denoting whether the
* update is a userstore state change.
* @throws UserStoreException throws when an error occurred when triggering listeners.
*/
public static void triggerListenersOnUserStorePreUpdate(UserStoreDTO userStoreDTO, boolean isStateChange) 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 update listener: %s for tenant: %s", userStoreConfigListener.getClass().getName(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain()));
}
userStoreConfigListener.onUserStorePreUpdate(tenantId, userStoreDTO, isStateChange);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class SecondaryUserStoreConfigurationUtil method triggerListenersOnUserStoresPostGet.
/**
* Trigger the listeners after all userstores are retrieved.
*
* @param userStoreDTOS Array of userstore configurations.
* @throws UserStoreException throws when an error occurred when triggering listeners.
*/
public static void triggerListenersOnUserStoresPostGet(UserStoreDTO[] userStoreDTOS) 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 userstores post get listener: %s for tenant: %s", userStoreConfigListener.getClass().getName(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain()));
}
userStoreConfigListener.onUserStoresPostGet(tenantId, userStoreDTOS);
}
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class DatabaseBasedUserStoreDAOImpl method getUserStoreDTO.
private UserStoreDTO getUserStoreDTO(RealmConfiguration realmConfiguration) {
Map<String, String> userStoreProperties = realmConfiguration.getUserStoreProperties();
String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT);
if (uuid == null) {
uuid = UUID.randomUUID().toString();
}
String className = realmConfiguration.getUserStoreClass();
UserStoreDTO userStoreDTO = getUserStoreDTO(realmConfiguration, userStoreProperties);
userStoreProperties.put("Class", className);
userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid);
MaskedProperty[] maskedProperties = setMaskInUserStoreProperties(realmConfiguration, userStoreProperties, ENCRYPTED_PROPERTY_MASK, className);
userStoreDTO.setProperties(convertMapToArray(userStoreProperties));
// Now revert back to original password.
for (MaskedProperty maskedProperty : maskedProperties) {
userStoreProperties.put(maskedProperty.getName(), maskedProperty.getValue());
}
return userStoreDTO;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class DatabaseBasedUserStoreDAOImpl method getUserStoreDTO.
private UserStoreDTO getUserStoreDTO(RealmConfiguration secondaryRealmConfiguration, Map<String, String> userStoreProperties) {
UserStoreDTO userStoreDTO = new UserStoreDTO();
userStoreDTO.setClassName(secondaryRealmConfiguration.getUserStoreClass());
userStoreDTO.setDescription(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigurationConstant.DESCRIPTION));
userStoreDTO.setDomainId(secondaryRealmConfiguration.getUserStoreProperty(UserStoreConfigConstants.DOMAIN_NAME));
userStoreDTO.setRepositoryClass(DATABASE_BASED);
if (userStoreProperties.get(DISABLED) != null) {
userStoreDTO.setDisabled(Boolean.valueOf(userStoreProperties.get(DISABLED)));
}
return userStoreDTO;
}
use of org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO in project carbon-identity-framework by wso2.
the class FileBasedUserStoreDAOImpl method doGetAllUserStores.
@Override
protected UserStorePersistanceDTO[] doGetAllUserStores() throws IdentityUserStoreMgtException {
RealmConfiguration secondaryRealmConfiguration;
List<UserStorePersistanceDTO> userStorePersistanceDAOList = new ArrayList<>();
UserStorePersistanceDTO userStorePersistanceDTO = new UserStorePersistanceDTO();
try {
secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration().getSecondaryRealmConfig();
} catch (UserStoreException e) {
String errorMessage = "Error while retrieving user store configurations";
throw new IdentityUserStoreMgtException(errorMessage);
}
if (secondaryRealmConfiguration == null) {
if (log.isDebugEnabled()) {
log.debug("SecondaryRealmConfiguration is null. Can not find any userStore.");
}
return new UserStorePersistanceDTO[0];
} else {
do {
Map<String, String> userStoreProperties = secondaryRealmConfiguration.getUserStoreProperties();
String uuid = userStoreProperties.get(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT);
if (uuid == null) {
uuid = UUID.randomUUID().toString();
}
String className = secondaryRealmConfiguration.getUserStoreClass();
UserStoreDTO userStoreDTO = getUserStoreDTO(secondaryRealmConfiguration, userStoreProperties);
userStoreProperties.put("Class", className);
userStoreProperties.put(UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, uuid);
MaskedProperty[] maskedProperties = setMaskInUserStoreProperties(secondaryRealmConfiguration, userStoreProperties, ENCRYPTED_PROPERTY_MASK, className);
userStoreDTO.setProperties(convertMapToArray(userStoreProperties));
// Now revert back to original password.
for (MaskedProperty maskedProperty : maskedProperties) {
userStoreProperties.put(maskedProperty.getName(), maskedProperty.getValue());
}
userStorePersistanceDTO.setUserStoreDTO(userStoreDTO);
userStorePersistanceDAOList.add(userStorePersistanceDTO);
secondaryRealmConfiguration = secondaryRealmConfiguration.getSecondaryRealmConfig();
} while (secondaryRealmConfiguration != null);
}
return userStorePersistanceDAOList.toArray(new UserStorePersistanceDTO[userStorePersistanceDAOList.size()]);
}
Aggregations