Search in sources :

Example 1 with CertBuilder

use of com.github.zhenwei.sdk.builder.CertBuilder in project LinLong-Java by zhenwei1108.

the class CertTest method main.

public static void main(String[] args) throws Exception {
    CertBuilder builder = CertBuilder.getInstance(new FileInputStream(new File("")));
    String certSn = builder.getCertSn();
    System.out.println(certSn);
    String issuerDN = builder.getIssuerDN();
    System.out.println(issuerDN);
    String subjectDN = builder.getSubjectDN();
    System.out.println(subjectDN);
    Date notAfter = builder.getNotAfter();
    System.out.println(notAfter);
    String sigAlgName = builder.getSigAlgName();
    System.out.println(sigAlgName);
}
Also used : CertBuilder(com.github.zhenwei.sdk.builder.CertBuilder) File(java.io.File) FileInputStream(java.io.FileInputStream) Date(java.util.Date)

Example 2 with CertBuilder

use of com.github.zhenwei.sdk.builder.CertBuilder in project LinLong-Java by zhenwei1108.

the class CertTest method parseCert.

@Test
public void parseCert() throws Exception {
    // CertBuilder builder = CertBuilder.getInstance(new FileInputStream(new File("")));
    CertBuilder builder = CertBuilder.getInstance(genCert().getEncoded());
    String certSn = builder.getCertSn();
    System.out.println(certSn);
    String issuerDN = builder.getIssuerDN();
    System.out.println(issuerDN);
    String subjectDN = builder.getSubjectDN();
    System.out.println(subjectDN);
    Date notAfter = builder.getNotAfter();
    System.out.println(notAfter);
    String sigAlgName = builder.getSigAlgName();
    System.out.println(sigAlgName);
    String algorithm = builder.getPublicKey().getAlgorithm();
    System.out.println(algorithm);
}
Also used : CertBuilder(com.github.zhenwei.sdk.builder.CertBuilder) Date(java.util.Date) Test(org.junit.Test)

Example 3 with CertBuilder

use of com.github.zhenwei.sdk.builder.CertBuilder in project LinLong-Java by zhenwei1108.

the class CertTest method genCert.

public Certificate genCert() throws Exception {
    KeyBuilder keyBuilder = new KeyBuilder(new WeGooProvider());
    KeyPair keyPair = keyBuilder.buildKeyPair(KeyPairAlgEnum.RSA_1024);
    byte[] certificate = CertBuilder.generateCertificate("O=zhenwei,CN=wegoo,C=CN", "O=zhenwei,CN=wegoo,C=CN", keyPair.getPublic(), keyPair.getPrivate());
    CertBuilder builder = CertBuilder.getInstance(certificate);
    return builder.getCert();
}
Also used : KeyBuilder(com.github.zhenwei.sdk.builder.KeyBuilder) KeyPair(java.security.KeyPair) CertBuilder(com.github.zhenwei.sdk.builder.CertBuilder) WeGooProvider(com.github.zhenwei.provider.jce.provider.WeGooProvider)

Aggregations

CertBuilder (com.github.zhenwei.sdk.builder.CertBuilder)3 Date (java.util.Date)2 WeGooProvider (com.github.zhenwei.provider.jce.provider.WeGooProvider)1 KeyBuilder (com.github.zhenwei.sdk.builder.KeyBuilder)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 KeyPair (java.security.KeyPair)1 Test (org.junit.Test)1