Examples of CertificateTransparencyException


Examples of org.certificatetransparency.ctlog.CertificateTransparencyException

    try {
      for (Certificate cert : certs) {
        retObject.add(Base64.encodeBase64String(cert.getEncoded()));
      }
    } catch (CertificateEncodingException e) {
      throw new CertificateTransparencyException("Error encoding certificate", e);
    }

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("chain", retObject);
    return jsonObject;
View Full Code Here

Examples of org.certificatetransparency.ctlog.CertificateTransparencyException

    JSONObject response = (JSONObject) JSONValue.parse(sthResponse);
    long treeSize = (Long) response.get("tree_size");
    long timeStamp = (Long) response.get("timestamp");
    if (treeSize < 0 || timeStamp < 0) {
      throw new CertificateTransparencyException(
        String.format("Bad response. Size of tree or timestamp cannot be a negative value. "
          + "Log Tree size: %d Timestamp: %d", treeSize, timeStamp));
    }
    String base64Signature = (String) response.get("tree_head_signature");
    String sha256RootHash = (String) response.get("sha256_root_hash");

    Ct.SignedTreeHead.Builder builder =  Ct.SignedTreeHead.newBuilder();
    builder.setVersion(Ct.Version.V1);
    builder.setTreeSize(treeSize);
    builder.setTimestamp(timeStamp);
    builder.setSha256RootHash(ByteString.copyFrom(Base64.decodeBase64(sha256RootHash)));
    builder.setSignature(Deserializer.parseDigitallySignedFromBinary(
      new ByteArrayInputStream(Base64.decodeBase64(base64Signature))));
    if (builder.getSha256RootHash().size() != 32) {
       throw new CertificateTransparencyException(
         String.format("Bad response. The root hash of the Merkle Hash Tree must be 32 bytes. "
           + "The size of the root hash is %d", builder.getSha256RootHash().size()));
      }
    return builder.build();
  }
View Full Code Here

Examples of org.certificatetransparency.ctlog.CertificateTransparencyException

      byte[] in = Base64.decodeBase64((String) i);
      try {
        certs.add(CertificateFactory.getInstance("X509").generateCertificate(
          new ByteArrayInputStream(in)));
      } catch (CertificateException e) {
        throw new CertificateTransparencyException(
          "Malformed data from a CT log have been received: " + e.getLocalizedMessage(), e);
      }
    }
    return certs;
  }
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.