Search in sources :

Example 26 with UserStoreDTO

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);
    }
}
Also used : UserStoreConfigListener(org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener)

Example 27 with UserStoreDTO

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);
    }
}
Also used : UserStoreConfigListener(org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener)

Example 28 with 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 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;
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) MaskedProperty(org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty)

Example 29 with 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;
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)

Example 30 with 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()]);
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) RealmConfiguration(org.wso2.carbon.user.api.RealmConfiguration) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) ArrayList(java.util.ArrayList) UserStoreException(org.wso2.carbon.user.api.UserStoreException) UserStorePersistanceDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStorePersistanceDTO) MaskedProperty(org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty)

Aggregations

UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)21 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.UserStoreDTO)14 IdentityUserStoreMgtException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException)13 UserStoreException (org.wso2.carbon.user.api.UserStoreException)11 ArrayList (java.util.ArrayList)9 AbstractUserStoreDAOFactory (org.wso2.carbon.identity.user.store.configuration.dao.AbstractUserStoreDAOFactory)8 Test (org.testng.annotations.Test)7 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.stub.dto.PropertyDTO)7 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)7 UserStorePersistanceDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStorePersistanceDTO)6 IdentityUserStoreClientException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreClientException)6 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)5 File (java.io.File)4 UserStoreConfigService (org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService)4 UserStoreConfigListener (org.wso2.carbon.identity.user.store.configuration.listener.UserStoreConfigListener)4 SecondaryUserStoreConfigurationUtil.buildIdentityUserStoreClientException (org.wso2.carbon.identity.user.store.configuration.utils.SecondaryUserStoreConfigurationUtil.buildIdentityUserStoreClientException)4 UserStoreClientException (org.wso2.carbon.user.api.UserStoreClientException)4 H2DataBaseManager (org.wso2.carbon.automation.test.utils.dbutils.H2DataBaseManager)3 MaskedProperty (org.wso2.carbon.identity.user.store.configuration.beans.MaskedProperty)3 Property (org.wso2.carbon.user.api.Property)3