Class GenkeyMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    public class GenkeyMojo
    extends AbstractKeyToolMojo
    Generates a keystore.

    Implemented as a wrapper around the SDK keytool -genkey command.

     -genkey   [-v] [-protected]
     [-alias <alias>]
     [-keyalg <keyalg>] [-keysize <keysize>]
     [-sigalg <sigalg>] [-dname <dname>]
     [-validity <valDays>] [-keypass <keypass>]
     [-keystore <keystore>] [-storepass <storepass>]
     [-storetype <storetype>] [-providerName <name>]
     [-providerClass <provider_class_name> [-providerArg <arg>]] ...
     
    Version:
    $Id: GenkeyMojo.java 2166 2006-07-18 21:32:16Z carlos $
    See Also:
    keystore documentation.
    • Constructor Summary

      Constructors 
      Constructor Description
      GenkeyMojo()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addArgIf​(java.util.List arguments, boolean b, java.lang.String value)
      Convenience method to add an argument to the command line conditionally based on the given flag.
      private void addArgIfNotEmpty​(java.util.List arguments, java.lang.String key, java.lang.String value)
      Convenience method to add an argument to the command line if the the value is not null or empty.
      private void addArgIfNotEmpty​(java.util.List arguments, java.lang.String key, java.lang.String value, boolean repeatKey)
      Convenience method to add an argument to the command line if the the value is not null or empty.
      private void addArgIfNotEmpty2​(java.util.List arguments, java.lang.String key, java.lang.String value, boolean ignored)
      Convenience method to add an argument to the command line if the the value is not null or empty.
      private void createParentDirIfNecessary​(java.lang.String file)  
      void execute()  
      protected int executeCommandLine​(org.codehaus.plexus.util.cli.Commandline commandLine, java.io.InputStream inputStream, org.codehaus.plexus.util.cli.StreamConsumer stream1, org.codehaus.plexus.util.cli.StreamConsumer stream2)  
      private static java.io.File getJDKCommandExe​(java.lang.String command)  
      private static java.lang.String getJDKCommandPath​(java.lang.String command, org.apache.maven.plugin.logging.Log logger)  
      private java.lang.String getKeytoolPath()
      Get the path of jarsigner tool depending the OS.
      void setAlias​(java.lang.String alias)  
      void setDname​(java.lang.String dname)  
      void setKeyalg​(java.lang.String keyalg)  
      void setKeypass​(java.lang.String keypass)  
      void setKeysize​(java.lang.String keysize)  
      void setSigalg​(java.lang.String sigalg)  
      void setStorepass​(java.lang.String storepass)  
      void setStoretype​(java.lang.String storetype)  
      void setValidity​(java.lang.String validity)  
      void setVerbose​(boolean verbose)  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • keyalg

        private java.lang.String keyalg
        See options.
      • keysize

        private java.lang.String keysize
        See options.
      • sigalg

        private java.lang.String sigalg
        See options.
      • storetype

        private java.lang.String storetype
        See options.
      • storepass

        private java.lang.String storepass
        See options.
      • keypass

        private java.lang.String keypass
        See options.
      • validity

        private java.lang.String validity
        See options.
      • dname

        private java.lang.String dname
        See options.
      • alias

        private java.lang.String alias
        See options.
      • verbose

        private boolean verbose
        Enable verbose See options.
    • Constructor Detail

      • GenkeyMojo

        public GenkeyMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • createParentDirIfNecessary

        private void createParentDirIfNecessary​(java.lang.String file)
      • getKeytoolPath

        private java.lang.String getKeytoolPath()
        Get the path of jarsigner tool depending the OS.
        Returns:
        the path of the jarsigner tool
      • getJDKCommandPath

        private static java.lang.String getJDKCommandPath​(java.lang.String command,
                                                          org.apache.maven.plugin.logging.Log logger)
      • getJDKCommandExe

        private static java.io.File getJDKCommandExe​(java.lang.String command)
      • addArgIf

        private void addArgIf​(java.util.List arguments,
                              boolean b,
                              java.lang.String value)
        Convenience method to add an argument to the command line conditionally based on the given flag.
        Parameters:
        arguments -
        b - the flag which controls if the argument is added or not.
        value - the argument value to be added.
      • addArgIfNotEmpty

        private void addArgIfNotEmpty​(java.util.List arguments,
                                      java.lang.String key,
                                      java.lang.String value)
        Convenience method to add an argument to the command line if the the value is not null or empty.

        Moreover, the value could be comma separated.

        Parameters:
        arguments -
        key - the argument name.
        value - the argument value to be added.
        See Also:
        addArgIfNotEmpty(java.util.List,String,String,boolean)
      • addArgIfNotEmpty2

        private void addArgIfNotEmpty2​(java.util.List arguments,
                                       java.lang.String key,
                                       java.lang.String value,
                                       boolean ignored)
        Convenience method to add an argument to the command line if the the value is not null or empty.

        Moreover, the value could be comma separated.

        Parameters:
        arguments -
        key - the argument name.
        value - the argument value to be added.
        ignored -
      • addArgIfNotEmpty

        private void addArgIfNotEmpty​(java.util.List arguments,
                                      java.lang.String key,
                                      java.lang.String value,
                                      boolean repeatKey)
        Convenience method to add an argument to the command line if the the value is not null or empty.

        Moreover, the value could be comma separated.

        Parameters:
        arguments -
        key - the argument name.
        value - the argument value to be added.
        repeatKey - repeat or not the key in the command line
      • executeCommandLine

        protected int executeCommandLine​(org.codehaus.plexus.util.cli.Commandline commandLine,
                                         java.io.InputStream inputStream,
                                         org.codehaus.plexus.util.cli.StreamConsumer stream1,
                                         org.codehaus.plexus.util.cli.StreamConsumer stream2)
                                  throws org.codehaus.plexus.util.cli.CommandLineException
        Throws:
        org.codehaus.plexus.util.cli.CommandLineException
      • setKeypass

        public void setKeypass​(java.lang.String keypass)
      • setStorepass

        public void setStorepass​(java.lang.String storepass)
      • setAlias

        public void setAlias​(java.lang.String alias)
      • setKeyalg

        public void setKeyalg​(java.lang.String keyalg)
      • setSigalg

        public void setSigalg​(java.lang.String sigalg)
      • setKeysize

        public void setKeysize​(java.lang.String keysize)
      • setStoretype

        public void setStoretype​(java.lang.String storetype)
      • setValidity

        public void setValidity​(java.lang.String validity)
      • setDname

        public void setDname​(java.lang.String dname)
      • setVerbose

        public void setVerbose​(boolean verbose)