Blackberry Java Development Environment 4.6.0 Manuale - Pagina 25

Sfoglia online o scarica il pdf Manuale per Software Blackberry Java Development Environment 4.6.0. Blackberry Java Development Environment 4.6.0 36. Cryptographic smart card driver

if ( zeros != 0 ) {
array = Arrays.copy( array, zeros, array.length - zeros );
}
int length = array.length;
if( length > 8 ) {
throw new IllegalArgumentException();
}
long n = 0;
for( int i=0; i<length; i++ ) {
n <<= 8;
n += array[i] & 0xff;
}
return n;
}
/**
* Retrieve some random data from the smart cards internal Random Number Generator.
*/
protected byte [] getRandomBytesImpl( int maxBytes ) throws SmartCardException
{
// Create a CommandAPDU which your smart card will understand
CommandAPDU command = new CommandAPDU( (byte)0x00, (byte)0x4C, (byte)0x00,
(byte)0x00, maxBytes );
ResponseAPDU response = new ResponseAPDU();
sendAPDU( command, response );
// Check for response codes specific to your smart card
if( response.checkStatusWords( (byte)0x90, (byte)0x00 ) ) {
// The appropriate response code containing the random data
return response.getData();
}
return null;
}
/**
* Retrieve certificates from the card.
*
* @return An array of certificates which are present on the card.
*/
protected CryptoSmartCardKeyStoreData[] getKeyStoreDataArrayImpl() throws
SmartCardException, CryptoTokenException
{
try {
// Show a progress dialog to the user as this operation may take a long time.
displayProgressDialog( WAITING_MSG, 4 );
// The certificates need to be associated with a particular card.
SmartCardID smartCardID = getSmartCardID();
3: Code samples
21