Search in sources :

Example 1 with InvalidConfigurationException

use of org.alfresco.jlan.server.config.InvalidConfigurationException 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 InvalidConfigurationException

use of org.alfresco.jlan.server.config.InvalidConfigurationException in project alfresco-repository by Alfresco.

the class AlfrescoRpcAuthenticator method afterPropertiesSet.

/**
 * Initialize the RPC authenticator
 * @throws InvalidConfigurationException
 */
public void afterPropertiesSet() throws InvalidConfigurationException {
    if (this.userMappings != null) {
        // Allocate the id mappings table
        m_idMap = new HashMap<Integer, String>(this.userMappings.size() * 2);
        for (UserMapping userElem : this.userMappings) {
            // Get the user name, user id and group id
            String userName = userElem.getName();
            if (userName == null || userName.length() == 0)
                throw new InvalidConfigurationException("Empty user name, or name not specified");
            // Check if the mapping already exists
            Integer idKey = new Integer((userElem.getGid() << 16) + userElem.getUid());
            if (m_idMap.containsKey(idKey) == false) {
                // Add the username uid/gid mapping
                m_idMap.put(idKey, userName);
                if (logger.isDebugEnabled())
                    logger.debug("Added RPC user mapping for user " + userName + " uid=" + userElem.getUid() + ", gid=" + userElem.getGid());
            } else if (logger.isDebugEnabled()) {
                // DEBUG
                logger.debug("Ignored duplicate mapping for uid=" + userElem.getUid() + ", gid=" + userElem.getGid());
            }
        }
    }
}
Also used : InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException)

Example 3 with InvalidConfigurationException

use of org.alfresco.jlan.server.config.InvalidConfigurationException in project alfresco-repository by Alfresco.

the class ServerConfigurationBean method processSecurityConfig.

/**
 * Process the security configuration
 */
protected void processSecurityConfig() {
    // Create the security configuration section
    SecurityConfigSection secConfig = new SecurityConfigSection(this);
    try {
        // Check if global access controls have been specified
        AccessControlListBean accessControls = securityConfigBean.getGlobalAccessControl();
        if (accessControls != null) {
            // Parse the access control list
            AccessControlList acls = accessControls.toAccessControlList(secConfig);
            if (acls != null)
                secConfig.setGlobalAccessControls(acls);
        }
        // Check if a JCE provider class has been specified
        String jceProvider = securityConfigBean.getJCEProvider();
        if (jceProvider != null && jceProvider.length() > 0) {
            // Set the JCE provider
            secConfig.setJCEProvider(jceProvider);
        } else {
            // Use the default Bouncy Castle JCE provider
            secConfig.setJCEProvider("org.bouncycastle.jce.provider.BouncyCastleProvider");
        }
        // Check if a share mapper has been specified
        ShareMapper shareMapper = securityConfigBean.getShareMapper();
        if (shareMapper != null) {
            // Associate the share mapper
            secConfig.setShareMapper(shareMapper);
        }
    } catch (InvalidConfigurationException ex) {
        throw new AlfrescoRuntimeException(ex.getMessage());
    }
}
Also used : AccessControlList(org.alfresco.jlan.server.auth.acl.AccessControlList) SecurityConfigSection(org.alfresco.jlan.server.config.SecurityConfigSection) ShareMapper(org.alfresco.jlan.server.core.ShareMapper) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) AccessControlListBean(org.alfresco.filesys.config.acl.AccessControlListBean) InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException)

Example 4 with InvalidConfigurationException

use of org.alfresco.jlan.server.config.InvalidConfigurationException in project alfresco-repository by Alfresco.

the class ServerConfigurationBean method processFilesystemsConfig.

/**
 * Process the filesystems configuration
 */
protected void processFilesystemsConfig() {
    // Create the filesystems configuration section
    FilesystemsConfigSection fsysConfig = new FilesystemsConfigSection(this);
    // Access the security configuration section
    SecurityConfigSection secConfig = (SecurityConfigSection) getConfigSection(SecurityConfigSection.SectionName);
    if (this.filesystemContexts != null) {
        for (DeviceContext filesystem : this.filesystemContexts) {
            try {
                // Check the filesystem type and use the appropriate driver
                DiskSharedDevice filesys = null;
                // Create a new filesystem driver instance and register a context for
                // the new filesystem
                ExtendedDiskInterface filesysDriver = getRepoDiskInterface();
                ContentContext filesysContext = (ContentContext) filesystem;
                // Create state cache here and inject
                StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache();
                standaloneCache.initializeCache(new GenericConfigElement(""), this);
                filesysContext.setStateCache(standaloneCache);
                if (filesysContext.hasStateCache()) {
                    // Register the state cache with the reaper thread
                    // has many side effects including initialisation of the cache
                    fsysConfig.addFileStateCache(filesystem.getDeviceName(), filesysContext.getStateCache());
                    // Create the lock manager for the context.
                    FileStateLockManager lockMgr = new FileStateLockManager(filesysContext.getStateCache());
                    filesysContext.setLockManager(lockMgr);
                    filesysContext.setOpLockManager(lockMgr);
                }
                if (!ftpConfigBean.getServerEnabled() && isContentDiskDriver2(filesysDriver)) {
                    ((ContentContext) filesystem).setDisableNodeMonitor(true);
                }
                filesysDriver.registerContext(filesystem);
                // Check if an access control list has been specified
                AccessControlList acls = null;
                AccessControlListBean accessControls = filesysContext.getAccessControlList();
                if (accessControls != null) {
                    // Parse the access control list
                    acls = accessControls.toAccessControlList(secConfig);
                } else if (secConfig.hasGlobalAccessControls()) {
                    // Use the global access control list for this disk share
                    acls = secConfig.getGlobalAccessControls();
                }
                // Create the shared filesystem
                filesys = new DiskSharedDevice(filesystem.getDeviceName(), filesysDriver, filesysContext);
                filesys.setConfiguration(this);
                // Add any access controls to the share
                filesys.setAccessControlList(acls);
                if (filesysContext.getDisableChangeNotifications() == false)
                    filesysContext.enableChangeHandler(true);
                // Start the filesystem
                filesysContext.startFilesystem(filesys);
                // Add the new filesystem
                fsysConfig.addShare(filesys);
            } catch (DeviceContextException ex) {
                throw new AlfrescoRuntimeException("Error creating filesystem " + filesystem.getDeviceName(), ex);
            } catch (InvalidConfigurationException ex) {
                throw new AlfrescoRuntimeException(ex.getMessage(), ex);
            }
        }
    } else {
        // No filesystems defined
        logger.warn("No filesystems defined");
    }
// home folder share mapper could be declared in security config
}
Also used : AccessControlList(org.alfresco.jlan.server.auth.acl.AccessControlList) DeviceContextException(org.alfresco.jlan.server.core.DeviceContextException) SecurityConfigSection(org.alfresco.jlan.server.config.SecurityConfigSection) GenericConfigElement(org.springframework.extensions.config.element.GenericConfigElement) ExtendedDiskInterface(org.alfresco.filesys.alfresco.ExtendedDiskInterface) StandaloneFileStateCache(org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache) AccessControlListBean(org.alfresco.filesys.config.acl.AccessControlListBean) InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException) FilesystemsConfigSection(org.alfresco.jlan.server.filesys.FilesystemsConfigSection) DeviceContext(org.alfresco.jlan.server.core.DeviceContext) FileStateLockManager(org.alfresco.jlan.server.filesys.cache.FileStateLockManager) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ContentContext(org.alfresco.filesys.repo.ContentContext) DiskSharedDevice(org.alfresco.jlan.server.filesys.DiskSharedDevice)

Example 5 with InvalidConfigurationException

use of org.alfresco.jlan.server.config.InvalidConfigurationException in project alfresco-repository by Alfresco.

the class ServerConfigurationBean method initialiseRuntimeContext.

/**
 * Initialise a runtime context - not configured through spring e.g MT.
 *
 * TODO - what about desktop actions etc?
 *
 * @param uniqueName String
 * @param diskCtx AlfrescoContext
 */
public void initialiseRuntimeContext(String uniqueName, AlfrescoContext diskCtx) {
    logger.debug("initialiseRuntimeContext" + diskCtx);
    if (diskCtx.getStateCache() == null) {
        // Set the state cache, use a hard coded standalone cache for now
        FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) this.getConfigSection(FilesystemsConfigSection.SectionName);
        if (filesysConfig != null) {
            try {
                // Create a standalone state cache
                StandaloneFileStateCache standaloneCache = new StandaloneFileStateCache();
                standaloneCache.initializeCache(new GenericConfigElement(""), this);
                filesysConfig.addFileStateCache(diskCtx.getDeviceName(), standaloneCache);
                diskCtx.setStateCache(standaloneCache);
                // Register the state cache with the reaper thread
                // has many side effects including initialisation of the cache
                filesysConfig.addFileStateCache(diskCtx.getShareName(), diskCtx.getStateCache());
                FileStateLockManager lockMgr = new FileStateLockManager(diskCtx.getStateCache());
                diskCtx.setLockManager(lockMgr);
                diskCtx.setOpLockManager(lockMgr);
            } catch (InvalidConfigurationException ex) {
                throw new AlfrescoRuntimeException("Failed to initialize standalone state cache for " + diskCtx.getDeviceName());
            }
        }
    }
}
Also used : FilesystemsConfigSection(org.alfresco.jlan.server.filesys.FilesystemsConfigSection) GenericConfigElement(org.springframework.extensions.config.element.GenericConfigElement) StandaloneFileStateCache(org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache) FileStateLockManager(org.alfresco.jlan.server.filesys.cache.FileStateLockManager) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) InvalidConfigurationException(org.alfresco.jlan.server.config.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (org.alfresco.jlan.server.config.InvalidConfigurationException)9 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)5 GenericConfigElement (org.springframework.extensions.config.element.GenericConfigElement)3 InetAddress (java.net.InetAddress)2 SocketException (java.net.SocketException)2 UnknownHostException (java.net.UnknownHostException)2 AccessControlListBean (org.alfresco.filesys.config.acl.AccessControlListBean)2 AccessControlList (org.alfresco.jlan.server.auth.acl.AccessControlList)2 SecurityConfigSection (org.alfresco.jlan.server.config.SecurityConfigSection)2 FilesystemsConfigSection (org.alfresco.jlan.server.filesys.FilesystemsConfigSection)2 FileStateLockManager (org.alfresco.jlan.server.filesys.cache.FileStateLockManager)2 StandaloneFileStateCache (org.alfresco.jlan.server.filesys.cache.StandaloneFileStateCache)2 File (java.io.File)1 IOException (java.io.IOException)1 NetworkInterface (java.net.NetworkInterface)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)1 KeyStoreException (java.security.KeyStoreException)1 LinkedList (java.util.LinkedList)1 StringTokenizer (java.util.StringTokenizer)1