// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/statics/LibConfig.java
// public class LibConfig {
//     public static final String WINDOWS32_LIB_NAME = "PKCS11Wrapper.dll";
//     public static final String WINDOWS64_LIB_NAME = "PKCS11Wrapper.dll";
//     public static final String LINUX_LIB_NAME = "libpkcs11wrapper.so";
//     public static final String MACOS_LIB_NAME = "libpkcs11wrapper.jnilib";
//     public static final String SOLARIS_LIB_NAME = "libpkcs11wrapper.so";
//     public static final String OTHER_LIB_NAME = "libpkcs11wrapper.so";
//     
//     public static final String WINDOWS32_LIB_PATH = "libs/windows/32/"+WINDOWS32_LIB_NAME;
//     public static final String WINDOWS64_LIB_PATH = "libs/windows/64/"+WINDOWS64_LIB_NAME;
//     public static final String LINUX32_LIB_PATH = "libs/linux/32/"+LINUX_LIB_NAME;
//     public static final String LINUX64_LIB_PATH = "libs/linux/64/"+LINUX_LIB_NAME;
//     public static final String MACOS_LIB_PATH = "libs/macos/"+MACOS_LIB_NAME;
//     public static final String SOLARIS_LIB_PATH = "libs/solaris/"+SOLARIS_LIB_NAME;
//     public static final String SOLARIS_V9_LIB_PATH = "libs/solaris/v9/"+SOLARIS_LIB_NAME;
//     //Other operating systems are assumed as linux.
//     public static final String OTHER32_LIB_PATH = "libs/linux/32/"+LINUX_LIB_NAME;
//     public static final String OTHER64_LIB_PATH = "libs/linux/64/"+LINUX_LIB_NAME;
//     
//     
// }
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/statics/OS.java
// public class OS {
//     final private static String WINDOWS = "windows";
//     final private static String LINUX = "linux";
//     final private static String MACOS = "mac";
//     final private static String SOLARIS = "solaris";
// 
//     /**
//      * Gets user operating system.
//      * 
//      * @return Return corresponding OS name. If user operation system is not supported returns OSNames.OTHER
//      */
//     public static OSNames getSystemOS() {
//         String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
//         if (osName.contains(WINDOWS)) {
//             return OSNames.WINDOWS;
//         } else if (osName.contains(LINUX)) {
//             return OSNames.LINUX;
//         } else if (osName.contains(MACOS)) {
//             return OSNames.MACOS;
//         } else if(osName.contains(SOLARIS)){
//             return OSNames.SOLARIS;
//         }else{
//             return OSNames.OTHER;
//         }
//     }
//     
//     /**
//      * Gets bits of operating system.
//      * 
//      * @return 
//      */
//     public static OSArch getSystemOSArch() {
//         String osAcrh = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH);
//         if (osAcrh.contains("64")) {
//             return OSArch._64BIT;
//         } else {
//             return OSArch._32BIT;
//         }
//     }
//     
//     /**
//      * Gets system version from Solaris operation system.
//      * 
//      * @return 
//      */
//     public static OSVersion getSystemOSVersionForSolaris() {
//         String osVersion = System.getProperty("os.version").toLowerCase(Locale.ENGLISH);
//         if (osVersion.contains("V9")) {
//             return OSVersion.SPARC_V9;
//         } else{
//             return OSVersion.SPARC;
//         }
//     }
//     
//     
// 
// }
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSArch.java
// public enum OSArch {_32BIT, _64BIT};
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSNames.java
// public enum OSNames {WINDOWS, LINUX, MACOS, OTHER, SOLARIS};
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSVersion.java
// public enum OSVersion {SPARC, SPARC_V9};


import tr.gov.turkiye.esign.statics.LibConfig;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import tr.gov.turkiye.esign.statics.OS;
import tr.gov.turkiye.esign.enums.OSArch;
import tr.gov.turkiye.esign.enums.OSNames;
import tr.gov.turkiye.esign.enums.OSVersion;
            }
            return t.getLocalizedMessage().contains("already loaded");
        }
        return true;
    }

    /**
     * Gets directory which contains installation packages.
     * 
     * @return 
     */
    private static String getInstallDir() {
        OSNames systemOS = OS.getSystemOS();
        if (systemOS.equals(OSNames.WINDOWS)) {
            OSArch systemOSArch = OS.getSystemOSArch();
            if (systemOSArch.equals(OSArch._64BIT)) {
                return LibConfig.WINDOWS64_LIB_PATH;
            } else {
                return LibConfig.WINDOWS32_LIB_PATH;
            }
        } else if (systemOS.equals(OSNames.LINUX)) {
            OSArch systemOSArch = OS.getSystemOSArch();
            if (systemOSArch.equals(OSArch._64BIT)) {
                return LibConfig.LINUX64_LIB_PATH;
            } else {
                return LibConfig.LINUX32_LIB_PATH;
            }
        } else if (systemOS.equals(OSNames.MACOS)) {
            return LibConfig.MACOS_LIB_PATH;
        } else if (systemOS.equals(OSNames.SOLARIS)) {
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/statics/LibConfig.java
// public class LibConfig {
//     public static final String WINDOWS32_LIB_NAME = "PKCS11Wrapper.dll";
//     public static final String WINDOWS64_LIB_NAME = "PKCS11Wrapper.dll";
//     public static final String LINUX_LIB_NAME = "libpkcs11wrapper.so";
//     public static final String MACOS_LIB_NAME = "libpkcs11wrapper.jnilib";
//     public static final String SOLARIS_LIB_NAME = "libpkcs11wrapper.so";
//     public static final String OTHER_LIB_NAME = "libpkcs11wrapper.so";
//     
//     public static final String WINDOWS32_LIB_PATH = "libs/windows/32/"+WINDOWS32_LIB_NAME;
//     public static final String WINDOWS64_LIB_PATH = "libs/windows/64/"+WINDOWS64_LIB_NAME;
//     public static final String LINUX32_LIB_PATH = "libs/linux/32/"+LINUX_LIB_NAME;
//     public static final String LINUX64_LIB_PATH = "libs/linux/64/"+LINUX_LIB_NAME;
//     public static final String MACOS_LIB_PATH = "libs/macos/"+MACOS_LIB_NAME;
//     public static final String SOLARIS_LIB_PATH = "libs/solaris/"+SOLARIS_LIB_NAME;
//     public static final String SOLARIS_V9_LIB_PATH = "libs/solaris/v9/"+SOLARIS_LIB_NAME;
//     //Other operating systems are assumed as linux.
//     public static final String OTHER32_LIB_PATH = "libs/linux/32/"+LINUX_LIB_NAME;
//     public static final String OTHER64_LIB_PATH = "libs/linux/64/"+LINUX_LIB_NAME;
//     
//     
// }
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/statics/OS.java
// public class OS {
//     final private static String WINDOWS = "windows";
//     final private static String LINUX = "linux";
//     final private static String MACOS = "mac";
//     final private static String SOLARIS = "solaris";
// 
//     /**
//      * Gets user operating system.
//      * 
//      * @return Return corresponding OS name. If user operation system is not supported returns OSNames.OTHER
//      */
//     public static OSNames getSystemOS() {
//         String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
//         if (osName.contains(WINDOWS)) {
//             return OSNames.WINDOWS;
//         } else if (osName.contains(LINUX)) {
//             return OSNames.LINUX;
//         } else if (osName.contains(MACOS)) {
//             return OSNames.MACOS;
//         } else if(osName.contains(SOLARIS)){
//             return OSNames.SOLARIS;
//         }else{
//             return OSNames.OTHER;
//         }
//     }
//     
//     /**
//      * Gets bits of operating system.
//      * 
//      * @return 
//      */
//     public static OSArch getSystemOSArch() {
//         String osAcrh = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH);
//         if (osAcrh.contains("64")) {
//             return OSArch._64BIT;
//         } else {
//             return OSArch._32BIT;
//         }
//     }
//     
//     /**
//      * Gets system version from Solaris operation system.
//      * 
//      * @return 
//      */
//     public static OSVersion getSystemOSVersionForSolaris() {
//         String osVersion = System.getProperty("os.version").toLowerCase(Locale.ENGLISH);
//         if (osVersion.contains("V9")) {
//             return OSVersion.SPARC_V9;
//         } else{
//             return OSVersion.SPARC;
//         }
//     }
//     
//     
// 
// }
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSArch.java
// public enum OSArch {_32BIT, _64BIT};
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSNames.java
// public enum OSNames {WINDOWS, LINUX, MACOS, OTHER, SOLARIS};
// 
// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/enums/OSVersion.java
// public enum OSVersion {SPARC, SPARC_V9};


// Path: ESignCore/src/main/java/tr/gov/turkiye/esign/manager/LibraryManager.java
import tr.gov.turkiye.esign.statics.LibConfig;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import tr.gov.turkiye.esign.statics.OS;
import tr.gov.turkiye.esign.enums.OSArch;
import tr.gov.turkiye.esign.enums.OSNames;
import tr.gov.turkiye.esign.enums.OSVersion;

            }
            return t.getLocalizedMessage().contains("already loaded");
        }
        return true;
    }

    /**
     * Gets directory which contains installation packages.
     * 
     * @return 
     */
    private static String getInstallDir() {
        OSNames systemOS = OS.getSystemOS();
        if (systemOS.equals(OSNames.WINDOWS)) {
            OSArch systemOSArch = OS.getSystemOSArch();
            if (systemOSArch.equals(OSArch._64BIT)) {
                return LibConfig.WINDOWS64_LIB_PATH;
            } else {
                return LibConfig.WINDOWS32_LIB_PATH;
            }
        } else if (systemOS.equals(OSNames.LINUX)) {
            OSArch systemOSArch = OS.getSystemOSArch();
            if (systemOSArch.equals(OSArch._64BIT)) {
                return LibConfig.LINUX64_LIB_PATH;
            } else {
                return LibConfig.LINUX32_LIB_PATH;
            }
        } else if (systemOS.equals(OSNames.MACOS)) {
            return LibConfig.MACOS_LIB_PATH;
        } else if (systemOS.equals(OSNames.SOLARIS)) {
            OSVersion systemOSVersion = OS.getSystemOSVersionForSolaris();