Examples of Crypter


Examples of org.keyczar.Crypter

            path = IoUtils.resolve("~/passwordrecovery");
        }

        log.info("Checking for existing password-recovery key");
        {
            Crypter crypter = null;
            GenericKeyczar store = keyczarFactory.find(Secrets.KEY_FORGOT_PASSWORD_PUBLIC, crypter);
            if (store != null) {
                // TODO: Should we allow key rotation? Replacement?
                log.info("Password-recovery key already exists");
                return;
View Full Code Here

Examples of org.keyczar.Crypter

        return (T) newBuilder.build();
    }

    public static <T extends GeneratedMessage> T unlock(ByteString secured, AesKey key,
            GeneratedMessage.Builder newBuilder) throws IOException {
        Crypter crypter = KeyczarUtils.buildCrypter(key);
        return unlock(secured, crypter, newBuilder);
    }
View Full Code Here

Examples of org.keyczar.Crypter

                        newBuilder);
            default:
                throw new IllegalArgumentException();
            }
        } else if (version == 1) {
            Crypter crypter;

            switch (encryptedWith) {
            case PUBLIC_KEY:
                crypter = user.getKeys().getAsymetricCrypter();
                break;
View Full Code Here

Examples of org.keyczar.Crypter

                version = 1;
            }
        }

        if (version == 1) {
            Crypter crypter;

            switch (encryptedWith) {
            case PUBLIC_KEY:
                throw new IllegalArgumentException();
            case SECRET_KEY:
View Full Code Here

Examples of org.keyczar.Crypter

            }

            AesKey aesKey;

            if (version == 1) {
                Crypter crypter = new Crypter(recoveryKey);

                byte[] plaintext;
                try {
                    plaintext = crypter.decrypt(entry.getCiphertext().toByteArray());
                } catch (KeyczarException e) {
                    throw new IllegalStateException("Error decrypting token", e);
                }

                aesKey = KeyczarUtils.unpack(plaintext);
View Full Code Here

Examples of org.keyczar.Crypter

        return new SecretToken(type, key, null);
    }

    byte[] encrypt(byte[] plaintext) {
        try {
            Crypter crypter = getCrypter();
            return crypter.encrypt(plaintext);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error encrypting data", e);
        }
    }
View Full Code Here

Examples of org.keyczar.Crypter

        // TODO: Cache??
        return KeyczarUtils.buildCrypter(cryptoKey);
    }

    byte[] decrypt(byte[] ciphertext) throws KeyczarException {
        Crypter crypter = getCrypter();
        return crypter.decrypt(ciphertext);
    }
View Full Code Here

Examples of org.keyczar.Crypter

        try {
            if (privateKey == null) {
                privateKey = KeyczarUtils.readRsaPrivateKey(userSecretData.getPrivateKey().getKeyczar());
            }
            // TODO: Cache crypter?
            return new Crypter(new KeyczarReaderWrapper(privateKey));
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error reading private key", e);
        }
    }
View Full Code Here

Examples of org.keyczar.Crypter

  @Override
  public byte[] generate(String algorithm, Map<String, String> generateParams)
      throws KeyczarException {
    if (generateParams.get("class").equals("crypter")) {
      Crypter crypter = new Crypter(
          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 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 {
View Full Code Here

Examples of org.keyczar.Crypter

  @Override
  public void test(
      Map<String, String> output, String algorithm, Map<String, String> generateParams,
      Map<String, String> testParams) throws KeyczarException {
    Crypter crypter = new Crypter(
        getReader(algorithm, generateParams.get("cryptedKeySet"), ""));
    if (generateParams.get("encoding").equals("encoded")) {
      String plaintext = crypter.decrypt(new String(readOutput(output)));
      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
TOP
Copyright © 2018 www.massapi.com. 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.