org.faceless.pdf2.viewer2.feature

## Class RemoteSignatureProvider

- java.lang.Object
- - org.faceless.pdf2.viewer2.ViewerFeature
  - - org.faceless.pdf2.viewer2.SignatureProvider
    - - org.faceless.pdf2.viewer2.feature.RemoteSignatureProvider

-     public class RemoteSignatureProvider
      extends SignatureProvider

  A SignatureProvider that allows digital signatures to applied using the `RemoteSignatureHandlerFactory` class. This factory works together with a `RemoteSigningServlet` on a remote host to sign the PDF without needing to manage the `KeyStore` on the client.

  This class needs a `Factory` to operate. This can be set by calling `setSignatureHandlerFactory()`, or by specifying the URL of the Factory as an initialization parameter (if neither is done then this class is not used).

  The following initialization parameters can be specified to configure this feature, as well as those parameters specified in the `SignatureProvider` API documentation.

  url | The URL of the `RemoteSigningServlet`
  digestAlgorithm | The digest algorithm to be use. The default (defined by the `RemoteSignatureHandlerFactory`) is "SHA1", other valid values are "MD5" or "SHA256".

  Here's a fully working example of how to specify these parameters when the PDF Viewer is installed as an applet. The URL specified is the URL of a demonstration `RemoteSigningServlet` which can be used for testing.

       <applet code="org.faceless.pdf2.viewer2.PDFViewerApplet" name="pdfapplet" archive="bfopdf.jar">
        <param name="feature.RemoteSignatureProvider.url" value="http://bfo.com/signdemo/" />
        <param name="feature.RemoteSignatureProvider.alias" value="" />
        <param name="feature.RemoteSignatureProvider.name" value="John User" />
        <param name="feature.RemoteSignatureProvider.certification" value="none" />
        <param name="feature.RemoteSignatureProvider.reason" value="" />
        <param name="feature.RemoteSignatureProvider.location" value="" />
       </applet>

  In this exampel we're specifying all the parameters required for signing, so no dialog will be presented to the user when signing - in fact, if this is the only `SignatureProvider` available to the `PDFViewer`, clicking a signature field will immediately sign the field using these parameters without prompting the user for any further information. Note the `RemoteSigningServlet` may be set up to ignore and override these values.

  The name of this feature is RemoteSignatureProvider

  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.

  Since:
    2.11

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.faceless.pdf2.viewer2.SignatureProvider

      `SignatureProvider.SignatureState`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RemoteSignatureProvider()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canSign(FormSignature field)` Return true if a `RemoteSignatureHandlerFactory` has been specified for signing.
    `boolean` | `canVerify(FormSignature field)` Signatures do not need to be verified remotely, so this method always returns false.
    `protected String` | `getDefaultAlias()` Return the default value of "alias" to be passed in to the signing method.
    `String` | `getDisplayName()` Return the "user friendly" name of this SignatureProvider, to use in dialogs and menus.
    `void` | `initialize(PDFViewer viewer)` Called when the feature is first added to a viewer
    `void` | `setSignatureHandlerFactory(RemoteSignatureHandlerFactory factory)` Set the `RemoteSignatureHandlerFactory` that is to be used to sign this PDF.
    `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 root, FormSignature field)` As the `canVerify()` method always returns false, this method does nothing.

    - ### Methods inherited from class org.faceless.pdf2.viewer2.SignatureProvider

      `getDefaultCertificationType, getDefaultLocation, getDefaultName, getDefaultReason, getIcon, getSignatureState, getViewer, selectSignProvider, selectVerifyProvider, setSignatureState, verify`

    - ### Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature

      `getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, isEnabledByDefault, setFeatureName, teardown, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### RemoteSignatureProvider

          public RemoteSignatureProvider()

  - ### Method Detail

    - #### getDisplayName

          public String getDisplayName()

      Description copied from class: `SignatureProvider`
      Return the "user friendly" name of this SignatureProvider, to use in dialogs and menus.
      Specified by:
        `getDisplayName` in class `SignatureProvider`

    - #### initialize

          public void initialize(PDFViewer viewer)

      Description copied from class: `ViewerFeature`
      Called when the feature is first added to a viewer
      Overrides:
        `initialize` in class `SignatureProvider`

    - #### getDefaultAlias

          protected String getDefaultAlias()

      Return the default value of "alias" to be passed in to the signing method. Whether this field is used or not depends on how the `RemoteSigningServlet` is set up - the default implementation of this method returns the `alias` initialization parameter for the viewer. If this method returs `null` then the user will be prompted for a value.

    - #### setSignatureHandlerFactory

          public void setSignatureHandlerFactory(RemoteSignatureHandlerFactory factory)

      Set the `RemoteSignatureHandlerFactory` that is to be used to sign this PDF. This will override any factory specified by the `url` property to this feature, as described in the API docs

    - #### canSign

          public boolean canSign(FormSignature field)

      Return true if a `RemoteSignatureHandlerFactory` has been specified for signing.
      Specified by:
        `canSign` in class `SignatureProvider`

    - #### canVerify

          public boolean canVerify(FormSignature field)

      Signatures do not need to be verified remotely, so this method always returns false.
      Specified by:
        `canVerify` in class `SignatureProvider`

    - #### showSignDialog

          public void showSignDialog(JComponent root,
                                     FormSignature field)
                              throws IOException,
                                     GeneralSecurityException

      Description copied from class: `SignatureProvider`
      Display the signing dialog for the specified field, and assuming all goes well sign the field at the end.
      Specified by:
        `showSignDialog` in class `SignatureProvider`
      Parameters:
        `root` - the JCompoment the dialog should be relative to - typically this is the `DocumentPanel`
        `field` - the field to be signed
      Throws:
        `IOException`
        `GeneralSecurityException`

    - #### showVerifyDialog

          public void showVerifyDialog(JComponent root,
                                       FormSignature field)

      As the `canVerify()` method always returns false, this method does nothing.
      Specified by:
        `showVerifyDialog` in class `SignatureProvider`
      Parameters:
        `root` - the JCompoment the dialog should be relative to - typically this is the `DocumentPanel`
        `field` - the field to be verified

Copyright © 2001-2015 Big Faceless Organization