Example usage for org.bouncycastle.asn1 DERPrintableString isPrintableString

List of usage examples for org.bouncycastle.asn1 DERPrintableString isPrintableString

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 DERPrintableString isPrintableString.

Prototype

public static boolean isPrintableString(String str) 

Source Link

Document

return true if the passed in String can be represented without loss as a PrintableString, false otherwise.

Usage

From source file:ca.trustpoint.m2m.EntityNameAttribute.java

License:Apache License

/**
 * Return true if this instance is a valid EntityName attribute. Values are checked for length and
 * allowed content against the attribute type rules.
 *
 * @return True if this instance is a valid EntityName attribute.
 *//* w w  w  .  j  a  v a2s . co  m*/
public boolean isValid() {
    switch (id) {
    case Country:
        if ((value == null) || (value.length() != 2)) {
            return false;
        }

        return DERPrintableString.isPrintableString(value);
    case Organization:
    case OrganizationalUnit:
    case Locality:
    case CommonName:
        return ((value != null) && (value.length() >= 1) && (value.length() <= 32));
    case DistinguishedNameQualifier:
    case SerialNumber:
        if ((value == null) || (value.length() < 1) || (value.length() > 32)) {
            return false;
        }

        return DERPrintableString.isPrintableString(value);
    case StateOrProvince:
        return ((value != null) && (value.length() >= 1) && (value.length() <= 4));
    case DomainComponent:
        if ((value == null) || (value.length() < 1) || (value.length() > 32)) {
            return false;
        }

        return DERIA5String.isIA5String(value);
    case RegisteredId:
        if ((value == null) || (value.length() < 1) || (value.length() > 32)) {
            return false;
        }

        return (ValidationUtils.isValidOid(value));
    case OctetsName:
        if ((value == null) || (value.length() < 1) || (value.length() > 16)) {
            return false;
        }

        return (ValidationUtils.isValidHex(value));
    default:
        return false;
    }
}

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

License:Open Source License

/**
 * return true if the passed in String can be represented without
 * loss as a PrintableString, false otherwise.
 *//*w  ww . j a v  a 2  s. com*/
private boolean canBePrintable(String str) {
    return DERPrintableString.isPrintableString(str);
}