01: package org.bouncycastle.asn1.test;
02:
03: import org.bouncycastle.asn1.x509.GeneralName;
04: import org.bouncycastle.asn1.x509.Target;
05: import org.bouncycastle.asn1.x509.TargetInformation;
06: import org.bouncycastle.asn1.x509.Targets;
07: import org.bouncycastle.util.test.SimpleTest;
08:
09: public class TargetInformationTest extends SimpleTest {
10:
11: public String getName() {
12: return "TargetInformation";
13: }
14:
15: public void performTest() throws Exception {
16: Target[] targets = new Target[2];
17: Target targetName = new Target(Target.targetName,
18: new GeneralName(GeneralName.dNSName, "www.test.com"));
19: Target targetGroup = new Target(Target.targetGroup,
20: new GeneralName(GeneralName.directoryName,
21: "o=Test, ou=Test"));
22: targets[0] = targetName;
23: targets[1] = targetGroup;
24: Targets targetss = new Targets(targets);
25: TargetInformation targetInformation1 = new TargetInformation(
26: targetss);
27: // use an Target array
28: TargetInformation targetInformation2 = new TargetInformation(
29: targets);
30: // targetInformation1 and targetInformation2 must have same
31: // encoding.
32: if (!targetInformation1.equals(targetInformation2)) {
33: fail("targetInformation1 and targetInformation2 should have the same encoding.");
34: }
35: TargetInformation targetInformation3 = TargetInformation
36: .getInstance(targetInformation1.getDERObject());
37: TargetInformation targetInformation4 = TargetInformation
38: .getInstance(targetInformation2.getDERObject());
39: if (!targetInformation3.equals(targetInformation4)) {
40: fail("targetInformation3 and targetInformation4 should have the same encoding.");
41: }
42: }
43:
44: public static void main(String[] args) {
45: runTest(new TargetInformationTest());
46: }
47: }
|