8296142: CertAttrSet::(getName|getElements|delete) are mostly useless

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2022-11-02 14:40:47 +00:00
parent 6626a29a74
commit 16a041a67a
41 changed files with 60 additions and 1162 deletions

View file

@ -105,8 +105,8 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
Object[] passed = new Object[] {Boolean.valueOf(ext.isCritical()),
ext.getExtensionValue()};
CertAttrSet<?> certExt = (CertAttrSet<?>) cons.newInstance(passed);
if (map.put(certExt.getName(), (Extension)certExt) != null) {
Extension certExt = (Extension) cons.newInstance(passed);
if (map.put(certExt.getName(), certExt) != null) {
throw new IOException("Duplicate extensions not allowed");
}
} catch (InvocationTargetException invk) {
@ -233,13 +233,6 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
return null;
}
/**
* Return an enumeration of names of attributes existing within this
* attribute.
*/
public Enumeration<Extension> getElements() {
return Collections.enumeration(map.values());
}
/**
* Return a collection view of the extensions.
@ -254,13 +247,6 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
Collections.emptyMap() : unparseableExtensions;
}
/**
* Return the name of this attribute.
*/
public String getName() {
return NAME;
}
/**
* Return true if a critical extension is found that is
* not supported, otherwise return false.
@ -283,24 +269,17 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof CertificateExtensions))
return false;
Collection<Extension> otherC =
((CertificateExtensions)other).getAllExtensions();
Object[] objs = otherC.toArray();
int len = objs.length;
if (len != map.size())
if (!(other instanceof CertificateExtensions otherCX))
return false;
Extension otherExt, thisExt;
String key = null;
for (int i = 0; i < len; i++) {
if (objs[i] instanceof CertAttrSet)
key = ((CertAttrSet)objs[i]).getName();
otherExt = (Extension)objs[i];
if (key == null)
key = otherExt.getExtensionId().toString();
Collection<Extension> otherX = otherCX.getAllExtensions();
if (otherX.size() != map.size())
return false;
Extension thisExt;
String key;
for (Extension otherExt : otherX) {
key = otherExt.getName();
thisExt = map.get(key);
if (thisExt == null)
return false;
@ -308,7 +287,7 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
return false;
}
return this.getUnparseableExtensions().equals(
((CertificateExtensions)other).getUnparseableExtensions());
otherCX.getUnparseableExtensions());
}
/**