49 lines
1.7 KiB
Java
49 lines
1.7 KiB
Java
package org.bouncycastle.asn1.x509;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Hashtable;
|
|
import java.util.Vector;
|
|
import org.bouncycastle.asn1.ASN1Encodable;
|
|
import org.bouncycastle.asn1.ASN1Encoding;
|
|
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
|
|
import org.bouncycastle.asn1.DEROctetString;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public class X509ExtensionsGenerator {
|
|
private Hashtable extensions = new Hashtable();
|
|
private Vector extOrdering = new Vector();
|
|
|
|
public void reset() {
|
|
this.extensions = new Hashtable();
|
|
this.extOrdering = new Vector();
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
return this.extOrdering.isEmpty();
|
|
}
|
|
|
|
public X509Extensions generate() {
|
|
return new X509Extensions(this.extOrdering, this.extensions);
|
|
}
|
|
|
|
public void addExtension(ASN1ObjectIdentifier aSN1ObjectIdentifier, boolean z, byte[] bArr) {
|
|
if (!this.extensions.containsKey(aSN1ObjectIdentifier)) {
|
|
this.extOrdering.addElement(aSN1ObjectIdentifier);
|
|
this.extensions.put(aSN1ObjectIdentifier, new X509Extension(z, new DEROctetString(bArr)));
|
|
} else {
|
|
StringBuilder sb = new StringBuilder("extension ");
|
|
sb.append(aSN1ObjectIdentifier);
|
|
sb.append(" already added");
|
|
throw new IllegalArgumentException(sb.toString());
|
|
}
|
|
}
|
|
|
|
public void addExtension(ASN1ObjectIdentifier aSN1ObjectIdentifier, boolean z, ASN1Encodable aSN1Encodable) {
|
|
try {
|
|
addExtension(aSN1ObjectIdentifier, z, aSN1Encodable.toASN1Primitive().getEncoded(ASN1Encoding.DER));
|
|
} catch (IOException e) {
|
|
throw new IllegalArgumentException("error encoding value: ".concat(String.valueOf(e)));
|
|
}
|
|
}
|
|
}
|