Troubleshooting guide

112
BlackBerry Java Development Environment Development Guide
Store the private key file location
Code sample: Storing the location of a private key file on the smart card
Example: MyCryptoTokenData.java
/**
* MyCryptoTokenData.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.device.smartcard;
import net.rim.device.api.crypto.*;
import net.rim.device.api.smartcard.*;
import net.rim.device.api.util.*;
/**
* This class stores the location of the private key file on the smart card.
*
*/
final class MyCryptoTokenData implements CryptoTokenPrivateKeyData, Persistable
{
/**
* Smart card containing the private key.
Task Steps
Store the location of the private key on the
smart card.
> In your application, implement the CryptoTokenPrivateKeyData interface.
Associate the implementing class object
with the smart card that contains the
private key.
1. Create an instance variable for storing the smart card ID.
private SmartCardID _id;
2. Create an instance variable for storing the location of the private key file on the smart card.
private byte _file;
3. Create a method that associates an object from the class that implements a
PrivateKeyData interface with the smart card.
public MyCryptoTokenData( SmartCardID id, byte file )
{_id = id;
_file = file;
}
Retrieve the ID of the key file that
contains the private key file.
> Create a method that returns the SmartCardID instance variable.
public SmartCardID getSmartCardID()
{
return _id;
}
Retrieve the location of the private key file
on the smart card.
> Create a method that returns the private key file smart card location instance variable.
public byte getFile()
{
return _file;
}