Fields Summary |
---|
private static final int | TYPE_BCDBCD PIN type constant. |
private static final int | TYPE_ASCIIASCII PIN type constant. |
private static final int | TYPE_UTFUTF PIN type constant. |
private static final int | TYPE_HNHN PIN type constant. |
private static final int | TYPE_ISOISO PIN type constant. |
public static final int | FLAG_CASE_SENSITIVECASE_SENSITIVE PIN flag constant. |
public static final int | FLAG_LOCALLOCAL PIN flag constant. |
public static final int | FLAG_CHANGE_DISABLEDCHANGE_DISABLED PIN flag constant. |
public static final int | FLAG_UNBLOCK_DISABLEDUNBLOCK_DISABLED PIN flag constant. |
public static final int | FLAG_INITIALIZEDINITIALIZED PIN flag constant. |
public static final int | FLAG_NEEDS_PADDINGNEEDS_PADDING PIN flag constant. |
public static final int | FLAG_UNBLOCKING_PINUNBLOCKING_PIN PIN flag constant. |
public static final int | FLAG_SOPINSOPIN PIN flag constant. |
public static final int | FLAG_DISABLE_ALLOWEDDISABLE_ALLOWED PIN flag constant. |
public static final int | FLAG_INTEGRITY_PROTECTEDINTEGRITY_PROTECTED PIN flag constant. |
public static final int | FLAG_CONFIDENTIALITY_PROTECTEDCONFIDENTIALITY_PROTECTED PIN flag constant. |
public static final int | FLAG_EXCHANGEREFDATAEXCHANGEREFDATA PIN flag constant. |
public String | labelPIN label. |
public int | idPIN identifier. |
public int | pinTypepinType PIN attribute. |
public int | minLengthminLength PIN attribute. |
public int | storedLengthstoredLength PIN attribute. |
public int | maxLengthmaxLength PIN attribute. |
public int | pinReferencepinReference PIN attribute. |
public int | padCharpadChar PIN attribute. |
public int | pinFlagspinFlags PIN attribute. |
public short[] | pathPath PIN attribute. |
private Vector | PINThis vector contains parsed objects from PIN file. |
private TLV | rootThis TLV contains root TLV |
Methods Summary |
---|
public boolean | check(int action)Verifies if the specified operation can be performed on this PIN.
if (action == ACLPermissions.CMD_CHANGE) {
return (pinFlags & FLAG_CHANGE_DISABLED) == 0;
}
if (action == ACLPermissions.CMD_DISABLE) {
return (pinFlags & FLAG_DISABLE_ALLOWED) != 0;
}
if (action == ACLPermissions.CMD_UNBLOCK) {
return (pinFlags & FLAG_UNBLOCK_DISABLED) == 0;
}
return true;
|
public int | getMaxLength()Returns maximum PIN length in characters.
if ((pinFlags & FLAG_NEEDS_PADDING) == 0) {
return maxLength;
}
if (pinType == TYPE_BCD) {
return storedLength * 2;
}
// UTF symbol may occupy 1 or 2 bytes, additional check is necessary
return storedLength;
|
public boolean | isNumeric()Returns true if this PIN is a number.
return (pinType != TYPE_UTF);
|
public boolean | isUnblockingPIN()Verifies if this PIN can be used to unblock other PINs.
return (pinFlags & FLAG_UNBLOCKING_PIN) != 0;
|
private void | readPINs()Read PIN information.
TLV t = root.child; // commonObjectAttributes
label = t.child.getUTF8().trim();
t = t.next; // CommonAuthenticationObjectAttributes
id = t.child.getId();
t = t.next;
if (t.type != ACEntry.CONTEXT_CONSTRUCTED_1) {
throw new TLVException("Incomplete PIN record");
}
t = t.child.child; // PinAttributes.pinFlags
byte[] buf = t.getValue();
int mask = 0;
for (int i = 0; i < buf[0]; i++) {
mask = mask | (1 << i);
}
mask = ~mask;
pinFlags = Utils.getShort(buf, 1) & mask;
t = t.next;
pinType = t.getEnumerated();
t = t.next;
minLength = t.getInteger();
t = t.next;
storedLength = t.getInteger();
t = t.next;
if (t.type == TLV.INTEGER_TYPE) {
maxLength = t.getInteger();
t = t.next;
} else {
maxLength = storedLength;
}
// this entry is optional, default value is 0
if (t.type == 0x80) {
pinReference = t.getInteger();
t = t.next;
}
padChar = t.getId();
|
public byte[] | transform(java.lang.String s)Transforms string entered by user according to PIN attributes.
if (s.length() < minLength) {
return null;
}
byte[] data = null;
if (pinType == TYPE_UTF) {
if ((pinFlags & FLAG_CASE_SENSITIVE) == 0) {
s = s.toUpperCase(); // locale?
}
data = Utils.stringToBytes(s);
if (data.length > getMaxLength()) {
return null;
}
} else {
byte[] tmp = new byte[s.length()];
for (int i = 0; i < tmp.length; i++) {
tmp[i] = (byte) (s.charAt(i));
}
if (pinType == TYPE_ASCII || pinType == TYPE_ISO) {
data = tmp;
} else {
if (pinType == TYPE_HN) {
data = tmp;
for (int i = 0; i < data.length; i++) {
data[i] = (byte) (0xf0 | (data[i] - 0x30));
}
} else { // type == TYPE_BCD
data = new byte[(tmp.length + 1) / 2];
for (int i = 0; i < data.length; i++) {
int l = i * 2;
int b1 = tmp[l] - 0x30;
int b2;
if (l + 1 == tmp.length) {
b2 = padChar;
} else {
b2 = tmp[l + 1] - 0x30;
}
data[i] = (byte) ((b1 << 4) | (b2 & 0xf));
}
}
}
}
if (((pinFlags & FLAG_NEEDS_PADDING) == 0) ||
(data.length == storedLength)) {
return data;
}
byte[] r = new byte[storedLength];
System.arraycopy(data, 0, r, 0, data.length);
for (int i = data.length; i < storedLength; i++) {
r[i] = (byte) padChar;
}
return r;
|