com.pdftools.crypto.providers.pkcs11.Device Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdftools-sdk Show documentation
Show all versions of pdftools-sdk Show documentation
The Pdftools SDK is a comprehensive development library that lets developers integrate advanced PDF functionalities into in-house applications.
The newest version!
/****************************************************************************
*
* File: Device.java
*
* Description: PDFTOOLS Device Class
*
* Author: PDF Tools AG
*
* Copyright: Copyright (C) 2023 - 2024 PDF Tools AG, Switzerland
* All rights reserved.
*
* Notice: By downloading and using this artifact, you accept PDF Tools AG's
* [license agreement](https://www.pdf-tools.com/license-agreement/),
* [privacy policy](https://www.pdf-tools.com/privacy-policy/),
* and allow PDF Tools AG to track your usage data.
*
***************************************************************************/
package com.pdftools.crypto.providers.pkcs11;
import com.pdftools.sys.*;
import com.pdftools.internal.*;
import java.util.EnumSet;
import java.time.OffsetDateTime;
/**
* The cryptographic device (HSM, USB token, etc.)
*/
public class Device extends NativeObject
{
protected Device(long handle)
{
super(handle);
}
/**
* @hidden
*/
public static Device createDynamicObject(long handle)
{
return new Device(handle);
}
/**
* Create a session
* @param password
* If this parameter is not {@code null}, the session is created and {@link Session#login } executed.
* @return
*/
public com.pdftools.crypto.providers.pkcs11.Session createSession(String password)
{
long retHandle = createSessionNative(getHandle(), password);
if (retHandle == 0)
{
switch (getLastErrorCode())
{
case 0: throw new RuntimeException("An unexpected error occurred");
default: throwLastRuntimeException();
}
}
return com.pdftools.crypto.providers.pkcs11.Session.createDynamicObject(retHandle);
}
/**
* Description of the device (Getter)
*
*/
public String getDescription()
{
String retVal = getDescriptionNative(getHandle());
if (retVal == null)
{
switch (getLastErrorCode())
{
case 0: break;
default: throwLastRuntimeException();
}
}
return retVal;
}
/**
* ID of the device's manufacturer (Getter)
*
*/
public String getManufacturerID()
{
String retVal = getManufacturerIDNative(getHandle());
if (retVal == null)
{
switch (getLastErrorCode())
{
case 0: break;
default: throwLastRuntimeException();
}
}
return retVal;
}
private native long createSessionNative(long handle, String password);
private native String getDescriptionNative(long handle);
private native String getManufacturerIDNative(long handle);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy