Fortanix Data Security Manager (DSM) provides multiple interfaces to application developers. For C/C++ programmers, Fortanix DSM provides a PKCS#11 interface through a library. For Java programmers, Fortanix DSM can be accessed through the JCE interface and through Java SDK. Fortanix DSM can also be accessed through its RESTful interface, documented at https://www.fortanix.com/api/
We provide examples for using Fortanix DSM in 7 languages – a C++ program using the PKCS#11 interface, a Java program using the JCE interface, and other programs using the REST interface through Java, Python, Go, C#, PHP and Javascript SDKs
The example programs can be downloaded in full at the Downloads page.
C++
CK_RV logout(CK_FUNCTION_LIST_PTR p11, CK_SESSION_HANDLE hSession) { return p11->C_Logout(hSession); }
C#
public void logout() {
AuthenticationApi authenticationApi = new AuthenticationApi();
authenticationApi.Terminate();
}
Go
// The better way to log out is to `defer` the statement below immediately after
// successful authentication. See the Initialization and Login example for more.
client.TerminateSession(ctx)
Java
private static boolean logout() {
try {
AuthenticationApi authenticationApi = new AuthenticationApi(apiClient);
authenticationApi.terminate();
return true;
} catch (Exception e) {
System.out.println("Can't logout: " + e);
return false;
}
}
Python
def logout():
api_instance = sdkms.v1.AuthenticationApi(api_client=client)
try:
api_instance.terminate()
except ApiException as e:
print("Exception when calling AuthenticationApi->terminate: %s\n" % e)
PHP
public function logout() {
$authenticationApi = new Swagger\Client\Api\AuthenticationApi($client);
$authInstance->terminate();
}
Javascript
var logoutCallback = function(error, data, response) {
if (error) {
console.error("Error: " + JSON.stringify(response));
} else {
console.log('logout successfully');
}
};
var authenticationApi = new FortanixSdkmsRestApi.AuthenticationApi()
authenticationApi.terminate(logoutCallback);