Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Manuel - Sayfa 24
Yazılım Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE için çevrimiçi göz atın veya pdf Manuel indirin. Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE 36 sayfaları. Cryptographic smart card driver
Cryptographic Smart Card Driver Development Guide
// Check for response codes specific to your smart card
if ( response.checkStatusWords( (byte)0x90, (byte)0x00 ) ) {
return true;
}
else if ( response.checkStatusWords( (byte)0x64, (byte)0xF8 ) ) {
throw new SmartCardLockedException();
}
else {
// Authentication failed
return false;
}
}
/**
* Retrieve an ID for this session's associated smart card.
*/
protected SmartCardID getSmartCardIDImpl() throws SmartCardException
{
// Retrieve a unique ID from the card
byte [] uniqueCardData = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b };
// Convert byte array to a long
SHA1Digest digest = new SHA1Digest();
digest.update( uniqueCardData );
long idLong = byteArrayToLong( Arrays.copy( digest.getDigest(), 0, 8 ) );
// Using friendly display name
return new SmartCardID( idLong , ID_STRING, getSmartCard() );
}
/**
* Converts <code>array</code> into a long integer (Note: the returned value should
* be considered as an unsigned value).
* @throws IllegalArgumentException if <code>array</code> contains a number bigger
* than 64 bits.
*
* Note:
* If your cryptographic smart card driver is only designed to work with
* BlackBerry Version 4.2 or later, you can replace this method with a call to
* CryptoByteArrayArithmetic.valueOf( byte [] ).
*
*/
private long byteArrayToLong( byte[] array )
{
if ( array == null ) {
throw new IllegalArgumentException();
}
// Remove the leading zeros from given byte[] and returns a new byte[] without them.
int zeros = 0;
for ( int i = 0; i < array.length && array[i] == 0; i++ ){
zeros++;
}
20