OIDTest.java
资源名称:security.rar [点击查看]
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:1k
源码类别:
CA认证
开发平台:
Java
- package org.bouncycastle.asn1.test;
- import java.io.*;
- import org.bouncycastle.util.encoders.*;
- import org.bouncycastle.util.test.*;
- import org.bouncycastle.asn1.*;
- import org.bouncycastle.asn1.pkcs.*;
- /**
- * X.690 test example
- */
- public class OIDTest
- implements Test
- {
- byte[] req = Hex.decode("0603813403");
- public String getName()
- {
- return "OID";
- }
- public TestResult perform()
- {
- try
- {
- ByteArrayInputStream bIn = new ByteArrayInputStream(req);
- DERInputStream dIn = new DERInputStream(bIn);
- DERObjectIdentifier o = new DERObjectIdentifier("2.100.3");
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- DEROutputStream dOut = new DEROutputStream(bOut);
- dOut.writeObject(o);
- byte[] bytes = bOut.toByteArray();
- if (bytes.length != req.length)
- {
- return new SimpleTestResult(false, getName() + ": failed length test");
- }
- for (int i = 0; i != req.length; i++)
- {
- if (bytes[i] != req[i])
- {
- return new SimpleTestResult(false, getName() + ": failed comparison test");
- }
- }
- }
- catch (Exception e)
- {
- return new SimpleTestResult(false, getName() + ": Exception - " + e.toString());
- }
- return new SimpleTestResult(true, getName() + ": Okay");
- }
- public static void main(
- String[] args)
- {
- Test test = new OIDTest();
- TestResult result = test.perform();
- System.out.println(result);
- }
- }