Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.github.joschi.jersey.security;
 
 

Author(s):
Bill Burke
Version:
$Revision: 1 $
public final class KeyTools {
    static {
        BouncyIntegration.init();
    }
    private KeyTools() {
    }
        final X500NameBuilder nameBuilder = new X500NameBuilder(.);
        final X500Name cn = nameBuilder.addRDN(."Test Certificate").build();
        final byte[] encoded = pair.getPublic().getEncoded();
        final SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(ASN1Sequence.getInstance(encoded));
        final X509v1CertificateBuilder certBuilder = new X509v1CertificateBuilder(
                cn,
                BigInteger.valueOf(System.currentTimeMillis()),
                new Date(System.currentTimeMillis() - 10000),
                new Date(System.currentTimeMillis() + 10000),
                cn,
                subjectPublicKeyInfo
        );
        final JcaContentSignerBuilder contentSignerBuilder = new JcaContentSignerBuilder("SHA256WithRSAEncryption");
        final ContentSigner contentSigner = contentSignerBuilder.build(pair.getPrivate());
        final X509CertificateHolder certificateHolder = certBuilder.build(contentSigner);
        return new JcaX509CertificateConverter().setProvider"BC" ).getCertificate(certificateHolder);
    }
New to GrepCode? Check out our FAQ X