Example usage for org.bouncycastle.asn1.x500.style IETFUtils valueFromHexString

List of usage examples for org.bouncycastle.asn1.x500.style IETFUtils valueFromHexString

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.x500.style IETFUtils valueFromHexString.

Prototype

public static ASN1Encodable valueFromHexString(String str, int off) throws IOException 

Source Link

Usage

From source file:org.cesecore.util.PrintableStringNameStyle.java

License:Open Source License

@Override
public ASN1Encodable stringToValue(ASN1ObjectIdentifier oid, String value) {
    if (value.length() != 0 && value.charAt(0) == '#') {
        try {/*  w  ww.j a  v a  2 s  .co m*/
            return IETFUtils.valueFromHexString(value, 1);
        } catch (IOException e) {
            throw new RuntimeException("can't recode value for oid " + oid.getId());
        }
    } else if (value.length() != 0 && value.charAt(0) == '\\') {
        value = value.substring(1);
    } else if (oid.equals(CeSecoreNameStyle.EmailAddress) || oid.equals(CeSecoreNameStyle.DC)) {
        return new DERIA5String(value);
    } else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility)
    {
        return new ASN1GeneralizedTime(value);
    } else if (canBePrintable(value)) {
        return new DERPrintableString(value);
    }

    return new DERUTF8String(value);
}