当前位置: 首页>>代码示例>>Java>>正文


Java ASN1Dump类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.util.ASN1Dump的典型用法代码示例。如果您正苦于以下问题:Java ASN1Dump类的具体用法?Java ASN1Dump怎么用?Java ASN1Dump使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ASN1Dump类属于org.bouncycastle.asn1.util包,在下文中一共展示了ASN1Dump类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDEREncoding

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
@Test
public void testDEREncoding() throws Exception {
	PcscEid pcscEidSpi = new PcscEid(new TestView(), this.messages);
	if (false == pcscEidSpi.isEidPresent()) {
		LOG.debug("insert eID card");
		pcscEidSpi.waitForEidPresent();
	}

	try {
		byte[] authnCert = pcscEidSpi.readFile(PcscEid.AUTHN_CERT_FILE_ID);
		DERSequence sequence = (DERSequence) new ASN1InputStream(new ByteArrayInputStream(authnCert)).readObject();
		String str = ASN1Dump.dumpAsString(sequence);
		LOG.debug(str);
	} finally {
		pcscEidSpi.close();
	}
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:18,代码来源:PcscTest.java

示例2: toString

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
/**
 * Return a printable representation of this
 * <code>PolicyQualifierInfo</code>.<br />
 * <br />
 * Uses {@link org.bouncycastle.asn1.ASN1InputStream ASN1InputStream},
 * {@link org.bouncycastle.asn1.ASN1Object ASN1Object}
 * 
 * @return a <code>String</code> describing the contents of this
 *         <code>PolicyQualifierInfo</code>
 */
public String toString()
{
    StringBuffer s = new StringBuffer();
    s.append("PolicyQualifierInfo: [\n");
    s.append("qualifierID: ").append(id).append('\n');
    try
    {
        ByteArrayInputStream inStream = new ByteArrayInputStream(qualifier);
        ASN1InputStream derInStream = new ASN1InputStream(inStream);
        ASN1Object derObject = derInStream.readObject();
        s
                .append("  qualifier:\n").append(ASN1Dump.dumpAsString(derObject))
                .append('\n');
    }
    catch (IOException ex)
    {
        s.append(ex.getMessage());
    }
    s.append("qualifier: ").append(id).append('\n');
    s.append(']');
    return s.toString();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:33,代码来源:PolicyQualifierInfo.java

示例3: testReadNonRepudiationCertificate

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
@Test
public void testReadNonRepudiationCertificate() throws Exception {
	PcscEid pcscEidSpi = new PcscEid(new TestView(), this.messages);
	if (false == pcscEidSpi.isEidPresent()) {
		LOG.debug("insert eID card");
		pcscEidSpi.waitForEidPresent();
	}

	File tmpFile = File.createTempFile("eid-sign-cert-", ".der");
	byte[] signCert = pcscEidSpi.readFile(PcscEid.SIGN_CERT_FILE_ID);
	FileUtils.writeByteArrayToFile(tmpFile, signCert);

	LOG.debug("ASN1 dump: " + ASN1Dump.dumpAsString(new ASN1InputStream(signCert).readObject()));

	LOG.debug("tmp file: " + tmpFile.getAbsolutePath());

	CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
	X509Certificate certificate = (X509Certificate) certificateFactory
			.generateCertificate(new ByteArrayInputStream(signCert));
	X509Principal issuerPrincipal = PrincipalUtil.getIssuerX509Principal(certificate);
	LOG.debug("BC issuer principal: " + issuerPrincipal.getName());
	LOG.debug("Sun issuer (getName): " + certificate.getIssuerX500Principal().getName());
	LOG.debug("Sun issuer (toString): " + certificate.getIssuerX500Principal());
	String issuerName = PrincipalUtil.getIssuerX509Principal(certificate).getName().replace(",", ", ");
	LOG.debug("issuer name: " + issuerName);
	LOG.debug("certificate: " + certificate);

	pcscEidSpi.close();
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:30,代码来源:PcscTest.java

示例4: toString

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(X509Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(X509Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:60,代码来源:X509CRLEntryObject.java

示例5: toString

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = Strings.lineSeparator();

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(X509Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(X509Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:60,代码来源:X509CRLEntryObject.java

示例6: toString

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = Strings.lineSeparator();

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:thedrummeraki,项目名称:Aki-SSL,代码行数:60,代码来源:X509CRLEntryObject.java

示例7: toString

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
public String toString()
{
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null)
    {
        Enumeration e = extensions.oids();
        if (e.hasMoreElements())
        {
            buf.append("   crlEntryExtensions:").append(nl);

            while (e.hasMoreElements())
            {
                ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)e.nextElement();
                Extension ext = extensions.getExtension(oid);
                if (ext.getExtnValue() != null)
                {
                    byte[]                  octs = ext.getExtnValue().getOctets();
                    ASN1InputStream dIn = new ASN1InputStream(octs);
                    buf.append("                       critical(").append(ext.isCritical()).append(") ");
                    try
                    {
                        if (oid.equals(X509Extension.reasonCode))
                        {
                            buf.append(CRLReason.getInstance(DEREnumerated.getInstance(dIn.readObject()))).append(nl);
                        }
                        else if (oid.equals(X509Extension.certificateIssuer))
                        {
                            buf.append("Certificate issuer: ").append(GeneralNames.getInstance(dIn.readObject())).append(nl);
                        }
                        else 
                        {
                            buf.append(oid.getId());
                            buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
                        }
                    }
                    catch (Exception ex)
                    {
                        buf.append(oid.getId());
                        buf.append(" value = ").append("*****").append(nl);
                    }
                }
                else
                {
                    buf.append(nl);
                }
            }
        }
    }

    return buf.toString();
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:59,代码来源:X509CRLEntryObject.java

示例8: testEncodeDecode

import org.bouncycastle.asn1.util.ASN1Dump; //导入依赖的package包/类
@Test
public void testEncodeDecode()
    throws Exception
{

    List<String> testList = new ArrayList<>();
    testList.add("cats");
    testList.add("dogs");
    testList.add("fish");
    testList.add("rabbit");


    NodeStatusMessage.Builder<NodeStatusMessage.Info> builder = new NodeStatusMessage.Builder(NodeStatusMessage.Info.class);


    builder.put("a", "bar");
    builder.put("b", 10);
    builder.put("list", testList);


    Map m = new HashMap<>();

    m.put("foo", "bar");
    m.put("cat", 1);


    builder.put("map", m);

    NodeStatusMessage nsm = builder.build();


    ASN1Primitive prim = nsm.toASN1Primitive();

    System.out.println(ASN1Dump.dumpAsString(prim, true));


    NodeStatusMessage res = NodeStatusMessage.Info.getInstance(prim);
    TestCase.assertTrue(nsm.getValues().get("a").equals(res.getValues().get("a")));
    TestCase.assertTrue(nsm.getValues().get("b").equals(res.getValues().get("b")));

    int t = 0;
    for (String v : testList)
    {
        TestCase.assertEquals(v, ((List)res.getValues().get("list")).get(t++));
    }

}
 
开发者ID:cwgit,项目名称:ximix,代码行数:48,代码来源:NodeStatusMessageTest.java


注:本文中的org.bouncycastle.asn1.util.ASN1Dump类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。