Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Manuel - Page 31
Parcourez en ligne ou téléchargez le pdf Manuel pour {nom_de_la_catégorie} Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE. Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE 36 pages. Cryptographic smart card driver
{
signDecryptHelper( cryptoSystem, privateKeyData, input, inputOffset, output,
outputOffset, SIGN_DESC, SmartCardSession.SIGN_OPERATION );
}
/**
* Help signing and decryption operations.
* This helper method assists data signing and decryption because
* the operations are very similar.
*/
private void signDecryptHelper( RSACryptoSystem cryptoSystem,
CryptoTokenPrivateKeyData privateKeyData, byte[] input, int inputOffset,
byte[] output, int outputOffset,String accessReason,int operation )
throws CryptoTokenException, CryptoUnsupportedOperationException
{
SmartCardSession smartCardSession = null;
try {
if( privateKeyData instanceof MyCryptoTokenData ) {
SmartCardID smartCardID = ((MyCryptoTokenData) privateKeyData
).getSmartCardID();
smartCardSession = SmartCardFactory.getSmartCardSession( smartCardID );
if ( smartCardSession instanceof MyCryptoSmartCardSession ) {
MyCryptoSmartCardSession mySmartCardSession = ( MyCryptoSmartCardSession
)smartCardSession;
// We must provide the user authentication since we returned true from
//providesUserAuthentication()
// Also, the smart card PIN is required for private key access.
mySmartCardSession.loginPrompt( accessReason, operation );
mySmartCardSession.signDecrypt( cryptoSystem,
(MyCryptoTokenData)privateKeyData, input, inputOffset, output, outputOffset
);
return;
}
}
throw new RuntimeException();
} catch ( SmartCardSessionClosedException e ) {
throw new CryptoTokenCancelException( e.toString() );
} catch ( SmartCardCancelException e ) {
throw new CryptoTokenCancelException( e.toString() );
} catch( SmartCardRemovedException e ) {
throw new CryptoTokenCancelException( e.toString() );
} catch ( SmartCardException e ) {
throw new CryptoTokenException( e.toString() );
} finally {
if ( smartCardSession != null ) {
smartCardSession.close();
}
3: Code samples
27