Search in sources :

Example 1 with AlfrescoConfigSection

use of org.alfresco.filesys.AlfrescoConfigSection in project alfresco-repository by Alfresco.

the class AlfrescoRpcAuthenticator method initialize.

/**
 * Initialize the RPC authenticator
 *
 * @param config ServerConfiguration
 * @param params NameValueList
 * @throws InvalidConfigurationException
 */
public void initialize(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException {
    // Get the alfresco configuration section, required to get hold of various services/components
    AlfrescoConfigSection alfrescoConfig = (AlfrescoConfigSection) config.getConfigSection(AlfrescoConfigSection.SectionName);
    // Copy over relevant bean properties for backward compatibility
    setAuthenticationComponent(alfrescoConfig.getAuthenticationComponent());
    setAuthenticationService((MutableAuthenticationService) alfrescoConfig.getAuthenticationService());
    setTransactionService(alfrescoConfig.getTransactionService());
    // Check for the user mappings
    ConfigElement userMappings = params.getChild("userMappings");
    if (userMappings != null) {
        // Allocate the id mappings table
        List<UserMapping> mappings = new LinkedList<UserMapping>();
        // Get the user map elements
        List<ConfigElement> userMaps = userMappings.getChildren();
        for (ConfigElement userElem : userMaps) {
            if (userElem.getName().equalsIgnoreCase("user")) {
                // Get the user name, user id and group id
                String userName = userElem.getAttribute("name");
                String uidStr = userElem.getAttribute("uid");
                String gidStr = userElem.getAttribute("gid");
                if (userName == null || userName.length() == 0)
                    throw new InvalidConfigurationException("Empty user name, or name not specified");
                if (uidStr == null || uidStr.length() == 0)
                    throw new InvalidConfigurationException("Invalid uid, or uid not specified, for user " + userName);
                if (gidStr == null || gidStr.length() == 0)
                    throw new InvalidConfigurationException("Invalid gid, or gid not specified, for user " + userName);
                // Parse the uid/gid
                int uid = -1;
                int gid = -1;
                try {
                    uid = Integer.parseInt(uidStr);
                } catch (NumberFormatException ex) {
                    throw new InvalidConfigurationException("Invalid uid value, " + uidStr + " for user " + userName);
                }
                try {
                    gid = Integer.parseInt(gidStr);
                } catch (NumberFormatException ex) {
                    throw new InvalidConfigurationException("Invalid gid value, " + gidStr + " for user " + userName);
                }
                mappings.add(new UserMapping(userName, uid, gid));
            }
        }
        setUserMappings(mappings);
    }
    afterPropertiesSet();
}
Also used : AlfrescoConfigSection(org.alfresco.filesys.AlfrescoConfigSection) ConfigElement(org.springframework.extensions.config.ConfigElement) LinkedList(java.util.LinkedList) InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException)

Example 2 with AlfrescoConfigSection

use of org.alfresco.filesys.AlfrescoConfigSection in project alfresco-repository by Alfresco.

the class FTPAuthenticatorBase method initialize.

/**
 * Initialize the authenticator
 *
 * @param config ServerConfiguration
 * @param params ConfigElement
 * @exception InvalidConfigurationException
 */
public void initialize(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException {
    setConfig(config);
    // Get the alfresco configuration section, required to get hold of various services/components
    AlfrescoConfigSection alfrescoConfig = (AlfrescoConfigSection) config.getConfigSection(AlfrescoConfigSection.SectionName);
    // Copy over relevant bean properties for backward compatibility
    setAuthenticationComponent(alfrescoConfig.getAuthenticationComponent());
    setAuthenticationService(alfrescoConfig.getAuthenticationService());
    setTransactionService(alfrescoConfig.getTransactionService());
    setAuthorityService(alfrescoConfig.getAuthorityService());
    // Complete initialization
    initialize();
}
Also used : AlfrescoConfigSection(org.alfresco.filesys.AlfrescoConfigSection)

Aggregations

AlfrescoConfigSection (org.alfresco.filesys.AlfrescoConfigSection)2 LinkedList (java.util.LinkedList)1 InvalidConfigurationException (org.alfresco.jlan.server.config.InvalidConfigurationException)1 ConfigElement (org.springframework.extensions.config.ConfigElement)1