KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javacard > framework > APDU

javacard.framework
Class APDU

java.lang.Object
  |
  +--javacard.framework.APDU
See Also:
APDUException, ISOException

public byte[] getBuffer()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[569]Find out the size of free EEPROM space
By Michael Chan JT & Monika Erdmann on 2003/12/19 08:10:35  Rate
public class EEPROMtrace extends Applet  {  
 /* ######################################################################################  
                                    --- GLOBAL VARIABLE --- 
    ###################################################################################### */
 
     byte [  ]  accomSpace;        // designated space to test the size of EEPROM 
  
  
  /* ######################################################################################  
                                       --- CONSTRUCTOR --- 
     ###################################################################################### */
 
     public static void install ( byte [  ]  bArray, short bOffset, byte bLength )   {  
   new EEPROMtrace (  ) .register (  ) ; 
      }  
      
 // -----------------------------  [ process ]  ----------------------------- 
     public void process ( APDU apdu )   {  
  
  
   byte [  ]  buffer= apdu.getBuffer (  ) ; 
   short sizeTest =  ( short ) 32767;      // maximum size to start with 
   boolean success = false; 
  
  
   while ( success == false )   {  
       try  {  
     accomSpace = new byte [ sizeTest ] ;  // initialised global array 
  
  
     success = true;        // this line will not be executed when the previous line fails 
        }  
       catch ( Exception e )   {  
     sizeTest--; 
     success = false; 
        }  
  
  
    }  
  
  
     // by now the size of free EEPROM space should be known 
     Util.setShort ( apdu.getBuffer (  ) ,  ( short ) 0, sizeTest ) ; 
     apdu.setOutgoingAndSend (  ( short ) 0,  ( short ) 2 ) ; 
      }  
  }  // ~ END EEPROMtrace


public static byte getCLAChannel()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static APDU getCurrentAPDU()
                           throws SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static byte[] getCurrentAPDUBuffer()
                                   throws SecurityException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public byte getCurrentState()
See Also:
BasicService, STATE_INITIAL
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static short getInBlockSize()
See Also:
receiveBytes(short)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public byte getNAD()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static short getOutBlockSize()
See Also:
setOutgoingLength(short)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static byte getProtocol()
See Also:
PROTOCOL_T0
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_MEDIA_CONTACTLESS_TYPE_A
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_MEDIA_CONTACTLESS_TYPE_B
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_MEDIA_DEFAULT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_MEDIA_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_MEDIA_USB
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_T0
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_T1
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte PROTOCOL_TYPE_MASK
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public short receiveBytes(short bOff)
                   throws APDUException
See Also:
getInBlockSize()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void sendBytes(short bOff,
                      short len)
               throws APDUException
See Also:
setOutgoingNoChaining(), setOutgoing()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void sendBytesLong(byte[] outData,
                          short bOff,
                          short len)
                   throws APDUException,
                          SecurityException
See Also:
setOutgoingNoChaining(), setOutgoing()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public short setIncomingAndReceive()
                            throws APDUException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[543]Loading APDU-CDATA
By Michael Chan JT on 2003/11/24 06:15:01  Rate
protected byte [  ]  APDUparse ( APDU apdu )      {  
       byte [  ]  apduBuffer = apdu.getBuffer (  ) ; 
       apdu.setIncomingAndReceive (  ) ; 
        
       // ensure loading of APDU-CDATA onto apduBuffer [  ]  
       Util.arrayCopyNonAtomic ( apduBuffer,  ( short ) ISO.OFFSET_CDATA, apduBuffer,  ( short ) ISO.OFFSET_CDATA, apduBuffer [ ISO.OFFSET_LC ]  ) ; 
        
       // ensure loading of LE onto apduBuffer [  ]  
       apduBuffer [  ( byte )  ( ISO.OFFSET_CDATA + apduBuffer [ ISO.OFFSET_LC ]  )  ]  =  ( byte ) apdu.setOutgoing (  ) ; 
        
         return apduBuffer; 
      } 


public short setOutgoing()
                  throws APDUException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[544]Receiving from JavaCard
By Michael Chan JT on 2003/11/24 06:15:27  Rate
protected byte [  ]  APDUparse ( APDU apdu )      {  
       byte [  ]  apduBuffer = apdu.getBuffer (  ) ; 
       apdu.setIncomingAndReceive (  ) ; 
        
       // ensure loading of APDU-CDATA onto apduBuffer [  ]  
       Util.arrayCopyNonAtomic ( apduBuffer,  ( short ) ISO.OFFSET_CDATA, apduBuffer,  ( short ) ISO.OFFSET_CDATA, apduBuffer [ ISO.OFFSET_LC ]  ) ; 
        
       // ensure loading of LE onto apduBuffer [  ]  
       apduBuffer [  ( byte )  ( ISO.OFFSET_CDATA + apduBuffer [ ISO.OFFSET_LC ]  )  ]  =  ( byte ) apdu.setOutgoing (  ) ; 
        
         return apduBuffer; 
      } 


public void setOutgoingAndSend(short bOff,
                               short len)
                        throws APDUException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[582]Send data to JavaCard
By Michael Chan JT & Monika Erdmann on 2003/12/22 07:36:55  Rate
 
 public class EEPROMtrace extends Applet  {  
 /* ######################################################################################  
                                    --- GLOBAL VARIABLE --- 
    ###################################################################################### */
 
     byte [  ]  accomSpace;        // designated space to test the size of EEPROM 
  
  
  /* ######################################################################################  
                                       --- CONSTRUCTOR --- 
     ###################################################################################### */
 
     public static void install ( byte [  ]  bArray, short bOffset, byte bLength )   {  
   new EEPROMtrace (  ) .register (  ) ; 
      }  
      
 // -----------------------------  [ process ]  ----------------------------- 
     public void process ( APDU apdu )   {  
  
  
   byte [  ]  buffer= apdu.getBuffer (  ) ; 
   short sizeTest =  ( short ) 32767;      // maximum size to start with 
   boolean success = false; 
  
  
   while ( success == false )   {  
       try  {  
     accomSpace = new byte [ sizeTest ] ;  // initialised global array 
  
  
     success = true;        // this line will not be executed when the previous line fails 
        }  
       catch ( Exception e )   {  
     sizeTest--; 
     success = false; 
        }  
  
  
    }  
  
  
     // by now the size of free EEPROM space should be known 
     Util.setShort ( apdu.getBuffer (  ) ,  ( short ) 0, sizeTest ) ; 
     apdu.setOutgoingAndSend (  ( short ) 0,  ( short ) 2 ) ; 
      }  
  }  // ~ END EEPROMtrace 
 


public void setOutgoingLength(short len)
                       throws APDUException
See Also:
getOutBlockSize()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public short setOutgoingNoChaining()
                            throws APDUException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_ERROR_IO
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_ERROR_NO_T0_GETRESPONSE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_ERROR_NO_T0_REISSUE
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_ERROR_T1_IFD_ABORT
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_FULL_INCOMING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_FULL_OUTGOING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_INITIAL
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_OUTGOING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_OUTGOING_LENGTH_KNOWN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_PARTIAL_INCOMING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final byte STATE_PARTIAL_OUTGOING
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static void waitExtension()
                          throws APDUException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags