public void getVirtualScore(APDU apdu) { // read apdu to byteArray byte[] byteArray = apdu.getBuffer(); buffer[0] = (byte) virtualScore >> 8; buffer[1] = (byte) (virtualScore & 0xFF); apdu.setOutgoingAndSend((short)0, (short)2); // send 2 bytes }
private boolean isMember(String person) { // assume members is a String return (members.indexOf(person) != -1); }
private MyApplet(Object[] o) {}
public void getGroupRoles(APDU apdu) { // read apdu to byteArray byte[] byteArray = apdu.getBuffer();
// check if groupRoles are null if(groupRoles == null) { // prepare apdu buffer for this disappointing response byteArray[0] = (byte)0; byteArray[1] = (byte)0; apdu.setOutgoingAndSend((short)0, (short)2); // send 2 bytes return; } // read APDU bytes into a buffer to construct a groupRole object /* * assume that the methods called here are correctly * defined in the same class */ AID specifiedGroup = readAIDobject(apdu, byteArray); short groupIndex = getGroupIndex(specifiedGroup); if(groupIndex < 0) { // groupIndex can be ERROR-coded // prepare apdu buffer for this disappointing response buffer[0] = (byte) groupIndex >> 8; buffer[1] = (byte) (groupIndex & 0xFF); apdu.setOutgoingAndSend((short)0, (short)2); // send 2 bytes return; } // get group roles for the specified group // transform group roles into a byte array // calculate the length of the roles byte array short len = apdu.setOutgoing(); len = groupRoles[groupIndex].getBytes(byteArray, 0); apdu.setOutgoingLength( (short)len ); // send response apdu.sendBytes ( (short)0 , (short)len ); }
private void checkPIN(APDU apdu) { byte[] byteArray = apdu.getBuffer(); byte readCount = (byte) apdu.setIncomingAndReceive(); if (!ownerPin.check(byteArray, ISO7816.OFFSET_CDATA, readCount)) { ISOException.throwIt(0x6300); } }
public byte readData(java.io.InputStream in) { return (byte) in.read(); }
private byte firstByte(byte[][] b) { return b[0][0]; }
|