Example usage for org.bouncycastle.asn1.ocsp ResponderID ResponderID

List of usage examples for org.bouncycastle.asn1.ocsp ResponderID ResponderID

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.ocsp ResponderID ResponderID.

Prototype

public ResponderID(X500Name value) 

Source Link

Usage

From source file:org.xipki.pki.ocsp.server.impl.ResponderSigner.java

License:Open Source License

ResponderSigner(final List<ConcurrentContentSigner> signers) throws CertificateException, IOException {
    this.signers = ParamUtil.requireNonEmpty("signers", signers);
    X509Certificate[] tmpCertificateChain = signers.get(0).getCertificateChain();
    if (tmpCertificateChain == null || tmpCertificateChain.length == 0) {
        throw new CertificateException("no certificate is bound with the signer");
    }/*w  w w . java  2  s . co  m*/
    int len = tmpCertificateChain.length;
    if (len > 1) {
        X509Certificate cert = tmpCertificateChain[len - 1];
        if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) {
            len--;
        }
    }
    this.certificateChain = new X509Certificate[len];
    System.arraycopy(tmpCertificateChain, 0, this.certificateChain, 0, len);

    this.certificate = certificateChain[0];

    this.bcCertificate = new X509CertificateHolder(this.certificate.getEncoded());
    this.bcCertificateChain = new X509CertificateHolder[this.certificateChain.length];
    for (int i = 0; i < certificateChain.length; i++) {
        this.bcCertificateChain[i] = new X509CertificateHolder(this.certificateChain[i].getEncoded());
    }

    this.responderIdByName = new RespID(this.bcCertificate.getSubject());
    byte[] keySha1 = HashAlgoType.SHA1
            .hash(this.bcCertificate.getSubjectPublicKeyInfo().getPublicKeyData().getBytes());
    this.responderIdByKey = new RespID(new ResponderID(new DEROctetString(keySha1)));

    algoSignerMap = new HashMap<>();
    for (ConcurrentContentSigner signer : signers) {
        String algoName = getSignatureAlgorithmName(signer.getAlgorithmIdentifier());
        algoSignerMap.put(algoName, signer);
    }
}