Index: C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/SignConfig.java =================================================================== --- C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/SignConfig.java (revision 1846) +++ C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/SignConfig.java (working copy) @@ -16,239 +16,32 @@ * limitations under the License. */ +import java.io.File; + +import org.apache.maven.plugin.logging.Log; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + /** - * Bean that represents the JarSigner configuration + * Bean that represents the JarSigner configuration. * * @author Jerome Lacoste * @version $Id$ */ -public class SignConfig { +public interface SignConfig { /** + * Returns a fully configured version of a Mojo ready to sign jars. + * @return */ - private String keystore; - + JarSignerMojo getJarSignerMojo() + throws MojoExecutionException, MojoFailureException; + /** + * Called before any Jars get signed. This method allows you to + * create any keys or perform any initialisation that the + * method of signature that you're implementing requires. */ - private String keyalg; - - /** - */ - private String keysize; - - /** - */ - private String sigalg; - - /** - */ - private String sigfile; - - /** - */ - private String storetype; - - /** - */ - private String storepass; - - /** - */ - private String keypass; - - /** - */ - private String validity; - - /** - */ - private String dnameCn; - - /** - */ - private String dnameOu; - - /** - */ - private String dnameL; - - /** - */ - private String dnameSt; - - /** - */ - private String dnameO; - - /** - */ - private String dnameC; - - /** - */ - private String alias; - - /** - * Whether we want to auto-verify the signed jars. - */ - private boolean verify; - - public void setKeystore( String keystore ) { - this.keystore = keystore; - } - - public void setKeyalg( String keyalg ) { - this.keyalg = keyalg; - } - - public void setKeysize( String keysize ) { - this.keysize = keysize; - } - - public void setSigalg( String sigalg ) { - this.sigalg = sigalg; - } - - public void setSigfile( String sigfile ) { - this.sigfile = sigfile; - } - - public void setStoretype( String storetype ) { - this.storetype = storetype; - } - - public void setStorepass( String storepass ) { - this.storepass = storepass; - } - - public void setKeypass( String keypass ) { - this.keypass = keypass; - } - - public void setValidity( String validity ) { - this.validity = validity; - } - - public void setDnameCn( String dnameCn ) { - this.dnameCn = dnameCn; - } - - public void setDnameOu( String dnameOu ) { - this.dnameOu = dnameOu; - } - - public void setDnameL( String dnameL ) { - this.dnameL = dnameL; - } - - public void setDnameSt( String dnameSt ) { - this.dnameSt = dnameSt; - } - - public void setDnameO( String dnameO ) { - this.dnameO = dnameO; - } - - public void setDnameC( String dnameC ) { - this.dnameC = dnameC; - } - - public void setAlias( String alias ) { - this.alias = alias; - } - - public void setVerify( boolean verify ) { - this.verify = verify; - } - - public String getKeystore() { - return keystore; - } - - public String getKeyalg() { - return keyalg; - } - - public String getKeysize() { - return keysize; - } - - public String getSigalg() { - return sigalg; - } - - public String getSigfile() { - return sigfile; - } - - public String getStoretype() { - return storetype; - } - - public String getStorepass() { - return storepass; - } - - public String getKeypass() { - return keypass; - } - - public String getValidity() { - return validity; - } - - public String getDnameCn() { - return dnameCn; - } - - public String getDnameOu() { - return dnameOu; - } - - public String getDnameL() { - return dnameL; - } - - public String getDnameSt() { - return dnameSt; - } - - public String getDnameO() { - return dnameO; - } - - public String getDnameC() { - return dnameC; - } - - public String getAlias() { - return alias; - } - - public boolean getVerify() { - return verify; - } - - public String getDname() { - StringBuffer buffer = new StringBuffer( 128 ); - - appendToDnameBuffer( dnameCn, buffer, "CN" ); - appendToDnameBuffer( dnameOu, buffer, "OU" ); - appendToDnameBuffer( dnameL, buffer, "L" ); - appendToDnameBuffer( dnameSt, buffer, "ST" ); - appendToDnameBuffer( dnameO, buffer, "O" ); - appendToDnameBuffer( dnameC, buffer, "C" ); - - return buffer.toString(); - } - - private void appendToDnameBuffer( final String property, StringBuffer buffer, final String prefix ) { - if ( property != null ) { - if ( buffer.length() > 0) - { - buffer.append(", "); - } - buffer.append(prefix).append("="); - buffer.append(property); - } - } -} + void init(Log log, File workingDirectory, boolean verbose) + throws MojoExecutionException, MojoFailureException; +} \ No newline at end of file Index: C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/JnlpMojo.java =================================================================== --- C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/JnlpMojo.java (revision 1846) +++ C:/dev/mojo-sandbox/webstart-maven-plugin/plugin/src/main/java/org/codehaus/mojo/webstart/JnlpMojo.java (working copy) @@ -25,6 +25,7 @@ import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.jar.JarSignMojo; import org.apache.maven.project.MavenProject; @@ -137,43 +138,9 @@ */ private SignConfig sign; - public static class KeystoreConfig - { - private boolean delete; - - private boolean gen; - - public boolean isDelete() - { - return delete; - } - - public void setDelete( boolean delete ) - { - this.delete = delete; - } - - public boolean isGen() - { - return gen; - } - - public void setGen( boolean gen ) - { - this.gen = gen; - } - } - /** * Xxx * - * @parameter - */ - private KeystoreConfig keystore; - - /** - * Xxx - * * @parameter default-value="false" */ // private boolean usejnlpservlet; @@ -424,14 +391,7 @@ if ( sign != null ) { - if ( keystore != null && keystore.isGen() ) - { - if ( keystore.isDelete() ) - { - deleteKeyStore(); - } - genKeyStore(); - } + sign.init(getLog(), getWorkDirectory(), verbose); if ( pack200 ) { @@ -744,60 +704,6 @@ } } - private void deleteKeyStore() - { - File keyStore = null; - if ( sign.getKeystore() != null ) - { - keyStore = new File( sign.getKeystore() ); - } - else - { - // FIXME decide if we really want this. - // keyStore = new File( System.getProperty( "user.home") + File.separator + ".keystore" ); - } - - if ( keyStore == null ) - { - return; - } - if ( keyStore.exists() ) - { - if ( keyStore.delete() ) - { - getLog().debug( "deleted keystore from: " + keyStore.getAbsolutePath() ); - } - else - { - getLog().warn( "Couldn't delete keystore from: " + keyStore.getAbsolutePath() ); - } - } - else - { - getLog().debug( "Skipping deletion of non existing keystore: " + keyStore.getAbsolutePath() ); - } - } - - private void genKeyStore() - throws MojoExecutionException - { - GenkeyMojo genKeystore = new GenkeyMojo(); - genKeystore.setAlias( sign.getAlias() ); - genKeystore.setDname( sign.getDname() ); - genKeystore.setKeyalg( sign.getKeyalg() ); - genKeystore.setKeypass( sign.getKeypass() ); - genKeystore.setKeysize( sign.getKeysize() ); - genKeystore.setKeystore( sign.getKeystore() ); - genKeystore.setSigalg( sign.getSigalg() ); - genKeystore.setStorepass( sign.getStorepass() ); - genKeystore.setStoretype( sign.getStoretype() ); - genKeystore.setValidity( sign.getValidity() ); - genKeystore.setVerbose( this.verbose ); - genKeystore.setWorkingDir( getWorkDirectory() ); - - genKeystore.execute(); - } - private File getWorkDirectory() { return workDirectory; @@ -838,7 +744,7 @@ /** return the number of signed jars **/ private int signJars( File directory, FileFilter fileFilter ) - throws MojoExecutionException + throws MojoExecutionException, MojoFailureException { File[] jarFiles = directory.listFiles( fileFilter ); @@ -848,17 +754,7 @@ if ( jarFiles.length == 0 ) return 0; - JarSignMojo signJar = new JarSignMojo(); - signJar.setAlias( sign.getAlias() ); - signJar.setBasedir( basedir ); - signJar.setKeypass( sign.getKeypass() ); - signJar.setKeystore( sign.getKeystore() ); - signJar.setSigFile( sign.getSigfile() ); - signJar.setStorepass( sign.getStorepass() ); - signJar.setType( sign.getStoretype() ); - signJar.setVerbose( this.verbose ); - signJar.setWorkingDir( getWorkDirectory() ); - signJar.setVerify( sign.getVerify() ); + JarSignerMojo signJar = sign.getJarSignerMojo(); for ( int i = 0; i < jarFiles.length; i++ ) {