Search in sources :

Example 1 with ASN1CharString

use of com.mindbright.asn1.ASN1CharString in project SpringRemote by HaleyWang.

the class AttributeTypeAndValue method valueAsString.

private String valueAsString() {
    ASN1Object vo = value.getValue();
    String vs = "<unknown>";
    if (vo instanceof DirectoryString) {
        vs = ((DirectoryString) vo).getString();
    } else if (vo instanceof ASN1CharString) {
        vs = ((ASN1CharString) vo).getValue();
    } else if (vo instanceof ASN1PrintableString) {
        vs = ((ASN1PrintableString) vo).getValue();
    } else if (vo instanceof ASN1BitString) {
        vs = ((ASN1BitString) vo).toPrintableString();
    }
    return vs;
}
Also used : ASN1CharString(com.mindbright.asn1.ASN1CharString) ASN1PrintableString(com.mindbright.asn1.ASN1PrintableString) ASN1BitString(com.mindbright.asn1.ASN1BitString) ASN1CharString(com.mindbright.asn1.ASN1CharString) ASN1PrintableString(com.mindbright.asn1.ASN1PrintableString) ASN1Object(com.mindbright.asn1.ASN1Object) ASN1BitString(com.mindbright.asn1.ASN1BitString)

Example 2 with ASN1CharString

use of com.mindbright.asn1.ASN1CharString in project SpringRemote by HaleyWang.

the class PKCS12KeyStore method getAttribute.

private String getAttribute(SafeBag safeBag, String attrType) {
    int cnt = safeBag.bagAttributes.getCount();
    String value = null;
    for (int i = 0; i < cnt; i++) {
        Attribute a = (Attribute) safeBag.bagAttributes.getComponent(i);
        if (attrType.equals(a.type.getString())) {
            ASN1Object v = a.values.getComponent(0);
            if (v instanceof ASN1CharString) {
                value = ((ASN1CharString) v).getValue();
            } else if (v instanceof ASN1OctetString) {
                value = HexDump.toString(((ASN1OctetString) v).getRaw());
            } else {
                value = v.toString();
            }
        }
    }
    return value;
}
Also used : ASN1OctetString(com.mindbright.asn1.ASN1OctetString) Attribute(com.mindbright.security.x509.Attribute) ASN1CharString(com.mindbright.asn1.ASN1CharString) ASN1OctetString(com.mindbright.asn1.ASN1OctetString) ASN1CharString(com.mindbright.asn1.ASN1CharString) ASN1Object(com.mindbright.asn1.ASN1Object)

Aggregations

ASN1CharString (com.mindbright.asn1.ASN1CharString)2 ASN1Object (com.mindbright.asn1.ASN1Object)2 ASN1BitString (com.mindbright.asn1.ASN1BitString)1 ASN1OctetString (com.mindbright.asn1.ASN1OctetString)1 ASN1PrintableString (com.mindbright.asn1.ASN1PrintableString)1 Attribute (com.mindbright.security.x509.Attribute)1