|
|||||||||
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.gemxcos.GemXCosCardService
public class GemXCosCardService
File access card service for Gemplus XCos cards.
Field Summary |
---|
Fields inherited from interface opencard.opt.iso.fs.FileAccessCardService |
---|
READ_SEVERAL |
Constructor Summary | |
---|---|
GemXCosCardService()
|
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)
Creates a file on the smartcard. |
void |
delete(CardFilePath file)
Deletes a file on the smartcard. |
protected ResponseAPDU |
doSelect(CardChannel channel,
CardFilePathComponent comp,
boolean isDF,
byte p1,
byte p2,
boolean sendLe)
Select a single path component |
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 void |
initialize(CardServiceScheduler scheduler,
SmartCard smartcard,
boolean blocking)
Create the IsoCardState object in the card channel if it does not yet exist. |
void |
invalidate(CardFilePath file)
Invalidates a file on the smartcard. |
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)
Reads a record from a structured file. |
byte[][] |
readRecords(CardFilePath file,
int number)
Reads consecutive records from a structured file. |
void |
rehabilitate(CardFilePath file)
Rehabilitates a file on the smartcard. |
CardFileInfo |
selectFile(CardChannel channel,
CardFilePath path)
Select directory or file according to path. |
boolean |
verifyPassword(SecurityDomain domain,
int number,
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 GemXCosCardService()
Method Detail |
---|
protected 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()
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
FileAccessCardService
Files with a cyclic structure may not be easily accessible with this method, since the absolute addressing may be interpreted in different ways by different cards. For example, the first record may be the record that is physically stored first on the card, or it may be the record that was last written into the ring buffer. The method readRecords is the preferred way to read cyclic files.
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.readRecords(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 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
protected ResponseAPDU doSelect(CardChannel channel, CardFilePathComponent comp, boolean isDF, byte p1, byte p2, boolean sendLe) throws InvalidCardChannelException, CardTerminalException
channel
- Card channel to use for SELECT commandcomp
- Path component. null is parent file is to be selectedisDF
- true if the path component is known to be a DF
InvalidCardChannelException
CardTerminalException
public CardFileInfo selectFile(CardChannel channel, CardFilePath path) throws InvalidCardChannelException, CardTerminalException, CardServiceObjectNotAvailableException, CardServiceUnexpectedStatusWordException
channel
- Card channel used to communicate with the cardpath
- Path to file to be selected
InvalidCardChannelException
CardTerminalException
CardServiceObjectNotAvailableException
CardServiceUnexpectedStatusWordException
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, 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
FileSystemCardService
This method is intended to be used in a scenario where new applications have to be downloaded on a smartcard. Typically, a server will be contacted to retrieve the information about the directories and files that have to be created. This server can be supplied with the card's ATR, which is encapsulated by class CardID. The server will then be able to send parameter blocks that are appropriate arguments for this method and the respective card.
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 delete(CardFilePath file) throws CardServiceException, CardTerminalException
FileSystemCardService
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 invalidate(CardFilePath file) throws CardServiceInabilityException, CardServiceException, CardTerminalException
FileSystemCardService
This method should not be implemented by setting all access conditions of the file to NEVER. Files with access condition NEVER are often used for internal purposes, for example to hold keys or application specific executable code. Invalidating a file should make the card OS ignore the file's contents.
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
FileSystemCardService
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 |