public String toString() { return getString(); }
/** * return a Numeric string from the passed in object * * @param obj a DERNumericString or an object that can be converted into one. * @exception IllegalArgumentException if the object cannot be converted. * @return a DERNumericString instance, or null */ public static DERNumericString getInstance( Object obj) { if (obj == null || obj instanceof DERNumericString) { return (DERNumericString)obj; } if (obj instanceof byte[]) { try { return (DERNumericString)fromByteArray((byte[])obj); } catch (Exception e) { throw new IllegalArgumentException("encoding error in getInstance: " + e.toString()); } } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
/** * Constructor with optional validation. * * @param string the base string to wrap. * @param validate whether or not to check the string. * @throws IllegalArgumentException if validate is true and the string * contains characters that should not be in a NumericString. */ public DERNumericString( String string, boolean validate) { if (validate && !isNumericString(string)) { throw new IllegalArgumentException("string contains illegal characters"); } this.string = Strings.toByteArray(string); }
/** * Return an Numeric String from a tagged object. * * @param obj the tagged object holding the object we want * @param explicit true if the object is meant to be explicitly * tagged false otherwise. * @exception IllegalArgumentException if the tagged object cannot * be converted. * @return a DERNumericString instance, or null. */ public static DERNumericString getInstance( ASN1TaggedObject obj, boolean explicit) { ASN1Primitive o = obj.getObject(); if (explicit || o instanceof DERNumericString) { return getInstance(o); } else { return new DERNumericString(ASN1OctetString.getInstance(o).getOctets()); } }
return DERNull.INSTANCE; // actual content is ignored (enforce 0 length?) case NUMERIC_STRING: return new DERNumericString(defIn.toByteArray()); case OBJECT_IDENTIFIER: return ASN1ObjectIdentifier.fromOctetString(getBuffer(defIn, tmpBuffers));
/** * return an Numeric String from a tagged object. * * @param obj the tagged object holding the object we want * @param explicit true if the object is meant to be explicitly * tagged false otherwise. * @exception IllegalArgumentException if the tagged object cannot * be converted. * @return a DERNumericString instance, or null. */ public static DERNumericString getInstance( ASN1TaggedObject obj, boolean explicit) { ASN1Primitive o = obj.getObject(); if (explicit || o instanceof DERNumericString) { return getInstance(o); } else { return new DERNumericString(ASN1OctetString.getInstance(o).getOctets()); } }
return DERNull.INSTANCE; // actual content is ignored (enforce 0 length?) case NUMERIC_STRING: return new DERNumericString(defIn.toByteArray()); case OBJECT_IDENTIFIER: return ASN1ObjectIdentifier.fromOctetString(getBuffer(defIn, tmpBuffers));
public String toString() { return getString(); }
/** * Constructor with optional validation. * * @param string the base string to wrap. * @param validate whether or not to check the string. * @throws IllegalArgumentException if validate is true and the string * contains characters that should not be in a NumericString. */ public DERNumericString( String string, boolean validate) { if (validate && !isNumericString(string)) { throw new IllegalArgumentException("string contains illegal characters"); } this.string = Strings.toByteArray(string); }
/** * Return a Numeric string from the passed in object * * @param obj a DERNumericString or an object that can be converted into one. * @exception IllegalArgumentException if the object cannot be converted. * @return a DERNumericString instance, or null */ public static DERNumericString getInstance( Object obj) { if (obj == null || obj instanceof DERNumericString) { return (DERNumericString)obj; } if (obj instanceof byte[]) { try { return (DERNumericString)fromByteArray((byte[])obj); } catch (Exception e) { throw new IllegalArgumentException("encoding error in getInstance: " + e.toString()); } } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
ASN1Set svn = DLSet.getInstance(seq.getObjectAt(1)); DERNumericString svnObject = DERNumericString.getInstance(svn.getObjectAt(0)); System.out.println("SVN: " + svnObject.getString());