Skip to content

Commit dfe9052

Browse files
committed
github bcgit#631 fixed class misalignment on OtherName in name constraints.
1 parent f7710a2 commit dfe9052

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

core/src/main/java/org/bouncycastle/asn1/x509/PKIXNameConstraintValidator.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ private Set unionDN(Set excluded, ASN1Sequence dn)
487487
Iterator it = excluded.iterator();
488488
while (it.hasNext())
489489
{
490-
ASN1Sequence subtree = (ASN1Sequence)it.next();
490+
ASN1Sequence subtree = ASN1Sequence.getInstance(it.next());
491491

492492
if (withinDNSubtree(dn, subtree))
493493
{
@@ -513,7 +513,7 @@ private Set intersectOtherName(Set permitted, Set otherNames)
513513
Set intersect = new HashSet();
514514
for (Iterator it = otherNames.iterator(); it.hasNext();)
515515
{
516-
Object otName = it.next();
516+
Object otName = OtherName.getInstance(((GeneralSubtree)it.next()).getBase().getName());
517517

518518
if (permitted == null)
519519
{
@@ -865,7 +865,7 @@ private void checkPermittedOtherName(Set permitted, OtherName name)
865865

866866
while (it.hasNext())
867867
{
868-
OtherName str = ((OtherName)it.next());
868+
OtherName str = OtherName.getInstance(it.next());
869869

870870
if (otherNameIsConstrained(name, str))
871871
{
@@ -2169,4 +2169,8 @@ public String toString()
21692169
}
21702170
return temp.toString();
21712171
}
2172+
2173+
public static void main(final String[] args) {
2174+
2175+
}
21722176
}

prov/src/test/java/org/bouncycastle/jce/provider/test/PKIXNameConstraintsTest.java

+25
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,31 @@ public void performTest() throws Exception
234234

235235
PKIXNameConstraintValidator validator = new PKIXNameConstraintValidator();
236236
validator.intersectPermittedSubtree(subtree);
237+
238+
name = new GeneralName(GeneralName.otherName, new OtherName(new ASN1ObjectIdentifier("1.1"), DERNull.INSTANCE));
239+
subtree = new GeneralSubtree(name);
240+
241+
validator = new PKIXNameConstraintValidator();
242+
validator.intersectPermittedSubtree(subtree);
243+
validator.addExcludedSubtree(subtree);
244+
245+
try
246+
{
247+
validator.checkExcluded(name);
248+
}
249+
catch (PKIXNameConstraintValidatorException e)
250+
{
251+
isEquals("OtherName is from an excluded subtree.", e.getMessage());
252+
}
253+
254+
try
255+
{
256+
validator.checkPermitted(name);
257+
}
258+
catch (PKIXNameConstraintValidatorException e)
259+
{
260+
fail(e.getMessage());
261+
}
237262
}
238263

239264
/**

0 commit comments

Comments
 (0)