org.wso2.carbon.user.core.tracker.UserStoreManagerRegistry Java Examples

The following examples show how to use org.wso2.carbon.user.core.tracker.UserStoreManagerRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerUserStoreService.java    From identity-api-server with Apache License 2.0 6 votes vote down vote up
/**
 * Construct the user store type's meta.
 *
 * @param typeId        the type id of the user store.
 * @return MetaUserStoreType.
 */
private MetaUserStoreType buildUserStoreMetaResponse(String typeId) {

    String typeName = base64URLDecodeId(typeId);
    Properties properties = UserStoreManagerRegistry.getUserStoreProperties(
            getUserStoreType(typeName));
    MetaUserStoreType metaUserStore = new MetaUserStoreType();
    UserStorePropertiesRes userStorePropertiesRes = new UserStorePropertiesRes();
    if ((properties != null)) {
        userStorePropertiesRes.mandatory(buildPropertiesRes(properties.getMandatoryProperties()));
        userStorePropertiesRes.optional(buildPropertiesRes(properties.getOptionalProperties()));
        userStorePropertiesRes.advanced(buildPropertiesRes(properties.getAdvancedProperties()));
    }
    metaUserStore.setProperties(userStorePropertiesRes);
    metaUserStore.setTypeId(typeId);
    metaUserStore.setTypeName(typeName);
    metaUserStore.setClassName(getUserStoreType(typeName));

    return metaUserStore;
}
 
Example #2
Source File: UserStoreConfigurationDeployer.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Get the list of properties from  mandatoryProperties list
 *
 * @param userStoreClass class name of user store
 * @return ArrayList consisting of mandatory properties to be encrypted
 */
private static ArrayList<String> getEncryptPropertyList(String userStoreClass) {
    //First check for mandatory field with #encrypt
    Property[] mandatoryProperties = UserStoreManagerRegistry.getUserStoreProperties(userStoreClass).
            getMandatoryProperties();
    ArrayList<String> propertyList = new ArrayList<String>();
    for (Property property : mandatoryProperties) {
        if (property != null) {
            String propertyName = property.getName();
            if (propertyName != null && property.getDescription().contains
                    (UserStoreConfigurationConstants.ENCRYPT_TEXT)) {
                propertyList.add(propertyName);
            }
        }
    }
    return propertyList;
}
 
Example #3
Source File: UserStoreConfigurationDeployer.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Get the list of properties from  mandatoryProperties list
 *
 * @param userStoreClass class name of user store
 * @return ArrayList consisting of mandatory properties to be encrypted
 */
private static ArrayList<String> getEncryptPropertyList(String userStoreClass) {
    //First check for mandatory field with #encrypt
    Property[] mandatoryProperties = UserStoreManagerRegistry.getUserStoreProperties(userStoreClass).
            getMandatoryProperties();
    ArrayList<String> propertyList = new ArrayList<String>();
    for (Property property : mandatoryProperties) {
        if (property != null) {
            String propertyName = property.getName();
            if (propertyName != null && property.getDescription().contains
                    (UserStoreConfigurationConstants.ENCRYPT_TEXT)) {
                propertyList.add(propertyName);
            }
        }
    }
    return propertyList;
}
 
Example #4
Source File: ServerUserStoreService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a map with class name and with the corresponding type name.
 *
 * @return HashMap.
 */
private HashMap<String, String> getHashMap() {

    Set<String> classNames = UserStoreManagerRegistry.getUserStoreManagerClasses();
    HashMap<String, String> userStoreMap = new HashMap<>();

    for (String className : classNames) {
        userStoreMap.put(className, className.substring(className.lastIndexOf('.') + 1));
    }
    return userStoreMap;
}
 
Example #5
Source File: UserStoreConfigAdminService.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Get User Store Manager default properties for a given implementation
 *
 * @param className Implementation class name for the user store
 * @return list of default properties(mandatory+optional)
 */
public Properties getUserStoreManagerProperties(String className) throws IdentityUserStoreMgtException {
    Properties properties = UserStoreManagerRegistry.getUserStoreProperties(className);

    if (properties != null && properties.getOptionalProperties() != null) {

        Property[] optionalProperties = properties.getOptionalProperties();
        boolean foundUniqueIDProperty = false;
        for (Property property : optionalProperties) {
            if (UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT.equals(property.getName())) {
                foundUniqueIDProperty = true;
                break;
            }
        }
        if (!foundUniqueIDProperty) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Inserting property : " + UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT +
                          " since " + UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT +
                          " property not defined as an optional property in " + className + " class");
            }
            List<Property> optionalPropertyList = new ArrayList<>(Arrays.asList(optionalProperties));
            Property uniqueIDProperty = new Property(
                    UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, "", "", null);
            optionalPropertyList.add(uniqueIDProperty);

            properties.setOptionalProperties(
                    optionalPropertyList.toArray(new Property[optionalPropertyList.size()]));
        }
    }

    return properties;
}
 
Example #6
Source File: UserStoreConfigAdminService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Get User Store Manager default properties for a given implementation
 *
 * @param className:Implementation class name for the user store
 * @return : list of default properties(mandatory+optional)
 */
public Properties getUserStoreManagerProperties(String className) throws IdentityUserStoreMgtException {
    Properties properties = UserStoreManagerRegistry.getUserStoreProperties(className);

    if (properties != null && properties.getOptionalProperties() != null) {

        Property[] optionalProperties =  properties.getOptionalProperties();

        boolean foundUniqueIDProperty = false;
        for (Property property : optionalProperties) {
            if (UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT.equals(property.getName())) {
                foundUniqueIDProperty = true;
                break;
            }
        }
        if (!foundUniqueIDProperty) {
            if (log.isDebugEnabled()) {
                log.debug("Inserting property : " + UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT +
                        " since " + UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT +
                        " property not defined as an optional property in " + className + " class");
            }
            List<Property> optionalPropertyList = new ArrayList<>(Arrays.asList(optionalProperties));
            Property uniqueIDProperty = new Property(
                    UserStoreConfigurationConstant.UNIQUE_ID_CONSTANT, "", "", null);
            optionalPropertyList.add(uniqueIDProperty);

            properties.setOptionalProperties(
                    optionalPropertyList.toArray(new Property[optionalPropertyList.size()]));
        }
    }

    return properties;
}
 
Example #7
Source File: UserStoreConfigServiceImpl.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
@Override
public Set<String> getAvailableUserStoreClasses() throws IdentityUserStoreMgtException {

    return getAllowedUserstoreClasses(UserStoreManagerRegistry.getUserStoreManagerClasses());
}
 
Example #8
Source File: SecondaryUserStoreConfigurationUtil.java    From carbon-identity-framework with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the mandatory properties for a given userStoreClass
 *
 * @param userStoreClass userStoreClass name
 * @return Property[] of Mandatory Properties
 */
private static Property[] getMandatoryProperties(String userStoreClass) {

    return UserStoreManagerRegistry.getUserStoreProperties(userStoreClass).getMandatoryProperties();
}
 
Example #9
Source File: UserStoreConfigAdminService.java    From carbon-identity with Apache License 2.0 2 votes vote down vote up
/**
 * Get available user store manager implementations
 *
 * @return: Available implementations for user store managers
 */
public String[] getAvailableUserStoreClasses() throws IdentityUserStoreMgtException {
    Set<String> classNames = UserStoreManagerRegistry.getUserStoreManagerClasses();
    return classNames.toArray(new String[classNames.size()]);
}
 
Example #10
Source File: UserStoreConfigAdminService.java    From carbon-identity with Apache License 2.0 2 votes vote down vote up
/**
 * Obtains the mandatory properties for a given userStoreClass
 *
 * @param userStoreClass userStoreClass name
 * @return Property[] of Mandatory Properties
 */
private Property[] getMandatoryProperties(String userStoreClass) {
    return UserStoreManagerRegistry.getUserStoreProperties(userStoreClass).getMandatoryProperties();
}