Blackberry Java Development Environment 4.6.0 매뉴얼 - 페이지 31
{카테고리_이름} Blackberry Java Development Environment 4.6.0에 대한 매뉴얼을 온라인으로 검색하거나 PDF를 다운로드하세요. Blackberry Java Development Environment 4.6.0 36 페이지. 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