Examples of ResponseAPDU


Examples of javax.smartcardio.ResponseAPDU

        exec(new CommandAPDU(command), "Write id error");
    }

    public int readID() throws CardException {
        commandSelect();
        ResponseAPDU resp = exec(new CommandAPDU(READ_COMMAND), "Read id error");
        if (Arrays.equals(Arrays.copyOf(COMMAND_HEAD, 14), Arrays.copyOf(resp.getData(), 14))) {
            return new BCD(resp.getData()).toInteger(16);
        } else {
            return 0;
        }
    }
View Full Code Here

Examples of javax.smartcardio.ResponseAPDU

        exec(SELECT_SOCIAL_APPLICATION, "Unable select social application");
        record1_7 = getRecord(READ_FILE_1_7);
    }

    private byte[] getRecord(CommandAPDU apdu) throws CardException {
        ResponseAPDU responce = exec(apdu, "Unable read user info");
        Messages msg = Messages.findMessage(responce);
        if (!msg.isOk()) {
            throw new CardException(msg.getMessage());
        }
        return responce.getData();
    }
View Full Code Here

Examples of javax.smartcardio.ResponseAPDU

     * @param errorMesssage Сообщение об ошибке, кторое будет отображено если будет ошибка
     * @return
     * @throws CardException
     */
    protected ResponseAPDU exec(CommandAPDU command, String errorMesssage) throws CardException {
        ResponseAPDU responce = smartcard.getCard().getBasicChannel().transmit(command);
        Messages msg = Messages.findMessage(responce);
        if (msg.isError()) {
            if (errorMesssage == null) {
                throw new CardFrameworkException(msg);
            } else {
View Full Code Here

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

        final CommandAPDU command =
                new CommandAPDU((byte) 0x00, (byte) 0x20, (byte) 0x00,
                        (byte) 0x00);
        command.setLcData(password.getBytes());

        final ResponseAPDU response = new ResponseAPDU();

        sendAPDU(command, response);

        // TODO: Check for response codes specific to your smart card.
        if (response.checkStatusWords((byte) 0x90, (byte) 0x00)) {
            return true;
        } else if (response.checkStatusWords((byte) 0x64, (byte) 0xF8)) {
            throw new SmartCardLockedException();
        } else {
            // Authentication failed.
            return false;
        }
View Full Code Here

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

        // TODO: Create a CommandAPDU which your smart card will understand.
        final CommandAPDU command =
                new CommandAPDU((byte) 0x00, (byte) 0x4C, (byte) 0x00,
                        (byte) 0x00, maxBytes);

        final ResponseAPDU response = new ResponseAPDU();

        sendAPDU(command, response);

        // TODO: Check for response codes specific to your smart card.
        if (response.checkStatusWords((byte) 0x90, (byte) 0x00)) {
            return response.getData();
        }

        return null;
    }
View Full Code Here

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

                || output.length < outputOffset + modulusLength) {
            throw new IllegalArgumentException();
        }

        // Construct the response Application Protocol Data Unit.
        final ResponseAPDU response = new ResponseAPDU();

        // Construct the command and set its information.
        // TODO: Create a CommandAPDU which your smart card will understand.
        final CommandAPDU signAPDU =
                new CommandAPDU((byte) 0x80, (byte) 0x56, (byte) 0x00,
                        (byte) 0x00, modulusLength);
        signAPDU.setLcData(input, inputOffset, input.length - inputOffset);

        // Send the command to the smart card
        sendAPDU(signAPDU, response);

        // Validate the status words of the response.
        // TODO: Check for response codes specific to your smart card.
        if (response.checkStatusWords((byte) 0x90, (byte) 0x00)) {
            final byte[] responseData = response.getData();
            System.arraycopy(responseData, 0, output, outputOffset,
                    responseData.length);
        } else {
            throw new SmartCardException("Invalid response code, sw1="
                    + Integer.toHexString(response.getSW1() & 0xff) + " sw2="
                    + Integer.toHexString(response.getSW2() & 0xff));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.