|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.faceless.pdf2.viewer2.ViewerFeature
org.faceless.pdf2.viewer2.SignatureProvider
org.faceless.pdf2.viewer2.feature.KeyStoreSignatureProvider
public class KeyStoreSignatureProvider
A SignatureProvider that signs and verifies signatures from
a KeyStoreManager (ie from a local KeyStore.
It can verify signatures using any PKCS7SignatureHandler, and it
can sign PDFs using any AcrobatSignatureHandlerFactory.
By default this class will prompt the user for the name, reason etc., and
let the user choose a private key from the KeyStore to sign the PDF.
Developers who want to pre-set this information can do so by specifying the
values as initialization parameters
for the PDFViewer.
SignatureProvider API documentation.
| alias | The default value returned by the getDefaultAlias() method |
|---|---|
| password | The default value returned by the getDefaultPassword() method |
| digestAlgorithm | The default value returned by the getDefaultDigestAlgorithm() method |
| timeStampServer | The default value returned by the getDefaultTimeStampServer() method |
| contentSize | The default value returned by the getDefaultContentSize() method |
As an example, when deploying the PDFViewer as an applet here's how to
ensure every signature applied with this class has the location specified is
cryptographically time-stamped using an RFC 3161 server. To save making two requests to the
time-stamp server, we're pre-allocating 8KB to store the PKCS#7 signature in the PDF. The
AcrobatSignatureHandlerFactory class has more information on these parameters.
<applet code="org.faceless.pdf2.viewer2.PDFViewerApplet" name="pdfapplet" archive="bfopdf.jar"> <param name="feature.KeyStoreSignatureProvider.location" value="Signed using demo application" /> <param name="feature.KeyStoreSignatureProvider.timeStampServer" value="https://tsa.aloaha.com/" /> <param name="feature.KeyStoreSignatureProvider.contentSize" value="8192" /> </applet>The name of this feature is KeyStoreSignatureProvider
This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.
AcrobatSignatureHandlerFactory,
PKCS7SignatureHandler,
KeyStoreManager| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.faceless.pdf2.viewer2.SignatureProvider |
|---|
SignatureProvider.SignatureState |
| Constructor Summary | |
|---|---|
KeyStoreSignatureProvider()
|
|
| Method Summary | |
|---|---|
boolean |
canSign(FormSignature field)
Return true if this SignatureProvider can sign the specified field |
boolean |
canVerify(FormSignature field)
Return true if this SignatureProvider can verify the specified field |
String |
getDefaultAlias()
Return the KeyStore alias to use when signing a PDF using this SignatureProvider. |
int |
getDefaultContentSize()
Return the "Content Size" to be used by the default AcrobatSignatureHandlerFactory. |
String |
getDefaultDigestAlgorithm()
Return the Digest Algorithm to be used by the default AcrobatSignatureHandlerFactory. |
char[] |
getDefaultPassword()
Return the password to use when signing a PDF using this SignatureProvider. |
URL |
getDefaultTimeStampServer()
Return the URL of an RFC 3161 TimeStamp server to be used by the default AcrobatSignatureHandlerFactory. |
String |
getDisplayName()
Return the "user friendly" name of this SignatureProvider, to use in dialogs and menus. |
KeyStoreManager |
getKeyStoreManager()
Return the KeyStoreManager used by this class - either the value returned by
PDFViewer.getKeyStoreManager() (the default) or a value previously set by a call
to setKeyStoreManager(). |
protected SignatureHandlerFactory |
getSignatureHandlerFactory()
Get the SignatureHandlerFactory used to sign fields using
this class. |
void |
setKeyStoreManager(KeyStoreManager keyStoreManager)
Set the KeyStoreManager used by this class, which will override the default. |
void |
setSignatureHandlerFactory(SignatureHandlerFactory factory)
Set the SignatureHandlerFactory used to sign fields using
this class. |
void |
showSignDialog(JComponent root,
FormSignature field)
Display the signing dialog for the specified field, and assuming all goes well sign the field at the end. |
void |
showVerifyDialog(JComponent jroot,
FormSignature field)
Show a dialog displaying information about the specified (signed) digital signature field. |
SignatureProvider.SignatureState |
verify(JComponent root,
FormSignature field)
Verify the field. |
| Methods inherited from class org.faceless.pdf2.viewer2.SignatureProvider |
|---|
getDefaultCertificationType, getDefaultLocation, getDefaultName, getDefaultReason, getIcon, getSignatureState, getViewer, initialize, selectSignProvider, selectVerifyProvider, setSignatureState |
| Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature |
|---|
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getName, isEnabledByDefault, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public KeyStoreSignatureProvider()
| Method Detail |
|---|
public String getDisplayName()
SignatureProvider
getDisplayName in class SignatureProviderpublic void setSignatureHandlerFactory(SignatureHandlerFactory factory)
SignatureHandlerFactory used to sign fields using
this class.
factory - the SignatureHandlerFactory to use when signingprotected SignatureHandlerFactory getSignatureHandlerFactory()
SignatureHandlerFactory used to sign fields using
this class. This is either set by setSignatureHandlerFactory(),
or a new AcrobatSignatureHandlerFactory which has
been initialized using the getDefaultContentSize(),
getDefaultDigestAlgorithm() and getDefaultTimeStampServer()
methods.
public KeyStoreManager getKeyStoreManager()
KeyStoreManager used by this class - either the value returned by
PDFViewer.getKeyStoreManager() (the default) or a value previously set by a call
to setKeyStoreManager().
public void setKeyStoreManager(KeyStoreManager keyStoreManager)
KeyStoreManager used by this class, which will override the default.
keyStoreManager - the KeyStoreManager to use, or null to use the default.public boolean canSign(FormSignature field)
SignatureProvider
canSign in class SignatureProviderpublic boolean canVerify(FormSignature field)
SignatureProvider
canVerify in class SignatureProviderpublic String getDefaultAlias()
feature property
for this class - if specified, it must be a valid alias from the KeyStore,
and the user won't be prompted to select one from the list. You will almost
certainly want to specify the password too.
null to let the user select one
from the KeyStore.public char[] getDefaultPassword()
getDefaultAlias(),
or null to let the user enter one.getDefaultAlias()public URL getDefaultTimeStampServer()
AcrobatSignatureHandlerFactory.
See that class for more information.
null not to specify one.public String getDefaultDigestAlgorithm()
AcrobatSignatureHandlerFactory.
See that class for more information.
null for the factory default.public int getDefaultContentSize()
AcrobatSignatureHandlerFactory.
See that class for more information.
0 for the factory default.
public void showSignDialog(JComponent root,
FormSignature field)
throws IOException,
GeneralSecurityException
SignatureProvider
showSignDialog in class SignatureProviderroot - the JCompoment the dialog should be relative to - typically this is the DocumentPanelfield - the field to be signed
IOException
GeneralSecurityException
public SignatureProvider.SignatureState verify(JComponent root,
FormSignature field)
SignatureProvidercanVerify(). This method may
provide visual feedback to the user, but it's primary purpose is
to verify the field and return its state so it should not block
user progress unless it's unavoidable.
verify in class SignatureProviderroot - the component that should be used as a root forfield - the signed field
public void showVerifyDialog(JComponent jroot,
FormSignature field)
SignatureProvider
showVerifyDialog in class SignatureProviderjroot - the JCompoment the dialog should be relative to - typically this is the DocumentPanelfield - the field to be verified
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||