Search in sources :

Example 1 with IdentityUserStoreMgtException

use of org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException in project carbon-identity-framework by wso2.

the class AbstractUserStoreDAO method getUserStoreProperty.

private UserStoreDTO getUserStoreProperty(UserStoreDTO userStoreDTO) throws IdentityUserStoreMgtException {
    boolean newState = userStoreDTO.getDisabled();
    UserStoreDTO userStoreDTOTemp = getUserStore(userStoreDTO.getDomainId());
    if (userStoreDTOTemp != null) {
        userStoreDTO = userStoreDTOTemp;
        userStoreDTO.setDisabled(newState);
        PropertyDTO[] propertyDTO = userStoreDTO.getProperties();
        for (PropertyDTO propertyDTOValue : propertyDTO) {
            if (propertyDTOValue.getName().equals(DISABLED)) {
                propertyDTOValue.setValue(String.valueOf(newState));
            }
        }
    }
    return userStoreDTO;
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) PropertyDTO(org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)

Example 2 with IdentityUserStoreMgtException

use of org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException in project carbon-identity-framework by wso2.

the class AbstractUserStoreDAO method addUserStore.

@Override
public void addUserStore(UserStoreDTO userStoreDTO) throws IdentityUserStoreMgtException {
    UserStorePersistanceDTO userStorePersistanceDTO = getUserStorePersistanceDTO(userStoreDTO, getUserStoreProperties(userStoreDTO, userStoreDTO.getDomainId()));
    doAddUserStore(userStorePersistanceDTO);
}
Also used : UserStorePersistanceDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStorePersistanceDTO)

Example 3 with IdentityUserStoreMgtException

use of org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException in project carbon-identity-framework by wso2.

the class AbstractUserStoreDAO method getUserStores.

@Override
public UserStoreDTO[] getUserStores() throws IdentityUserStoreMgtException {
    UserStorePersistanceDTO[] userStorePersistanceDTOS = doGetAllUserStores();
    List<UserStoreDTO> userStoreDTOs = new ArrayList<>();
    for (UserStorePersistanceDTO userStorePersistanceDTO : userStorePersistanceDTOS) {
        userStoreDTOs.add(userStorePersistanceDTO.getUserStoreDTO());
    }
    return userStoreDTOs.toArray(new UserStoreDTO[userStoreDTOs.size()]);
}
Also used : UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) ArrayList(java.util.ArrayList) UserStorePersistanceDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStorePersistanceDTO)

Example 4 with IdentityUserStoreMgtException

use of org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException in project carbon-identity-framework by wso2.

the class DatabaseBasedUserStoreDAOImpl method deleteUserStore.

private void deleteUserStore(String domain, int tenantId) throws IdentityUserStoreMgtException {
    String msg = "Error while removing the user store with the domain name: " + domain + " in the tenant: " + tenantId;
    try (Connection connection = IdentityDatabaseUtil.getDBConnection()) {
        try (PreparedStatement ps = connection.prepareStatement(UserStoreMgtDBQueries.DELETE_USERSTORE_PROPERTIES)) {
            ps.setString(1, domain);
            ps.setInt(2, tenantId);
            ps.setString(3, USERSTORE);
            ps.executeUpdate();
            if (log.isDebugEnabled()) {
                log.debug("The userstore domain :" + domain + "removed for the tenant" + tenantId);
            }
            IdentityDatabaseUtil.commitTransaction(connection);
        } catch (SQLException e) {
            IdentityDatabaseUtil.rollbackTransaction(connection);
            throw new IdentityUserStoreMgtException(msg, e);
        }
    } catch (SQLException e) {
        throw new IdentityUserStoreMgtException(msg, e);
    }
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement)

Example 5 with IdentityUserStoreMgtException

use of org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException in project carbon-identity-framework by wso2.

the class UserStoreConfigAdminService method changeUserStoreState.

/**
 * Update a domain to be disabled/enabled in file repository.
 *
 * @param domain Name of the domain to be updated
 * @param isDisable Whether to disable/enable domain(true/false)
 * @throws IdentityUserStoreMgtException If error occurs during domain validation
 * @throws TransformerConfigurationException If error occurs during configuration transformation
 */
public void changeUserStoreState(String domain, Boolean isDisable) throws IdentityUserStoreMgtException, TransformerConfigurationException {
    validateDomain(domain, isDisable);
    try {
        triggerListenersOnUserStorePreStateChange(domain, isDisable);
    } catch (UserStoreException e) {
        throw new IdentityUserStoreMgtException("Error occurred while triggering the user store pre state change" + " listeners.");
    }
    UserStoreDTO userStoreDTO = getUserStoreDTO(domain, isDisable, null);
    updateStateInFileRepository(userStoreDTO);
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) UserStoreDTO(org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO) UserStoreException(org.wso2.carbon.user.api.UserStoreException)

Aggregations

IdentityUserStoreMgtException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException)37 UserStoreException (org.wso2.carbon.user.api.UserStoreException)25 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)14 IdentityUserStoreClientException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreClientException)14 ArrayList (java.util.ArrayList)13 UserStoreConfigService (org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService)11 SecondaryUserStoreConfigurationUtil.buildIdentityUserStoreClientException (org.wso2.carbon.identity.user.store.configuration.utils.SecondaryUserStoreConfigurationUtil.buildIdentityUserStoreClientException)11 UserStoreClientException (org.wso2.carbon.user.api.UserStoreClientException)9 AbstractUserStoreDAOFactory (org.wso2.carbon.identity.user.store.configuration.dao.AbstractUserStoreDAOFactory)8 IOException (java.io.IOException)7 UserStorePersistanceDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStorePersistanceDTO)7 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 SQLException (java.sql.SQLException)6 Path (java.nio.file.Path)5 XMLStreamException (javax.xml.stream.XMLStreamException)5 RealmConfiguration (org.wso2.carbon.user.api.RealmConfiguration)5 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)4 File (java.io.File)3 InputStream (java.io.InputStream)3