Package org.infotechservice.smartcard.smartcard

Source Code of org.infotechservice.smartcard.smartcard.OldSocialCardService

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.infotechservice.smartcard.smartcard;

import javax.smartcardio.CardException;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import org.infotechservice.smartcard.service.CardService;
import org.infotechservice.smartcard.service.SmartCard;
import org.infotechservice.smartcard.utils.Converter;

/**
* Сервисный объект
* Должен использоваться для работы со старой социальной картой
* @author Finder
*/
public class OldSocialCardService extends CardService {

   
    private CommandAPDU COMMAND_SELECT = new CommandAPDU(new byte[] {
        (byte)0x00, (byte)0xA4, (byte)0x04, (byte)0x00,
        (byte)0x08, (byte)0xA0, (byte)0x00, (byte)0x00,
        (byte)0x00, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x00
    });
    private CommandAPDU COMMAND_GET = new CommandAPDU(new byte[] {
        (byte)0x80, (byte)0xCA, (byte)0x9f, (byte)0x7f, (byte)0x00
    });

    public OldSocialCardService(SmartCard card) {
        super(card);
    }

    public String readID() throws CardException {
        exec(COMMAND_SELECT, "Incorrect card type");
        ResponseAPDU res = exec(COMMAND_GET, "Incorrect card type");
        byte[] data = res.getData();
        byte[] target = new byte[10];
        // зделано аналогично алгоритму sunray сервера
        System.arraycopy(data, 3, target, 0, 4);
        System.arraycopy(data, 19, target, 4, 2);
        System.arraycopy(data, 15, target, 6, 4);
        return Converter.hexDump(target, '\0');
    }
}
TOP

Related Classes of org.infotechservice.smartcard.smartcard.OldSocialCardService

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.