Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JDK 11 java.smartcardio.jmod - Smart Card IO Module
JDK 11 java.smartcardio.jmod is the JMOD file for JDK 11 Smartcardio module.
JDK 11 Smart Card IO module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\java.smartcardio.jmod.
JDK 11 Smart Card IO module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.
JDK 11 Smart Card IO module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\java.smartcardio.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ sun/security/smartcardio/CardImpl.java
/*
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package sun.security.smartcardio;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.smartcardio.*;
import static sun.security.smartcardio.PCSC.*;
/**
* Card implementation.
*
* @since 1.6
* @author Andreas Sterbenz
*/
final class CardImpl extends Card {
private static enum State { OK, REMOVED, DISCONNECTED };
// the terminal that created this card
private final TerminalImpl terminal;
// the native SCARDHANDLE
final long cardId;
// atr of this card
private final ATR atr;
// protocol in use, one of SCARD_PROTOCOL_T0 and SCARD_PROTOCOL_T1
final int protocol;
// the basic logical channel (channel 0)
private final ChannelImpl basicChannel;
// state of this card connection
private volatile State state;
// thread holding exclusive access to the card, or null
private volatile Thread exclusiveThread;
// used for platform specific logic
private static final boolean isWindows;
static {
final String osName = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("os.name"));
isWindows = osName.startsWith("Windows");
}
CardImpl(TerminalImpl terminal, String protocol) throws PCSCException {
this.terminal = terminal;
int sharingMode = SCARD_SHARE_SHARED;
int connectProtocol;
if (protocol.equals("*")) {
connectProtocol = SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1;
} else if (protocol.equalsIgnoreCase("T=0")) {
connectProtocol = SCARD_PROTOCOL_T0;
} else if (protocol.equalsIgnoreCase("T=1")) {
connectProtocol = SCARD_PROTOCOL_T1;
} else if (protocol.equalsIgnoreCase("direct")) {
// testing
// MSDN states that the preferred protocol can be zero, but doesn't
// specify whether other values are allowed.
// pcsc-lite implementation expects the preferred protocol to be non zero.
connectProtocol = isWindows ? 0 : SCARD_PROTOCOL_RAW;
sharingMode = SCARD_SHARE_DIRECT;
} else {
throw new IllegalArgumentException("Unsupported protocol " + protocol);
}
cardId = SCardConnect(terminal.contextId, terminal.name,
sharingMode, connectProtocol);
byte[] status = new byte[2];
byte[] atrBytes = SCardStatus(cardId, status);
atr = new ATR(atrBytes);
this.protocol = status[1] & 0xff;
basicChannel = new ChannelImpl(this, 0);
state = State.OK;
}
void checkState() {
State s = state;
if (s == State.DISCONNECTED) {
throw new IllegalStateException("Card has been disconnected");
} else if (s == State.REMOVED) {
throw new IllegalStateException("Card has been removed");
}
}
boolean isValid() {
if (state != State.OK) {
return false;
}
// ping card via SCardStatus
try {
SCardStatus(cardId, new byte[2]);
return true;
} catch (PCSCException e) {
state = State.REMOVED;
return false;
}
}
private void checkSecurity(String action) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new CardPermission(terminal.name, action));
}
}
void handleError(PCSCException e) {
if (e.code == SCARD_W_REMOVED_CARD) {
state = State.REMOVED;
}
}
public ATR getATR() {
return atr;
}
public String getProtocol() {
switch (protocol) {
case SCARD_PROTOCOL_T0:
return "T=0";
case SCARD_PROTOCOL_T1:
return "T=1";
default:
// should never occur
return "Unknown protocol " + protocol;
}
}
public CardChannel getBasicChannel() {
checkSecurity("getBasicChannel");
checkState();
return basicChannel;
}
private static int getSW(byte[] b) {
if (b.length < 2) {
return -1;
}
int sw1 = b[b.length - 2] & 0xff;
int sw2 = b[b.length - 1] & 0xff;
return (sw1 << 8) | sw2;
}
private static byte[] commandOpenChannel = new byte[] {0, 0x70, 0, 0, 1};
public CardChannel openLogicalChannel() throws CardException {
checkSecurity("openLogicalChannel");
checkState();
checkExclusive();
try {
byte[] response = SCardTransmit
(cardId, protocol, commandOpenChannel, 0, commandOpenChannel.length);
if ((response.length != 3) || (getSW(response) != 0x9000)) {
throw new CardException
("openLogicalChannel() failed, card response: "
+ PCSC.toString(response));
}
return new ChannelImpl(this, response[0]);
} catch (PCSCException e) {
handleError(e);
throw new CardException("openLogicalChannel() failed", e);
}
}
void checkExclusive() throws CardException {
Thread t = exclusiveThread;
if (t == null) {
return;
}
if (t != Thread.currentThread()) {
throw new CardException("Exclusive access established by another Thread");
}
}
public synchronized void beginExclusive() throws CardException {
checkSecurity("exclusive");
checkState();
if (exclusiveThread != null) {
throw new CardException
("Exclusive access has already been assigned to Thread "
+ exclusiveThread.getName());
}
try {
SCardBeginTransaction(cardId);
} catch (PCSCException e) {
handleError(e);
throw new CardException("beginExclusive() failed", e);
}
exclusiveThread = Thread.currentThread();
}
public synchronized void endExclusive() throws CardException {
checkState();
if (exclusiveThread != Thread.currentThread()) {
throw new IllegalStateException
("Exclusive access not assigned to current Thread");
}
try {
SCardEndTransaction(cardId, SCARD_LEAVE_CARD);
} catch (PCSCException e) {
handleError(e);
throw new CardException("endExclusive() failed", e);
} finally {
exclusiveThread = null;
}
}
public byte[] transmitControlCommand(int controlCode, byte[] command)
throws CardException {
checkSecurity("transmitControl");
checkState();
checkExclusive();
if (command == null) {
throw new NullPointerException();
}
try {
byte[] r = SCardControl(cardId, controlCode, command);
return r;
} catch (PCSCException e) {
handleError(e);
throw new CardException("transmitControlCommand() failed", e);
}
}
public void disconnect(boolean reset) throws CardException {
if (reset) {
checkSecurity("reset");
}
if (state != State.OK) {
return;
}
checkExclusive();
try {
SCardDisconnect(cardId, (reset ? SCARD_RESET_CARD : SCARD_LEAVE_CARD));
} catch (PCSCException e) {
throw new CardException("disconnect() failed", e);
} finally {
state = State.DISCONNECTED;
exclusiveThread = null;
}
}
public String toString() {
return "PC/SC card in " + terminal.name
+ ", protocol " + getProtocol() + ", state " + state;
}
@SuppressWarnings("deprecation")
protected void finalize() throws Throwable {
try {
if (state == State.OK) {
state = State.DISCONNECTED;
SCardDisconnect(cardId, SCARD_LEAVE_CARD);
}
} finally {
super.finalize();
}
}
}
⏎ sun/security/smartcardio/CardImpl.java
Or download all of them as a single archive file:
File name: java.smartcardio-11.0.1-src.zip File size: 39053 bytes Release date: 2018-11-04 Download
⇒ JDK 11 java.sql.jmod - SQL Module
2021-02-17, ≈20🔥, 1💬
Popular Posts:
What Is poi-ooxml-5.2.3.jar? poi-ooxml-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which...
JDOM provides a solution for using XML from Java that is as simple as Java itself. There is no compe...
JRE 8 plugin.jar is the JAR file for JRE 8 Java Control Panel Plugin interface and tools. JRE (Java ...
JDK 11 jdk.crypto.cryptoki.jmod is the JMOD file for JDK 11 Crypto Cryptoki module. JDK 11 Crypto KI...
If you are a Java developer, it is very often that you need to use some 3rd party libraries to perfo...