Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.ConfigurationException


        while (i.hasNext())
        {
            String key = i.next().toLowerCase();
            if (!i.hasNext())
            {
                throw new ConfigurationException(String.format(PROPERTY_KEY_ONLY_MSG, getLine()));
            }
            if (!"=".equals(i.next()))
            {
                throw new ConfigurationException(String.format(PROPERTY_NO_EQUALS_MSG, getLine()));
            }
            if (!i.hasNext())
            {
                throw new ConfigurationException(String.format(PROPERTY_NO_VALUE_MSG, getLine()));
            }

            // parse property value and save
            Boolean value = Boolean.valueOf(i.next());
            properties.put(key, value);
View Full Code Here


            String keyStorePath = _serverConfiguration.getManagementKeyStorePath();

            //check the keystore path value is valid
            if (keyStorePath == null)
            {
                throw new ConfigurationException("JMX management SSL keystore path not defined, " +
                                                 "unable to start SSL protected JMX ConnectorServer");
            }
            else
            {
                //ensure the system property is set (for use by SslRMIClientSocketFactory and SslRMIServerSocketFactory)
                System.setProperty("javax.net.ssl.keyStore", keyStorePath);

                //check the file is usable
                File ksf = new File(keyStorePath);

                if (!ksf.exists())
                {
                    throw new FileNotFoundException("Cannot find JMX management SSL keystore file: " + ksf);
                }
                if (!ksf.canRead())
                {
                    throw new FileNotFoundException("Cannot read JMX management SSL keystore file: "
                                                    + ksf +  ". Check permissions.");
                }

                CurrentActor.get().message(ManagementConsoleMessages.SSL_KEYSTORE(ksf.getAbsolutePath()));
            }

            if (_serverConfiguration.getManagementKeyStorePassword() == null)
            {
                throw new ConfigurationException("JMX management SSL keystore password not defined, " +
                                                 "unable to start requested SSL protected JMX server");
            }
            else
            {
               System.setProperty("javax.net.ssl.keyStorePassword",
View Full Code Here

        {
            passwordFileEntry = new Passwd().getOutput("admin", "admin");
        }
        catch (NoSuchAlgorithmException e)
        {
            throw new ConfigurationException(e);
        }

        // store the entry in the file
        File passwordFile = File.createTempFile("passwd", "pwd");
        passwordFile.deleteOnExit();
View Full Code Here

        {
            _groupDatabase.setGroupFile(groupFile);
        }
        catch (IOException e)
        {
            throw new ConfigurationException("Unable to set group file " + groupFile, e);
        }
    }
View Full Code Here

        {
            createAuthManagers(serverConfiguration.getConfig());

            if(_classToAuthManagerMap.isEmpty())
            {
                throw new ConfigurationException("No authentication managers configured within the configuration file.");
            }

            _defaultSubjectCreator = createDefaultSubectCreator(serverConfiguration, groupPrincipalAccessor);

            _portToSubjectCreatorMap = createPortToSubjectCreatorMap(serverConfiguration, groupPrincipalAccessor);
View Full Code Here

        if (getListValue("security.jmx.access").size() > 0)
        {
            String message = "Validation error : security/jmx/access is no longer a supported element within the configuration xml."
                    + (_configFile == null ? "" : " Configuration file : " + _configFile);
            throw new ConfigurationException(message);
        }

        if (getListValue("security.jmx.principal-database").size() > 0)
        {
            String message = "Validation error : security/jmx/principal-database is no longer a supported element within the configuration xml."
                    + (_configFile == null ? "" : " Configuration file : " + _configFile);
            throw new ConfigurationException(message);
        }

        if (getListValue("security.principal-databases.principal-database(0).class").size() > 0)
        {
            String message = "Validation error : security/principal-databases is no longer supported within the configuration xml."
                    + (_configFile == null ? "" : " Configuration file : " + _configFile);
            throw new ConfigurationException(message);
        }

        // QPID-3266.  Tidy up housekeeping configuration option for scheduling frequency
        if (contains("housekeeping.expiredMessageCheckPeriod"))
        {
            String message = "Validation error : housekeeping/expiredMessageCheckPeriod must be replaced by housekeeping/checkPeriod."
                    + (_configFile == null ? "" : " Configuration file : " + _configFile);
            throw new ConfigurationException(message);
        }

        String[] ports = getConfig().getStringArray(SECURITY_PORT_MAPPINGS_PORT_MAPPING_PORT);
        String[] authManagers = getConfig().getStringArray(SECURITY_PORT_MAPPINGS_PORT_MAPPING_AUTH_MANAGER);
        if (ports.length != authManagers.length)
        {
            throw new ConfigurationException("Validation error: Each port-mapping must have exactly one port and exactly one auth-manager.");
        }

        // QPID-3517: Inconsistency in capitalisation in the SSL configuration keys used within the connector and management configuration
        // sections. For the moment, continue to understand both but generate a deprecated warning if the less preferred keystore is used.
        for (String key : new String[] {"management.ssl.keystorePath",
View Full Code Here

        else if(serverConfiguration.getDefaultAuthenticationManager() != null)
        {
            defaultAuthenticationManager = _classToAuthManagerMap.get(serverConfiguration.getDefaultAuthenticationManager());
            if(defaultAuthenticationManager == null)
            {
                throw new ConfigurationException("No authentication managers configured of type "
                                                 + serverConfiguration.getDefaultAuthenticationManager()
                                                 + " which is specified as the default.  Available managers are: "
                                                 + _classToAuthManagerMap.keySet());
            }
        }
        else
        {
            throw new ConfigurationException("If more than one authentication manager is configured a default MUST be specified.");
        }
        return new SubjectCreator(defaultAuthenticationManager, groupAccessor);
    }
View Full Code Here

        Configuration vhostConfig = conf.subset("virtualhosts");

        // Only one configuration mechanism allowed
        if (!vhostFiles.isEmpty() && !vhostConfig.subset("virtualhost").isEmpty())
        {
            throw new ConfigurationException("Only one of external or embedded virtualhosts configuration allowed.");
        }

        // We can only have one vhosts XML file included
        if (vhostFiles.size() > 1)
        {
            throw new ConfigurationException("Only one external virtualhosts configuration file allowed, multiple filenames found.");
        }

        // Virtualhost configuration object
        Configuration vhostConfiguration = new HierarchicalConfiguration();

        // Load from embedded configuration if possible
        if (!vhostConfig.subset("virtualhost").isEmpty())
        {
            vhostConfiguration = vhostConfig;
        }
        else
        {
        // Load from the external configuration if possible
        for (String fileName : vhostFiles)
          {
              // Open the vhosts XML file and copy values from it to our config
                _vhostsFile = new File(fileName);
                if (!_vhostsFile.exists())
                {
                    throw new ConfigurationException("Virtualhosts file does not exist");
                }
            vhostConfiguration = parseConfig(new File(fileName));

                // save the default virtualhost name
                String defaultVirtualHost = vhostConfiguration.getString("default");
View Full Code Here

        {

            AuthenticationManager authenticationManager = _classToAuthManagerMap.get(portMapping.getValue());
            if(authenticationManager == null)
            {
                throw new ConfigurationException("Unknown authentication manager class " + portMapping.getValue() +
                                                " configured for port " + portMapping.getKey());
            }

            SubjectCreator subjectCreator = new SubjectCreator(authenticationManager, groupPrincipalAccessor);
            portToSubjectCreatorMap.put(portMapping.getKey(), subjectCreator);
View Full Code Here

    {
        try
        {
            if (!containsPositiveLong(property))
            {
                throw new ConfigurationException(this.getClass().getSimpleName()
                                                 + ": '" + property +
                                                 "' must be a Positive Long value.");
            }
        }
        catch (Exception e)
        {
            Throwable last = e;

            // Find the first cause
            if (e instanceof ConversionException)
            {
                Throwable t = e.getCause();
                while (t != null)
                {
                    last = t;
                    t = last.getCause();
                }
            }

            throw new ConfigurationException(this.getClass().getSimpleName() +
                                             ": unable to configure invalid " +
                                             property + ":" +
                                             _config.getString(property),
                                             last);
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.ConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.