FileDocCategorySizeDatePackage
OIDTest.javaAPI DocBouncy Castle Crypto API 1.41 (Java 1.5)2549Wed Oct 01 10:56:10 BST 2008org.bouncycastle.sasn1.test

OIDTest

public class OIDTest extends TestCase
X.690 test example
deprecated
obsolete test case

Fields Summary
byte[]
req1
byte[]
req2
Constructors Summary
Methods Summary
private voidrecodeCheck(java.lang.String oid, byte[] enc)

    
      
          
          
         
    
        ByteArrayInputStream     bIn = new ByteArrayInputStream(enc);
        Asn1InputStream          aIn = new Asn1InputStream(bIn);

        Asn1ObjectIdentifier      o = new Asn1ObjectIdentifier(oid);
        Asn1ObjectIdentifier      encO = (Asn1ObjectIdentifier)aIn.readObject();
        
        if (!o.equals(encO))
        {
            fail("oid ID didn't match - got: " + o + " expected " + encO);
        }

        byte[]                    bytes = o.getEncoded();

        if (bytes.length != enc.length)
        {
            fail("failed length test");
        }

        for (int i = 0; i != enc.length; i++)
        {
            if (bytes[i] != enc[i])
            {
                fail("failed comparison test - got: " + new String(Hex.encode(enc)) + " expected " +  new String(Hex.encode(bytes)));
            }
        }
    
public voidtestRecode()

        recodeCheck("2.100.3", req1);
        recodeCheck("1.2.54.34359733987.17", req2);
    
public voidtestValue()

        valueCheck(PKCSObjectIdentifiers.pkcs_9_at_contentType.getId());
        valueCheck("1.1.127.32512.8323072.2130706432.545460846592.139637976727552.35747322042253312.9151314442816847872");
        valueCheck("1.2.123.12345678901.1.1.1");
        valueCheck("2.25.196556539987194312349856245628873852187.1");
    
private voidvalueCheck(java.lang.String oid)

        Asn1ObjectIdentifier    o = new Asn1ObjectIdentifier(oid);
        ByteArrayInputStream    bIn = new ByteArrayInputStream(o.getEncoded());
        Asn1InputStream         aIn = new Asn1InputStream(bIn);
        
        o = (Asn1ObjectIdentifier)aIn.readObject();
        
        if (!o.toString().equals(oid))
        {
            fail("failed oid check for " + oid);
        }