Package java.util

Examples of java.util.Properties


   * @return A decrypted Properies object with all of the properties from the
   *         CentraView Customer server.
   */
  private static final Properties decryptLicenseFile(Key blowfishKey, byte[] licenseFile)
  {
    Properties returnProperties = null;
    try {
      byte[] zeros = new byte[8];
      Arrays.fill(zeros, (byte)0);
      IvParameterSpec ivSpec = new IvParameterSpec(zeros);
      Cipher cipher = Cipher.getInstance("Blowfish/CBC/PKCS5Padding");
      cipher.init(Cipher.DECRYPT_MODE, blowfishKey, ivSpec);

      ByteArrayInputStream byteArrayInStream = new ByteArrayInputStream(cipher.doFinal(licenseFile));
      returnProperties = new Properties();
      returnProperties.load(byteArrayInStream);
    } catch (Exception exception) {
      logger.error("decryptLicenseFile: generic Exception", exception);
    }
    return returnProperties;
  } //end of decryptLicenseFile method
View Full Code Here


  {
    boolean returnValue = false;
    try {
      SettingsInterface settings = Settings.getInstance();
      LicenseInstanceVO licenseInstanceVO = new LicenseInstanceVO();
      Properties props = new Properties();

      props.setProperty(PROPS_MAC_KEY, settings.getMACAddress());
      props.setProperty(PROPS_HOST_NAME_KEY, LicenseUtil.getHostName(dataSource));
      props.setProperty(PROPS_TIMESTAMP_KEY, String.valueOf(Calendar.getInstance().getTimeInMillis()));
      String licenseKey = LicenseUtil.getLicenseKey(dataSource);
      if (null == licenseKey) {
        props.setProperty(PROPS_LICENSE_KEY, "");
      } else {
        props.setProperty(PROPS_LICENSE_KEY, licenseKey);
      }

      HashMap names = LicenseUtil.getEntityNameAndIndividualName(dataSource);
      String entityName = "";
      String individualName = "";
      if (!names.isEmpty()) {
        entityName = (String)names.get("entityName");
        individualName =(String)names.get("individualName");
      }

      props.setProperty(PROPS_ENTITY_KEY, entityName);
      props.setProperty(PROPS_INDIVIDUAL_KEY, individualName);
      props.setProperty(PROPS_CV_VERSION_KEY, CentraViewConfiguration.getVersion());
      logger.debug("fetchLicenseFile: ServerProperties being sent: ");
      logger.debug(props);

      Key blowfishKey = LicenseUtil.generateBlowfishKey();
      byte[] encryptedServerData = LicenseUtil.encryptServerData(blowfishKey, props);
      byte[] encryptedBlowfishKey = LicenseUtil.encryptBlowfishKey(blowfishKey);
      Byte[] byteArrayServerData = (Byte[])LicenseUtil.convertToObjectArray(encryptedServerData);
      Byte[] byteArrayKeyData = (Byte[])LicenseUtil.convertToObjectArray(encryptedBlowfishKey);
      byte[] encryptedResponse = LicenseUtil.obtainLicenseFile(byteArrayKeyData, byteArrayServerData);
      logger.debug("fetchLicenseFile: Response Size: "+encryptedResponse.length+" bytes.");
      if (encryptedResponse.length < 1) {
        throw new AxisFault(SERVER_DOWN_MESSAGE);
      }
      logger.debug("fetchLicenseFile: Writing new license to disk.");
      File centraViewLicenseFile = LicenseUtil.getCentraViewLicenseFile(dataSource);
      LicenseUtil.writeLicenseFileToDisk(encryptedResponse, centraViewLicenseFile);
      logger.debug("fetchLicenseFile: Decrpting License.");
      byte[] encryptedLicenseFile = LicenseUtil.getLicenseFromLicenseFile(encryptedResponse);
      byte[] encryptedKey = LicenseUtil.getKeyFromLicenseFile(encryptedResponse);
      Key newBlowfishKey = LicenseUtil.decryptBlowfishKey(encryptedKey);
      Properties licenseFile = LicenseUtil.decryptLicenseFile(newBlowfishKey, encryptedLicenseFile);
      logger.debug("fetchLicenseFile: The recieved license file:");
      logger.debug(licenseFile);
      //do SHA to make sure is valid
      //save data to database.
      licenseInstanceVO.updateLicenseInformation(licenseFile);
View Full Code Here

      if (initialContext == null) {
        // so one or both aren't set. Either the LoadProperties filter failed,
        // or
        // we could be calling from JBoss and for somereason it isn't setup.
        // So we are going to try and default.
        Properties props = new Properties();
        props.setProperty(NAMING_FACTORY_KEY, "org.jnp.interfaces.NamingContextFactory");
        props.setProperty(NAMING_PROVIDER_KEY, "jnp://localhost:1099");
        initialContext = new InitialContext(props);
      }
      return initialContext;
    } catch (Exception e) {
      logger.error("[getInitialContext] Exception thrown.", e);
View Full Code Here

     * @param path path to the properties file relative to the classpath
     */
    static void loadProperties(String path) {
        InputStream stream = null;
        try {
            Properties props = new Properties();
            stream = ProtocolDirectory.class.getResourceAsStream(path);
            if (stream == null) {
                throw new RuntimeException("Unable to load required properties file '" + path + '\'');
            }
            props.load(stream);

            for (Iterator iter = props.keySet().iterator(); iter.hasNext();) {
                String name = (String) iter.next();
                String objectName = props.getProperty(name);
                Protocol inst = loadProtocol(objectName);
                s_protocolMap.put(name, inst);
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to load required properties file '" + path + '\'');
View Full Code Here

        setOutput(writer);
        nsSupport = new NamespaceSupport();
        prefixTable = new Hashtable();
        forcedDeclTable = new Hashtable();
        doneDeclTable = new Hashtable();
        outputProperties = new Properties();
    }
View Full Code Here

  @Test
  public void testLoadProperties()
  {

    Properties properties = ConfigUtils.loadProperties("/org/strecks/builder/strecks.properties");
    assert !properties.isEmpty();

    properties = ConfigUtils.loadProperties("empty.properties");
    assert properties.isEmpty();
  }
View Full Code Here

  @Test
  public void testGetDefaultConfig()
  {
    PropertiesBuilder builder = new PropertiesBuilder();
    ImplementationConfig implementationConfig = builder.getImplementationConfig(new Properties());

    assertEquals(implementationConfig.getActionCreatorClassName(), DefaultImplementations.ACTION_CREATOR);
    assertEquals(implementationConfig.getBuilderClassName(), DefaultImplementations.BUILDER);
    assertEquals(implementationConfig.getDelegateClassName(), DefaultImplementations.DELEGATE);
    assertEquals(implementationConfig.getContextFactoryClassName(), DefaultImplementations.ACTION_CONTEXT_FACTORY);
    assertEquals(implementationConfig.getFormHandlerClassName(), DefaultImplementations.FORM_HANDLER);
    assertEquals(implementationConfig.getFormValidationHandlerClassName(), DefaultImplementations.FORM_VALIDATION_HANDLER);
    assertEquals(implementationConfig.getFormPopulateSourceClassName(), DefaultImplementations.FORM_POPULATION_SOURCE);
    assertEquals(implementationConfig.getRequestPreprocessorClassName(), DefaultImplementations.REQUEST_PREPROCESSOR);

    InterceptorConfig interceptorConfig = builder.getInterceptorConfig(new Properties());
    assert interceptorConfig.getBeforeInterceptors().isEmpty();
    assert interceptorConfig.getAfterInterceptors().isEmpty();
  }
View Full Code Here

  @Test
  public void testGetModifiedConfig()
  {
    PropertiesBuilder builder = new PropertiesBuilder();
    Properties properties = ConfigUtils.loadProperties("/org/strecks/builder/strecks.properties");
    ImplementationConfig implementationConfig = builder.getImplementationConfig(properties);

    assertEquals(implementationConfig.getActionCreatorClassName(), "actionCreatorImpl");
    assertEquals(implementationConfig.getBuilderClassName(), "builderImpl");
    assertEquals(implementationConfig.getDelegateClassName(), "delegateImpl");
View Full Code Here

        initAliases();
    }

    public void initProperties() {
        propFile = "timefinder.properties";
        prop = new Properties();
        prop.setProperty("tf.column.separator", "TAB");
        prop.setProperty("tf.id.separator", "COMMA");
        prop.setProperty("tf.days", "5");
        prop.setProperty("tf.timeSlotsPerDay", "10");
        prop.setProperty("tf.msPerTimeSlot", "" + 1000 * 60 * 60L);
 
View Full Code Here

  private static Log log = LogFactory.getLog(ConfigUtils.class);

  public static Properties loadProperties(String resourceName)
  {
    Properties properties = new Properties();
    InputStream stream = ConfigUtils.class.getResourceAsStream(resourceName);

    try
    {
      properties.load(stream);
    }
    catch (IOException e)
    {
      log.warn("No " + resourceName + " found on classpath. Using default settings.");
    }
View Full Code Here

TOP

Related Classes of java.util.Properties

Copyright © 2015 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.