com.digisigner.api
Class SigningData

java.lang.Object
  extended by com.digisigner.api.SigningData

public class SigningData
extends Object

Holds the data required to create a digital signature in the document.

Author:
DigiSigner Software

Method Summary
static SigningData fromJksFile(String jksStoreFilename, String jksStorePassword, String keyPassword)
          Creates a SigningData object from a JKS (Java Key Store) file with only one valid key.
static SigningData fromJksFile(String jksStoreFilename, String jksStorePassword, String keyAlias, String keyPassword)
          Creates a SigningData object from a JKS (Java Key Store) file.
static SigningData fromKeyStore(KeyStore keyStore, String keyAlias, String keyPassword)
          Creates a SigningData object from a general KeyStore.
static SigningData fromPkcs11Token(String libraryFilename, String tokenPin)
          Creates a SigningData object from a PKCS#11 token with only one valid key.
static SigningData fromPkcs11Token(String libraryFilename, String keyAlias, String tokenPin)
          Creates a SigningData object from a PKCS#11 token.
static SigningData fromPkcs12File(String pkcs12StoreFilename, String pkcs12StorePassword)
          Creates a SigningData object from a PKCS#12 (also known as PFX) file with only one valid key.
static SigningData fromPkcs12File(String pkcs12StoreFilename, String pkcs12StorePassword, String keyAlias)
          Creates a SigningData object from a PKCS#12 (also known as PFX) file.
static SigningData fromWindowsKeyStore()
          Creates a SigningData object from Windows key store with only one valid key.
static SigningData fromWindowsKeyStore(String keyAlias)
          Creates a SigningData object from Windows key store.
 SignatureAppearanceData getAppearanceData()
          Returns signature appearance data.
 CertificationLevelEnum getCertificationLevel()
          Returns the certification level of the signature.
 String getContact()
          Returns the contact information of the signer.
 String getFieldName()
          Returns the name of the signature field, where the signature will be created.
 Rectangle2D.Float getFieldRectangle()
          Returns the rectangle with coordinates for the new signature field, where the digital signature will be placed.
 HashAlgorithmEnum getHashAlgorithm()
          Returns the hash algorithm that will be used by creating the signature.
 String getKeyAlias()
          Returns the alias of the key that will be used for signing.
 String getKeyPassword()
          Returns the key password.
 KeyStore getKeyStore()
          Returns the key store with the key.
 String getLocation()
          Returns the geographic location, where the signature is created.
 int getPageNumber()
          Returns the page number, where the signature will be created.
 Provider getProvider()
          Returns the provider that was used to load key store.
 String getProxyServerHost()
          Returns the address of the proxy server host.
 int getProxyServerPort()
          Returns the port of the proxy server host.
 String getReason()
          Return the reason of the signature.
 String getTsaServerAccount()
          Returns your account name (login information) on the time stamp server.
 String getTsaServerPassword()
          Returns the password for your account on the time stamp server.
 String getTsaServerPolicyOid()
          Returns the policy OID for the time stamp server.
 String getTsaServerUrl()
          Return the URL of the time stamp server.
 boolean isIncludeCrls()
          Returns true if signature will include CRLs (Certificate Revocation Lists).
 boolean isIncludeOcspResponse()
          Returns true if signature will include OCSP response (Online Certificate Status Protocol).
 void setAppearanceData(SignatureAppearanceData appearanceData)
          Specifies signature appearance data, that is how the signature will look like.
 void setCertificationLevel(CertificationLevelEnum certificationLevel)
          With the certification level for your signature you can specify what changes are allowed on your document after signing.
 void setContact(String contact)
          Specifies the contact information of the signer, like email address or phone number.
 void setFieldName(String fieldName)
          Specifies the name of some existing empty signature field in the document, where the signature will be created.
 void setFieldRectangle(Rectangle2D.Float fieldRectangle)
          Specifies the rectangle coordinates for the new signature field, that will be created before signing the document.
 void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm)
          Sets the hash algorithm that will be used by creating the signature.
 void setIncludeCrls(boolean includeCrls)
          Specifies if the signature should include CRLs (Certificate Revocation Lists).
 void setIncludeOcspResponse(boolean includeOcspReponse)
          Specifies if the signature should include OCSP response (Online Certificate Status Protocol).
 void setLocation(String location)
          Returns the geographic location, where the signature is created.
 void setPageNumber(int pageNumber)
          Specifies the page number, where the signature will be created.
 void setProvider(Provider provider)
          Sets the provider that was used to load the key store.
 void setProxyServerHost(String proxyServerHost)
          Sets the address of the proxy server host.
 void setProxyServerPort(int proxyServerPort)
          Sets the prot of the proxy server host.
 void setReason(String reason)
          Specifies the reason of the signature.
 void setTsaServerAccount(String tsaServerAccount)
          Sets your account name (login information) for the time stamp server.
 void setTsaServerPassword(String tsaServerPassword)
          Sets the password for your account on the time stamp server.
 void setTsaServerPolicyOid(String tsaServerPolicyOid)
          Sets the policy OID for your time stamp server.
 void setTsaServerUrl(String tsaServerUrl)
          Sets the URL of the time stamp server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fromKeyStore

public static SigningData fromKeyStore(KeyStore keyStore,
                                       String keyAlias,
                                       String keyPassword)
Creates a SigningData object from a general KeyStore.

Parameters:
keyStore - key store object
keyAlias - alias of the key in the key store that will be used for signing
keyPassword - password required to access the key
Returns:
SigningData object

fromPkcs12File

public static SigningData fromPkcs12File(String pkcs12StoreFilename,
                                         String pkcs12StorePassword,
                                         String keyAlias)
Creates a SigningData object from a PKCS#12 (also known as PFX) file.

Parameters:
pkcs12StoreFilename - name of the PKCS#12 file with the key store
pkcs12StorePassword - key store password
keyAlias - alias of the key in the key store that will be used for signing
Returns:
SigningData object

fromPkcs12File

public static SigningData fromPkcs12File(String pkcs12StoreFilename,
                                         String pkcs12StorePassword)
Creates a SigningData object from a PKCS#12 (also known as PFX) file with only one valid key. No key alias is required for this method. Use it when you have only one valid key in your key store. If you have more than one valid key, the key will be used, that will expire as first.

Parameters:
pkcs12StoreFilename - name of the PKCS#12 file with the key store
pkcs12StorePassword - key store password
Returns:
SigningData object

fromJksFile

public static SigningData fromJksFile(String jksStoreFilename,
                                      String jksStorePassword,
                                      String keyAlias,
                                      String keyPassword)
Creates a SigningData object from a JKS (Java Key Store) file.

Parameters:
jksStoreFilename - name of the JKS file with the key store
jksStorePassword - key store password
keyAlias - alias of the key in the key store that will be used for signing
keyPassword - password required to access the key
Returns:
SigningData object

fromJksFile

public static SigningData fromJksFile(String jksStoreFilename,
                                      String jksStorePassword,
                                      String keyPassword)
Creates a SigningData object from a JKS (Java Key Store) file with only one valid key. No key alias is required for this method. Use it when you have only one valid key in your key store. If you have more than one valid key, the key will be used, that will expire as first.

Parameters:
jksStoreFilename - name of the JKS file with the key store
jksStorePassword - key store password
keyPassword - password required to access the key
Returns:
SigningData object

fromPkcs11Token

public static SigningData fromPkcs11Token(String libraryFilename,
                                          String keyAlias,
                                          String tokenPin)
Creates a SigningData object from a PKCS#11 token.

Parameters:
libraryFilename - name of the PKCS#11 library file
keyAlias - alias of the key on the token that will be used for signing
tokenPin - token pin
Returns:
SigningData object

fromPkcs11Token

public static SigningData fromPkcs11Token(String libraryFilename,
                                          String tokenPin)
Creates a SigningData object from a PKCS#11 token with only one valid key. No key alias is required for this method. Use it when you have only one valid key on your token. If you have more than one valid key, the key will be used, that will expire as first.

Parameters:
libraryFilename - name of the PKCS#11 library file
tokenPin - token pin
Returns:
SigningData object

fromWindowsKeyStore

public static SigningData fromWindowsKeyStore(String keyAlias)
Creates a SigningData object from Windows key store.

Parameters:
keyAlias - alias of the key in Windows Key store that will be used for signing
Returns:
SigningData object

fromWindowsKeyStore

public static SigningData fromWindowsKeyStore()
Creates a SigningData object from Windows key store with only one valid key. No key alias is required for this method. Use it when you have only one valid key in the Windows key store. If you have more than one valid key, the key will be used, that will expire as first.

Parameters:
keyAlias - alias of the key in Windows Key store that will be used for signing
Returns:
SigningData object

getKeyStore

public KeyStore getKeyStore()
Returns the key store with the key.

Returns:
key store

getKeyAlias

public String getKeyAlias()
Returns the alias of the key that will be used for signing.

Returns:
key alias

getKeyPassword

public String getKeyPassword()
Returns the key password. In some cases (e.g. PKCS#12 key store) the key password is the same as the key store password. In other cases (e.g. JKS key store) the key password may differ from the key store password.

Returns:
key password

getFieldName

public String getFieldName()
Returns the name of the signature field, where the signature will be created. This method just returns what was set by setFieldName(String).

Returns:
signature field name

setFieldName

public void setFieldName(String fieldName)
Specifies the name of some existing empty signature field in the document, where the signature will be created. If you specify the field rectangle using setFieldRectangle(java.awt.geom.Rectangle2D.Float) then the signature field name will be ignored.

Parameters:
fieldName - signature field name where the signature will be created

getFieldRectangle

public Rectangle2D.Float getFieldRectangle()
Returns the rectangle with coordinates for the new signature field, where the digital signature will be placed.

Returns:
new signature field rectangle

setFieldRectangle

public void setFieldRectangle(Rectangle2D.Float fieldRectangle)
Specifies the rectangle coordinates for the new signature field, that will be created before signing the document. The signature will then be created in this rectangle.

Parameters:
fieldRectangle - new signature field rectangle, where the signature will be created

getPageNumber

public int getPageNumber()
Returns the page number, where the signature will be created. The page number is zero based, that is the the first page has the number 0. The default value is also 0.

Returns:
page number, where the signature will be created

setPageNumber

public void setPageNumber(int pageNumber)
Specifies the page number, where the signature will be created. The page number is zero based, that is the the first page has the number 0. The default value is also 0.

Parameters:
pageNumber - page number, where the signature will be created

getAppearanceData

public SignatureAppearanceData getAppearanceData()
Returns signature appearance data.

Returns:
signature appearance data

setAppearanceData

public void setAppearanceData(SignatureAppearanceData appearanceData)
Specifies signature appearance data, that is how the signature will look like.

Parameters:
appearanceData - signature appearance data

getReason

public String getReason()
Return the reason of the signature.

Returns:
signature reason

setReason

public void setReason(String reason)
Specifies the reason of the signature.

Parameters:
reason - signature reason

getLocation

public String getLocation()
Returns the geographic location, where the signature is created.

Returns:
signature location

setLocation

public void setLocation(String location)
Returns the geographic location, where the signature is created.

Parameters:
location - signature location

getContact

public String getContact()
Returns the contact information of the signer.

Returns:
signer contact information

setContact

public void setContact(String contact)
Specifies the contact information of the signer, like email address or phone number.

Parameters:
contact - signer contact information

getCertificationLevel

public CertificationLevelEnum getCertificationLevel()
Returns the certification level of the signature.

Returns:
signature certification level

setCertificationLevel

public void setCertificationLevel(CertificationLevelEnum certificationLevel)
With the certification level for your signature you can specify what changes are allowed on your document after signing. You can even prohibit all kind of changes.

Parameters:
certificationLevel - signature certification level
See Also:
CertificationLevelEnum

getTsaServerUrl

public String getTsaServerUrl()
Return the URL of the time stamp server.

Returns:
time stamp server URL

setTsaServerUrl

public void setTsaServerUrl(String tsaServerUrl)
Sets the URL of the time stamp server. The time stamp for the signature will be taken from this particular server and not from your computer.

Parameters:
tsaServerUrl - time stamp server URL

getTsaServerAccount

public String getTsaServerAccount()
Returns your account name (login information) on the time stamp server.

Returns:
account name on the time stamp server

setTsaServerAccount

public void setTsaServerAccount(String tsaServerAccount)
Sets your account name (login information) for the time stamp server. Depending on your time stamp server this information can be optional.

Parameters:
tsaServerAccount - account name on the time stamp server

getTsaServerPassword

public String getTsaServerPassword()
Returns the password for your account on the time stamp server.

Returns:
password for the account on the time stamp server

setTsaServerPassword

public void setTsaServerPassword(String tsaServerPassword)
Sets the password for your account on the time stamp server.

Parameters:
tsaServerPassword - password for the account on the time stamp server

getTsaServerPolicyOid

public String getTsaServerPolicyOid()
Returns the policy OID for the time stamp server.

Returns:
time stamp server policy OID

setTsaServerPolicyOid

public void setTsaServerPolicyOid(String tsaServerPolicyOid)
Sets the policy OID for your time stamp server. You can get this information (if it is required) from the administrator of the time stamp server. In many cases it is optional.

Parameters:
tsaServerPolicyOid - time stamp server policy OID

isIncludeCrls

public boolean isIncludeCrls()
Returns true if signature will include CRLs (Certificate Revocation Lists). See setIncludeCrls(boolean) for more information.

Returns:
flag indicating if include CRLs in the signature

setIncludeCrls

public void setIncludeCrls(boolean includeCrls)
Specifies if the signature should include CRLs (Certificate Revocation Lists). If you set it to true, for every certificate in your certificate chain the corresponding list of revoked certificates will be downloaded from the web site of responsible certificate authority. Those lists will be encoded in the digital signature.

Parameters:
includeCrls - flag indicating if include CRLs in the signature

isIncludeOcspResponse

public boolean isIncludeOcspResponse()
Returns true if signature will include OCSP response (Online Certificate Status Protocol). See setIncludeOcspResponse(boolean) for more information.

Returns:
flag indicating if include OCSP response in the signature

setIncludeOcspResponse

public void setIncludeOcspResponse(boolean includeOcspReponse)
Specifies if the signature should include OCSP response (Online Certificate Status Protocol). If you set it to true, for your signing certificate the request to the OCSP server of the responsible certificate authority will be made. The result of the request will be saved in the digital signature.

Parameters:
includeOcspReponse - flag indicating if include OCSP response in the signature

getProxyServerHost

public String getProxyServerHost()
Returns the address of the proxy server host.

Returns:
proxy server host address

setProxyServerHost

public void setProxyServerHost(String proxyServerHost)
Sets the address of the proxy server host. This can be required if you are behind a proxy server and activated options like time stamp server that require the internet connection.

Parameters:
proxyServerHost - proxy server host address

getProxyServerPort

public int getProxyServerPort()
Returns the port of the proxy server host.

Returns:
port of the proxy server host

setProxyServerPort

public void setProxyServerPort(int proxyServerPort)
Sets the prot of the proxy server host.

Parameters:
proxyServerPort - port of the proxy server host

getHashAlgorithm

public HashAlgorithmEnum getHashAlgorithm()
Returns the hash algorithm that will be used by creating the signature.

Returns:
signature hash algorithm
See Also:
HashAlgorithmEnum

setHashAlgorithm

public void setHashAlgorithm(HashAlgorithmEnum hashAlgorithm)
Sets the hash algorithm that will be used by creating the signature.

Parameters:
hashAlgorithm - signature hash algorithm
See Also:
HashAlgorithmEnum

getProvider

public Provider getProvider()
Returns the provider that was used to load key store.

Returns:
provider that was used to load key store

setProvider

public void setProvider(Provider provider)
Sets the provider that was used to load the key store. This is only required if your key store is a token which you access through PKCS#11 interface.

Parameters:
provider - provider that was used to load the key store