Package org.keyczar

Examples of org.keyczar.Signer


    @Override
    public Signer buildSigner(String key) {
        try {
            KeyczarReader child = keyczarFactory.getReader(key);
            return new Signer(child);
        } catch (KeyczarException e) {
            throw new IllegalStateException("Error building signer", e);
        }
    }
View Full Code Here


  }

  @Override
  public byte[] generate(String algorithm, Map<String, String> generateParams)
      throws KeyczarException{
    Signer signer = new Signer(
        getReader(algorithm, generateParams.get("cryptedKeySet"), ""));
    if (generateParams.get("encoding").equals("encoded")) {
      String signature = signer.sign(testData);
      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

  @Override
  public void test(
      Map<String, String> output, String algorithm, Map<String, String> generateParams,
      Map<String, String> testParams) 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")) {
        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

  @Override
  public byte[] generate(String algorithm, Map<String, String> generateParams)
      throws KeyczarException {
    Encrypter keyEncrypter = new Encrypter(
        getReader(algorithm, generateParams.get("cryptedKeySet"), generateParams.get("pubKey")));
    Signer signer = new Signer(getReader(
        generateParams.get("signer"), generateParams.get("cryptedKeySet"), ""));
    SignedSessionEncrypter crypter = new SignedSessionEncrypter(keyEncrypter, signer);
    String sessionMaterial = crypter.newSession();
    byte[] ciphertext = crypter.encrypt(testData.getBytes());
   
View Full Code Here

  }

  @Override
  public byte[] generate(String algorithm, Map<String, String> generateParams)
      throws KeyczarException {
    Signer signer = new Signer(getReader(algorithm, generateParams.get("cryptedKeySet"), ""));
    if (generateParams.get("encoding").equals("encoded")) {
      // String signature = signer.attachedSign(testData, "".getBytes());
      // Not implemented
      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

  public void test(
      Map<String, String> output, String algorithm,
      Map<String, String> generateParams, Map<String, String> testParams)
      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 class UriSigner {
  private static final String DEFAULT_SIG_PARAM = "sig";
  private Signer signer;

  public UriSigner(KeyczarReader reader) throws KeyczarException {
    signer = new Signer(reader);
  }
View Full Code Here

  public UriSigner(KeyczarReader reader) throws KeyczarException {
    signer = new Signer(reader);
  }

  public UriSigner(String fileLocation) throws KeyczarException {
    signer = new Signer(fileLocation);
  }
View Full Code Here

TOP

Related Classes of org.keyczar.Signer

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.