Troubleshooting guide
98
BlackBerry Java Development Environment Development Guide
Code sample: Creating a smart card object
Example: MyCryptoSmartCard.java
/**
* MyCryptoSmartCard.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.device.smartcard;
import net.rim.device.api.smartcard.*;
import net.rim.device.api.util.*;
import net.rim.device.api.crypto.*;
import net.rim.device.api.ui.component.*;
/**
* This class represents a kind (or model or family) of a physical smart card.
* There should only be one instance of this class in the system at one time. The instance
* is managed by the SmartCardFactory.
*/
public class MyCryptoSmartCard extends CryptoSmartCard implements Persistable
{
private final static byte MY_ATR [] = { (byte)0x3b, (byte)0x7d, (byte)0x11,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x31,
(byte)0x80, (byte)0x71, (byte)0x8e, (byte)0x64,
(byte)0x86, (byte)0xd6, (byte)0x01, (byte)0x00,
(byte)0x81, (byte)0x90, (byte)0x00 };
private final static AnswerToReset _myATR = new AnswerToReset( MY_ATR );
Let a smart card driver to open a session with
a smart card.
>Implement SmartCard.openSessionImpl(SmartCardReaderSession).
Let a smart card driver to verify the
compatibility of a smart card with a specific
ATR.
> Implement SmartCard.checkAnswerToResetImpl(AnswerToReset) .
Let a smart card driver to display settings or
properties.
>Implement SmartCard.displaySettingsImpl(Object).
Let a smart card driver to indicate support
for display settings.
>Implement SmartCard.isDisplaySettingsAvailableImpl(Object).
Retrieve the capabilities of a smart card. >Implement SmartCard.getCapabilitiesImpl().
Determine the smart card type. >Implement SmartCard.getLabelImpl().
Retrieve a string representation of the smart
card.
>Implement SmartCard.toString().
Retrieve the names of all algorithms that the
smart card supports, for example “RSA,”
“DSA.”
>Implement CryptoSmartCard.getAlgorithms().
Retrieve a CryptoToken that supports the
given algorithm.
>Implement CryptoSmartCard.getCryptoToken(String).
Task Steps