Java 类org.bouncycastle.asn1.misc.NetscapeRevocationURL 实例源码

项目:gwt-crypto    文件:MiscTest.java   
public void performTest()
    throws Exception
{
    byte[]  testIv = { 1, 2, 3, 4, 5, 6, 7, 8 };

    ASN1Encodable[]     values = {
        new CAST5CBCParameters(testIv, 128), 
        new NetscapeCertType(NetscapeCertType.smime),    
        new VerisignCzagExtension(new DERIA5String("hello")),
        new IDEACBCPar(testIv),        
        new NetscapeRevocationURL(new DERIA5String("http://test"))
    };

    byte[] data = Base64.decode("MA4ECAECAwQFBgcIAgIAgAMCBSAWBWhlbGxvMAoECAECAwQFBgcIFgtodHRwOi8vdGVzdA==");

    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    ASN1OutputStream aOut = new ASN1OutputStream(bOut);

    for (int i = 0; i != values.length; i++)
    {
        aOut.writeObject(values[i]);
    }

    ASN1Primitive[] readValues = new ASN1Primitive[values.length];

    if (!isSameAs(bOut.toByteArray(), data))
    {
        fail("Failed data check");
    }

    ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
    ASN1InputStream aIn = new ASN1InputStream(bIn);

    for (int i = 0; i != values.length; i++)
    {
        ASN1Primitive o = aIn.readObject();
        if (!values[i].equals(o))
        {
            fail("Failed equality test for " + o);
        }

        if (o.hashCode() != values[i].hashCode())
        {
            fail("Failed hashCode test for " + o);
        }
    }

    shouldFailOnExtraData();
}
项目:irma_future_id    文件:MiscTest.java   
public TestResult perform()
{
    byte[]  testIv = { 1, 2, 3, 4, 5, 6, 7, 8 };

    ASN1Encodable[]     values = {
        new CAST5CBCParameters(testIv, 128), 
        new NetscapeCertType(NetscapeCertType.smime),    
        new VerisignCzagExtension(new DERIA5String("hello")),
        new IDEACBCPar(testIv),        
        new NetscapeRevocationURL(new DERIA5String("http://test"))
    };

    byte[] data = Base64.decode("MA4ECAECAwQFBgcIAgIAgAMCBSAWBWhlbGxvMAoECAECAwQFBgcIFgtodHRwOi8vdGVzdA==");

    try
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

        for (int i = 0; i != values.length; i++)
        {
            aOut.writeObject(values[i]);
        }

        ASN1Primitive[] readValues = new ASN1Primitive[values.length];

        if (!isSameAs(bOut.toByteArray(), data))
        {
            return new SimpleTestResult(false, getName() + ": Failed data check");
        }

        ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
        ASN1InputStream         aIn = new ASN1InputStream(bIn);

        for (int i = 0; i != values.length; i++)
        {
            ASN1Primitive   o = aIn.readObject();
            if (!values[i].equals(o))
            {
                return new SimpleTestResult(false, getName() + ": Failed equality test for " + o);
            }

            if (o.hashCode() != values[i].hashCode())
            {
                return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o);
            }
        }

        return new SimpleTestResult(true, getName() + ": Okay");
    }
    catch (Exception e)
    {
        return new SimpleTestResult(false, getName() + ": Failed - exception " + e.toString(), e);
    }
}
项目:bc-java    文件:MiscTest.java   
public TestResult perform()
{
    byte[]  testIv = { 1, 2, 3, 4, 5, 6, 7, 8 };

    ASN1Encodable[]     values = {
        new CAST5CBCParameters(testIv, 128), 
        new NetscapeCertType(NetscapeCertType.smime),    
        new VerisignCzagExtension(new DERIA5String("hello")),
        new IDEACBCPar(testIv),        
        new NetscapeRevocationURL(new DERIA5String("http://test"))
    };

    byte[] data = Base64.decode("MA4ECAECAwQFBgcIAgIAgAMCBSAWBWhlbGxvMAoECAECAwQFBgcIFgtodHRwOi8vdGVzdA==");

    try
    {
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
        ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

        for (int i = 0; i != values.length; i++)
        {
            aOut.writeObject(values[i]);
        }

        ASN1Primitive[] readValues = new ASN1Primitive[values.length];

        if (!isSameAs(bOut.toByteArray(), data))
        {
            return new SimpleTestResult(false, getName() + ": Failed data check");
        }

        ByteArrayInputStream    bIn = new ByteArrayInputStream(bOut.toByteArray());
        ASN1InputStream         aIn = new ASN1InputStream(bIn);

        for (int i = 0; i != values.length; i++)
        {
            ASN1Primitive   o = aIn.readObject();
            if (!values[i].equals(o))
            {
                return new SimpleTestResult(false, getName() + ": Failed equality test for " + o);
            }

            if (o.hashCode() != values[i].hashCode())
            {
                return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o);
            }
        }

        return new SimpleTestResult(true, getName() + ": Okay");
    }
    catch (Exception e)
    {
        return new SimpleTestResult(false, getName() + ": Failed - exception " + e.toString(), e);
    }
}