Blackberry Java Development Environment 4.6.0 Manual - Página 28

Navegue en línea o descargue pdf Manual para Software Blackberry Java Development Environment 4.6.0. Blackberry Java Development Environment 4.6.0 36 páginas. Cryptographic smart card driver

Cryptographic Smart Card Driver Development Guide
Code sample: Enabling a CryptoToken object for RSA
operations using a private key
Example: MyRSACryptoToken.java
/**
* MyRSACryptoToken.java
* Copyright (C) 2001-2007 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.device.smartcard;
import net.rim.device.api.smartcard.*;
import net.rim.device.api.crypto.*;
import net.rim.device.api.crypto.keystore.*;
import net.rim.device.api.util.*;
import net.rim.device.api.crypto.certificate.x509.*;
import net.rim.device.api.crypto.certificate.*;
import net.rim.device.api.crypto.asn1.*;
import net.rim.device.api.compress.*;
import net.rim.device.api.i18n.*;
/**
* This class describes an implmentation of an RSA cryptographic token.
*
* The RIM Crypto API will use this object to perform a private key RSA operation.
* This object should delegate the operation to the smart card.
*/
final class MyRSACryptoToken extends RSACryptoToken implements Persistable
{
private static final String DECRYPT_DESC = "The private key will be used to decrypt
encrypted data.";
private static final String SIGN_DESC = "The private key will be used to generate a
digital signature.";
/**
* Constructs a new MyRSACryptoToken object.
*/
MyRSACryptoToken()
{
}
/**
* Determine if this token does the user authentication for the system.
*
* If not the KeyStore will prompt for the key store password when the user
* tries to access the private key.
*
* @return True if this token will prompt for the necessary
* user authentication when private key access is requested.
*/
public boolean providesUserAuthentication()
{
return true;
}
24