com.cryptware.jcardosapi
Class CardOS

java.lang.Object
  extended by com.cryptware.jcardosapi.CardOS
Direct Known Subclasses:
CNS

public class CardOS
extends java.lang.Object

Base class for all CardOS based smart cards

Author:
Ugo Chirico

Field Summary
static byte SELECT_MODE_ABSOLUTE
          Select EF or DF by absolute path selection.
static byte SELECT_MODE_BY_AID
          DF Selection by AID DF Data fiels is the AID (1..16 bytes)
static byte SELECT_MODE_NORMAL
          Selection of the EF or the DF with the given FID under the current DF - Data field contains the File ID (2 bytes) or Selection of the MF.
static byte SELECT_MODE_PARENT
          Selection of the parent DF.
static byte SELECT_MODE_RELATIVE
          Select EF or DF by relative path selection.
 
Constructor Summary
CardOS(SmartCard sc)
          Construct a CNS object
 
Method Summary
 ResponseAPDU ChangeReferenceData(byte id, java.lang.String pin)
          Change the Reference Data of a PIN object This function needs that the PIN object has been verified before
 ResponseAPDU ChangeReferenceData(byte id, java.lang.String oldpin, java.lang.String newpin)
          Change the Reference Data of PIN object
 ResponseAPDU ReadBinary(byte hi, byte low, short len)
          Reads bytes from the currently selected file
 byte[] ReadBinary(int toRead)
          Reads bytes from the currently selected file
 ResponseAPDU SelectFile(byte mode, java.lang.String path)
          Selects the file given in tha path
 ResponseAPDU UpdateBinary(byte hi, byte low, byte[] toWrite, short offset, short len)
          UpdateBinary Command
Sends a Update Binary Command APDU with specified offset and data
 ResponseAPDU UpdateBinary(short hi, short low, byte[] toWrite)
          UpdateBinary Command
Sends a Update Binary Command APDU with specified offset and data
 ResponseAPDU VerifyPIN(byte id, java.lang.String pin)
          VerifyPIN Command
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SELECT_MODE_NORMAL

public static final byte SELECT_MODE_NORMAL
Selection of the EF or the DF with the given FID under the current DF - Data field contains the File ID (2 bytes) or Selection of the MF. Data field is Empty (0 bytes) or Selection of the MF. Data field is 3Fh 00h (2 bytes)

See Also:
Constant Field Values

SELECT_MODE_PARENT

public static final byte SELECT_MODE_PARENT
Selection of the parent DF. Data field is Empty (0 bytes)

See Also:
Constant Field Values

SELECT_MODE_BY_AID

public static final byte SELECT_MODE_BY_AID
DF Selection by AID DF Data fiels is the AID (1..16 bytes)

See Also:
Constant Field Values

SELECT_MODE_ABSOLUTE

public static final byte SELECT_MODE_ABSOLUTE
Select EF or DF by absolute path selection. The data field is the path (m*2 Bytes)

See Also:
Constant Field Values

SELECT_MODE_RELATIVE

public static final byte SELECT_MODE_RELATIVE
Select EF or DF by relative path selection. The data field is the path (m*2 Bytes)

See Also:
Constant Field Values
Constructor Detail

CardOS

public CardOS(SmartCard sc)
Construct a CNS object

Parameters:
sc - the smart card
Method Detail

VerifyPIN

public ResponseAPDU VerifyPIN(byte id,
                              java.lang.String pin)
VerifyPIN Command

Parameters:
id - the id to verify
pin -
Returns:
the response

ChangeReferenceData

public ResponseAPDU ChangeReferenceData(byte id,
                                        java.lang.String pin)
Change the Reference Data of a PIN object This function needs that the PIN object has been verified before

Parameters:
id - the id of the PIN object
pin - the new PIN object to set
Returns:
the result of the command

ChangeReferenceData

public ResponseAPDU ChangeReferenceData(byte id,
                                        java.lang.String oldpin,
                                        java.lang.String newpin)
Change the Reference Data of PIN object

Parameters:
id - the id of the PIN object
oldpin - the old PIN object to change
newpin - the new PIN object
Returns:
the result of the command

SelectFile

public ResponseAPDU SelectFile(byte mode,
                               java.lang.String path)
Selects the file given in tha path

Parameters:
mode - Selection Mode:
- SELECT_MODE_NORMAL
- SELECT_MODE_ABSOLUTE
- SELECT_MODE_BY_AID
- SELECT_MODE_PARENT
- SELECT_MODE_RELATIVE
path - the file path
Returns:
the response

ReadBinary

public byte[] ReadBinary(int toRead)
                  throws SmartCardException
Reads bytes from the currently selected file

Parameters:
toRead - Number of bytes to read
Returns:
the bytes read
Throws:
SmartCardException

ReadBinary

public ResponseAPDU ReadBinary(byte hi,
                               byte low,
                               short len)
Reads bytes from the currently selected file

Parameters:
hi - highest byte of the offset
low - offset lowest byte of the offset
len - number of bytes to read
Returns:
the response

UpdateBinary

public ResponseAPDU UpdateBinary(byte hi,
                                 byte low,
                                 byte[] toWrite,
                                 short offset,
                                 short len)
UpdateBinary Command
Sends a Update Binary Command APDU with specified offset and data

Parameters:
hi - highest byte of the offset
low - offset lowest byte of the offset
toWrite - bytes to write
offset - the offset in toWrite
len - the number of bytes to write
Returns:
the response

UpdateBinary

public ResponseAPDU UpdateBinary(short hi,
                                 short low,
                                 byte[] toWrite)
UpdateBinary Command
Sends a Update Binary Command APDU with specified offset and data

Parameters:
hi - highest byte of the offset
low - offset lowest byte of the offset
toWrite - bytes to write
Returns:
the response