Class LibJ2PCSCGNULinuxFix

java.lang.Object
es.gob.jmulticard.jse.smartcardio.LibJ2PCSCGNULinuxFix

final class LibJ2PCSCGNULinuxFix extends Object
Encapsulate fixes regarding the dynamic loading of the pcsclite library on GNU/Linux Systems. Statically call LibJ2PCSCGNULinuxFix.fixNativeLibrary() before using a TerminalFactory.
  • Field Details

  • Constructor Details

    • LibJ2PCSCGNULinuxFix

      private LibJ2PCSCGNULinuxFix()
  • Method Details

    • fixNativeLibrary

      static void fixNativeLibrary()
      Make sure libpcsclite is found. The libj2pcsc.so from the JRE attempts to dlopen using the linker name "libpcsclite.so" instead of the appropriate "libpcsclite.so.1". This causes libpcsclite not to be found on GNU/Linux distributions that don't have the libpcsclite.so symbolic link. This method finds the library and forces the JRE to use it instead of attempting to locate it by itself. See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529339
      Does nothing if not on a GNU/Linux system.
    • getUbuntuBitness

      private static LibJ2PCSCGNULinuxFix.UbuntuBitness getUbuntuBitness()
      Determine Ubuntu-type multilib configuration.
    • extendLibraryPath

      private static String extendLibraryPath(String libPath, String extension)
      Return the path with extension appended, if it wasn't already contained in the path.
    • addMultiarchPath

      private static String addMultiarchPath(String libPath, String suffix)
    • fixPathForUbuntuMultiLib

      private static String fixPathForUbuntuMultiLib(String libraryPath)
      Oracle Java 7, java.library.path is severely limited as compared to the OpenJDK default and doesn't contain Ubuntu 12's MULTILIB directories. Test for Ubuntu in various configs and add the required paths.
    • findGNULinuxNativeLibrary

      private static File findGNULinuxNativeLibrary(String baseName, int version)
      Finds .so.version file on GNU/Linux. avoid guessing all GNU/Linux distros' library path configurations on 32 and 64-bit when working around the buggy libj2pcsc.so implementation based on JRE implementations adding the native library paths to the end of java.library.path. Fixes the path for Oracle JRE which doesn't contain the Ubuntu MULTILIB directories.