Package net.rim.device.api.smartcard

Examples of net.rim.device.api.smartcard.SmartCardSession


    private void signDecryptHelper(final RSACryptoSystem cryptoSystem,
            final CryptoTokenPrivateKeyData privateKeyData, final byte[] input,
            final int inputOffset, final byte[] output, final int outputOffset,
            final String accessReason, final int operation)
            throws CryptoTokenException, CryptoUnsupportedOperationException {
        SmartCardSession smartCardSession = null;
        try {

            if (privateKeyData instanceof MyCryptoTokenData) {
                final SmartCardID smartCardID =
                        ((MyCryptoTokenData) privateKeyData).getSmartCardID();
                smartCardSession =
                        SmartCardFactory.getSmartCardSession(smartCardID);

                if (smartCardSession instanceof MyCryptoSmartCardSession) {
                    final 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 (final SmartCardSessionClosedException e) {
            throw new CryptoTokenCancelException(e.toString());
        } catch (final SmartCardCancelException e) {
            throw new CryptoTokenCancelException(e.toString());
        } catch (final SmartCardRemovedException e) {
            throw new CryptoTokenCancelException(e.toString());
        } catch (final SmartCardException e) {
            throw new CryptoTokenException(e.toString());
        } finally {
            if (smartCardSession != null) {
                smartCardSession.close();
            }
        }
    }
View Full Code Here

TOP

Related Classes of net.rim.device.api.smartcard.SmartCardSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.