⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testjpf.java

📁 进行与数字证书相关开发必须的java源码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   TestJpf.java

package jit.testsuit;

import java.io.FileOutputStream;
import jit.asn1.pkcs.pkcs12.Pfx;
import jit.asn1parser.Parser;
import jit.asn1parser.x509.X509Cert;
import jit.jcrypto.*;
import jit.util.jitca.Jpf;
import junit.framework.Assert;
import junit.framework.TestCase;

public class TestJpf extends TestCase
{

    private Jpf jpf;
    private Session session;

    public TestJpf(String name)
    {
        super(name);
        jpf = null;
        session = null;
    }

    protected void setUp()
        throws Exception
    {
        super.setUp();
        JCrypto jcrypto = new JCrypto();
        jcrypto.initialize(0, null);
        session = jcrypto.openSession(0);
        jpf = new Jpf(session);
    }

    protected void tearDown()
        throws Exception
    {
        jpf = null;
        session = null;
        super.tearDown();
    }

    public void testDecodeFromC()
        throws Exception
    {
        jpf.open("c:/testData/connector.jpf", "11111111".toCharArray());
        X509Cert encryptCert = jpf.getEncryptCert();
        JKey encryptKey = jpf.getEncryptPrivKey();
        X509Cert signCert = jpf.getSignCert();
        JKey signKey = jpf.getSignPrivKey();
        Assert.assertNotNull(encryptCert);
        Assert.assertNotNull(encryptKey);
        Assert.assertNotNull(signCert);
        Assert.assertNotNull(signKey);
    }

    public void testGenerateForC()
        throws Exception
    {
        jpf.open("c:/testData/connector.jpf", "11111111".toCharArray());
        Pfx signPfx = jpf.getSignPfx(null);
        byte data[] = Parser.writeDERObj2Bytes(signPfx.getDERObject());
        FileOutputStream fos = new FileOutputStream("c:/signPfx.pfx");
        fos.write(data);
        fos.close();
        Pfx enPfx = jpf.getEncryptPfx(null);
        data = Parser.writeDERObj2Bytes(enPfx.getDERObject());
        fos = new FileOutputStream("c:/encryptPfx.pfx");
        fos.write(data);
        fos.close();
        X509Cert encryptCert = jpf.getEncryptCert();
        JKey encryptKey = jpf.getEncryptPrivKey();
        X509Cert signCert = jpf.getSignCert();
        JKey signKey = jpf.getSignPrivKey();
        Jpf gen = new Jpf(session);
        gen.open("c:/myjpf.jpf", "2222".toCharArray());
        gen.setEncryptCert(encryptCert);
        gen.setEncryptPrivKey(encryptKey);
        gen.setSignCert(signCert);
        gen.setSignPrivKey(signKey);
        gen.save();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -