org.faceless.pdf2

## Class RemoteSigningServlet

- java.lang.Object
- - javax.servlet.GenericServlet
  - - javax.servlet.http.HttpServlet
    - - org.faceless.pdf2.RemoteSigningServlet

- All Implemented Interfaces:
    Serializable, Servlet, ServletConfig

      public class RemoteSigningServlet
      extends HttpServlet

  This Servlet can be used in conjunction with the `RemoteSignatureHandlerFactory` to remotely calculate the signature for a PDF. The API documentation for that class has fairly high-level details on how to install and use remote signing capabilities. This class documentation has information on customizing the installation.

  As supplied, this class takes all it's setup parameters from the servlet's `init-param`. settings. The following parameters are recognised:

  alias | The alias of the signing key to use in the keystore
  password | The password required to open the signing key in the keystore. If not specified this defaults to `keystore.password`
  keystore.path | The path to the keystore, relative to the root of the web application. Typically the keystore would be stored in the `WEB-INF` folder, so this path will be something like `WEB-INF/keystore.jks`
  keystore.password | The password to unlock the keystore
  keystore.provider | The provider to use to create the KeyStore, eg "BC" for the Bouncy Castle package
  keystore.type | The type of keystore. Defaults to `KeyStore.getDefaultType()`, typical values are "JKS" or "PKCS12"
  sig.name | The "name" field to apply to the signature, representing the name of the signing entity. The client API will prevent this from being overridden by the user, but as this field is not part of the PKCS#7 object it's not possible to guarantee this won't happen (cryptographically speaking). Acrobat should display the name from the PKCS#7 object if available in place of this one
  sig.reason | The "reason" field to apply to the signature. The client API will prevent this from being overridden by the user, but as this field is not part of the PKCS#7 object it's not possible to guarantee this won't happen (cryptographically speaking)
  sig.location | The "location" field to apply to the signature. The client API will prevent this from being overridden by the user, but as this field is not part of the PKCS#7 object it's not possible to guarantee this won't happen (cryptographically speaking)
  sig.contactinfo | The "contact information" field to apply to the signature. The client API will prevent this from being overridden by the user, but as this field is not part of the PKCS#7 object it's not possible to guarantee this won't happen (cryptographically speaking)
  timestampserver | The URL of an RFC3161 TimeStamp server that should be use to timestamp the PKCS#7 object

  For those wanting more control, this class can be extended and any of the public methods overridden. This would allow tricks not possible with this class, such as using a different signing key depending on the `HttpServletRequest.getPathInfo()` and so on.
  Since:
    2.7.1
  See Also:
    `RemoteSigningServlet`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RemoteSigningServlet()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `doPost(HttpServletRequest req, HttpServletResponse res)`
    `String` | `getAlias(HttpServletRequest req)` Return the alias of the key in the KeyStore to use for signing.
    `String` | `getContactInfo(HttpServletRequest req)` Return the contact information for the entity createing the signature.
    `KeyStore` | `getKeyStore(HttpServletRequest req)` Return a `KeyStore` to load the key from.
    `String` | `getLocation(HttpServletRequest req)` Return the location the signature is being signed at.
    `String` | `getName(HttpServletRequest req)` Return the name of the entity signing the signature.
    `char[]` | `getPassword(HttpServletRequest req)` Return the password for the alias in the KeyStore.
    `String` | `getReason(HttpServletRequest req)` Return the reason the signature is being signed.
    `String` | `getTimeStampServer(HttpServletRequest req)` Return the server to use for RFC3161 timestamping of this signature.
    `void` | `init()`

    - ### Methods inherited from class javax.servlet.http.HttpServlet

      `service`

    - ### Methods inherited from class javax.servlet.GenericServlet

      `destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RemoteSigningServlet

          public RemoteSigningServlet()

  - ### Method Detail

    - #### doPost

          public void doPost(HttpServletRequest req,
                             HttpServletResponse res)
                      throws ServletException,
                             IOException

      Overrides:
        `doPost` in class `HttpServlet`
      Throws:
        `ServletException`
        `IOException`

    - #### init

          public void init()
                    throws ServletException

      Overrides:
        `init` in class `GenericServlet`
      Throws:
        `ServletException`

    - #### getName

          public String getName(HttpServletRequest req)

      Return the name of the entity signing the signature. This value will be set in the PDF. The default action is to return the `sig.name` init-parameter if specified.
      Parameters:
        `req` - the servlet request.

    - #### getReason

          public String getReason(HttpServletRequest req)

      Return the reason the signature is being signed. This value will be set in the PDF. The default action is to return the `sig.reason` init-parameter if specified.
      Parameters:
        `req` - the servlet request.

    - #### getLocation

          public String getLocation(HttpServletRequest req)

      Return the location the signature is being signed at. This value will be set in the PDF. The default action is to return the `sig.location` init-parameter if specified.
      Parameters:
        `req` - the servlet request.

    - #### getContactInfo

          public String getContactInfo(HttpServletRequest req)

      Return the contact information for the entity createing the signature. This value will be set in the PDF. The default action is to return the `sig.contactinfo` init-parameter if specified.
      Parameters:
        `req` - the servlet request.

    - #### getKeyStore

          public KeyStore getKeyStore(HttpServletRequest req)
                               throws ServletException,
                                      IOException,
                                      GeneralSecurityException

      Return a `KeyStore` to load the key from. The default implementation of this method returns the KeyStore created in the `init()` method from the `keystore.path`, `keystore.type`, `keystore.provider` and `keystore.password` init-parameters, but this method may be overridden if required.
      Parameters:
        `req` - the `HttpServletRequest` made to this servlet.
      Returns:
        a `KeyStore` containing a private key that can be used for signing.
      Throws:
        `ServletException`
        `IOException`
        `GeneralSecurityException`

    - #### getAlias

          public String getAlias(HttpServletRequest req)
                          throws ServletException

      Return the alias of the key in the KeyStore to use for signing. The default implementation of this method returns the values of the `alias` init-parameter, and fails if it's not specified.
      Parameters:
        `req` - the `HttpServletRequest` made to this servlet.
      Returns:
        the alias of the private key in the KeyStore to use for signing.
      Throws:
        `ServletException`

    - #### getPassword

          public char[] getPassword(HttpServletRequest req)
                             throws ServletException

      Return the password for the alias in the KeyStore. The default implementation of this method returns the values of the `password` init-parameter if specified, or the `keystore.password` init-parameter if not. If neither are specified this method fails.
      Parameters:
        `req` - the `HttpServletRequest` made to this servlet.
      Returns:
        the password of the private key in the KeyStore
      Throws:
        `ServletException`

    - #### getTimeStampServer

          public String getTimeStampServer(HttpServletRequest req)
                                    throws ServletException

      Return the server to use for RFC3161 timestamping of this signature. The default implementation of this method returns value of the `timestampserver` init-param if specified, or null if not.
      Returns:
        the URL of the Time Stamp server to connect to, or `null` to not timestamp the signature
      Throws:
        `ServletException`

Copyright © 2001-2015 Big Faceless Organization