Search in sources :

Example 11 with UserStoreConfigService

use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService in project identity-api-server by wso2.

the class ServerUserStoreService method getUserStoreManagerProperties.

/**
 * Retrieve the meta of user store type.
 *
 * @param typeId the user store type id.
 * @return MetaUserStoreType.
 */
public MetaUserStoreType getUserStoreManagerProperties(String typeId) {
    UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
    Set<String> classNames;
    try {
        classNames = userStoreConfigService.getAvailableUserStoreClasses();
        if (CollectionUtils.isNotEmpty(classNames) && classNames.contains(getUserStoreType(base64URLDecodeId(typeId)))) {
            return buildUserStoreMetaResponse(typeId);
        } else {
            throw handleException(Response.Status.NOT_FOUND, UserStoreConstants.ErrorMessage.ERROR_CODE_NOT_FOUND);
        }
    } catch (IdentityUserStoreMgtException e) {
        UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE;
        throw handleIdentityUserStoreMgtException(e, errorEnum);
    }
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) UserStoreConfigService(org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService)

Example 12 with UserStoreConfigService

use of org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService in project identity-api-server by wso2.

the class ServerUserStoreService method getAttributeMappings.

/**
 * Get user store attribute mappings for a given user store typeId.
 *
 * @param userStoreName                String user store name (base64 decoded user store id).
 * @param includeIdentityClaimMappings Whether to include claim mapping for identity claims with other userstore
 *                                     attributes.
 * @return List of user store attribute mappings for the given typeId.
 */
private List<UserStoreAttribute> getAttributeMappings(String userStoreName, boolean includeIdentityClaimMappings) {
    UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
    try {
        UserStoreAttributeMappings userStoreAttributeMappings = userStoreConfigService.getUserStoreAttributeMappings();
        Map<String, Map<String, UserStoreAttribute>> mapping = userStoreAttributeMappings.getUserStoreAttributeMappings();
        Map<String, UserStoreAttribute> userStoreAttributeMap = userStoreAttributeMappings.getDefaultUserStoreAttributeMappings();
        if (mapping.containsKey(userStoreName)) {
            userStoreAttributeMap = mapping.get(userStoreName);
        }
        if (!includeIdentityClaimMappings) {
            // Remove identity claim mappings by iterating through all the claim mappings.
            return excludeIdentityClaims(userStoreAttributeMap);
        }
        return new ArrayList<>(userStoreAttributeMap.values());
    } catch (IdentityUserStoreMgtException e) {
        LOG.error("Error occurred while retrieving user store attribute metadata", e);
        throw handleException(Response.Status.INTERNAL_SERVER_ERROR, UserStoreConstants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_USER_STORE_ATTRIBUTE_METADATA);
    }
}
Also used : IdentityUserStoreMgtException(org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException) UserStoreAttributeMappings(org.wso2.carbon.identity.user.store.configuration.model.UserStoreAttributeMappings) ArrayList(java.util.ArrayList) UserStoreConfigService(org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService) Map(java.util.Map) HashMap(java.util.HashMap) UserStoreAttribute(org.wso2.carbon.identity.user.store.configuration.model.UserStoreAttribute)

Aggregations

UserStoreConfigService (org.wso2.carbon.identity.user.store.configuration.UserStoreConfigService)12 IdentityUserStoreMgtException (org.wso2.carbon.identity.user.store.configuration.utils.IdentityUserStoreMgtException)11 ArrayList (java.util.ArrayList)5 UserStoreDTO (org.wso2.carbon.identity.user.store.configuration.dto.UserStoreDTO)4 ClaimAttributeMapping (org.wso2.carbon.identity.api.server.userstore.v1.model.ClaimAttributeMapping)3 LocalClaim (org.wso2.carbon.identity.claim.metadata.mgt.model.LocalClaim)2 PropertyDTO (org.wso2.carbon.identity.user.store.configuration.dto.PropertyDTO)2 UserStoreAttribute (org.wso2.carbon.identity.user.store.configuration.model.UserStoreAttribute)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BundleContext (org.osgi.framework.BundleContext)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 Activate (org.osgi.service.component.annotations.Activate)1 AttributeMappingsToApiModel (org.wso2.carbon.identity.api.server.userstore.v1.core.functions.userstore.AttributeMappingsToApiModel)1 AddUserStorePropertiesRes (org.wso2.carbon.identity.api.server.userstore.v1.model.AddUserStorePropertiesRes)1 AvailableUserStoreClassesRes (org.wso2.carbon.identity.api.server.userstore.v1.model.AvailableUserStoreClassesRes)1 ConnectionEstablishedResponse (org.wso2.carbon.identity.api.server.userstore.v1.model.ConnectionEstablishedResponse)1 PatchDocument (org.wso2.carbon.identity.api.server.userstore.v1.model.PatchDocument)1 UserStoreAttributeMappingResponse (org.wso2.carbon.identity.api.server.userstore.v1.model.UserStoreAttributeMappingResponse)1