Package org.jmrtd.lds

Class CardSecurityFile

  • All Implemented Interfaces:
    java.io.Serializable

    public class CardSecurityFile
    extends java.lang.Object
    implements java.io.Serializable
    Card security file stores a set of SecurityInfos for PACE with Chip Authentication Mapping (CAM).
    Since:
    0.5.6
    Version:
    $Revision: 1827 $
    Author:
    The JMRTD team ([email protected])
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CardSecurityFile​(java.io.InputStream inputStream)
      Constructs a new file from the data in an input stream.
      CardSecurityFile​(java.lang.String digestAlgorithm, java.lang.String digestEncryptionAlgorithm, java.util.Collection<SecurityInfo> securityInfos, byte[] encryptedDigest, java.security.cert.X509Certificate certificate)
      Constructs a new file from the provided data.
      CardSecurityFile​(java.lang.String digestAlgorithm, java.lang.String digestEncryptionAlgorithm, java.util.Collection<SecurityInfo> securityInfos, java.security.PrivateKey privateKey, java.security.cert.X509Certificate certificate)
      Constructs a new file from the provided data.
      CardSecurityFile​(java.lang.String digestAlgorithm, java.lang.String digestEncryptionAlgorithm, java.util.Collection<SecurityInfo> securityInfos, java.security.PrivateKey privateKey, java.security.cert.X509Certificate certificate, java.lang.String provider)
      Constructs a new file from the provided data.
    • Constructor Detail

      • CardSecurityFile

        public CardSecurityFile​(java.lang.String digestAlgorithm,
                                java.lang.String digestEncryptionAlgorithm,
                                java.util.Collection<SecurityInfo> securityInfos,
                                java.security.PrivateKey privateKey,
                                java.security.cert.X509Certificate certificate)
        Constructs a new file from the provided data.
        Parameters:
        digestAlgorithm - the digest algorithm as Java mnemonic
        digestEncryptionAlgorithm - the signature algorithm as Java mnemonic
        securityInfos - a non-empty list of security infos
        privateKey - the private signing key
        certificate - the certificate to embed, which should correspond to the given private key
      • CardSecurityFile

        public CardSecurityFile​(java.lang.String digestAlgorithm,
                                java.lang.String digestEncryptionAlgorithm,
                                java.util.Collection<SecurityInfo> securityInfos,
                                java.security.PrivateKey privateKey,
                                java.security.cert.X509Certificate certificate,
                                java.lang.String provider)
        Constructs a new file from the provided data.
        Parameters:
        digestAlgorithm - the digest algorithm as Java mnemonic
        digestEncryptionAlgorithm - the signature algorithm as Java mnemonic
        securityInfos - a non-empty list of security infos
        privateKey - the private signing key
        certificate - the certificate to embed, which should correspond to the given private key
        provider - the security provider to use
      • CardSecurityFile

        public CardSecurityFile​(java.lang.String digestAlgorithm,
                                java.lang.String digestEncryptionAlgorithm,
                                java.util.Collection<SecurityInfo> securityInfos,
                                byte[] encryptedDigest,
                                java.security.cert.X509Certificate certificate)
        Constructs a new file from the provided data.
        Parameters:
        digestAlgorithm - the digest algorithm as Java mnemonic
        digestEncryptionAlgorithm - the signature algorithm as Java mnemonic
        securityInfos - a non-empty list of security infos
        encryptedDigest - the signature
        certificate - the certificate to embed
      • CardSecurityFile

        public CardSecurityFile​(java.io.InputStream inputStream)
                         throws java.io.IOException
        Constructs a new file from the data in an input stream.
        Parameters:
        inputStream - the input stream to parse the data from
        Throws:
        java.io.IOException - on error reading input stream
    • Method Detail

      • getDigestAlgorithm

        public java.lang.String getDigestAlgorithm()
        Returns the digest algorithm.
        Returns:
        the digest algorithm
      • getDigestEncryptionAlgorithm

        public java.lang.String getDigestEncryptionAlgorithm()
        Returns the signature algorithm.
        Returns:
        the signature algorithm
      • getEncryptedDigest

        public byte[] getEncryptedDigest()
        Returns the encrypted digest (signature bytes).
        Returns:
        the encrypted digest
      • readContent

        protected void readContent​(java.io.InputStream inputStream)
                            throws java.io.IOException
        Reads the contents of this file from a stream.
        Parameters:
        inputStream - the stream to read from
        Throws:
        java.io.IOException - on error reading from the stream
      • writeContent

        protected void writeContent​(java.io.OutputStream outputStream)
                             throws java.io.IOException
        Writes the contents of this file to a stream.
        Parameters:
        outputStream - the stream to write to
        Throws:
        java.io.IOException - on error writing to the stream
      • getEncoded

        public byte[] getEncoded()
        Returns a DER encoded of this file.
        Returns:
        the encoded file
      • getSecurityInfos

        public java.util.Collection<SecurityInfo> getSecurityInfos()
        Returns the security infos as an unordered collection.
        Returns:
        security infos
      • getPACEInfos

        @Deprecated
        public java.util.Collection<PACEInfo> getPACEInfos()
        Deprecated.
        Use filter utility functions in SignedDataUtil instead.
        Returns the PACE infos embedded in this card access file. If no infos are present, an empty list is returned.
        Returns:
        a list of PACE infos
      • getChipAuthenticationInfos

        @Deprecated
        public java.util.Collection<ChipAuthenticationInfo> getChipAuthenticationInfos()
        Deprecated.
        Use filter utility functions in SignedDataUtil instead.
        Returns the CA public key infos embedded in this card access file. If no infos are present, an empty list is returned.
        Returns:
        a list of CA public key infos
      • getChipAuthenticationPublicKeyInfos

        @Deprecated
        public java.util.Collection<ChipAuthenticationPublicKeyInfo> getChipAuthenticationPublicKeyInfos()
        Deprecated.
        Use filter utility functions in SignedDataUtil instead.
        Returns the CA public key infos embedded in this card access file. If no infos are present, an empty list is returned.
        Returns:
        a list of CA public key infos
      • toString

        public java.lang.String toString()
        Returns the signature algorithm object identifier.
        Overrides:
        toString in class java.lang.Object
        Returns:
        signature algorithm OID
      • equals

        public boolean equals​(java.lang.Object otherObj)
        Tests equality with respect to another object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        otherObj - another object
        Returns:
        whether this object equals the other object
      • hashCode

        public int hashCode()
        Returns a hash code of this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code