Package org.osgi.service.cm

Examples of org.osgi.service.cm.ConfigurationException


          forbiddenGroup = ((String) value).trim();
          TelnetConfig.configuration.put(key, value);
        } else
          TelnetConfig.configuration.put(key, value);
      } catch (IndexOutOfBoundsException ioobe) {
        throw new ConfigurationException(key, "Wrong type");
      } catch (ClassCastException cce) {
        throw new ConfigurationException(key, "Wrong type: "
                                         + value.getClass().getName());
      }
    }
  }
View Full Code Here


        {
            context = SSLContext.getInstance(ConstsIf.PROT_TLS_V1);
       
        } catch (NoSuchAlgorithmException e)
        {
            throw new ConfigurationException(
                        "",
                        "creating SSLContext: ERROR no such algorithm");
        }

       
        //Step 2: obtain a key store instance, type is fixed
        KeyStore myKeys;
        try
        {
            myKeys = KeyStore.getInstance(ConstsIf.KS_TYPE_JKS);

        } catch (KeyStoreException e1)
        {
            throw new ConfigurationException(
                        "",
                        "creating SSLContext: ERROR no such algorithm");
        }

       
        InputStream is = null;
        char[] keyPassPhrase = null;

        if (!isDefaultConfig)
        {
            //Step 3:obtain password phrase for a keystore
            try
            {
                keyPassPhrase = ((String) m_config.get(KEYSTOREPASS_KEY)).toCharArray();
           
            } catch (Exception epass) {}
   
            //Step 4:obtain input stream for a key store
            // - if the config admin set it to type byte[], assume it is a keystore itself
            // - else if it is of type string try to interpret this string as an (absolute) path
            //   to a file
            // - else assume that this is a incomplete configruation we got from the CM Admin,
            //   use the default keystore
   
            // from CM as byte[] ?
            if ((keyPassPhrase != null) && (is == null))
            {       
                try
                {
                    is = new ByteArrayInputStream((byte[]) m_config.get(KEYSTORE_KEY));
       
                } catch (Exception eb) {}
            }       
   
            //from CM as a file pointer ?
            if ((keyPassPhrase != null) && (is == null))
            {       
                try
                {
                    is = new FileInputStream((String) m_config.get(KEYSTORE_KEY));
               
                } catch (Exception ef) {}
            }
       
            if ((is == null) &&  m_log.doWarn())
            {
                m_log.warn("using default, config is invalid: " + m_config.get("service.pid"));
            }
        }
       
        // Step 3 & 4 executed now if config is bad or we just use the default config
        if (is == null)
        {      
            try
            {
                keyPassPhrase = DEFAULT_PASSPHR_VALUE.toCharArray();
                is = getClass().getResourceAsStream(DEFAULT_KEYSTORE_VALUE);
           
            } catch (Exception edef)
            {
            }
        }
       
        // Step 5: load keys into keystore
        try
        {
            myKeys.load(is, keyPassPhrase);
           
        } catch (Exception eload)
        {
            throw new ConfigurationException(
                            KEYSTORE_KEY + "," + KEYSTOREPASS_KEY,
                            "ERROR loading keys !, passphrase " + String.valueOf(keyPassPhrase));
        }
       
        //Step 6: create and initialize KeyManagerFactory
        KeyManagerFactory kmf;
        try
        {
            kmf = KeyManagerFactory.getInstance(ConstsIf.KM_TYPE_SUN);

        } catch (NoSuchAlgorithmException e4)
        {
            throw new ConfigurationException(
                        "",
                        "creating KeyManagerFactory: ERROR no such algorithm");
        }
        try
        {
            kmf.init(myKeys, keyPassPhrase);

        } catch (Exception e5)
        {
            throw new ConfigurationException(
                        "",
                        "initing kmf: " + e5.getMessage());
        }
       
        //Step 7: initialize context with the key manager factory
        try
        {
            context.init(kmf.getKeyManagers(), null, null);

        } catch (KeyManagementException e6)
        {
            throw new ConfigurationException(
                        "",
                        "initing SSLContext: " + e6.getMessage());
        }
   
        //Step 8: create SSL Server Socket Factory
        SSLServerSocketFactory ssl = null;
        try
        {
      ssl = context.getServerSocketFactory();
   
        } catch (Exception e7)
        {
            throw new ConfigurationException(
                    "",
                    "creating SSLServerSocketFactory object: " + e7.getMessage());       
        }

        m_reg = m_bc.registerService(SSLServerSocketFactory.class.getName(),
View Full Code Here

        valid = false;
        try {
          acceptConfig(cfg);
          valid = true;
        } catch (Exception all) {
          throw new ConfigurationException(null,
              "Fault occurred when " + "setting configuration. "
                  + "Check that all properties "
                  + "are valid.");
        } finally {
          if (!valid) {
View Full Code Here

              + " Correct type to use is String. " + obj + " "
              + obj.getClass().getName());
    }
    int filterVal = LogUtil.toLevel(filter, -1);
    if (filterVal == -1) {
      throw new ConfigurationException(L_FILTER, "Undefined log level <"
          + filter + ">.");
    }
    if (filterVal == 0) {
      cfg.put(L_FILTER, LogUtil.fromLevel(LOG_WARNING));
    }
View Full Code Here

                  + "Please supply a valid log level.");
        }
        int testFilter = 0;
        testFilter = LogUtil.toLevel((bundle[FILTER_POS].trim()), -1);
        if (testFilter == -1) {
          throw new ConfigurationException
              (BL_FILTERS,
                  "Undefined log level <" + bundle[FILTER_POS]
                      + "> specified for bundle <"
                      + bundle[LOCATION_POS] + ">.");
        }
View Full Code Here

            // Get console service
            srefConsole = bc.getServiceReference(consoleServiceName);
            sConsole = (ConsoleService) bc.getService(srefConsole);
            if (sConsole == null) {
                log(LogService.LOG_ERROR, "Failed to get ConsoleService");
                throw new ConfigurationException(null,
                        "Failed to get ConsoleService");
            }
        }
        tAccept = new AcceptThread(sConsole);
        tAccept.setDaemon(false);
View Full Code Here

         * always be executed synchronously, e.g. in this invocation. This might
         * not be the case for HTTPs, which might happen on different threads.
         * Therefore, try to throw any ConfigurationEx as early as possible
         */
        if ((port < 0) || (port > 0xFFFF)) {
            throw new ConfigurationException(
                    (httpConfig.isSecure() ? HttpConfig.HTTPS_PORT_KEY
                            : HttpConfig.HTTP_PORT_KEY), "invalid value="
                            + port);

        }
        if (maxConnections < 1) {
            throw new ConfigurationException("maxConnections", "invalid value="
                    + maxConnections);

        }

        if (!isSecure) {
            // for HTTP create the socket right away AND start
            try {
                if (log.doDebug())
                    log.debug("Creating socket");
                if (host == null || host.length() == 0) {
                    socket = new ServerSocket(port, maxConnections);
                } else {
                    try {
                        socket = new ServerSocket(port, maxConnections,
                                InetAddress.getByName(host));
                    } catch (UnknownHostException uhe) {
                        socket = new ServerSocket(port, maxConnections);
                    }
                }

                init();

            } catch (Exception e) {
                if (log.doDebug())
                    log.debug("Exception creating HTTP Socket", e);
                throw new ConfigurationException(
                        "Exception creating HTTP Socket", e.toString());
            }

        } else // secure case, can not create socket by myself, need to get
                // service
View Full Code Here

          this.requireClientAuth = ((Boolean) value).booleanValue();
          this.configuration.put(key, value);
        } else
          this.configuration.put(key, value);
      } catch (IndexOutOfBoundsException ioobe) {
        throw new ConfigurationException(key, "Wrong type");
      } catch (ClassCastException cce) {
        throw new ConfigurationException(key, "Wrong type: "
                                         + value.getClass().getName());
      }
    }
  }
View Full Code Here

    public void updated(Dictionary dict) throws ConfigurationException {
        if (dict != null) {
            String locationString = (String) dict.get(KEY_REPOSITORY_LOCATION);
            if (locationString == null) {
                throw new ConfigurationException(KEY_REPOSITORY_LOCATION, "Property missing.");
            }
            URL location;
            try {
                location = new URL(locationString);
            }
            catch (MalformedURLException e) {
                throw new ConfigurationException(KEY_REPOSITORY_LOCATION, "Location " + locationString + " is not a valid URL.");
            }
            String customer = (String) dict.get(KEY_REPOSITORY_CUSTOMER);
            if (customer == null) {
                throw new ConfigurationException(KEY_REPOSITORY_CUSTOMER, "Property missing.");
            }
            String name = (String) dict.get(KEY_REPOSITORY_NAME);
            if (name == null) {
                throw new ConfigurationException(KEY_REPOSITORY_NAME, "Property missing.");
            }

            String fileRoot = FILE_ROOT + File.separator + location.getAuthority().replace(':', '-') + location.getPath().replace('/', '\\') + File.separator + customer + File.separator + name + File.separator;
            File local = getFile(fileRoot + "local");
            File backup = getFile(fileRoot + "backup");
View Full Code Here

    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void updated(String pid, Dictionary properties)
    throws ConfigurationException {
        final String name = (String) properties.get(ModifiableThreadPoolConfig.PROPERTY_NAME);
        if ( name == null || name.length() == 0 ) {
            throw new ConfigurationException(ModifiableThreadPoolConfig.PROPERTY_NAME, "Property is missing or empty.");
        }
        this.logger.debug("Updating {} with {}", pid, properties);
        Entry createdEntry = null;
        synchronized ( this.pools ) {
            final ThreadPoolConfig config = this.createConfig(properties);
View Full Code Here

TOP

Related Classes of org.osgi.service.cm.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.