Package net.jsign

Class AuthenticodeSigner


  • public class AuthenticodeSigner
    extends Object
    Sign a file with Authenticode. Timestamping is enabled by default and relies on the Sectigo server (http://timestamp.sectigo.com).
    Since:
    3.0
    Author:
    Emmanuel Bourg
    • Method Detail

      • withProgramName

        public AuthenticodeSigner withProgramName​(String programName)
        Set the program name embedded in the signature.
        Parameters:
        programName - the program name
        Returns:
        the current signer
      • withProgramURL

        public AuthenticodeSigner withProgramURL​(String programURL)
        Set the program URL embedded in the signature.
        Parameters:
        programURL - the program URL
        Returns:
        the current signer
      • withSignaturesReplaced

        public AuthenticodeSigner withSignaturesReplaced​(boolean replace)
        Enable or disable the replacement of the previous signatures (disabled by default).
        Parameters:
        replace - true if the new signature should replace the existing ones, false to append it
        Returns:
        the current signer
        Since:
        2.0
      • withTimestamping

        public AuthenticodeSigner withTimestamping​(boolean timestamping)
        Enable or disable the timestamping (enabled by default).
        Parameters:
        timestamping - true to enable timestamping, false to disable it
        Returns:
        the current signer
      • withTimestampingAuthority

        public AuthenticodeSigner withTimestampingAuthority​(String url)
        Set the URL of the timestamping authority. Both RFC 3161 (as used for jar signing) and Authenticode timestamping services are supported.
        Parameters:
        url - the URL of the timestamping authority
        Returns:
        the current signer
        Since:
        2.1
      • withTimestampingAuthority

        public AuthenticodeSigner withTimestampingAuthority​(String... urls)
        Set the URLs of the timestamping authorities. Both RFC 3161 (as used for jar signing) and Authenticode timestamping services are supported.
        Parameters:
        urls - the URLs of the timestamping authorities
        Returns:
        the current signer
        Since:
        2.1
      • withTimestampingRetries

        public AuthenticodeSigner withTimestampingRetries​(int timestampingRetries)
        Set the number of retries for timestamping.
        Parameters:
        timestampingRetries - the number of retries
        Returns:
        the current signer
      • withTimestampingRetryWait

        public AuthenticodeSigner withTimestampingRetryWait​(int timestampingRetryWait)
        Set the number of seconds to wait between timestamping retries.
        Parameters:
        timestampingRetryWait - the wait time between retries (in seconds)
        Returns:
        the current signer
      • withSignatureAlgorithm

        public AuthenticodeSigner withSignatureAlgorithm​(String signatureAlgorithm)
        Explicitly sets the signature algorithm to use.
        Parameters:
        signatureAlgorithm - the signature algorithm
        Returns:
        the current signer
        Since:
        2.0
      • withSignatureAlgorithm

        public AuthenticodeSigner withSignatureAlgorithm​(String signatureAlgorithm,
                                                         String signatureProvider)
        Explicitly sets the signature algorithm and provider to use.
        Parameters:
        signatureAlgorithm - the signature algorithm
        signatureProvider - the security provider for the specified algorithm
        Returns:
        the current signer
        Since:
        2.0
      • withSignatureAlgorithm

        public AuthenticodeSigner withSignatureAlgorithm​(String signatureAlgorithm,
                                                         Provider signatureProvider)
        Explicitly sets the signature algorithm and provider to use.
        Parameters:
        signatureAlgorithm - the signature algorithm
        signatureProvider - the security provider for the specified algorithm
        Returns:
        the current signer
        Since:
        2.0
      • withSignatureProvider

        public AuthenticodeSigner withSignatureProvider​(Provider signatureProvider)
        Set the signature provider to use.
        Parameters:
        signatureProvider - the security provider for the signature algorithm
        Returns:
        the current signer
        Since:
        2.0
      • sign

        public void sign​(Signable file)
                  throws Exception
        Sign the specified file.
        Parameters:
        file - the file to sign
        Throws:
        Exception - if signing fails