Package es.gob.jmulticard.card.dnie
Class Dnie3
- All Implemented Interfaces:
Card
,CryptoCard
,Cwa14890Card
,Dni
,MrtdLds1
- Direct Known Subclasses:
DnieNfc
,IcaoMrtdWithBac
DNI Electrónico versión 3.0.
-
Field Summary
FieldsFields inherited from class es.gob.jmulticard.card.dnie.Dnie
CDF_LOCATION, CERT_ALIAS_AUTH, CERT_ALIAS_CYPHER, CERT_ALIAS_INTERMEDIATE_CA, CERT_ALIAS_SIGN, CERT_ALIAS_SIGNALIAS, certAuth, certCyph, certIcc, certSign, certSignAlias, cryptoHelper, IDESP_LOCATION, intermediateCaCert, LOGGER, PRKDF_LOCATION, rawConnection
Fields inherited from class es.gob.jmulticard.card.AbstractSmartCard
DEBUG
Fields inherited from interface es.gob.jmulticard.card.icao.MrtdLds1
FILE_ATR_INFO_LOCATION, FILE_CARD_ACCESS_LOCATION, FILE_CARD_SECURITY_LOCATION, FILE_COM_LOCATION, FILE_DG01_LOCATION, FILE_DG02_LOCATION, FILE_DG03_LOCATION, FILE_DG04_LOCATION, FILE_DG05_LOCATION, FILE_DG06_LOCATION, FILE_DG07_LOCATION, FILE_DG08_LOCATION, FILE_DG09_LOCATION, FILE_DG10_LOCATION, FILE_DG11_LOCATION, FILE_DG12_LOCATION, FILE_DG13_LOCATION, FILE_DG14_LOCATION, FILE_DG15_LOCATION, FILE_DG16_LOCATION, FILE_SOD_LOCATION
-
Constructor Summary
ConstructorsModifierConstructorDescription(package private)
Dnie3
(ApduConnection conn, PasswordCallback pwc, CryptoHelper cryptoHlpr, CallbackHandler ch) Construye una clase que representa un DNIe 3.0.protected
Dnie3
(ApduConnection conn, PasswordCallback pwc, CryptoHelper cryptoHlpr, CallbackHandler ch, boolean loadCertsAndKeys) Construye una clase que representa un DNIe 3.0. -
Method Summary
Modifier and TypeMethodDescriptionComprueba la validez de los objetos de seguridad a partir del SOD.byte[]
Obtiene el ATR/INFO.byte[]
Obtiene el CardAccess.Obtiene el nombre de la tarjeta.byte[]
Obtiene el CardSecurity.getCom()
Obtiene el COM.getDg1()
Obtiene el DG1 (MRZ).byte[]
getDg10()
Obtiene el DG10 (elemento sustancia).byte[]
getDg11()
Obtiene el DG11 (detalles personales adicionales).byte[]
getDg12()
Obtiene el DG12 (detalles del documento adicionales).getDg13()
Obtiene el DG13 (detalles opcionales).byte[]
getDg14()
Obtiene el DG14 (opciones de seguridad).byte[]
getDg15()
Obtiene el DG15 (información de clave pública de autenticación activa).byte[]
getDg16()
Obtiene el DG16 (personas que han de notificarse).getDg2()
Obtiene el DG2 (fotografía del rostro del titular).byte[]
getDg3()
Obtiene el DG3 (elementos de identificación adicionales - Dedos).byte[]
getDg4()
Obtiene el DG4 (elementos de identificación adicionales - Iris).byte[]
getDg5()
Obtiene el DG5 (retrato exhibido).byte[]
getDg6()
Obtiene el DG6 (reservado para uso futuro).getDg7()
Obtiene el DG7 (imagen de la firma o marca habitual exhibida).byte[]
getDg8()
Obtiene el DG8 (elemento datos).byte[]
getDg9()
Obtiene el DG9 (elemento estructura).getSod()
Obtiene el SOD.protected boolean
Indica si este DNIe necesita validar el PIN para tener acceso a los certificados.void
Si no se había hecho anteriormente, establece y abre el canal seguro de PIN CWA-14890, solicita y comprueba el PIN e inmediatamente después y, si la verificación es correcta, establece el canal de usuario CWA-14890.void
openSecureChannelIfNotAlreadyOpened
(boolean doChv) Establece y abre el canal seguro CWA-14890 si no lo estaba ya.Abre el canal seguro de usuario.protected byte[]
signInternal
(byte[] data, String signAlgorithm, PrivateKeyReference privateKeyReference) Ejecuta la operación interna de firma del DNIe.Methods inherited from class es.gob.jmulticard.card.dnie.Dnie
changePIN, cipherData, connect, externalAuthentication, getAliases, getCdf, getCertificate, getChrCCvIfd, getCryptoHelper, getCwa14890PrivateConstants, getCwa14890PublicConstants, getIccCertPublicKey, getIdesp, getIfdKeyLength, getIfdPrivateKey, getInternalAuthenticateMessage, getInternalPasswordCallback, getInternalPasswordCallback, getPasswordCallback, getPinMessage, getPinRetriesLeft, getPrivateKey, getRefIccPrivateKey, getSerialNumber, isSecurityChannelOpen, loadCertificates, loadCertificatesPaths, loadKeyReferences, needAuthorizationToSign, selectMasterFile, setCallbackHandler, setKeysToAuthentication, setPasswordCallback, sign, signOperation, toString, verifyIcc, verifyIfdCertificateChain, verifyPin
Methods inherited from class es.gob.jmulticard.card.iso7816eight.AbstractIso7816EightCard
verifyCertificate
Methods inherited from class es.gob.jmulticard.card.iso7816four.AbstractIso7816FourCard
getChallenge, readAllRecords, readBinaryComplete, selectFileById, selectFileByIdAndRead, selectFileByLocation, selectFileByLocationAndRead, selectFileByName, selectFileByName, setPublicKeyToVerification
Methods inherited from class es.gob.jmulticard.card.AbstractSmartCard
getCla, getConnection, sendArbitraryApdu, setConnection
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface es.gob.jmulticard.card.cwa14890.Cwa14890Card
getChallenge
-
Field Details
-
idesp
-
-
Constructor Details
-
Dnie3
protected Dnie3(ApduConnection conn, PasswordCallback pwc, CryptoHelper cryptoHlpr, CallbackHandler ch, boolean loadCertsAndKeys) throws ApduConnectionException Construye una clase que representa un DNIe 3.0.- Parameters:
conn
- Conexión con la tarjeta.pwc
- PasswordCallback para obtener el PIN del DNIe.cryptoHlpr
- Funcionalidades criptográficas de utilidad que pueden variar entre máquinas virtuales.ch
- Gestor de las Callbacks (PIN, confirmación, etc.).loadCertsAndKeys
- Si se indicatrue
, se cargan las referencias a las claves privadas y a los certificados mientras que, si se indicafalse
, no se cargan, permitiendo la instanciación de un DNIe sin capacidades de firma o autenticación con certificados.- Throws:
ApduConnectionException
- Si la conexión con la tarjeta se proporciona cerrada y no es posible abrirla.
-
Dnie3
Dnie3(ApduConnection conn, PasswordCallback pwc, CryptoHelper cryptoHlpr, CallbackHandler ch) throws ApduConnectionException Construye una clase que representa un DNIe 3.0.- Parameters:
conn
- Conexión con la tarjeta.pwc
- PasswordCallback para obtener el PIN del DNIe.cryptoHlpr
- Funcionalidades criptográficas de utilidad que pueden variar entre máquinas virtuales.ch
- Gestor de las Callbacks (PIN, confirmación, etc.).- Throws:
ApduConnectionException
- Si la conexión con la tarjeta se proporciona cerrada y no es posible abrirla.
-
-
Method Details
-
getCardName
Description copied from class:AbstractSmartCard
Obtiene el nombre de la tarjeta.- Overrides:
getCardName
in classDnie
- Returns:
- Nombre de la tarjeta
-
openSecureChannelIfNotAlreadyOpened
Si no se había hecho anteriormente, establece y abre el canal seguro de PIN CWA-14890, solicita y comprueba el PIN e inmediatamente después y, si la verificación es correcta, establece el canal de usuario CWA-14890. Si falla algún punto del proceso, vuelve al modo inicial de conexión (sin canal seguro).- Overrides:
openSecureChannelIfNotAlreadyOpened
in classDnie
- Throws:
CryptoCardException
- Si hay problemas en el proceso.PinException
- Si el PIN usado para la apertura de canal no es válido.
-
openSecureChannelIfNotAlreadyOpened
public void openSecureChannelIfNotAlreadyOpened(boolean doChv) throws CryptoCardException, PinException Description copied from class:Dnie
Establece y abre el canal seguro CWA-14890 si no lo estaba ya.- Overrides:
openSecureChannelIfNotAlreadyOpened
in classDnie
- Parameters:
doChv
-true
si la apertura de canal seguro debe incluir la verificación de PIN,false
si debe abrirse canal seguro sin verificar PIN.- Throws:
CryptoCardException
- Si hay problemas en el proceso.PinException
- Si el PIN usado para la apertura de canal no es válido o no se ha proporcionado un PIN para validar (en el caso de que se opte por verificar el PIN).
-
signInternal
protected byte[] signInternal(byte[] data, String signAlgorithm, PrivateKeyReference privateKeyReference) throws CryptoCardException, PinException Description copied from class:Dnie
Ejecuta la operación interna de firma del DNIe.- Overrides:
signInternal
in classDnie
- Parameters:
data
- Datos a firmar.signAlgorithm
- Algoritmo de firma.privateKeyReference
- Referencia a la clave privada de firma.- Returns:
- Datos firmados.
- Throws:
CryptoCardException
- Si hay problemas durante el proceso.PinException
- Si no se ha podido realizar la firma por un problema con el PIN (no estar hecha la autenticación de PIN).
-
openUserChannel
Abre el canal seguro de usuario.- Returns:
- Nueva conexión establecida.
- Throws:
CryptoCardException
- Si hay problemas en la apertura de canal.
-
needsPinForLoadingCerts
protected boolean needsPinForLoadingCerts()Description copied from class:Dnie
Indica si este DNIe necesita validar el PIN para tener acceso a los certificados.- Overrides:
needsPinForLoadingCerts
in classDnie
- Returns:
true
si este DNIe necesita validar el PIN para tener acceso a los certificadosfalse
en caso contrario.
-
checkSecurityObjects
public X509Certificate[] checkSecurityObjects() throws IOException, InvalidSecurityObjectException, TlvException, Asn1Exception, SignatureException, CertificateExceptionDescription copied from interface:MrtdLds1
Comprueba la validez de los objetos de seguridad a partir del SOD.- Specified by:
checkSecurityObjects
in interfaceMrtdLds1
- Returns:
- Cadena de certificados del firmante del SOD (para comprobación externa).
- Throws:
IOException
- Si no se puede finalizar la comprobación.InvalidSecurityObjectException
- Si un objeto de seguridad no supera las comprobaciones de seguridad.TlvException
- Si el SOD del documento no es un TLV válido.Asn1Exception
- Si el SOD es estructuralmente incorrecto.SignatureException
- Si la firma del SOD es inválida o presenta problemas.CertificateException
- Si los certificados de firma del SOD presentan problemas.
-
getCardAccess
Description copied from interface:MrtdLds1
Obtiene el CardAccess.- Specified by:
getCardAccess
in interfaceMrtdLds1
- Returns:
- CardAccess.
- Throws:
IOException
- Si no se puede leer el fichero.
-
getAtrInfo
Description copied from interface:MrtdLds1
Obtiene el ATR/INFO.- Specified by:
getAtrInfo
in interfaceMrtdLds1
- Returns:
- ATR/INFO.
- Throws:
IOException
- Si no se puede leer el fichero.
-
getDg1
Description copied from interface:MrtdLds1
Obtiene el DG1 (MRZ). Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg1
in interfaceMrtdLds1
- Returns:
- DG1 (MRZ).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg2
Description copied from interface:MrtdLds1
Obtiene el DG2 (fotografía del rostro del titular). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg2
in interfaceMrtdLds1
- Returns:
- DG2 (fotografía del rostro del titular).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg3
Description copied from interface:MrtdLds1
Obtiene el DG3 (elementos de identificación adicionales - Dedos). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de administración esté previamente establecido.- Specified by:
getDg3
in interfaceMrtdLds1
- Returns:
- DG3 (elementos de identificación adicionales - Dedos).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg7
Description copied from interface:MrtdLds1
Obtiene el DG7 (imagen de la firma o marca habitual exhibida). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg7
in interfaceMrtdLds1
- Returns:
- DG7 (imagen de la firma o marca habitual exhibida).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg11
Description copied from interface:MrtdLds1
Obtiene el DG11 (detalles personales adicionales). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg11
in interfaceMrtdLds1
- Returns:
- DG11 (detalles personales adicionales).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg12
Description copied from interface:MrtdLds1
Obtiene el DG12 (detalles del documento adicionales). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg12
in interfaceMrtdLds1
- Returns:
- DG12 (detalles del documento adicionales).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg13
Description copied from interface:MrtdLds1
Obtiene el DG13 (detalles opcionales). Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg13
in interfaceMrtdLds1
- Returns:
- DG13 (detalles opcionales).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg14
Description copied from interface:MrtdLds1
Obtiene el DG14 (opciones de seguridad). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg14
in interfaceMrtdLds1
- Returns:
- DG14 (opciones de seguridad).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getSod
Description copied from interface:MrtdLds1
Obtiene el SOD. El SOD contiene las huellas digitales de los DG. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getSod
in interfaceMrtdLds1
- Returns:
- SOD.
- Throws:
IOException
- Si hay problemas obteniendo el objeto.
-
getCom
Description copied from interface:MrtdLds1
Obtiene el COM. El COM contiene los "datos comunes" (Common Data). Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getCom
in interfaceMrtdLds1
- Returns:
- COM.
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getCardSecurity
Description copied from interface:MrtdLds1
Obtiene el CardSecurity.- Specified by:
getCardSecurity
in interfaceMrtdLds1
- Returns:
- CardSecurity.
- Throws:
IOException
- Si no se puede leer el fichero.
-
getDg4
Description copied from interface:MrtdLds1
Obtiene el DG4 (elementos de identificación adicionales - Iris). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de administración esté previamente establecido.- Specified by:
getDg4
in interfaceMrtdLds1
- Returns:
- DG4 (elementos de identificación adicionales - Iris).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg5
Description copied from interface:MrtdLds1
Obtiene el DG5 (retrato exhibido). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg5
in interfaceMrtdLds1
- Returns:
- DG5 (retrato exhibido).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg6
Description copied from interface:MrtdLds1
Obtiene el DG6 (reservado para uso futuro). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg6
in interfaceMrtdLds1
- Returns:
- DG6 (reservado para uso futuro).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg8
Description copied from interface:MrtdLds1
Obtiene el DG8 (elemento datos). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg8
in interfaceMrtdLds1
- Returns:
- DG7 (elemento datos).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg9
Description copied from interface:MrtdLds1
Obtiene el DG9 (elemento estructura). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg9
in interfaceMrtdLds1
- Returns:
- DG9 (elemento estructura).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg10
Description copied from interface:MrtdLds1
Obtiene el DG10 (elemento sustancia). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg10
in interfaceMrtdLds1
- Returns:
- DG10 (elemento sustancia).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg15
Description copied from interface:MrtdLds1
Obtiene el DG15 (información de clave pública de autenticación activa). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg15
in interfaceMrtdLds1
- Returns:
- DG15 (información de clave pública de autenticación activa).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-
getDg16
Description copied from interface:MrtdLds1
Obtiene el DG16 (personas que han de notificarse). Devuelve el objeto binario sin tratar. Puede necesitar que el canal de usuario esté previamente establecido.- Specified by:
getDg16
in interfaceMrtdLds1
- Returns:
- DG16 (personas que han de notificarse).
- Throws:
IOException
- Si hay problemas leyendo el fichero.
-