Class DirectoryAttribute

  • All Implemented Interfaces:
    TreeNode

    public class DirectoryAttribute
    extends Sequence
    Handle SubjectDirectoryAttribute constructs from X.509 The class implements the following ASN.1 syntax Attribute ::= SEQUENCE { type AttributeType, values SET OF AttributeValue } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY
    Author:
    Andreas Schwier (info@cardcontact.de)
    • Constructor Detail

      • DirectoryAttribute

        public DirectoryAttribute​(ObjectIdentifier newoid)
        Create DirectoryAttribute object with given object identifier
        Parameters:
        newoid - Object identifier for attribute
      • DirectoryAttribute

        public DirectoryAttribute​(TLV tlv)
                           throws TLVEncodingException
        Create DirectoryAttribute from TLV structure
        Parameters:
        tlv - TLV object
        Throws:
        TLVEncodingException - Data structure can not be converted
    • Method Detail

      • addElement

        public void addElement​(TLV element)
        Add TLV element to value SET of attribute
        Parameters:
        element - TLV object to be added
      • getElement

        public TLV getElement​(int tag)
        Return TLV element with given tag from SET of attributes
        Parameters:
        tag -
        Returns:
        TLV object or null if object was not found
      • getString

        public java.lang.String getString​(int tag,
                                          java.lang.String encoding)
                                   throws java.io.UnsupportedEncodingException
        Find string with given tag and decode using given encoding format
        Parameters:
        tag - Tag to look for
        encoding - Encoding format (e.g. "UTF-8" or "8859_1")
        Returns:
        String or null if object was not found
        Throws:
        java.io.UnsupportedEncodingException - Character string can not be encoded
      • addNumericString

        public void addNumericString​(java.lang.String numericString)
                              throws java.io.UnsupportedEncodingException
        Add numeric string to value SET of attribute
        Parameters:
        numericString -
        Throws:
        java.io.UnsupportedEncodingException
      • getNumericString

        public java.lang.String getNumericString()
                                          throws java.io.UnsupportedEncodingException
        Return numeric string from value set of attribute
        Returns:
        String or null if object was not found
        Throws:
        java.io.UnsupportedEncodingException
      • addUTF8String

        public void addUTF8String​(java.lang.String utf8String)
                           throws java.io.UnsupportedEncodingException
        Add UTF-8 encoded string to value SET of attribute
        Throws:
        java.io.UnsupportedEncodingException
      • getUTF8String

        public java.lang.String getUTF8String()
                                       throws java.io.UnsupportedEncodingException
        Return UTF-8 string from value set of attribute
        Returns:
        String or null if object was not found
        Throws:
        java.io.UnsupportedEncodingException
      • addPrintableString

        public void addPrintableString​(java.lang.String printableString)
                                throws java.io.UnsupportedEncodingException
        Add Plain string encoded string to value SET of attribute
        Parameters:
        printableString - Plain String
        Throws:
        java.io.UnsupportedEncodingException
      • getPrintableString

        public java.lang.String getPrintableString()
                                            throws java.io.UnsupportedEncodingException
        Return printable string from value set of attribute
        Returns:
        String or null if object was not found
        Throws:
        java.io.UnsupportedEncodingException
      • addLatin1String

        public void addLatin1String​(java.lang.String latin1String)
                             throws java.io.UnsupportedEncodingException
        Add Latin-1 encoded string to value SET of attribute
        Parameters:
        latin1String - Unicode string
        Throws:
        java.io.UnsupportedEncodingException
      • getLatin1String

        public java.lang.String getLatin1String()
                                         throws java.io.UnsupportedEncodingException
        Return Latin-1 string from value set of attribute
        Returns:
        String or null if object was not found
        Throws:
        java.io.UnsupportedEncodingException
      • addGeneralizedTime

        public void addGeneralizedTime​(java.util.Date date)
                                throws java.io.UnsupportedEncodingException
        Add date encoded as generalized time to value SET of attribute
        Parameters:
        date - Date to add
        Throws:
        java.io.UnsupportedEncodingException
      • getGeneralizedTime

        public java.util.Date getGeneralizedTime()
                                          throws java.io.UnsupportedEncodingException
        Return date from value set of attribute
        Returns:
        date
        Throws:
        java.io.UnsupportedEncodingException
      • getOID

        public ObjectIdentifier getOID()
        Return object identifier
        Returns:
        Object identifier
      • isOID

        public boolean isOID​(ObjectIdentifier testoid)
        Test if directory attribute has given object identifier
        Parameters:
        testoid - Object identifier to test for.
        Returns:
        True if the directory attribute has given object identifier