Software Javax.smartcardio.card Jar File

  1. Software Javax Smartcardio Card Jar File

May 15, 2018 - You can a sign documents using a smart card through a user's web browser using a Java applet. Throughout this article, you will discover how.

10 02 03 01: records 2 and 3 in the file with SFI 2 18 01 02 00: records 1 and 2 in the file with SFI 3 18 04 04 00: record 4 in the file with SFI 3 So you can't expect a record 1 in a file with SFI 1 to be present on the card. Java Build Error when adding javax.smartcardio to. Rt.jar even though I have checked repeatedly and the jar is there in.

(Previously known as jna2pcsc.) A re-implementation of the javax.smartcardio API. It allows you to communicate to a smart card (at the APDU level) from within Java.

This library allows you to transmit and receive application protocol data units (APDUs) specified by ISO/IEC 7816-3 to a smart card.

This java library is built on top of the WinSCard native library that comes with the operating system (or libpcsclite1 installed on Linux), which in turn communicates to the myriad USB smart card readers, contactless card readers, and dongles.

We can crack or emulate any protection type: Dongle, Hardlock, Hasp, Serial, Password, Hasp4, Flexlm, Sentinel, Wibu, Eutron Smartkey, Hasphl, Proteq, All the Protections!! Esko software suite 7 full crack.

Protocols built on top of APDUs include PKCS#15 public key authentication, EMV credit/debit transaction, GSM SIM cellular subscriber information, CAC U.S. military identification, Mifare Classic or DESfire transit payment, and any number of custom protocols.

Alternatives

Software Javax Smartcardio Card Jar File

First, if you are using smart cards for authentication and it comes with a PKCS#11 native library (or is supported by opensc-pkcs11), you should probably use the SunPKCS11 KeyStore provider instead of implementing the PKCS#15 client protocol yourself.

Once you have decided on APDU communication, you may wonder why this library exists, given that the JRE already comes with an implementation of javax.smartcardio. What’s wrong with it? There are a couple reasons you might consider switching to a JNA solution:

Software Javax.smartcardio.card Jar File
  • The default smartcardio library in JRE 7 and JRE 8 on 64-bit OS X was compiled incorrectly; bug 7195480. In particular, Terminal.isCardPresent() always returns false, Terminals.list() occasionally causes SIGSEGV, and Terminal.waitForCard(boolean, long) and Terminals.waitForChange(long) don’t wait. Ivan Gerasimov (igerasim) fixed waitForCard, fixed list and isCardPresent, and fixed Card.openLogicalChannel for JRE 7u80, 8u20, and 9.
  • The default smartcardio library only calls SCardEstablishContext once. If the daemon isn’t up yet, then your process will never be able to connect to it again. This is a big problem because in Windows 8, OS X, and new versions of pcscd, the daemon is not started until a reader is plugged in, and it quits when there are no more readers.
  • It’s easier to fix bugs in this project than it is to fix bugs in the libraries that are bundled with the JRE. Anybody can create and comment on issues.

Film thor 2 gratis subtitle indonesia. Another implementation of the smartcardio API is intarsys/smartcard-io, which is much more mature than this project. Please consider it. You might choose jnasmartcardio instead because:

  • jnasmartcardio is much smaller and has fewer dependencies than smartcard-io.

Installation

Requires JDK 1.6 or above.

Download the most recent published release from the Maven Central Repository. If you are using maven, you simply add this dependency to your own project’s pom.xml:

To build from source, run the following command to compile, jar, and install to your local Maven repository. Don’t forget to also modify your own project’s pom.xml to depend on the same SNAPSHOT version. You may need to learn the Maven version arcana.

Software Javax.smartcardio.card Jar File

Once you have jnasmartcardio in your classpath, there are 3 ways to use this smartcard provider instead of the one that is bundled with JRE:

  1. Modify <java_home>/jre/lib/security/java.security; replace security.provider.9=sun.security.smartcardio.SunPCSC with security.provider.9=jnasmartcardio.Smartcardio. Then use TerminalFactory.getDefault().
  2. Create a file override.java.security, then add system property -Djava.security.properties=override.java.security. This should be a file that contains a line like the above. But make sure that you override the same numbered line as the existing SunPCSC in your JRE; otherwise, you may disable some other factory too! Then use TerminalFactory.getDefault()
  3. Explicitly reference the Smartcardio class at compile time. There are a few variations of this:
    • Security.addProvider(new Smartcardio());TerminalFactory.getInstance('PC/SC', null, Smartcardio.PROVIDER_NAME);
    • Security.insertProviderAt(new Smartcardio(), 1);TerminalFactory.getInstance('PC/SC', null);
    • TerminalFactory.getInstance('PC/SC', null, new Smartcardio());

Once you have a TerminalFactory, you call cardTerminals = factory.terminals();; see javax.smartcardio API javadoc.

Documentation

The javadoc is uploaded to maven. You can see javadoc at javadoc.io

Changelog

See CHANGES.md.

Caveats

This library requires JNA to talk to the native libraries (winscard.dll, libpcsc.so, or PCSC). You can’t use this library if you are writing an applet or are otherwise using a security manager.

Differences from JRE

Some things to keep in mind which are different from JRE:

Generally, all methods will throw a JnaPCSCException if the daemon/service is off (when there are no readers). On Windows 8, the service is stopped immediately when there are no more readers.

TerminalFactory

TerminalFactory.terminals() will (re-)establish connection with the PCSC daemon/service. If the service is not running, terminals() will throw an unchecked exception EstablishContextException.

JnaCardTerminals

JnaCardTerminals owns the SCardContext native handle, and you should call cardTerminals.close() to clean up. Unfortunately, close() does not exist on the base class, so this library also closes it in its finalizer.

To make the implementation simpler, the caller must be able to handle spurious wakeups when calling waitForChange(long). In other words, list(State.CARD_REMOVAL) and list(State.CARD_INSERTION) might both be empty lists after waitForChange returns.

list(State) with CARD_INSERTION/CARD_REMOVAL always reflects the result of the previous waitForChange call. If there was no previous waitForChange call, it returns an empty list; I do not return the current CARD_PRESENT/CARD_ABSENT value as Sun does because this would be inconsistent with the internal waitForChange state.

As well as waking up when a card is inserted/removed, waitForChange will also wake up when a card reader is plugged in/unplugged. However, in Windows 8, when all readers are unplugged the service will immediately exit, so waitForChange will throw an exception instead of returning.

Mac

JnaCardTerminal

connect(String protocol) supports exactly the same connection modes as Sun does: T=0, T=1, T=*, and T=DIRECT (T=CL is mentioned in the smartcardio documentation but is not accepted). Unlike Sun, it does not return the same connection when you connect twice.

If the protocol is prepended with EXCLUSIVE; the usual SCARD_SHARE_SHARED mode shall be replaced with SCARD_SHARE_EXCLUSIVE.This allows to use a safely locked reader on Windows 8+ where otherwise a transaction initiated with SCardBeginTransaction (beginExclusive()) would be closedafter 5 seconds and SCARD_W_RESET_CARD returned. See this post on MSDN.

JnaCard

beginExclusive() simply calls SCardBeginTransaction. It does not use thread-local storage, as Sun does.

disconnect(boolean reset) did the opposite in Sun’s implementation, which suffered bug 7047033. Ivan Gerasim of Oracle fixed their implementation to match mine in JRE 7u80, 8u20, and 9, although the old behavior can be obtained by -Djdk.smartcard.invertReset=true in JRE 8.

JnaCardChannel

transmit(CommandAPDU command) currently has a response limit of 8192 bytes.

Transmit does the following automatically:

  • Sets the channel number in the class byte (CLA)
  • If T=0 and Lc ≠ 0 and Le ≠ 0, then the Le byte is removed as required.
  • If sw=61xx, then Get Response is automatically sent until the entire response is received.
  • If sw=6cxx, then the request is re-sent with the right Le byte.

However, keep in mind:

  • If T=0, then you must not send a Command APDU with extended Lc/Le. User is responsible for using Envelope commands if needed to turn T=1 commands into T=0 commands.
  • You may perform your own command chaining (e.g. if command is too long to fit in one Command APDU). You must put the command chaining bits in the correct position within the CLA byte, depending on the channel number.
  • If you are using secure messaging, you must put the secure messaging bits in the right position within the CLA byte, depending on the channel number.

License

This code is released under CC0; it is a “universal donor” in the hope that others can find it useful and contribute back.

I'm studying the javax.smartcardio classes. I'm using eclipse 3.6 and I have JDK 6 SE. I can use the statement import javax.smartcardio.* or any of its individual classes, as long as I change preferences to warn or ignore forbidden references.

I don't see any mention of javax.smartcardio in the standard documentation at Java SE 6and no javadoc help pops up in eclipse. I have found docs here.

Is there a way of linking Eclipse to the javadocs for smartcardio?

NickTNickT

3 Answers

I've asked Sun back in the day multiple times to include the javax.smartcardio in the documentation, but they have refused all the times. Now it seems that 64 bit Java version 6/7 for Windows do not have javax.smartcardio, and that the access rules rule out using it directly. This is pretty strange as javax.smartcardio seems to be an accepted JSR.

Sun and Oracle don't really communicate well regarding security API's. They are relatively well designed, but the support is lacking, and they do introduce features out of the blue.

[EDIT]

Although the javax.smartcardio package is an accepted JSR, the umbrella JSR's for Java 6 and 7 SE don't include it. See java_se-fr-spec.zip for more information (see below). So javacardx.smartcardio it is not part of the Java SE standard API. Nowadays you may have trouble accessing the API even if it is present. And you cannot add your own as it may be present for a particular edition. You can use Eclipse access rules to enable javax.smartcardio and remove access violations from your 'Problem view'.

Java 8 from Oracle does include an javax.smartcardio implementation. You may still have to configure access to it.

JSR 268, the Java Smart-Card I/O API, will not be included because the JSR 270 Expert Group concluded that it would not be of sufficiently wide interest in the Java SE 6 time frame.

Maarten BodewesMaarten Bodewes

I found a WebLog about it (Konstantin Flitschew WebLog (german)). It's in german but it worked for me, so I give a short translation here:

  1. create a java project or open an existing project
  2. right-click the project and open the properties dialog
  3. select build path -> libraries tab and unfold the 'JRE System Library' tree
  4. select the entry 'Access Rules' and push the 'edit' button on the right
  5. you can apply a rule with the 'add' button: set the drop down to 'accessible' and enter the value “javax/smartcardio/**”

With this setting I was able to access the classes of javax.smartcardio.

MatheMathe

I was in the same situation as you were but then I found this http://intelligenzija.net/?q=node/1Basically you need to set Access rules for these classes in the IDE so you can use them.

mapuomapuo

Not the answer you're looking for? Browse other questions tagged javasmartcard or ask your own question.