net.east301.keyring.osx.NativeLibraryManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-keyring Show documentation
Show all versions of java-keyring Show documentation
A Java library to store password securely
The newest version!
/**
* @author $Author: east301 $
* @date $Date: 2012/10/21 11:18:21 $
* @version $Revision: fb93b8608b64 $
*/
package net.east301.keyring.osx;
import com.sun.jna.Native;
import net.east301.keyring.BackendNotSupportedException;
/**
* Global native library manager
*/
class NativeLibraryManager {
public static synchronized void loadNativeLibraries() throws BackendNotSupportedException {
if (CoreFoundation != null && Security != null) { return; }
try {
CoreFoundation = (CoreFoundationLibrary)Native.loadLibrary(
"CoreFoundation", CoreFoundationLibrary.class);
Security = (SecurityLibrary)Native.loadLibrary(
"Security", SecurityLibrary.class);
} catch (UnsatisfiedLinkError ex) {
throw new BackendNotSupportedException("Failed to load native library");
}
}
/**
* An instance of CoreFoundationLibrary
*/
public static CoreFoundationLibrary CoreFoundation = null;
/**
* An instance of SecurityLibrary
*/
public static SecurityLibrary Security = null;
} // class NativeLibraryManager