Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public interface PdfSignatureProvider
Supplies the key material of a PDF signature without exposing the key.
PdfDocument computes what has to be signed and calls [#sign(byte[])]
exactly once while saving. On a device, PdfSigner.provider answers
with the platform crypto bridge. On a Codename One server, implement it
over com.codename1.backend.Crypto.sign (RS256 or ES256 with the
PKCS#8 key), which runs on the JVM and compiled alike; a hardware
security module fits the same shape, so the private key never leaves
it.
Methods
public abstract String getKeyAlgorithm() | The key algorithm, RSA or EC. |
public abstract byte[][] getCertificateChain() | The DER X.509 certificates: the signer’s first, then any intermediates a verifier needs to build the chain. |
public abstract byte[] sign(byte[] data)
throws IOException | Signs data with SHA-256 and the private key. |
Method details
getKeyAlgorithm
public abstract String getKeyAlgorithm()The key algorithm,
RSA or EC. The signature is SHA-256 with
that key (SHA256withRSA or SHA256withECDSA).getCertificateChain
public abstract byte[][] getCertificateChain()The DER X.509 certificates: the signer’s first, then any
intermediates a verifier needs to build the chain.
sign
public abstract byte[] sign(byte[] data)
throws IOExceptionSigns
data with SHA-256 and the private key. ECDSA signatures are
returned DER encoded (ECDSA-Sig-Value), as every Codename One port and
the backend’s Crypto.sign produce them.Throws
IOException- when the key cannot sign: a hardware key that is locked, a remote signing service that cannot be reached. The save that asked fails with it.