Package org.jmrtd

Class BACKey

    • Constructor Detail

      • BACKey

        protected BACKey()
        Creates an empty BAC key entry.
      • BACKey

        public BACKey​(String documentNumber,
                      Date dateOfBirth,
                      Date dateOfExpiry)
        Creates a BAC key.
        Parameters:
        documentNumber - the document number string, withou check digit, cannot be null, and may be shorter than 9
        dateOfBirth - the date of birth, in yymmdd format, cannot be null
        dateOfExpiry - the date of expiry, in yymmdd format, cannot be null
      • BACKey

        public BACKey​(String documentNumber,
                      String dateOfBirth,
                      String dateOfExpiry)
        Creates a BAC key.
        Parameters:
        documentNumber - the document number string, cannot be null
        dateOfBirth - the date of birth string in yymmdd format, cannot be null
        dateOfExpiry - the date of expiry string in yymmdd format, cannot be null
    • Method Detail

      • getDocumentNumber

        public String getDocumentNumber()
        Returns the document number string.
        Specified by:
        getDocumentNumber in interface BACKeySpec
        Returns:
        the document number string
      • getDateOfBirth

        public String getDateOfBirth()
        Returns the date of birth string.
        Specified by:
        getDateOfBirth in interface BACKeySpec
        Returns:
        a date in yymmdd format
      • getDateOfExpiry

        public String getDateOfExpiry()
        Returns the date of expiry string.
        Specified by:
        getDateOfExpiry in interface BACKeySpec
        Returns:
        a date in yymmdd format
      • toString

        public String toString()
        Returns a textual representation of this BAC key.
        Overrides:
        toString in class Object
        Returns:
        a textual representation of this BAC key
      • hashCode

        public int hashCode()
        Gets the hash code of this BAC key. Document number, date of birth, and date of expiry (with year in yy precision) are taken into account.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code
      • equals

        public boolean equals​(Object o)
        Tests equality of this BAC key with respect to another object.
        Overrides:
        equals in class Object
        Parameters:
        o - another object
        Returns:
        whether this BAC key equals another object
      • getAlgorithm

        public String getAlgorithm()
        The algorithm of this key specification.
        Specified by:
        getAlgorithm in interface AccessKeySpec
        Returns:
        constant "BAC"
      • getKey

        public byte[] getKey()
        Returns the encoded key (key seed) for use in key derivation.
        Specified by:
        getKey in interface AccessKeySpec
        Returns:
        the encoded key
      • setDocumentNumber

        protected void setDocumentNumber​(String documentNumber)
        Sets the document number.
        Parameters:
        documentNumber - the document number to set
      • setDateOfBirth

        protected void setDateOfBirth​(String dateOfBirth)
        Sets the date of birth.
        Parameters:
        dateOfBirth - the date of birth to set
      • setDateOfExpiry

        protected void setDateOfExpiry​(String dateOfExpiry)
        Sets the date of expiry.
        Parameters:
        dateOfExpiry - the date of expiry to set