public abstract class SignatureProvider extends ViewerFeature
A ViewerFeature that acts as a service provider for applying Digital Signatures.
When a digital signature field is encounted by the PDF viewer, it will search
its list of features for an instance of this class that can sign
or can verify
the field as appropriate. A dialog will then
be presented.
Although each type of subclass will be different, there are several properties
that apply to any digital signature and so they can be specified here. Subclasses
implementing the showSignDialog()
method are expected to
use these values if specified, or prompt the user otherwise.
name | The name of the entity signing the document - the default value of getDefaultName() |
---|---|
reason | The reason for the signature - the default value of getDefaultReason() . |
location | The location the signature is being applied - the default value of getDefaultLocation() . |
certification | The type of certification to use for the first signature applied to a PDF (the default value of getDefaultCertificationType() ). Valid values are none , nochanges , forms or comments . If the signature being applied is not the initial signature this is ignored |
Modifier and Type | Class and Description |
---|---|
class |
SignatureProvider.SignatureState
A SignatureState contains information about a
FormSignature once it's been verified. |
Modifier | Constructor and Description |
---|---|
protected |
SignatureProvider(String name) |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canSign(FormSignature field)
Return true if this SignatureProvider can sign the specified field
|
abstract boolean |
canVerify(FormSignature field)
Return true if this SignatureProvider can verify the specified field
|
int |
getDefaultCertificationType()
Return the default type of certification for any new signatures
using the
showSignDialog() method,
or -1 to not specify a default. |
String |
getDefaultLocation()
Return the location of the new signature being applied
using the
showSignDialog() method,
or null to not specify a default. |
String |
getDefaultName()
Return the name of the entity signing the document
using the
showSignDialog() method,
or null to not specify a default. |
String |
getDefaultReason()
Return the reason that the new signature is being applied
using the
showSignDialog() method,
or null to not specify a default. |
abstract String |
getDisplayName()
Return the "user friendly" name of this SignatureProvider,
to use in dialogs and menus.
|
static ImageIcon |
getIcon(DocumentPanel docpanel,
FormSignature field)
Get an Icon that can be used to describe the specified signature.
|
static SignatureProvider.SignatureState |
getSignatureState(DocumentPanel docpanel,
FormSignature field)
Get a previously determined
SignatureProvider.SignatureState for the specified signature field, as set by
setSignatureState() . |
PDFViewer |
getViewer()
Return the
PDFViewer set in initialize(org.faceless.pdf2.viewer2.PDFViewer) |
void |
initialize(PDFViewer viewer)
Called when the feature is first added to a viewer
|
static void |
selectSignProvider(DocumentPanel docpanel,
FormSignature field,
JComponent comp,
Point point,
ActionListener listener)
Select a SignatureProvider that can be used to sign the specified signature field.
|
static void |
selectVerifyProvider(DocumentPanel docpanel,
FormSignature field,
JComponent comp,
Point point,
ActionListener listener)
Select a SignatureProvider that can be used to verify the specified signature field.
|
static void |
setSignatureState(DocumentPanel docpanel,
FormSignature field,
SignatureProvider.SignatureState state)
Set the
SignatureProvider.SignatureState of this field - should be called by the showVerifyDialog()
method after the field has been verified, to save the details of the verification. |
abstract 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.
|
abstract void |
showVerifyDialog(JComponent root,
FormSignature field)
Show a dialog displaying information about the specified (signed) digital signature field.
|
SignatureProvider.SignatureState |
verify(JComponent root,
FormSignature field)
Verify the field.
|
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown, toString
protected SignatureProvider(String name)
public void initialize(PDFViewer viewer)
ViewerFeature
initialize
in class ViewerFeature
public final PDFViewer getViewer()
PDFViewer
set in initialize(org.faceless.pdf2.viewer2.PDFViewer)
public abstract String getDisplayName()
public String getDefaultName()
showSignDialog()
method,
or null
to not specify a default.public String getDefaultReason()
showSignDialog()
method,
or null
to not specify a default.public String getDefaultLocation()
showSignDialog()
method,
or null
to not specify a default.public int getDefaultCertificationType()
showSignDialog()
method,
or -1 to not specify a default.FormSignature.CERTIFICATION_UNCERTIFIED
, FormSignature.CERTIFICATION_NOCHANGES
, FormSignature.CERTIFICATION_ALLOWFORMS
, FormSignature.CERTIFICATION_ALLOWCOMMENTS
, or the value -1 to prompt the user (the default).public abstract boolean canSign(FormSignature field)
public abstract boolean canVerify(FormSignature field)
public abstract void showSignDialog(JComponent root, FormSignature field) throws IOException, GeneralSecurityException
root
- the JCompoment the dialog should be relative to - typically this is the DocumentPanel
field
- the field to be signedIOException
GeneralSecurityException
public abstract void showVerifyDialog(JComponent root, FormSignature field)
root
- the JCompoment the dialog should be relative to - typically this is the DocumentPanel
field
- the field to be verifiedpublic SignatureProvider.SignatureState verify(JComponent root, FormSignature field)
canVerify()
. 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.root
- the component that should be used as a root forfield
- the signed fieldpublic static final ImageIcon getIcon(DocumentPanel docpanel, FormSignature field)
public static final void selectSignProvider(DocumentPanel docpanel, FormSignature field, JComponent comp, Point point, ActionListener listener)
Select a SignatureProvider that can be used to sign the specified signature field.
The listener
parameter specifies an ActionListener
which will be called with
the chosen provider - the ActionEvent
it will be given will have the source set to
the chosen provider and the action type set to "sign".
If more than one SignatureProvider is available this method will show a dialog allowing the user to choose,
otherwise the the listener
will be called without a dialog being displayed.
docpanel
- the DocumentPanel containing the PDFfield
- the field the user is requesting to signcomp
- the Component the user has clicked on or selected to request the signingpoint
- the position relative to comp
that any dialog should be based aroundlistener
- the ActionListener that should be called when the SignatureProvider is chosenpublic static final void selectVerifyProvider(DocumentPanel docpanel, FormSignature field, JComponent comp, Point point, ActionListener listener)
Select a SignatureProvider that can be used to verify the specified signature field.
The listener
parameter specifies an ActionListener
which will be called with
the chosen provider - the ActionEvent
it will be given will have the source set to the chosen
provider and the action type set to "verify".
If more than one SignatureProvider is available this method will show a dialog allowing the user to choose,
otherwise the the listener
will be called without a dialog being displayed.
docpanel
- the DocumentPanel containing the PDFfield
- the field the user is requesting to verifycomp
- the Component the user has clicked on or selected to request the verificationpoint
- the position relative to comp
that any dialog should be based aroundlistener
- the ActionListener that should be called when the SignatureProvider is chosenpublic static final SignatureProvider.SignatureState getSignatureState(DocumentPanel docpanel, FormSignature field)
SignatureProvider.SignatureState
for the specified signature field, as set by
setSignatureState()
. If this method returns
null
then the signature has not been verified yet.docpanel
- the DocumentPanel containing the signaturefield
- the FormSignature whose state is being checkedpublic static final void setSignatureState(DocumentPanel docpanel, FormSignature field, SignatureProvider.SignatureState state)
SignatureProvider.SignatureState
of this field - should be called by the showVerifyDialog()
method after the field has been verified, to save the details of the verification.
This method may be called in any thread, but it will fire the "stateChanged"
DocumentPanelEvent
on the Swing Event Dispatch Thread.docpanel
- the DocumentPanel containing the signaturefield
- the FormSignature that was verifiedstate
- the state of the signatureCopyright © 2001-2017 Big Faceless Organization