|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectopencard.core.service.CardService
de.cardcontact.opencard.service.isocard.IsoCardService
public class IsoCardService
File access card service for ISO7816-4,-8 and -9 cards. First implemented and tested with ORGA Micardo 2.x operating systems
Field Summary |
---|
Fields inherited from interface opencard.opt.iso.fs.FileAccessCardService |
---|
READ_SEVERAL |
Constructor Summary | |
---|---|
IsoCardService()
|
Method Summary | |
---|---|
void |
appendRecord(CardFilePath file,
byte[] data)
Append record to linear file |
void |
closeApplication(SecurityDomain domain)
Resets the achieved card holder verifications on the smartcard. |
void |
create(CardFilePath parent,
byte[] data)
Create file in parent usind file information supplied as byte array This is the original signature defined by OCF |
void |
create(CardFilePath parent,
byte fileDescriptorByte,
byte shortFileIdentifier,
byte[] data)
Create file in parent usind file information supplied as byte array This is the signature defined by OpenSCPD |
void |
delete(CardFilePath file)
Delete the file referenced This is the original signature defined by OCF |
void |
delete(CardFilePath file,
CardFilePathComponent child,
boolean childIsDF)
Delete the referenced file This is the signature defined by OpenSCDP |
boolean |
exists(CardFilePath file)
Determine if file exists |
CardFileInfo |
getFileInfo(CardFilePath file)
Obtain file information as returned in the SELECT command |
int |
getPasswordLength(SecurityDomain domain,
int number)
Determines the padded length of a password. |
CardFilePath |
getRoot()
Return the root path (:3F00) of this card service |
protected SecureChannelCredential |
getSecureChannelCredential(CardFilePath file,
int accessMode)
Obtain a secure channel credential, if any is defined for the given file and access mode |
void |
initialize(CardServiceScheduler scheduler,
SmartCard smartcard,
boolean blocking)
Create the IsoCardSelector object in the card channel if it does not yet exist. |
void |
invalidate(CardFilePath file)
Invalidate (Deactivate) the file specified |
void |
provideCredentials(SecurityDomain domain,
CredentialBag creds)
Provides credentials to a card service. |
byte[] |
read(CardFilePath file,
int offset,
int length)
Read binary data from transparent file |
byte[] |
readRecord(CardFilePath file,
int recordNumber)
Read record from linear file |
byte[][] |
readRecords(CardFilePath file,
int number)
Reads consecutive records from a structured file. |
void |
rehabilitate(CardFilePath file)
Rehabilitate (Activate) the file specified |
protected ResponseAPDU |
sendCommandAPDU(CardChannel channel,
SecureChannelCredential secureChannelCredential,
CommandAPDU com)
Exchange APDU with card, optionally transforming the APDU with a secure channel |
protected ResponseAPDU |
sendCommandAPDU(CardChannel channel,
SecureChannelCredential secureChannelCredential,
int uq,
CommandAPDU com)
Exchange APDU with card, optionally transforming the APDU with a secure channel |
ResponseAPDU |
sendCommandAPDU(CardFilePath path,
CommandAPDU com,
int usageQualifier)
Send APDU making sure that the object referenced by path is selected |
boolean |
verifyPassword(SecurityDomain domain,
int number,
byte[] password)
Checks a password for card holder verification. |
boolean |
verifyPassword(SecurityDomain domain,
int number,
CHVControl cc,
byte[] password)
Checks a password for card holder verification. |
void |
write(CardFilePath file,
int offset,
byte[] data)
Write binary data to transparent file |
void |
write(CardFilePath file,
int foffset,
byte[] source,
int soffset,
int length)
Write binary data to transparent file |
void |
writeRecord(CardFilePath file,
int recordNumber,
byte[] data)
Update record in linear file |
Methods inherited from class opencard.core.service.CardService |
---|
allocateCardChannel, getCard, getCardChannel, getCHVDialog, releaseCardChannel, setCardChannel, setCHVDialog |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface opencard.opt.service.CardServiceInterface |
---|
getCard, setCHVDialog |
Constructor Detail |
---|
public IsoCardService()
Method Detail |
---|
public void initialize(CardServiceScheduler scheduler, SmartCard smartcard, boolean blocking) throws CardServiceException
initialize
in class CardService
scheduler
- where this service is going to allocate channelssmartcard
- which smartcard has to be supported by this serviceblocking
- whether channel allocation is going to be blocking
CardServiceException
- if the service could not be initialized. The object created via the
default constructor may not be used if this happens.CardServiceFactory
public boolean exists(CardFilePath file) throws CardServiceException, CardTerminalException
exists
in interface FileAccessCardService
file
- the path to the file to query
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.exists(opencard.opt.iso.fs.CardFilePath)
public CardFileInfo getFileInfo(CardFilePath file) throws CardServiceException, CardTerminalException
getFileInfo
in interface FileAccessCardService
file
- the path to the file to query
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.getFileInfo(opencard.opt.iso.fs.CardFilePath)
public CardFilePath getRoot()
getRoot
in interface FileAccessCardService
FileAccessCardService.getRoot()
protected SecureChannelCredential getSecureChannelCredential(CardFilePath file, int accessMode)
file
- File for which a secure channel credential should be obtainedaccessMode
- Desired mode of access (READ, UPDATE or APPEND)
protected ResponseAPDU sendCommandAPDU(CardChannel channel, SecureChannelCredential secureChannelCredential, int uq, CommandAPDU com) throws InvalidCardChannelException, CardTerminalException
channel
- secureChannelCredential
- uq
- usage Qualifiercom
-
InvalidCardChannelException
CardTerminalException
protected ResponseAPDU sendCommandAPDU(CardChannel channel, SecureChannelCredential secureChannelCredential, CommandAPDU com) throws InvalidCardChannelException, CardTerminalException
channel
- secureChannelCredential
- com
-
InvalidCardChannelException
CardTerminalException
public byte[] read(CardFilePath file, int offset, int length) throws CardServiceException, CardTerminalException
read
in interface FileAccessCardService
file
- the path to the file to read fromoffset
- the index of the first byte to read (0 for first)length
- the number of bytes to read, or READ_SEVERAL.
If 0 is passed, the behavior is implementation dependent.
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.read(opencard.opt.iso.fs.CardFilePath, int, int)
public byte[] readRecord(CardFilePath file, int recordNumber) throws CardServiceException, CardTerminalException
readRecord
in interface FileAccessCardService
file
- the path to the file to read fromrecordNumber
- the index of the record to read (0 for first)
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.readRecord(opencard.opt.iso.fs.CardFilePath, int)
public byte[][] readRecords(CardFilePath file, int number) throws CardServiceException, CardTerminalException
FileAccessCardService
readRecords
in interface FileAccessCardService
file
- the path to the file to read fromnumber
- the number of records to read, or READ_SEVERAL.
If 0 is passed, the behavior is implementation dependent.
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.readRecord(opencard.opt.iso.fs.CardFilePath, int)
,
FileAccessCardService.READ_SEVERAL
public void write(CardFilePath file, int foffset, byte[] source, int soffset, int length) throws CardServiceException, CardTerminalException
write
in interface FileAccessCardService
file
- the path to the file to write tofoffset
- the file index of the first byte to overwrite
(0 for first byte in file)source
- an array holding the data to writesoffset
- the array index of the first byte to writelength
- the number of bytes to write
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.write(opencard.opt.iso.fs.CardFilePath, int, byte[], int, int)
public void write(CardFilePath file, int offset, byte[] data) throws CardServiceException, CardTerminalException
write
in interface FileAccessCardService
file
- the path to the file to write tooffset
- the file index of the first byte to overwrite
(0 for first byte in file)data
- the data to write to the file
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.write(opencard.opt.iso.fs.CardFilePath, int, byte[])
public void writeRecord(CardFilePath file, int recordNumber, byte[] data) throws CardServiceException, CardTerminalException
writeRecord
in interface FileAccessCardService
file
- the path to the file to write torecordNumber
- the index of the record to overwrite (0 for first)data
- the data to write to the file
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.writeRecord(opencard.opt.iso.fs.CardFilePath, int, byte[])
public void appendRecord(CardFilePath file, byte[] data) throws CardServiceException, CardTerminalException
appendRecord
in interface FileAccessCardService
file
- the path to the file to append todata
- the data to write to the new record
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.appendRecord(opencard.opt.iso.fs.CardFilePath, byte[])
public ResponseAPDU sendCommandAPDU(CardFilePath path, CommandAPDU com, int usageQualifier) throws CardServiceException, CardTerminalException
path
- com
- usageQualifier
-
CardServiceException
CardTerminalException
public void provideCredentials(SecurityDomain domain, CredentialBag creds) throws CardServiceException
SecureService
provideCredentials
in interface SecureService
domain
- the security domain for which to provide credentialscreds
- the credentials for that domain
CardServiceException
- If the card service could not process the credentials,
if the SecurityDomain is invalid.CardService
public int getPasswordLength(SecurityDomain domain, int number) throws CardServiceException, CardTerminalException
CHVCardService
getPasswordLength
in interface CHVCardService
domain
- The security domain in which the password resides.
null can be passed to refer to the root
domain on the smartcard.
number
- The number of the password. This parameter
is used to distinguish between different passwords
in the same security domain.
CardServiceException
- if this service encountered an error.
This may occur if the service needs to contact the smartcard
in order to determine the password length. An exception may
also be thrown if the service is unable to locate the security
domain.
CardTerminalException
- if the underlying card terminal encountered an error
when communicating with the smartcardpublic boolean verifyPassword(SecurityDomain domain, int number, CHVControl cc, byte[] password) throws CardServiceException, CardTerminalException
CHVCardServiceWithControl
verifyPassword
in interface CHVCardServiceWithControl
domain
- The security domain in which to verify the password.
null can be passed to refer to the root
domain on the smartcard.
number
- The number of the password to verify. This parameter
is used to distinguish between different passwords
in the same security domain.cc
- Control parameter defined by the applicationpassword
- The password data that has to be verified.
If the data is supplied, it has to be padded to the
length returned by getPasswordLength for
that password.
CardServiceException
- if this service encountered an error.
In this context, it is not considered an error if the password
to be verified is wrong. However, if the password is blocked
on the smartcard, an exception will be thrown.
CardTerminalException
- if the underlying card terminal encountered an error
when communicating with the smartcardpublic boolean verifyPassword(SecurityDomain domain, int number, byte[] password) throws CardServiceException, CardTerminalException
CHVCardService
verifyPassword
in interface CHVCardService
domain
- The security domain in which to verify the password.
null can be passed to refer to the root
domain on the smartcard.
number
- The number of the password to verify. This parameter
is used to distinguish between different passwords
in the same security domain.password
- The password data that has to be verified.
If the data is supplied, it has to be padded to the
length returned by getPasswordLength for
that password.
CardServiceException
- if this service encountered an error.
In this context, it is not considered an error if the password
to be verified is wrong. However, if the password is blocked
on the smartcard, an exception will be thrown.
CardTerminalException
- if the underlying card terminal encountered an error
when communicating with the smartcardpublic void closeApplication(SecurityDomain domain) throws CardServiceException, CardTerminalException
CHVCardService
The name of this method implies that an application on the smartcard is first selected and then opened by performing card holder verification, giving access to the application data. By resetting the card holder verification, the on-card application therefore gets closed.
closeApplication
in interface CHVCardService
domain
- the security domain for which to reset card holder
verifications
CardServiceException
- if this service, or the underlying implementation,
encountered an error
CardTerminalException
- if the underlying terminal encountered an error while
communicating with the smartcardpublic void create(CardFilePath parent, byte[] data) throws CardServiceException, CardTerminalException
create
in interface FileSystemCardService
parent
- the path to the directory in which to create a new filedata
- the parameters specifying the file to create.
This argument is card-specific. Refer to the documentation
of the card-specific service for details.
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileAccessCardService.getFileInfo(opencard.opt.iso.fs.CardFilePath)
,
CardFileInfo.getHeader()
,
CardID
,
SmartCard.getCardID()
public void create(CardFilePath parent, byte fileDescriptorByte, byte shortFileIdentifier, byte[] data) throws CardServiceException, CardTerminalException
create
in interface IsoFileSystemCardService
parent
- the path to the directory in which to create a new filefileDescriptorByte
- File descriptor byte according to ISO 7816-4shortFileIdentifier
- Short file identifer coded on bit b8 - b4data
- the parameters specifying the file to create.
This argument is card-specific. Refer to the documentation
of the card-specific service for details.
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorFileSystemCardService
,
FileAccessCardService.getFileInfo(opencard.opt.iso.fs.CardFilePath)
,
CardFileInfo.getHeader()
,
CardID
,
SmartCard.getCardID()
public void delete(CardFilePath file) throws CardServiceException, CardTerminalException
delete
in interface FileSystemCardService
file
- the path to the file to delete
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorpublic void delete(CardFilePath file, CardFilePathComponent child, boolean childIsDF) throws CardServiceException, CardTerminalException
delete
in interface IsoFileSystemCardService
file
- the path to the file to deletechild
- File identifier of child object (either EF, DF or application)childIsDF
- True, if the child is a dedicated file
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorpublic void invalidate(CardFilePath file) throws CardServiceInabilityException, CardServiceException, CardTerminalException
invalidate
in interface FileSystemCardService
file
- the path to the file to invalidate
CardServiceInabilityException
- if the service does not support this operation
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an errorpublic void rehabilitate(CardFilePath file) throws CardServiceInabilityException, CardServiceException, CardTerminalException
rehabilitate
in interface FileSystemCardService
file
- the path to the file to rehabilitate
CardServiceInabilityException
- if the service does not support this operation
CardServiceException
- if the service encountered an error
CardTerminalException
- if the terminal encountered an error
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |