Class ASJarSigner

  • All Implemented Interfaces:
    org.glassfish.hk2.api.PostConstruct

    @Service
    @Singleton
    public class ASJarSigner
    extends Object
    implements org.glassfish.hk2.api.PostConstruct
    Signs a specified JAR file.

    This implementation searches the available keystores for the signing alias indicated in the domain.xml config or, if not specified, the default alias, the first time it is invoked to sign a JAR file. After the first requested signing it uses the same alias and provider to sign all JARs.

    The public interface to this class is the static signJar method.

    Author:
    tjquinn
    • Field Detail

      • USER_SPECIFIED_ALIAS_PROPERTYNAME

        public static final String USER_SPECIFIED_ALIAS_PROPERTYNAME
        property name optionally set by the admin in domain.xml to select an alias for signing
        See Also:
        Constant Field Values
    • Constructor Detail

      • ASJarSigner

        public ASJarSigner()
    • Method Detail

      • postConstruct

        public void postConstruct()
        Specified by:
        postConstruct in interface org.glassfish.hk2.api.PostConstruct
      • signJar

        public long signJar​(File unsignedJar,
                            File signedJar,
                            String alias,
                            Attributes attrs)
                     throws Exception
        Creates a signed jar from the specified unsigned jar.
        Parameters:
        unsignedJar - the unsigned JAR file
        signedJar - the signed JAR to be created
        attrs - additional attributes to be added to the JAR's manifest main section
        Returns:
        the elapsed time to sign the JAR (in milliseconds)
        Throws:
        Exception - getting the keystores from SSLUtils fails
      • signJar

        public long signJar​(File unsignedJar,
                            ZipOutputStream signedJar,
                            String alias,
                            Attributes attrs,
                            Map<String,​byte[]> additionalContent)
                     throws Exception
        Creates a signed ZIP output stream from an unsigned JAR and, possibly, additional content.
        Parameters:
        unsignedJar - JAR file containing most of the content to sign and return
        signedJar - already-opened ZipOutputStream to receive the signed content
        alias - the alias with which to identify the cert for signing the output
        attrs - additional manifest attributes to add
        additionalContent - additional JAR entries to add
        Returns:
        Throws:
        Exception