Package org.keyczar.exceptions

Examples of org.keyczar.exceptions.KeyczarException


        try {
            Stat stat = new Stat();
            byte[] data = zk.getData(path, null, stat);
            return new String(data, Charsets.UTF_8);
        } catch (IOException e) {
            throw new KeyczarException("Error reading key", e);
        } catch (KeeperException e) {
            throw new KeyczarException("Error reading key", e);
        }
    }
View Full Code Here


    private boolean exists(String path) throws KeyczarException {
        try {
            Stat stat = zk.exists(path, false);
            return stat != null;
        } catch (IOException e) {
            throw new KeyczarException("Error reading key", e);
        } catch (KeeperException e) {
            throw new KeyczarException("Error reading key", e);
        }
    }
View Full Code Here

                zk.createOrUpdate(path, data, true);
            } catch (KeeperException e) {
                throw new IOException("Error writing key", e);
            }
        } catch (IOException e) {
            throw new KeyczarException(Messages.getString("KeyczarTool.UnableToWrite", location), e);
        }
    }
View Full Code Here

    MessageDigest md = DIGEST_QUEUE.poll();
    if (md == null) {
      try {
        md = MessageDigest.getInstance("SHA-1");
      } catch (NoSuchAlgorithmException e) {
        throw new KeyczarException(e);
      }
    }
    for (byte[] array : inputs) {
      md.update(fromInt(array.length));
      md.update(array);
View Full Code Here

    MessageDigest md = DIGEST_QUEUE.poll();
    if (md == null) {
      try {
        md = MessageDigest.getInstance("SHA-1");
      } catch (NoSuchAlgorithmException e) {
        throw new KeyczarException(e);
      }
    }
    for (byte[] array : inputs) {
      md.update(array);
    }
View Full Code Here

      return signature.getBytes();
    } else if (generateParams.get("encoding").equals("unencoded")) {
      byte[] signature = signer.sign(testData.getBytes());
      return signature;
    } else {
      throw new KeyczarException("Expects encoded or unencoded in parameters");
    }
  }
View Full Code Here

      if (generateParams.get("encoding").equals("encoded")) {
        assert(verifier.verify(testData, new String(readOutput(output))));
      } else if (generateParams.get("encoding").equals("unencoded")) {
        assert(verifier.verify(testData.getBytes(), readOutput(output)));
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else if (testParams.get("class").equals("verifier")) {
      UnversionedVerifier verifier = new UnversionedVerifier(
          getReader(algorithm, generateParams.get("cryptedKeySet"), testParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        assert(verifier.verify(testData, new String(readOutput(output))));
      } else if (generateParams.get("encoding").equals("unencoded")) {
        assert(verifier.verify(testData.getBytes(), readOutput(output)));
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else {
      throw new KeyczarException("Expects signer or verifier in parameters");
   
  }
View Full Code Here

        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else if (generateParams.get("class").equals("encrypter")) {
      Encrypter crypter = new Encrypter(
          getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
      if (generateParams.get("encoding").equals("encoded")) {
        String ciphertext = crypter.encrypt(testData);
        return ciphertext.getBytes();
      } else if (generateParams.get("encoding").equals("unencoded")) {
        byte[] ciphertext = crypter.encrypt(testData.getBytes());
        return ciphertext;
      } else {
        throw new KeyczarException("Expects encoded or unencoded in parameters");
      }
    } else {
      throw new KeyczarException("Expects crypter or encrypter in parameters");
    }
  }
View Full Code Here

      assert(plaintext.equals(testData));
    } else if (generateParams.get("encoding").equals("unencoded")) {
      byte[] plaintext = crypter.decrypt(readOutput(output));
      assert((new String(plaintext)).equals(testData));
    } else {
      throw new KeyczarException("Expects encoded or unencoded in parameters");
    }
  }
View Full Code Here

      return signature.getBytes();
    } else if (generateParams.get("encoding").equals("unencoded")) {
      byte[] signature = signer.sign(testData.getBytes());
      return signature;
    } else {
      throw new KeyczarException("Expects encoded or unencoded in parameters");
    }
  }
View Full Code Here

TOP

Related Classes of org.keyczar.exceptions.KeyczarException

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.