/** * Public constructor from a protobuf. * * @param protobuf * @throws SignatureException */ public SignerInfo(ProtocolSignerInfo protobuf) throws SignatureException { this.protobuf = protobuf; this.certChain = getCertificatesFromListOfByteArrays( protobuf.getCertificateList()); this.signerId = calculateSignerId(this.certChain); }
/** * Public constructor. * @param hashAlg The hash algorithm to use to calculate the signer id (which * is the base-64-encoding of the hash of the PkiPath-encoding of the cert * chain). * @param certs the cert chain used by this signer. Cert of the signer is * first, and cert of the CA is last. * @param domain the domain that the certificates are issued to. This should * match the CN in the target certificate. * @throws SignatureException if the certs couldn't be parsed into a cert * chain, or if the hash couldn't be calculated. */ public SignerInfo(HashAlgorithm hashAlg, List<X509Certificate> certs, String domain) throws SignatureException { Preconditions.checkArgument(certs.size() > 0, "need at least one" + "cert in the chain"); try { this.protobuf = ProtocolSignerInfo.newBuilder() .setHashAlgorithm(hashAlg) .setDomain(domain) .addAllCertificate(getCertificatesAsListOfByteArrays(certs)) .build(); } catch (CertificateEncodingException e) { throw new SignatureException("couldn't parse certificates", e); } this.certChain = ImmutableList.copyOf(certs); this.signerId = calculateSignerId(this.certChain); }