FileDocCategorySizeDatePackage
SamplePasswdBioApplet.javaAPI DocJava Card3558Wed Mar 22 21:07:24 GMT 2006com.sun.javacard.samples.biometry.bioApplet

SamplePasswdBioApplet

public class SamplePasswdBioApplet extends Applet
package AID: 0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x0f:0x02 applet AID: 0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x0f:0x02:0x01

Fields Summary
public static final byte
CLA
public static final byte
INS_GET_REQ
public static final byte
INS_MATCH
public static final short
ERROR_MATCH_FAILED
private SharedBioTemplate
bioImpl
private static final byte[]
BIO_SERVER_AID
Constructors Summary
protected SamplePasswdBioApplet(byte[] bArray, short bOffset, byte bLength)
Only this class's install method should create the applet object.

                   
             
        byte aidLen = bArray[bOffset];
        if (aidLen== (byte)0){
            register();
        } else {
            register(bArray, (short)(bOffset+1), aidLen);
        }
        AID bioServerAID = JCSystem.lookupAID(BIO_SERVER_AID,(short)0,(byte)BIO_SERVER_AID.length);
        bioImpl = (SharedBioTemplate)JCSystem.getAppletShareableInterfaceObject(bioServerAID,(byte)0);
    
Methods Summary
public voidgetRequirements(APDU apdu)
method returns the public template data.

        byte []buffer = apdu.getBuffer();
        //byte []pubTemp = JCSystem.makeTransientByteArray((short)4,JCSystem.CLEAR_ON_DESELECT);
        
        short length = bioImpl.getPublicTemplateData((short)0, buffer, (short)0, (short)buffer.length);
        apdu.setOutgoing();
        apdu.setOutgoingLength(length);
        apdu.sendBytes((short)0,length);
    
public static voidinstall(byte[] bArray, short bOffset, byte bLength)
Installs this applet.

param
bArray the array containing installation parameters
param
bOffset the starting offset in bArray
param
bLength the length in bytes of the parameter data in bArray

        new SamplePasswdBioApplet(bArray,bOffset,bLength);
    
public voidmatch(APDU apdu)
following match method matches the password passed in with the reference template

        byte []buffer = apdu.getBuffer();
        short bytesRead = apdu.setIncomingAndReceive();
        short result = bioImpl.initMatch(buffer, ISO7816.OFFSET_CDATA, bytesRead);
        if(result < BioTemplate.MINIMUM_SUCCESSFUL_MATCH_SCORE){
            ISOException.throwIt(ERROR_MATCH_FAILED);
        }
    
public voidprocess(APDU apdu)
Processes an incoming APDU.

see
APDU
param
apdu the incoming APDU
exception
ISOException with the response bytes per ISO 7816-4

         byte buffer[] = apdu.getBuffer();
         // check SELECT APDU command
         if(selectingApplet())
             return;
         switch (buffer[ISO7816.OFFSET_INS]){
             case INS_GET_REQ:
             getRequirements(apdu);
             break;
             case INS_MATCH:
             match(apdu);
             break;
             default:
            ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }