Class LibJ2PCSCGNULinuxFix


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

      • SMARTCARDIO_LIBRARY_PROPERTY

        private static final java.lang.String SMARTCARDIO_LIBRARY_PROPERTY
        See Also:
        Constant Field Values
      • LIBRARY_PATH_PROPERTY

        private static final java.lang.String LIBRARY_PATH_PROPERTY
        See Also:
        Constant Field Values
      • GNULINUX_OS_PROPERTY_PREFIX

        private static final java.lang.String GNULINUX_OS_PROPERTY_PREFIX
        See Also:
        Constant Field Values
      • PCSC_LIBRARY_NAME

        private static final java.lang.String PCSC_LIBRARY_NAME
        See Also:
        Constant Field Values
      • UBUNTU_MULTILIB_32_SUFFIX

        private static final java.lang.String UBUNTU_MULTILIB_32_SUFFIX
        See Also:
        Constant Field Values
      • UBUNTU_MULTILIB_64_SUFFIX

        private static final java.lang.String UBUNTU_MULTILIB_64_SUFFIX
        See Also:
        Constant Field Values
      • JRE_BITNESS_PROPERTY

        private static final java.lang.String JRE_BITNESS_PROPERTY
        See Also:
        Constant Field Values
      • OS_NAME_PROPERTY

        private static final java.lang.String OS_NAME_PROPERTY
        See Also:
        Constant Field Values
      • JRE_BITNESS_32_VALUE

        private static final java.lang.String JRE_BITNESS_32_VALUE
        See Also:
        Constant Field Values
      • JRE_BITNESS_64_VALUE

        private static final java.lang.String JRE_BITNESS_64_VALUE
        See Also:
        Constant Field Values
    • Constructor Detail

      • LibJ2PCSCGNULinuxFix

        private LibJ2PCSCGNULinuxFix()
    • Method Detail

      • 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.
      • extendLibraryPath

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

        private static java.lang.String addMultiarchPath​(java.lang.String libPath,
                                                         java.lang.String suffix)
      • fixPathForUbuntuMultiLib

        private static java.lang.String fixPathForUbuntuMultiLib​(java.lang.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 java.io.File findGNULinuxNativeLibrary​(java.lang.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.