Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.ConfigurationException


            final AuthenticationManager tmp = factory.newInstance(securityConfiguration);
            if (tmp != null)
            {
                if(_classToAuthManagerMap.containsKey(tmp.getClass().getSimpleName()))
                {
                    throw new ConfigurationException("Cannot configure more than one authentication manager of type "
                                                     + tmp.getClass().getSimpleName() + "."
                                                     + " Remove configuration for one of the authentication managers.");
                }
                _classToAuthManagerMap.put(tmp.getClass().getSimpleName(),tmp);
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 defaultAuthenticationManager;
    }
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());
            }
            portToAuthenticationManagerMap.put(portMapping.getKey(), authenticationManager);
        }
View Full Code Here

        {
            _pluginManager = new PluginManager(_configuration.getPluginDirectory(), _configuration.getCacheDirectory(), _bundleContext);
        }
        catch (Exception e)
        {
            throw new ConfigurationException(e);
        }

        _configuration.initialise();
    }
View Full Code Here

                _felix.start();
                _logger.info("Started plugin manager framework");
            }
            catch (BundleException e)
            {
                throw new ConfigurationException("Could not start plugin manager: " + e.getMessage(), e);
            }

            bundleContext = _activator.getContext();
        }
        else
View Full Code Here

        // all rules must have an access attribute or a default value
        if (_finalConfig.getList("rule[@access]").size() == 0 &&
            getConfig().getString("[@default-action]") == null)
        {
            throw new ConfigurationException("No rules or default-action found in firewall configuration.");
        }
    }
View Full Code Here

    public void validateConfiguration() throws ConfigurationException
    {
        String filename = getFileName();
        if (filename == null)
        {
            throw new ConfigurationException("No ACL file name specified");
        }

        File aclFile = new File(filename);
       
        ConfigurationFile configFile = new PlainConfiguration(aclFile);
View Full Code Here

                        // pull out the first token from the bottom of the stack and check arguments exist
                        String first = stack.firstElement();
                        stack.removeElementAt(0);
                        if (stack.isEmpty())
                        {
                            throw new ConfigurationException(String.format(NOT_ENOUGH_TOKENS_MSG, getLine()));
                        }
                       
                        // check for and parse optional initial number for ACL lines
                        Integer number = null;
                        if (StringUtils.isNumeric(first))
                        {
                            // set the acl number and get the next element
                            number = Integer.valueOf(first);                           
                            first = stack.firstElement();
                            stack.removeElementAt(0);
                        }

                        if (StringUtils.equalsIgnoreCase(ACL, first))
                        {
                            parseAcl(number, stack);
                        }
                        else if (number == null)
                        {
                            if (StringUtils.equalsIgnoreCase(GROUP, first))
                            {
                                parseGroup(stack);
                            }
                            else if (StringUtils.equalsIgnoreCase(CONFIG, first))
                            {
                                parseConfig(stack);
                            }
                            else
                            {
                                throw new ConfigurationException(String.format(UNRECOGNISED_INITIAL_MSG, first, getLine()));
                            }
                        }
                        else
                        {
                            throw new ConfigurationException(String.format(NUMBER_NOT_ALLOWED_MSG, first, getLine()));
                        }
                       
                        // reset stack, start next line
                        stack.clear();
                        break;
                    case StreamTokenizer.TT_NUMBER:
                        stack.push(Integer.toString(Double.valueOf(_st.nval).intValue()));
                        break;
                    case StreamTokenizer.TT_WORD:
                        stack.push(_st.sval); // token
                        break;
                    default:
                        if (_st.ttype == CONTINUATION)
                        {
                            int next = _st.nextToken();
                            if (next == StreamTokenizer.TT_EOL)
                            {
                              break; // continue reading next line
                            }
                           
                            // invalid location for continuation character (add one to line beacuse we ate the EOL)
                            throw new ConfigurationException(String.format(PREMATURE_CONTINUATION_MSG, getLine() + 1));
                        }
                        else if (_st.ttype == '\'' || _st.ttype == '"')
                        {
                            stack.push(_st.sval); // quoted token
                        }
                        else
                        {
                            stack.push(Character.toString((char) _st.ttype)); // single character
                        }
                }
            } while (current != StreamTokenizer.TT_EOF);
       
            if (!stack.isEmpty())
            {
                throw new ConfigurationException(String.format(PREMATURE_EOF_MSG, getLine()));
            }
        }
        catch (IllegalArgumentException iae)
        {
            throw new ConfigurationException(String.format(PARSE_TOKEN_FAILED_MSG, getLine()), iae);
        }
        catch (FileNotFoundException fnfe)
        {
            throw new ConfigurationException(String.format(CONFIG_NOT_FOUND_MSG, getFile().getName()), fnfe);
        }
        catch (IOException ioe)
        {
            throw new ConfigurationException(String.format(CANNOT_LOAD_MSG, getFile().getName()), ioe);
        }
       
        return ruleSet;
    }
View Full Code Here

   
    private void parseGroup(List<String> args) throws ConfigurationException
    {
        if (args.size() < 2)
        {
            throw new ConfigurationException(String.format(NOT_ENOUGH_GROUP_MSG, getLine()));
        }
       
        getConfiguration().addGroup(args.get(0), args.subList(1, args.size()));
    }
View Full Code Here

   
    private void parseAcl(Integer number, List<String> args) throws ConfigurationException
    {
        if (args.size() < 3)
        {
            throw new ConfigurationException(String.format(NOT_ENOUGH_ACL_MSG, getLine()));
        }

        Permission permission = Permission.parse(args.get(0));
        String identity = args.get(1);
        Operation operation = Operation.parse(args.get(2));
       
        if (number != null && !getConfiguration().isValidNumber(number))
        {
            throw new ConfigurationException(String.format(BAD_ACL_RULE_NUMBER_MSG, getLine()));
        }
       
        if (args.size() == 3)
        {
            getConfiguration().grant(number, identity, permission, operation);
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.