Package org.keyczar.exceptions

Examples of org.keyczar.exceptions.KeyczarException


      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")) {
      Verifier verifier = new Verifier(
          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


    } else if (name.equals("sign")){
      return new SignOperation(keyPath, testData);
    } else if (name.equals("encrypt")){
      return new EncryptOperation(keyPath, testData);
    } else {
      throw new KeyczarException("Operation does not exist");
    }
  }
View Full Code Here

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

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

   */
  public URI sign(URI uri, String sigParam) throws KeyczarException {
    try {
      uri = canonicalUri(uri);
    } catch (URISyntaxException e) {
      throw new KeyczarException(e);
    }
    String uriString = uri.toASCIIString();
    String sig = signer.sign(uriString);
    String signedQuery = sigParam + "=" + sig;
    String query = uri.getQuery();
    if (query != null) {
      signedQuery = query + "&" + signedQuery;
    }

    try {
      return new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(),
          signedQuery, uri.getFragment());
    } catch (URISyntaxException e) {
      throw new KeyczarException(e);
    }
  }
View Full Code Here

      byte[] contents = new byte[(int) file.length()];
      file.read(contents);
      file.close();
      return new String(contents);
    } catch (IOException e) {
      throw new KeyczarException(
          Messages.getString("KeyczarFileReader.FileError", filename), e);
    }
  }
View Full Code Here

    try {
      KeyFactory kf = KeyFactory.getInstance(KEY_GEN_ALGORITHM);
      jcePrivateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(pkcs8Bytes));
      publicKey.init();
    } catch (GeneralSecurityException e) {
      throw new KeyczarException(e);
    }
  }
View Full Code Here

      kpg.initialize(key.size());
      KeyPair pair = kpg.generateKeyPair();
      key.jcePrivateKey = pair.getPrivate();
      key.publicKey.set(pair.getPublic().getEncoded());
    } catch (GeneralSecurityException e) {
      throw new KeyczarException(e);
    }
    key.pkcs8 = Base64Coder.encodeWebSafe(key.jcePrivateKey.getEncoded());
    key.init();
    return key;
  }
View Full Code Here

  public boolean verify(String data, String signature) throws KeyczarException {
    try {
      return verify(data.getBytes(Keyczar.DEFAULT_ENCODING),
          Base64Coder.decode(signature));
    } catch (UnsupportedEncodingException e) {
      throw new KeyczarException(e);
    }
  }
View Full Code Here

        // Make sure we use our own impl; there may be other EC signature
        // generators...
        signature = Signature.getInstance(SIG_ALGORITHM, EcCore.NAME);
        verifyingStream = (VerifyingStream) publicKey.getStream();
      } catch (GeneralSecurityException e) {
        throw new KeyczarException(e);
      }
    }
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.