本文整理汇总了Java中javax.smartcardio.ResponseAPDU.getSW1方法的典型用法代码示例。如果您正苦于以下问题:Java ResponseAPDU.getSW1方法的具体用法?Java ResponseAPDU.getSW1怎么用?Java ResponseAPDU.getSW1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.smartcardio.ResponseAPDU
的用法示例。
在下文中一共展示了ResponseAPDU.getSW1方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transmit
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
ResponseAPDU responseApdu = this.cardChannel.transmit(commandApdu);
if (0x6c == responseApdu.getSW1()) {
/*
* A minimum delay of 10 msec between the answer ‘6C xx’ and the
* next APDU is mandatory for eID v1.0 and v1.1 cards.
*/
this.view.addDetailMessage("sleeping...");
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException("cannot sleep");
}
responseApdu = this.cardChannel.transmit(commandApdu);
}
return responseApdu;
}
示例2: getFile
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
* Reads the content of an elementary transparent file (EF). If the file is
* bigger then 255 byte this function uses multiply READ BINARY command to
* get the whole file.
*
* @param sfid
* Short File Identififier of the EF to read. Must be between
* 0x01 and 0x1F.
* @return Returns the content of the EF with the given SFID
* @throws CardException
* @throws SecureMessagingException
*/
public byte[] getFile(byte sfid) throws SecureMessagingException, CardException{
if (sfid > 0x1F) throw new IllegalArgumentException("Invalid Short File Identifier!");
ResponseAPDU resp = ch.transceive(readBinary(sfid, (byte) 0x08));
if (resp.getSW1() != 0x90) return null;
int fileLength = 0;
byte[] data = null;
try {
fileLength = getLength(resp.getData());
data = readFile(fileLength);
} catch (IOException e) {
return null;
}
return data;
}
示例3: sendPSOVerifyCertificate
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
* @param dvCert
* @throws SecureMessagingException
* @throws CardException
* @throws TAException
*/
private ResponseAPDU sendPSOVerifyCertificate(CVCertificate dvCert) throws SecureMessagingException, CardException, TAException {
byte[] certBody = null;
byte[] certSignature = null;
byte[] data = null;
try {
certBody = dvCert.getBody().getEncoded(ASN1Encoding.DER);
certSignature = dvCert.getSignature().getEncoded(ASN1Encoding.DER);
data = new byte[certBody.length+certSignature.length];
System.arraycopy(certBody, 0, data, 0, certBody.length);
System.arraycopy(certSignature, 0, data, certBody.length, certSignature.length);
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
}
CommandAPDU pso = new CommandAPDU(0x00, 0x2A, 0x00, 0xBE, data);
ResponseAPDU resp = cardHandler.transceive(pso);
if (resp.getSW1()!=0x90) throw new TAException("PSO:Verify failed "+HexString.bufferToHex(resp.getBytes()));
return resp;
}
示例4: sendMSESetDST
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
* @param pubKeyRef
* @return
* @throws CardException
* @throws SecureMessagingException
* @throws TAException
*/
private ResponseAPDU sendMSESetDST(String pubKeyRef) throws SecureMessagingException, CardException, TAException{
DERTaggedObject do83 = new DERTaggedObject(false, 0x03, new DEROctetString(pubKeyRef.getBytes()));
byte[] data = null;
try {
data = do83.getEncoded(ASN1Encoding.DER);
} catch (IOException e) {
logger.error(e.getLocalizedMessage());
}
CommandAPDU setdst = new CommandAPDU(0x00,0x22,0x81,0xB6,data);
ResponseAPDU resp = cardHandler.transceive(setdst);
if (resp.getSW1()!=0x90) throw new TAException("MSE:Set id_AT failed "+HexString.bufferToHex(resp.getBytes()));
return resp;
}
示例5: transmit
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private ResponseAPDU transmit(CommandAPDU commandApdu) throws CardException {
ResponseAPDU responseApdu = this.cardChannel.transmit(commandApdu);
if (0x6c == responseApdu.getSW1()) {
/*
* A minimum delay of 10 msec between the answer ‘6C xx’ and the
* next APDU is mandatory for eID v1.0 and v1.1 cards.
*/
try {
Thread.sleep(10);
} catch (InterruptedException e) {
throw new RuntimeException("cannot sleep");
}
responseApdu = this.cardChannel.transmit(commandApdu);
}
return responseApdu;
}
示例6: verifyPin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void verifyPin(CCIDFeature directPinVerifyFeature, CCIDFeature verifyPinStartFeature,
Map<Byte, CCIDFeature> ccidFeatures)
throws IOException, CardException, InterruptedException, UserCancelledException {
if (isWindows8()) {
this.card.endExclusive();
}
ResponseAPDU responseApdu;
int retriesLeft = -1;
do {
if (null != directPinVerifyFeature) {
responseApdu = verifyPinDirect(retriesLeft, directPinVerifyFeature);
} else if (null != verifyPinStartFeature) {
responseApdu = verifyPin(retriesLeft, verifyPinStartFeature, ccidFeatures);
} else {
responseApdu = verifyPin(retriesLeft);
}
if (0x9000 != responseApdu.getSW()) {
this.view.addDetailMessage("VERIFY_PIN error");
this.view.addDetailMessage("SW: " + Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
this.dialogs.showPinBlockedDialog();
throw new RuntimeException("eID card blocked!");
}
if (0x63 != responseApdu.getSW1()) {
this.view.addDetailMessage("PIN verification error.");
throw new RuntimeException("PIN verification error.");
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.view.addDetailMessage("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
if (isWindows8()) {
this.card.beginExclusive();
}
}
示例7: unblockPin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
* Unblocking PIN using PUKs. This will choose the most secure method
* available to unblock a blocked PIN. If requireSecureReader is true, will
* throw SecurityException if an SPR is not available
*
* @param requireSecureReader
* @throws Exception
*/
public void unblockPin(final boolean requireSecureReader) throws Exception {
if (requireSecureReader
&& (!getCCID().hasFeature(CCID.FEATURE.VERIFY_PIN_DIRECT))) {
throw new SecurityException("not a secure reader");
}
ResponseAPDU responseApdu;
int retriesLeft = -1;
do {
if (getCCID().hasFeature(CCID.FEATURE.VERIFY_PIN_DIRECT)) {
this.logger.debug("could use direct PIN verify here...");
responseApdu = unblockPINViaCCIDVerifyPINDirectOfPUK(retriesLeft);
} else {
responseApdu = unblockPINViaUI(retriesLeft);
}
if (0x9000 != responseApdu.getSW()) {
this.logger.debug("PIN unblock error");
this.logger.debug("SW: "
+ Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
getUI().advisePINBlocked();
throw new ResponseAPDUException("eID card blocked!",
responseApdu);
}
if (0x63 != responseApdu.getSW1()) {
this.logger.debug("PIN unblock error.");
throw new ResponseAPDUException("PIN unblock error",
responseApdu);
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.logger.debug("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
getUI().advisePINUnblocked();
}
示例8: verifyPin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
private void verifyPin(final PINPurpose purpose,
final String applicationName) throws IOException, CardException,
InterruptedException, UserCancelledException {
ResponseAPDU responseApdu;
int retriesLeft = -1;
do {
if (getCCID().hasFeature(CCID.FEATURE.VERIFY_PIN_DIRECT)) {
responseApdu = verifyPINViaCCIDDirect(retriesLeft, purpose,
applicationName);
} else if (getCCID().hasFeature(CCID.FEATURE.VERIFY_PIN_START)) {
responseApdu = verifyPINViaCCIDStartFinish(retriesLeft,
purpose, applicationName);
} else {
responseApdu = verifyPINViaUI(retriesLeft, purpose,
applicationName);
}
if (0x9000 != responseApdu.getSW()) {
this.logger.debug("VERIFY_PIN error");
this.logger.debug("SW: "
+ Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
getUI().advisePINBlocked();
throw new ResponseAPDUException("eID card blocked!",
responseApdu);
}
if (0x63 != responseApdu.getSW1()) {
this.logger.debug("PIN verification error.");
throw new ResponseAPDUException("PIN Verification Error",
responseApdu);
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.logger.debug("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
}
示例9: changePin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
public void changePin(boolean requireSecureReader) throws Exception {
Map<Byte, CCIDFeature> ccidFeatures = getCCIDFeatures();
CCIDFeature directPinModifyFeature = ccidFeatures.get(FEATURE_MODIFY_PIN_DIRECT_TAG);
CCIDFeature modifyPinStartFeature = ccidFeatures.get(FEATURE_MODIFY_PIN_START_TAG);
if (requireSecureReader && null == directPinModifyFeature && null == modifyPinStartFeature) {
throw new SecurityException("not a secure reader");
}
if (isWindows8()) {
this.card.endExclusive();
}
int retriesLeft = -1;
ResponseAPDU responseApdu;
do {
if (null != modifyPinStartFeature) {
this.view.addDetailMessage("using modify pin start/finish...");
responseApdu = doChangePinStartFinish(retriesLeft, modifyPinStartFeature, ccidFeatures);
} else if (null != directPinModifyFeature) {
this.view.addDetailMessage("could use direct PIN modify here...");
responseApdu = doChangePinDirect(retriesLeft, directPinModifyFeature);
} else {
responseApdu = doChangePin(retriesLeft);
}
if (0x9000 != responseApdu.getSW()) {
this.view.addDetailMessage("CHANGE PIN error");
this.view.addDetailMessage("SW: " + Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
this.dialogs.showPinBlockedDialog();
throw new RuntimeException("eID card blocked!");
}
if (0x63 != responseApdu.getSW1()) {
this.view.addDetailMessage("PIN change error. Card blocked?");
throw new RuntimeException("PIN change error.");
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.view.addDetailMessage("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
this.dialogs.showPinChanged();
if (isWindows8()) {
this.card.beginExclusive();
}
}
示例10: unblockPin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
public void unblockPin(boolean requireSecureReader) throws Exception {
Map<Byte, CCIDFeature> ccidFeatures = getCCIDFeatures();
CCIDFeature directPinVerifyFeature = ccidFeatures.get(FEATURE_VERIFY_PIN_DIRECT_TAG);
if (requireSecureReader && null == directPinVerifyFeature) {
throw new SecurityException("not a secure reader");
}
if (isWindows8()) {
this.card.endExclusive();
}
ResponseAPDU responseApdu;
int retriesLeft = -1;
do {
if (null != directPinVerifyFeature) {
this.view.addDetailMessage("could use direct PIN verify here...");
responseApdu = verifyPukDirect(retriesLeft, directPinVerifyFeature);
} else {
responseApdu = doUnblockPin(retriesLeft);
}
if (0x9000 != responseApdu.getSW()) {
this.view.addDetailMessage("PIN unblock error");
this.view.addDetailMessage("SW: " + Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
this.dialogs.showPinBlockedDialog();
throw new RuntimeException("eID card blocked!");
}
if (0x63 != responseApdu.getSW1()) {
this.view.addDetailMessage("PIN unblock error.");
throw new RuntimeException("PIN unblock error.");
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.view.addDetailMessage("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
this.dialogs.showPinUnblocked();
if (isWindows8()) {
this.card.beginExclusive();
}
}
示例11: changePin
import javax.smartcardio.ResponseAPDU; //导入方法依赖的package包/类
/**
* Change PIN code. This method will attempt to change PIN using the most
* secure method available. if requiresSecureReader is true, this will throw
* a SecurityException if no SPR is available, otherwise, this will default
* to changing the PIN via the UI
*
* @param requireSecureReader
* @throws Exception
*/
public void changePin(final boolean requireSecureReader) throws Exception {
if (requireSecureReader
&& (!getCCID().hasFeature(CCID.FEATURE.MODIFY_PIN_DIRECT))
&& (!getCCID().hasFeature(CCID.FEATURE.MODIFY_PIN_START))) {
throw new SecurityException("not a secure reader");
}
int retriesLeft = -1;
ResponseAPDU responseApdu;
do {
if (getCCID().hasFeature(CCID.FEATURE.MODIFY_PIN_START)) {
this.logger.debug("using modify pin start/finish...");
responseApdu = changePINViaCCIDStartFinish(retriesLeft);
} else if (getCCID().hasFeature(CCID.FEATURE.MODIFY_PIN_DIRECT)) {
this.logger.debug("could use direct PIN modify here...");
responseApdu = changePINViaCCIDDirect(retriesLeft);
} else {
responseApdu = changePINViaUI(retriesLeft);
}
if (0x9000 != responseApdu.getSW()) {
this.logger.debug("CHANGE PIN error");
this.logger.debug("SW: "
+ Integer.toHexString(responseApdu.getSW()));
if (0x6983 == responseApdu.getSW()) {
getUI().advisePINBlocked();
throw new ResponseAPDUException("eID card blocked!",
responseApdu);
}
if (0x63 != responseApdu.getSW1()) {
this.logger.debug("PIN change error. Card blocked?");
throw new ResponseAPDUException("PIN Change Error",
responseApdu);
}
retriesLeft = responseApdu.getSW2() & 0xf;
this.logger.debug("retries left: " + retriesLeft);
}
} while (0x9000 != responseApdu.getSW());
getUI().advisePINChanged();
}