Methods Summary |
---|
public static junit.framework.Test | suite()
return new TestSuite(Asn1SequenceTest.class);
|
public void | testBerExplicitTaggedSequenceWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BerSequenceGenerator seqGen = new BerSequenceGenerator(bOut, 1, true);
seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
seqGen.close();
assertTrue("explicit BER tag writing test failed.", Arrays.equals(berExpTagSeqData, bOut.toByteArray()));
|
public void | testBerReading()
Asn1InputStream aIn = new Asn1InputStream(berSeqData);
Asn1Sequence seq = (Asn1Sequence)aIn.readObject();
Object o = null;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof Asn1Integer);
break;
case 1:
assertTrue(o instanceof Asn1ObjectIdentifier);
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 2, count);
|
public void | testBerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BerSequenceGenerator seqGen = new BerSequenceGenerator(bOut);
seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
seqGen.close();
assertTrue("basic BER writing test failed.", Arrays.equals(berSeqData, bOut.toByteArray()));
|
public void | testDerExplicitTaggedSequenceWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen = new DerSequenceGenerator(bOut, 1, true);
seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
seqGen.close();
assertTrue("explicit tag writing test failed.", Arrays.equals(expTagSeqData, bOut.toByteArray()));
|
public void | testDerImplicitTaggedSequenceWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen = new DerSequenceGenerator(bOut, 1, false);
seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
seqGen.close();
assertTrue("implicit tag writing test failed.", Arrays.equals(implTagSeqData, bOut.toByteArray()));
|
public void | testDerReading()
Asn1InputStream aIn = new Asn1InputStream(seqData);
Asn1Sequence seq = (Asn1Sequence)aIn.readObject();
Object o = null;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof Asn1Integer);
break;
case 1:
assertTrue(o instanceof Asn1ObjectIdentifier);
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 2, count);
|
public void | testDerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen = new DerSequenceGenerator(bOut);
seqGen.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen.addObject(new Asn1ObjectIdentifier("1.1"));
seqGen.close();
assertTrue("basic DER writing test failed.", Arrays.equals(seqData, bOut.toByteArray()));
|
public void | testNestedBerDerReading()
testNestedReading(berDerNestedSeqData);
|
public void | testNestedBerDerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BerSequenceGenerator seqGen1 = new BerSequenceGenerator(bOut);
seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream());
seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
seqGen2.close();
seqGen1.close();
assertTrue("nested BER/DER writing test failed.", Arrays.equals(berDerNestedSeqData, bOut.toByteArray()));
|
public void | testNestedBerReading()
testNestedReading(berNestedSeqData);
|
public void | testNestedBerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BerSequenceGenerator seqGen1 = new BerSequenceGenerator(bOut);
seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
BerSequenceGenerator seqGen2 = new BerSequenceGenerator(seqGen1.getRawOutputStream());
seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
seqGen2.close();
seqGen1.close();
assertTrue("nested BER writing test failed.", Arrays.equals(berNestedSeqData, bOut.toByteArray()));
|
public void | testNestedDerReading()
testNestedReading(nestedSeqData);
|
public void | testNestedDerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen1 = new DerSequenceGenerator(bOut);
seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream());
seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
seqGen2.close();
seqGen1.close();
assertTrue("nested DER writing test failed.", Arrays.equals(nestedSeqData, bOut.toByteArray()));
|
public void | testNestedExplicitTagDerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen1 = new DerSequenceGenerator(bOut);
seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream(), 1, true);
seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
seqGen2.close();
seqGen1.close();
assertTrue("nested explicit tagged DER writing test failed.", Arrays.equals(nestedSeqExpTagData, bOut.toByteArray()));
|
public void | testNestedImplicitTagDerWriting()
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DerSequenceGenerator seqGen1 = new DerSequenceGenerator(bOut);
seqGen1.addObject(new Asn1Integer(BigInteger.valueOf(0)));
seqGen1.addObject(new Asn1ObjectIdentifier("1.1"));
DerSequenceGenerator seqGen2 = new DerSequenceGenerator(seqGen1.getRawOutputStream(), 1, false);
seqGen2.addObject(new Asn1Integer(BigInteger.valueOf(1)));
seqGen2.close();
seqGen1.close();
assertTrue("nested implicit tagged DER writing test failed.", Arrays.equals(nestedSeqImpTagData, bOut.toByteArray()));
|
public void | testNestedReading(byte[] data)
Asn1InputStream aIn = new Asn1InputStream(data);
Asn1Sequence seq = (Asn1Sequence)aIn.readObject();
Object o = null;
int count = 0;
assertNotNull("null sequence returned", seq);
while ((o = seq.readObject()) != null)
{
switch (count)
{
case 0:
assertTrue(o instanceof Asn1Integer);
break;
case 1:
assertTrue(o instanceof Asn1ObjectIdentifier);
break;
case 2:
assertTrue(o instanceof Asn1Sequence);
Asn1Sequence s = (Asn1Sequence)o;
s.readObject();
break;
}
count++;
}
assertEquals("wrong number of objects in sequence", 3, count);
|