1 package org.apache.maven.shared.jarsigner;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.shared.utils.cli.javatool.JavaToolResult;
23
24 import java.io.File;
25
26
27
28
29 public class SimpleJarSignTest
30 extends AbstractJarSignerTest
31 {
32 private JarSigner jarSigner;
33
34 public void setUp()
35 throws Exception
36 {
37 super.setUp();
38
39 jarSigner = (JarSigner) lookup( JarSigner.class.getName() );
40 }
41
42 public void testSimpleSign()
43 throws Exception
44 {
45 File target = prepareTestJar( "simple.jar" );
46
47 JarSignerSignRequest jarSignerRequest = new JarSignerSignRequest();
48 jarSignerRequest.setArchive( target );
49 jarSignerRequest.setKeystore( "src/test/keystore" );
50 jarSignerRequest.setVerbose( true );
51 jarSignerRequest.setAlias( "foo_alias" );
52 jarSignerRequest.setKeypass( "key-passwd" );
53 jarSignerRequest.setStorepass( "changeit" );
54 jarSignerRequest.setSignedjar( new File( "target/ssimple.jar" ) );
55
56 JavaToolResult jarSignerResult = jarSigner.execute( jarSignerRequest );
57
58 assertEquals( "not exit code 0 " + jarSignerResult.getExecutionException(), 0, jarSignerResult.getExitCode() );
59 }
60
61 public void testSimpleSignAndVerify()
62 throws Exception
63 {
64 testSimpleSign();
65
66 JarSignerVerifyRequest request = new JarSignerVerifyRequest();
67 request.setCerts( true );
68 request.setVerbose( true );
69 request.setArchive( new File( "target/ssimple.jar" ) );
70 request.setKeystore( "src/test/keystore" );
71 request.setAlias( "foo_alias" );
72 request.setStorepass( "changeit" );
73
74 JavaToolResult jarSignerResult = jarSigner.execute( request );
75
76 assertEquals( "not exit code 0 " + jarSignerResult.getExecutionException(), 0, jarSignerResult.getExitCode() );
77 }
78 }