Example usage for org.bouncycastle.operator OperatorCreationException OperatorCreationException

List of usage examples for org.bouncycastle.operator OperatorCreationException OperatorCreationException

Introduction

In this page you can find the example usage for org.bouncycastle.operator OperatorCreationException OperatorCreationException.

Prototype

public OperatorCreationException(String msg, Throwable cause) 

Source Link

Usage

From source file:org.apache.nifi.toolkit.tls.util.TlsHelper.java

License:Apache License

public static JcaPKCS10CertificationRequest generateCertificationRequest(String requestedDn,
        String domainAlternativeNames, KeyPair keyPair, String signingAlgorithm)
        throws OperatorCreationException {
    JcaPKCS10CertificationRequestBuilder jcaPKCS10CertificationRequestBuilder = new JcaPKCS10CertificationRequestBuilder(
            new X500Name(requestedDn), keyPair.getPublic());

    // add Subject Alternative Name(s)
    try {//from   w w  w.j  a v  a  2  s .c  om
        jcaPKCS10CertificationRequestBuilder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest,
                createDomainAlternativeNamesExtensions(domainAlternativeNames, requestedDn));
    } catch (IOException e) {
        throw new OperatorCreationException(
                "Error while adding " + domainAlternativeNames + " as Subject Alternative Name.", e);
    }

    JcaContentSignerBuilder jcaContentSignerBuilder = new JcaContentSignerBuilder(signingAlgorithm);
    return new JcaPKCS10CertificationRequest(
            jcaPKCS10CertificationRequestBuilder.build(jcaContentSignerBuilder.build(keyPair.getPrivate())));
}

From source file:org.xipki.commons.security.bcbugfix.XipkiRSAContentVerifierProviderBuilder.java

License:Open Source License

@Override
protected Signer createSigner(AlgorithmIdentifier sigAlgId) throws OperatorCreationException {
    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(sigAlgId.getAlgorithm())) {
        try {//w ww .j  av  a  2 s  . co m
            return SignerUtil.createPSSRSASigner(sigAlgId);
        } catch (XiSecurityException ex) {
            throw new OperatorCreationException(ex.getMessage(), ex);
        }
    } else {
        AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId);
        Digest dig = digestProvider.get(digAlg);

        return new RSADigestSigner(dig);
    }
}

From source file:org.xipki.security.p11.P11RSAPSSContentSigner.java

License:Open Source License

public P11RSAPSSContentSigner(final P11CryptService cryptService, final P11SlotIdentifier slot,
        final P11KeyIdentifier keyId, final AlgorithmIdentifier signatureAlgId)
        throws NoSuchAlgorithmException, NoSuchPaddingException, OperatorCreationException {
    ParamChecker.assertNotNull("slot", slot);
    ParamChecker.assertNotNull("cryptService", cryptService);
    ParamChecker.assertNotNull("signatureAlgId", signatureAlgId);
    ParamChecker.assertNotNull("keyId", keyId);

    if (PKCSObjectIdentifiers.id_RSASSA_PSS.equals(signatureAlgId.getAlgorithm()) == false) {
        throw new IllegalArgumentException("unsupported signature algorithm " + signatureAlgId.getAlgorithm());
    }/*from   ww w .  ja  va2 s  . c o m*/

    this.algorithmIdentifier = signatureAlgId;

    AsymmetricBlockCipher cipher = new P11PlainRSASigner();

    P11RSAKeyParameter keyParam;
    try {
        keyParam = P11RSAKeyParameter.getInstance(cryptService, slot, keyId);
    } catch (InvalidKeyException e) {
        throw new OperatorCreationException(e.getMessage(), e);
    }

    this.pssSigner = SignerUtil.createPSSRSASigner(signatureAlgId, cipher);
    this.pssSigner.init(true, keyParam);

    this.outputStream = new PSSSignerOutputStream();
}