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 17 java.smartcardio.jmod - Smart Card IO Module
JDK 17 java.smartcardio.jmod is the JMOD file for JDK 17 Smartcardio module.
JDK 17 Smart Card IO module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\java.smartcardio.jmod.
JDK 17 Smart Card IO module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 Smart Card IO module source code files are stored in \fyicenter\jdk-17.0.5\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, 2021, 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 { @SuppressWarnings("removal") 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) { @SuppressWarnings("removal") 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-17.0.5-src.zip File size: 43002 bytes Release date: 2022-09-13 Download
⇒ JDK 17 java.sql.jmod - SQL Module
2023-10-27, 3192👍, 0💬
Popular Posts:
How to display XML element type information with the jaxp\TypeInfoWriter.java provided in the Apache...
Apache Avalon began in 1999 as the Java Apache Server Framework and in late 2002 separated from the ...
How to show the XML parsing flow with sax\DocumentTracer.java provided in the Apache Xerces package?...
What Is HttpComponents httpcore-4.2.2.jar? HttpComponents httpcore-4.2.2.jar is the JAR file for Apa...
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...