use of org.apache.harmony.security.utils.ObjectIdentifier in project robovm by robovm.
the class AttributeTypeAndValue method getObjectIdentifier.
/**
* Parses OID string representation.
*
* @param sOid
* string representation of OID
*
* @throws IOException
* if OID can not be created from its string representation
*/
public static ObjectIdentifier getObjectIdentifier(String sOid) throws IOException {
if (sOid.charAt(0) >= '0' && sOid.charAt(0) <= '9') {
int[] array = org.apache.harmony.security.asn1.ObjectIdentifier.toIntArray(sOid);
ObjectIdentifier thisOid = getOID(array);
if (thisOid == null) {
thisOid = new ObjectIdentifier(array);
}
return thisOid;
}
ObjectIdentifier thisOid = KNOWN_NAMES.get(sOid.toUpperCase(Locale.US));
if (thisOid == null) {
throw new IOException("Unrecognizable attribute name: " + sOid);
}
return thisOid;
}
use of org.apache.harmony.security.utils.ObjectIdentifier in project robovm by robovm.
the class DNParser method parse.
/**
* Parses DN
*
* @return a list of Relative Distinguished Names(RDN),
* each RDN is represented as a list of AttributeTypeAndValue objects
*/
public List<List<AttributeTypeAndValue>> parse() throws IOException {
List<List<AttributeTypeAndValue>> list = new ArrayList<List<AttributeTypeAndValue>>();
String attType = nextAT();
if (attType == null) {
//empty list of RDNs
return list;
}
ObjectIdentifier oid = AttributeTypeAndValue.getObjectIdentifier(attType);
List<AttributeTypeAndValue> atav = new ArrayList<AttributeTypeAndValue>();
while (true) {
if (pos == chars.length) {
//empty Attribute Value
atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
list.add(0, atav);
return list;
}
switch(chars[pos]) {
case '"':
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(quotedAV(), hasQE, oid)));
break;
case '#':
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(hexAV(), encoded)));
break;
case '+':
case ',':
case // compatibility with RFC 1779: semicolon can separate RDNs
';':
//empty attribute value
atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
break;
default:
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(escapedAV(), hasQE, oid)));
}
if (pos >= chars.length) {
list.add(0, atav);
return list;
}
if (chars[pos] == ',' || chars[pos] == ';') {
list.add(0, atav);
atav = new ArrayList<AttributeTypeAndValue>();
} else if (chars[pos] != '+') {
throw new IOException("Invalid distinguished name string");
}
pos++;
attType = nextAT();
if (attType == null) {
throw new IOException("Invalid distinguished name string");
}
oid = AttributeTypeAndValue.getObjectIdentifier(attType);
}
}
use of org.apache.harmony.security.utils.ObjectIdentifier in project j2objc by google.
the class AttributeTypeAndValue method getObjectIdentifier.
/**
* Parses OID string representation.
*
* @param sOid
* string representation of OID
*
* @throws IOException
* if OID can not be created from its string representation
*/
public static ObjectIdentifier getObjectIdentifier(String sOid) throws IOException {
if (sOid.charAt(0) >= '0' && sOid.charAt(0) <= '9') {
int[] array = org.apache.harmony.security.asn1.ObjectIdentifier.toIntArray(sOid);
ObjectIdentifier thisOid = getOID(array);
if (thisOid == null) {
thisOid = new ObjectIdentifier(array);
}
return thisOid;
}
ObjectIdentifier thisOid = KNOWN_NAMES.get(sOid.toUpperCase(Locale.US));
if (thisOid == null) {
throw new IOException("Unrecognizable attribute name: " + sOid);
}
return thisOid;
}
use of org.apache.harmony.security.utils.ObjectIdentifier in project j2objc by google.
the class DNParser method parse.
/**
* Parses DN
*
* @return a list of Relative Distinguished Names(RDN),
* each RDN is represented as a list of AttributeTypeAndValue objects
*/
public List<List<AttributeTypeAndValue>> parse() throws IOException {
List<List<AttributeTypeAndValue>> list = new ArrayList<List<AttributeTypeAndValue>>();
String attType = nextAT();
if (attType == null) {
//empty list of RDNs
return list;
}
ObjectIdentifier oid = AttributeTypeAndValue.getObjectIdentifier(attType);
List<AttributeTypeAndValue> atav = new ArrayList<AttributeTypeAndValue>();
while (true) {
if (pos == chars.length) {
//empty Attribute Value
atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
list.add(0, atav);
return list;
}
switch(chars[pos]) {
case '"':
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(quotedAV(), hasQE, oid)));
break;
case '#':
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(hexAV(), encoded)));
break;
case '+':
case ',':
case // compatibility with RFC 1779: semicolon can separate RDNs
';':
//empty attribute value
atav.add(new AttributeTypeAndValue(oid, new AttributeValue("", false, oid)));
break;
default:
atav.add(new AttributeTypeAndValue(oid, new AttributeValue(escapedAV(), hasQE, oid)));
}
if (pos >= chars.length) {
list.add(0, atav);
return list;
}
if (chars[pos] == ',' || chars[pos] == ';') {
list.add(0, atav);
atav = new ArrayList<AttributeTypeAndValue>();
} else if (chars[pos] != '+') {
throw new IOException("Invalid distinguished name string");
}
pos++;
attType = nextAT();
if (attType == null) {
throw new IOException("Invalid distinguished name string");
}
oid = AttributeTypeAndValue.getObjectIdentifier(attType);
}
}
Aggregations