public class BeIDCard extends Object
BeIDCard instances rely on an instance of BeIDCardUI to support user interaction, such as obtaining PIN and PUK codes for authentication, signing, verifying, changing PIN codes, and for notifying the user of the progress of such operations on a Secure Pinpad Device. A default implementation is available as DefaultBeIDCardUI, and unless replaced by an explicit call to setUI() will automatically be used (when present in the class path).
BeIDCard instances automatically detect CCID features in the underlying CardTerminal, and will choose the most secure path where several are available, for example, when needing to acquire PIN codes from the user, and the card is in a CCID-compliant Secure Pinpad Reader the PIN entry features of the reader will be used instead of the corresponding "obtain.." feature from the active BeIDCardUI. In that case, the corresponding "advise.." method of the active BeIDCardUI will be called instead, to advise the user to attend to the SPR.
To receive notifications of the progress of lengthy operations such as reading 'files' (certificates, photo,..) or signing (which may be lengthy because of user PIN interaction), register an instance of BeIDCardListener using addCardListener(). This is useful, for example, for providing progress indication to the user.
For detailed progress and error/debug logging, provide an instance of be.fedict.commons.eid.spi.Logger to BeIDCard's constructor (the default VoidLogger discards all logging and debug messages). You are advised to provide some form of logging facility, for all but the most trivial applications.
Constructor and Description |
---|
BeIDCard(javax.smartcardio.Card card)
Instantiate a BeIDCard from an already connected javax.smartcardio.Card no
logging information will be available.
|
BeIDCard(javax.smartcardio.Card card,
Logger logger)
Instantiate a BeIDCard from an already connected javax.smartcardio.Card, with
a Logger implementation to receive logging output.
|
BeIDCard(javax.smartcardio.CardTerminal cardTerminal)
Instantiate a BeIDCard from a javax.smartcardio.CardTerminal, with no logging
information will be available.
|
BeIDCard(javax.smartcardio.CardTerminal cardTerminal,
Logger logger)
Instantiate a BeIDCard from a javax.smartcardio.CardTerminal, with a Logger
implementation to receive logging output.
|
Modifier and Type | Method and Description |
---|---|
BeIDCard |
addCardListener(BeIDCardListener beIDCardListener)
Register a BeIDCardListener to receive updates on any consequent file
reading/signature operations executed by this BeIDCard.
|
BeIDCard |
beginExclusive()
Begin an exclusive transaction with the card.
|
boolean |
cardTerminalHasCCIDFeature(CCID.FEATURE feature)
test for CCID Features in the card reader this BeIDCard is inserted into
|
void |
changePin(boolean requireSecureReader)
Change PIN code.
|
BeIDCard |
close()
close this BeIDCard, when you are done with it, to release any underlying
resources.
|
BeIDCard |
endExclusive()
Release an exclusive transaction with the card, started by beginExclusive().
|
javax.smartcardio.ATR |
getATR()
getATR returns the ATR of the eID Card.
|
X509Certificate |
getAuthenticationCertificate()
Returns the X509 authentication certificate.
|
List<X509Certificate> |
getAuthenticationCertificateChain()
Returns the X509 authentication certificate chain.
|
ECPublicKey |
getBasicPublicKey()
Gives back the basic public key file.
|
X509Certificate |
getCACertificate()
Returns the citizen CA certificate.
|
List<X509Certificate> |
getCACertificateChain()
Returns the Citizen CA X509 certificate chain.
|
byte[] |
getCardData()
Gives back the card data as byte array.
|
javax.smartcardio.CardTerminal |
getCardTerminal()
Return the CardTerminal that held this BeIdCard when it was detected Will
return null if the physical Card that we represent was removed.
|
X509Certificate |
getCertificate(FileType fileType)
Reads a certain certificate from the card.
|
List<X509Certificate> |
getCertificateChain(FileType fileType)
Returns the entire certificate chain for a given file type.
|
byte[] |
getChallenge(int size)
Returns random data generated by the eID card itself.
|
Locale |
getLocale() |
List<byte[]> |
getRawAuthenticationCertificateChain() |
List<byte[]> |
getRawCertificateChain(FileType fileType) |
List<byte[]> |
getRawRRNCertificateChain() |
List<byte[]> |
getRawSigningCertificateChain() |
X509Certificate |
getRootCACertificate()
Returns the Root CA certificate.
|
X509Certificate |
getRRNCertificate()
Returns the national registration certificate.
|
List<X509Certificate> |
getRRNCertificateChain()
Returns the national registry X509 certificate chain.
|
X509Certificate |
getSigningCertificate()
Returns the X509 non-repudiation certificate.
|
List<X509Certificate> |
getSigningCertificateChain()
Returns the X509 non-repudiation certificate chain.
|
byte[] |
internalAuthenticate(byte[] challenge)
Performs an internal authentication, i.e., authentication of the eID card
itself.
|
boolean |
isEC()
Returns
true if this eID card supports elliptic curve crypto. |
BeIDCard |
logoff()
Discard the citizen's PIN code from the PIN cache.
|
byte[] |
readBinary(FileType fileType,
int estimatedMaxSize)
Read bytes from a previously selected "File" on the card. should be preceded
by a call to selectFile so the card knows what you want to read.
|
byte[] |
readFile(FileType fileType)
Reads a file from the card.
|
BeIDCard |
removeCardListener(BeIDCardListener beIDCardListener)
Unregister a BeIDCardListener to no longer receive updates on any consequent
file reading/signature operations executed by this BeIDCard.
|
BeIDCard |
selectApplet()
Select the BELPIC applet on the chip.
|
BeIDCard |
selectFile(byte[] fileId)
Selects a file to read on the card
|
void |
setCardTerminal(javax.smartcardio.CardTerminal cardTerminal) |
BeIDCard |
setLocale(Locale newLocale)
set the Locale to use for subsequent UI and CCID operations. this will modify
the Locale of any explicitly set UI, as well.
|
BeIDCard |
setUI(BeIDCardUI userInterface)
Explicitly set the User Interface to be used for consequent operations.
|
byte[] |
sign(byte[] digestValue,
BeIDDigest digestAlgo,
FileType fileType,
boolean requireSecureReader)
Sign a given digest value.
|
byte[] |
sign(byte[] digestValue,
BeIDDigest digestAlgo,
FileType fileType,
boolean requireSecureReader,
String applicationName)
Sign a given digest value.
|
byte[] |
signAuthn(byte[] toBeSigned,
boolean requireSecureReader)
Create an authentication signature.
|
byte[] |
signAuthn(byte[] toBeSigned,
boolean requireSecureReader,
String applicationName)
Create an authentication signature.
|
byte[] |
signTransactionMessage(String transactionMessage,
boolean requireSecureReader)
Create a text message transaction signature.
|
byte[] |
signTransactionMessage(String transactionMessage,
boolean requireSecureReader,
String applicationName)
Create a text message transaction signature.
|
protected byte[] |
transmitCCIDControl(boolean usePPDU,
CCID.FEATURE feature) |
protected byte[] |
transmitCCIDControl(boolean usePPDU,
CCID.FEATURE feature,
byte[] command) |
protected javax.smartcardio.ResponseAPDU |
transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu,
byte[] data) |
protected javax.smartcardio.ResponseAPDU |
transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu,
byte[] data,
int dataOffset,
int dataLength,
int ne) |
protected javax.smartcardio.ResponseAPDU |
transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu,
int le) |
protected javax.smartcardio.ResponseAPDU |
transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu,
int p2,
byte[] data) |
protected javax.smartcardio.ResponseAPDU |
transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu,
int p1,
int p2,
int le) |
protected byte[] |
transmitControlCommand(int controlCode,
byte[] command) |
protected byte[] |
transmitPPDUCommand(int controlCode,
byte[] command) |
void |
unblockPin(boolean requireSecureReader)
Unblocking PIN using PUKs.
|
void |
verifyPin()
Verifying PIN Code (without other actions, for testing PIN), using the most
secure method available.
|
void |
verifyPin(String applicationName)
Verifying PIN Code (without other actions, for testing PIN), using the most
secure method available.
|
public BeIDCard(javax.smartcardio.Card card, Logger logger)
card
- a javax.smartcardio.Card that you have previously determined to
be a BeID Cardlogger
- an instance of be.fedict.commons.eid.spi.LoggerIllegalArgumentException
- when passed a null logger. to disable
logging, call BeIDCard(Card) instead.RuntimeException
- when no CertificateFactory capable of
producing X509 Certificates is available.public BeIDCard(javax.smartcardio.Card card)
card
- a javax.smartcardio.Card that you have previously determined to
be a BeID CardRuntimeException
- when no CertificateFactory capable of producing X509
Certificates is available.public BeIDCard(javax.smartcardio.CardTerminal cardTerminal, Logger logger) throws javax.smartcardio.CardException
cardTerminal
- a javax.smartcardio.CardTerminal that you have previously
determined to contain a BeID Cardlogger
- an instance of be.fedict.commons.eid.spi.LoggerIllegalArgumentException
- when passed a null logger. to disable
logging, call public BeIDCard(CardTerminal)
instead.RuntimeException
- when no CertificateFactory capable of
producing X509 Certificates is available.javax.smartcardio.CardException
- in case of a smart card I/O error.public BeIDCard(javax.smartcardio.CardTerminal cardTerminal) throws javax.smartcardio.CardException
cardTerminal
- a javax.smartcardio.CardTerminal that you have previously
determined to contain a BeID CardRuntimeException
- when no CertificateFactory capable of producing X509
Certificates is available.javax.smartcardio.CardException
- in case of a smart card I/O error.public BeIDCard close()
public final BeIDCard setUI(BeIDCardUI userInterface)
userInterface
- an instance of BeIDCardUIpublic final BeIDCard addCardListener(BeIDCardListener beIDCardListener)
beIDCardListener
- a beIDCardListener instancepublic final BeIDCard removeCardListener(BeIDCardListener beIDCardListener)
beIDCardListener
- a beIDCardListener instancepublic X509Certificate getCertificate(FileType fileType) throws CertificateException, javax.smartcardio.CardException, IOException, InterruptedException
fileType
- CertificateException
javax.smartcardio.CardException
IOException
InterruptedException
public X509Certificate getAuthenticationCertificate() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificate(FileType.AuthentificationCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public X509Certificate getSigningCertificate() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificate(FileType.NonRepudiationCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public X509Certificate getCACertificate() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificate(FileType.CACertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public X509Certificate getRootCACertificate() throws CertificateException, javax.smartcardio.CardException, IOException, InterruptedException
CertificateException
javax.smartcardio.CardException
IOException
InterruptedException
public X509Certificate getRRNCertificate() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificate(FileType.RRNCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public List<X509Certificate> getCertificateChain(FileType fileType) throws CertificateException, javax.smartcardio.CardException, IOException, InterruptedException
fileType
- which certificate's chain to returnCertificateException
javax.smartcardio.CardException
IOException
InterruptedException
public List<byte[]> getRawCertificateChain(FileType fileType) throws javax.smartcardio.CardException, IOException, InterruptedException
javax.smartcardio.CardException
IOException
InterruptedException
public List<X509Certificate> getAuthenticationCertificateChain() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificateChain(FileType.AuthentificationCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public List<byte[]> getRawAuthenticationCertificateChain() throws javax.smartcardio.CardException, IOException, InterruptedException
javax.smartcardio.CardException
IOException
InterruptedException
public List<X509Certificate> getSigningCertificateChain() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificateChain(FileType.NonRepudiationCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public List<byte[]> getRawSigningCertificateChain() throws javax.smartcardio.CardException, IOException, InterruptedException
javax.smartcardio.CardException
IOException
InterruptedException
public List<X509Certificate> getCACertificateChain() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificateChain(FileType.CACertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public List<X509Certificate> getRRNCertificateChain() throws javax.smartcardio.CardException, IOException, CertificateException, InterruptedException
getCertificateChain(FileType.RRNCertificate)
javax.smartcardio.CardException
IOException
CertificateException
InterruptedException
public List<byte[]> getRawRRNCertificateChain() throws javax.smartcardio.CardException, IOException, InterruptedException
javax.smartcardio.CardException
IOException
InterruptedException
public ECPublicKey getBasicPublicKey() throws javax.smartcardio.CardException, IOException, InterruptedException, InvalidKeySpecException
javax.smartcardio.CardException
IOException
InterruptedException
InvalidKeySpecException
public byte[] sign(byte[] digestValue, BeIDDigest digestAlgo, FileType fileType, boolean requireSecureReader) throws javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
digestValue
- the digest value to be signed.digestAlgo
- the algorithm used to calculate the given digest
value.fileType
- the certificate's file type.requireSecureReader
- true
if a secure pinpad reader is
required.javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public byte[] sign(byte[] digestValue, BeIDDigest digestAlgo, FileType fileType, boolean requireSecureReader, String applicationName) throws javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
digestValue
- the digest value to be signed.digestAlgo
- the algorithm used to calculate the given digest
value.fileType
- the certificate's file type.requireSecureReader
- true
if a secure pinpad reader is
required.applicationName
- the optional application name.javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public byte[] signAuthn(byte[] toBeSigned, boolean requireSecureReader) throws NoSuchAlgorithmException, javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
toBeSigned
- the data to be signedrequireSecureReader
- whether to require a secure pinpad reader to
obtain the citizen's PIN if false, the current
BeIDCardUI will be used in the absence of a secure
pinpad reader. If true, an exception will be
thrown unless an SPR is availableNoSuchAlgorithmException
javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public byte[] signAuthn(byte[] toBeSigned, boolean requireSecureReader, String applicationName) throws NoSuchAlgorithmException, javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
toBeSigned
- the data to be signedrequireSecureReader
- whether to require a secure pinpad reader to
obtain the citizen's PIN if false, the current
BeIDCardUI will be used in the absence of a secure
pinpad reader. If true, an exception will be
thrown unless an SPR is availableapplicationName
- the optional application name.NoSuchAlgorithmException
javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public byte[] internalAuthenticate(byte[] challenge) throws javax.smartcardio.CardException
challenge
- javax.smartcardio.CardException
public void verifyPin() throws IOException, javax.smartcardio.CardException, InterruptedException, UserCancelledException
IOException
javax.smartcardio.CardException
InterruptedException
UserCancelledException
public void verifyPin(String applicationName) throws IOException, javax.smartcardio.CardException, InterruptedException, UserCancelledException
applicationName
- the optional application name.IOException
javax.smartcardio.CardException
InterruptedException
UserCancelledException
public void changePin(boolean requireSecureReader) throws Exception
requireSecureReader
- Exception
public byte[] getChallenge(int size) throws javax.smartcardio.CardException
size
- the size of the requested random data.javax.smartcardio.CardException
public byte[] signTransactionMessage(String transactionMessage, boolean requireSecureReader) throws javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
transactionMessage
- the transaction message to be signed.requireSecureReader
- javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public byte[] signTransactionMessage(String transactionMessage, boolean requireSecureReader, String applicationName) throws javax.smartcardio.CardException, IOException, InterruptedException, UserCancelledException
transactionMessage
- the transaction message to be signed.requireSecureReader
- applicationName
- the optional application name.javax.smartcardio.CardException
IOException
InterruptedException
UserCancelledException
public BeIDCard logoff() throws Exception
Exception
public void unblockPin(boolean requireSecureReader) throws Exception
requireSecureReader
- Exception
public javax.smartcardio.ATR getATR()
public Locale getLocale()
public BeIDCard setLocale(Locale newLocale)
newLocale
- public BeIDCard selectApplet() throws javax.smartcardio.CardException
javax.smartcardio.CardException
public BeIDCard beginExclusive() throws javax.smartcardio.CardException
javax.smartcardio.CardException
public BeIDCard endExclusive() throws javax.smartcardio.CardException
javax.smartcardio.CardException
public byte[] readBinary(FileType fileType, int estimatedMaxSize) throws javax.smartcardio.CardException, IOException, InterruptedException
fileType
- the file to read (to allow for notification)estimatedMaxSize
- the estimated total size of the file to read (to
allow for notification)javax.smartcardio.CardException
IOException
InterruptedException
public BeIDCard selectFile(byte[] fileId) throws javax.smartcardio.CardException, FileNotFoundException
fileId
- the file to readjavax.smartcardio.CardException
FileNotFoundException
public byte[] readFile(FileType fileType) throws javax.smartcardio.CardException, IOException, InterruptedException
fileType
- the file to readjavax.smartcardio.CardException
IOException
InterruptedException
public boolean cardTerminalHasCCIDFeature(CCID.FEATURE feature)
feature
- the feature to test for (CCID.FEATURE)public byte[] getCardData() throws javax.smartcardio.CardException, FileNotFoundException
javax.smartcardio.CardException
FileNotFoundException
public boolean isEC()
true
if this eID card supports elliptic curve crypto.protected byte[] transmitCCIDControl(boolean usePPDU, CCID.FEATURE feature) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected byte[] transmitCCIDControl(boolean usePPDU, CCID.FEATURE feature, byte[] command) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected byte[] transmitControlCommand(int controlCode, byte[] command) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected byte[] transmitPPDUCommand(int controlCode, byte[] command) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected javax.smartcardio.ResponseAPDU transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu, int le) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected javax.smartcardio.ResponseAPDU transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu, int p2, byte[] data) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected javax.smartcardio.ResponseAPDU transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu, int p1, int p2, int le) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected javax.smartcardio.ResponseAPDU transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu, byte[] data) throws javax.smartcardio.CardException
javax.smartcardio.CardException
protected javax.smartcardio.ResponseAPDU transmitCommand(be.fedict.commons.eid.client.BeIDCard.BeIDCommandAPDU apdu, byte[] data, int dataOffset, int dataLength, int ne) throws javax.smartcardio.CardException
javax.smartcardio.CardException
public javax.smartcardio.CardTerminal getCardTerminal()
public void setCardTerminal(javax.smartcardio.CardTerminal cardTerminal)
cardTerminal
- Copyright © 2012–2024 e-Contract.be BV. All rights reserved.