Search in sources :

Example 1 with InvalidOidOrNameException

use of org.xipki.security.exception.InvalidOidOrNameException in project xipki by xipki.

the class CsrGenAction method toOid.

private static ASN1ObjectIdentifier toOid(String str) throws InvalidOidOrNameException {
    final int n = str.length();
    boolean isName = false;
    for (int i = 0; i < n; i++) {
        char ch = str.charAt(i);
        if (!((ch >= '0' && ch <= '1') || ch == '.')) {
            isName = true;
        }
    }
    if (!isName) {
        try {
            return new ASN1ObjectIdentifier(str);
        } catch (IllegalArgumentException ex) {
        // CHECKSTYLE:SKIP
        }
    }
    ASN1ObjectIdentifier oid = ObjectIdentifiers.nameToOid(str);
    if (oid == null) {
        throw new InvalidOidOrNameException(str);
    }
    return oid;
}
Also used : InvalidOidOrNameException(org.xipki.security.exception.InvalidOidOrNameException) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 2 with InvalidOidOrNameException

use of org.xipki.security.exception.InvalidOidOrNameException in project xipki by xipki.

the class EnrollCertAction method toOid.

private static ASN1ObjectIdentifier toOid(String str) throws InvalidOidOrNameException {
    final int n = str.length();
    boolean isName = false;
    for (int i = 0; i < n; i++) {
        char ch = str.charAt(i);
        if (!((ch >= '0' && ch <= '1') || ch == '.')) {
            isName = true;
        }
    }
    if (!isName) {
        try {
            return new ASN1ObjectIdentifier(str);
        } catch (IllegalArgumentException ex) {
        // CHECKSTYLE:SKIP
        }
    }
    ASN1ObjectIdentifier oid = ObjectIdentifiers.nameToOid(str);
    if (oid == null) {
        throw new InvalidOidOrNameException(str);
    }
    return oid;
}
Also used : InvalidOidOrNameException(org.xipki.security.exception.InvalidOidOrNameException) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)2 InvalidOidOrNameException (org.xipki.security.exception.InvalidOidOrNameException)2