com.ibm.jc
Class JCApplet

java.lang.Object
  extended bycom.ibm.jc.JCApplet
Direct Known Subclasses:
LoadFile, OPApplet

public class JCApplet
extends java.lang.Object

This class implements the off-card behavior of an applet on a JavaCard.

See Also:
OPApplet

Field Summary
protected  byte[] apdu
          APDU buffer (size 300 bytes) (5 bytes header, 255 bytes max body, 1 byte LE, 39 bytes for misc stuff (MAC, encryption padding)
 
Constructor Summary
JCApplet()
           
JCApplet(JCApplet app)
          Create the off-card representation of a JavaCard applet.
JCApplet(JCard card, byte[] aid)
          Create the off-card representation of a JavaCard applet.
JCApplet(JCard card, byte[] aid, int aidBeg, int aidLen)
          Create the off-card representation of a JavaCard applet.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 void flush()
          Flush off-card cache of on-card mutable properties.
 byte[] getAID()
           
 JCard getCard()
           
 JCTerminal getTerminal()
          Deprecated. use getCard().getTerminal()
 byte[] select()
          Select applet via the current logial channel.
 byte[] setAID(byte[] aid)
          Sets the AID of the applet.
 void setCard(JCard c)
          sets the Card the applet resides on
protected  void setHeader(int cla, int ins, int p1, int p2)
          Set APDU header with given values.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

apdu

protected byte[] apdu
APDU buffer (size 300 bytes) (5 bytes header, 255 bytes max body, 1 byte LE, 39 bytes for misc stuff (MAC, encryption padding)

Constructor Detail

JCApplet

public JCApplet(JCard card,
                byte[] aid,
                int aidBeg,
                int aidLen)
Create the off-card representation of a JavaCard applet.

Parameters:
card - the JavaCard on which this applet lives
aid - the buffer containing the AID of the applet
aidBeg - start offset for AID
aidLen - the length of the applet. This value must be in the range [5;16].
Throws:
JCException - if AID is too short/long or if 'card' is null.

JCApplet

public JCApplet(JCard card,
                byte[] aid)
Create the off-card representation of a JavaCard applet.

Parameters:
card - the JavaCard on which this applet lives
aid - the buffer containing the AID of the applet starting at offset zero with the length of aid.length.
Throws:
JCException - if AID is too short or too long.

JCApplet

public JCApplet(JCApplet app)
Create the off-card representation of a JavaCard applet.

Throws:
JCException - if AID is too short or too long.

JCApplet

public JCApplet()
Method Detail

equals

public boolean equals(java.lang.Object o)
Returns:
true if both applets have the same AID and are on the same card.

getTerminal

public JCTerminal getTerminal()
Deprecated. use getCard().getTerminal()

Returns:
the terminal the card is inserted.

getCard

public JCard getCard()
Returns:
the card on which this applet lives.

setCard

public void setCard(JCard c)
sets the Card the applet resides on


getAID

public byte[] getAID()
Returns:
the AID of the applet. The returned array is shared with this instance. Modifying it will result in unexpected behavior.

setAID

public byte[] setAID(byte[] aid)
Sets the AID of the applet.

Parameters:
aid - byte array holding the new AID (data is not copied).
Returns:
the new AID.

setHeader

protected void setHeader(int cla,
                         int ins,
                         int p1,
                         int p2)
Set APDU header with given values.


flush

public void flush()
Flush off-card cache of on-card mutable properties. This default implementation is empty.


select

public byte[] select()
Select applet via the current logial channel.

Returns:
response APDU.
Throws:
if - status of R-APDU is neither JCStatus.NOERROR (9000) nor JCStatus.APPLET_INVALIDATED (6283).