Register   Login   About   Study   Enterprise   Share
Internet / AI Technology University (ITU/AITU)
Fast Login - available after registration


Created by info@itofthefuture.com
Welcome Anonimous.User to this quiz related to Java Card.

Read the question and choose correct answers. Time is limited to 40 seconds!

Important! Do not forget to rank the quality of the question (from bad to excellent).
An initiator of the quiz will get royalty score for QnAs created by her/him and can win the Top Creativity Prize.
Question:
Which of the following methods and constructors are valid in a JavaCard applet?

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];
}



Rank the Quality of the Question from "-10" (bad) or "0" (not clear) to 10 (correct) or even 20 (very good!)
-10 (bad/wrong) 0 (not clear) 10 (correct) 20 (very good!)
Your summary report will be available to you and your instructor. Thank you for your work!!!