1 package org.apache.maven.plugins.jarsigner;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23
24 import org.codehaus.plexus.util.StringUtils;
25 import org.codehaus.plexus.util.cli.Commandline;
26
27
28
29
30
31
32
33
34
35 public class JarsignerSignMojo
36 extends AbstractJarsignerMojo
37 {
38
39
40
41
42
43
44 private String keystore;
45
46
47
48
49
50
51 private String storepass;
52
53
54
55
56
57
58 private String keypass;
59
60
61
62
63
64
65 private String sigfile;
66
67
68
69
70
71
72 private String storetype;
73
74
75
76
77
78
79 private String providerName;
80
81
82
83
84
85
86 private String providerClass;
87
88
89
90
91
92
93 private String providerArg;
94
95
96
97
98
99
100
101 private String alias;
102
103 protected Commandline getCommandline( final File archive, final Commandline commandLine )
104 {
105 if ( archive == null )
106 {
107 throw new NullPointerException( "archive" );
108 }
109 if ( commandLine == null )
110 {
111 throw new NullPointerException( "commandLine" );
112 }
113
114 if ( !StringUtils.isEmpty( this.keystore ) )
115 {
116 commandLine.createArg().setValue( "-keystore" );
117 commandLine.createArg().setValue( this.keystore );
118 }
119 if ( !StringUtils.isEmpty( this.storepass ) )
120 {
121 commandLine.createArg().setValue( "-storepass" );
122 commandLine.createArg().setValue( this.storepass );
123 }
124 if ( !StringUtils.isEmpty( this.keypass ) )
125 {
126 commandLine.createArg().setValue( "-keypass" );
127 commandLine.createArg().setValue( this.keypass );
128 }
129 if ( !StringUtils.isEmpty( this.storetype ) )
130 {
131 commandLine.createArg().setValue( "-storetype" );
132 commandLine.createArg().setValue( this.storetype );
133 }
134 if ( !StringUtils.isEmpty( this.providerName ) )
135 {
136 commandLine.createArg().setValue( "-providerName" );
137 commandLine.createArg().setValue( this.providerName );
138 }
139 if ( !StringUtils.isEmpty( this.providerClass ) )
140 {
141 commandLine.createArg().setValue( "-providerClass" );
142 commandLine.createArg().setValue( this.providerClass );
143 }
144 if ( !StringUtils.isEmpty( this.providerArg ) )
145 {
146 commandLine.createArg().setValue( "-providerArg" );
147 commandLine.createArg().setValue( this.providerArg );
148 }
149 if ( !StringUtils.isEmpty( this.sigfile ) )
150 {
151 commandLine.createArg().setValue( "-sigfile" );
152 commandLine.createArg().setValue( this.sigfile );
153 }
154
155 commandLine.createArg().setFile( archive );
156
157 if ( !StringUtils.isEmpty( this.alias ) )
158 {
159 commandLine.createArg().setValue( this.alias );
160 }
161
162 return commandLine;
163 }
164
165 protected String getCommandlineInfo( final Commandline commandLine )
166 {
167 String commandLineInfo = commandLine != null ? commandLine.toString() : null;
168
169 if ( commandLineInfo != null )
170 {
171 commandLineInfo = StringUtils.replace( commandLineInfo, this.keypass, "'*****'" );
172 commandLineInfo = StringUtils.replace( commandLineInfo, this.storepass, "'*****'" );
173 }
174
175 return commandLineInfo;
176 }
177
178 }