예제 #1
0
파일: OCPAgent.java 프로젝트: ccbon/ocp
  public void readConfig() throws Exception {

    // debugging aspect
    if (ds().getProperty("debug", "false").equalsIgnoreCase("true")) {
      LOG.debug_on();
      LOG.info("working directory = " + System.getProperty("user.dir"));
    }

    Iterator<String> it = ds().iterator();
    while (it.hasNext()) {
      String key = it.next();
      String value = ds().getProperty(key);
      LOG.info(key + "=" + value);
    }
    name = ds().getProperty("name", "anonymous");

    // each agent has its own symmetric key cipher
    // TODO: test with other algo than AES
    KeyGenerator keyGen = KeyGenerator.getInstance(this.ds().getProperty("cypher.algo", "AES"));
    keyGen.init(Integer.parseInt(this.ds().getProperty("cipher.keysize", "128")));
    secretKey = keyGen.generateKey();
    cipher = Cipher.getInstance(this.ds().getProperty("cipher.algo", "AES"));

    // user cipher
    byte[] salt = {1, 1, 1, 2, 2, 2, 3, 3};
    int count = 20;
    userParamSpec = new PBEParameterSpec(salt, count);
  }