use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project robovm by robovm.
the class X509Name method equals.
/**
* test for equality - note: case is ignored.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof X509Name || obj instanceof ASN1Sequence)) {
return false;
}
ASN1Primitive derO = ((ASN1Encodable) obj).toASN1Primitive();
if (this.toASN1Primitive().equals(derO)) {
return true;
}
X509Name other;
try {
other = X509Name.getInstance(obj);
} catch (IllegalArgumentException e) {
return false;
}
int orderingSize = ordering.size();
if (orderingSize != other.ordering.size()) {
return false;
}
boolean[] indexes = new boolean[orderingSize];
int start, end, delta;
if (// guess forward
ordering.elementAt(0).equals(other.ordering.elementAt(0))) {
start = 0;
end = orderingSize;
delta = 1;
} else // guess reversed - most common problem
{
start = orderingSize - 1;
end = -1;
delta = -1;
}
for (int i = start; i != end; i += delta) {
boolean found = false;
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) ordering.elementAt(i);
String value = (String) values.elementAt(i);
for (int j = 0; j < orderingSize; j++) {
if (indexes[j]) {
continue;
}
ASN1ObjectIdentifier oOid = (ASN1ObjectIdentifier) other.ordering.elementAt(j);
if (oid.equals(oOid)) {
String oValue = (String) other.values.elementAt(j);
if (equivalentStrings(value, oValue)) {
indexes[j] = true;
found = true;
break;
}
}
}
if (!found) {
return false;
}
}
return true;
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project robovm by robovm.
the class X509Name method appendValue.
private void appendValue(StringBuffer buf, Hashtable oidSymbols, ASN1ObjectIdentifier oid, String value) {
String sym = (String) oidSymbols.get(oid);
if (sym != null) {
buf.append(sym);
} else {
buf.append(oid.getId());
}
buf.append('=');
int index = buf.length();
int start = index;
buf.append(value);
int end = buf.length();
if (value.length() >= 2 && value.charAt(0) == '\\' && value.charAt(1) == '#') {
index += 2;
}
while (index != end) {
if ((buf.charAt(index) == ',') || (buf.charAt(index) == '"') || (buf.charAt(index) == '\\') || (buf.charAt(index) == '+') || (buf.charAt(index) == '=') || (buf.charAt(index) == '<') || (buf.charAt(index) == '>') || (buf.charAt(index) == ';')) {
buf.insert(index, "\\");
index++;
end++;
}
index++;
}
while (buf.charAt(start) == ' ') {
buf.insert(start, "\\");
start += 2;
}
int endBuf = buf.length() - 1;
while (endBuf >= 0 && buf.charAt(endBuf) == ' ') {
buf.insert(endBuf, '\\');
endBuf--;
}
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project robovm by robovm.
the class IETFUtils method findAttrNamesForOID.
public static String[] findAttrNamesForOID(ASN1ObjectIdentifier oid, Hashtable lookup) {
int count = 0;
for (Enumeration en = lookup.elements(); en.hasMoreElements(); ) {
if (oid.equals(en.nextElement())) {
count++;
}
}
String[] aliases = new String[count];
count = 0;
for (Enumeration en = lookup.keys(); en.hasMoreElements(); ) {
String key = (String) en.nextElement();
if (oid.equals(lookup.get(key))) {
aliases[count++] = key;
}
}
return aliases;
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project robovm by robovm.
the class Extensions method toASN1Primitive.
/**
* <pre>
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*
* Extension ::= SEQUENCE {
* extnId EXTENSION.&id ({ExtensionSet}),
* critical BOOLEAN DEFAULT FALSE,
* extnValue OCTET STRING }
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector vec = new ASN1EncodableVector();
Enumeration e = ordering.elements();
while (e.hasMoreElements()) {
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
Extension ext = (Extension) extensions.get(oid);
vec.add(ext);
}
return new DERSequence(vec);
}
use of org.bouncycastle.asn1.ASN1ObjectIdentifier in project robovm by robovm.
the class X509CRLObject method getExtensionOIDs.
private Set getExtensionOIDs(boolean critical) {
if (this.getVersion() == 2) {
Extensions extensions = c.getTBSCertList().getExtensions();
if (extensions != null) {
Set set = new HashSet();
Enumeration e = extensions.oids();
while (e.hasMoreElements()) {
ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
Extension ext = extensions.getExtension(oid);
if (critical == ext.isCritical()) {
set.add(oid.getId());
}
}
return set;
}
}
return null;
}
Aggregations