12
12
*/
13
13
public class Commander {
14
14
15
+ @ Parameter (description = "This parameter catches all unrecognized arguments." )
16
+ private List <String > unknownOptions = new ArrayList <>();
15
17
@ Parameter (names = {"-h" , "--help" }, help = true , description = "Print this help text." )
16
18
private boolean help ;
17
19
@ Parameter (names = {"-c" , "--create \" base\" " }, order = 0 ,
18
20
description = "The type of RIM to create. A base RIM will be created by default." )
19
21
private String createType = "" ;
20
- @ Parameter (names = {"-v" , "--verify <path>" }, order = 3 ,
22
+ @ Parameter (names = {"-v" , "--verify <path>" }, validateWith = FileArgumentValidator . class ,
21
23
description = "Specify a RIM file to verify." )
22
24
private String verifyFile = "" ;
23
25
@ Parameter (names = {"-V" , "--version" }, description = "Output the current version." )
24
26
private boolean version = false ;
25
- @ Parameter (names = {"-a" , "--attributes <path>" }, order = 1 ,
27
+ @ Parameter (names = {"-a" , "--attributes <path>" }, validateWith = FileArgumentValidator . class ,
26
28
description = "The configuration file holding attributes "
27
- + "to populate the base RIM with." )
29
+ + "to populate the base RIM with. An example file can be found in /opt/rimtool/data. " )
28
30
private String attributesFile = "" ;
29
31
@ Parameter (names = {"-o" , "--out <path>" }, order = 2 ,
30
32
description = "The file to write the RIM out to. "
31
33
+ "The RIM will be written to stdout by default." )
32
34
private String outFile = "" ;
33
- @ Parameter (names = {"-t" , "--truststore <path>" }, order = 4 ,
35
+ @ Parameter (names = {"--verbose" }, description = "Control output verbosity." )
36
+ private boolean verbose = false ;
37
+ @ Parameter (names = {"-t" , "--truststore <path>" }, validateWith = FileArgumentValidator .class ,
34
38
description = "The truststore to sign the base RIM created "
35
39
+ "or to validate the signed base RIM." )
36
40
private String truststoreFile = "" ;
37
- @ Parameter (names = {"-k" , "--privateKeyFile <path>" }, order = 5 ,
41
+ @ Parameter (names = {"-k" , "--privateKeyFile <path>" },
42
+ validateWith = FileArgumentValidator .class ,
38
43
description = "The private key used to sign the base RIM created by this tool." )
39
44
private String privateKeyFile = "" ;
40
- @ Parameter (names = {"-p" , "--publicCertificate <path>" }, order = 6 ,
45
+ @ Parameter (names = {"-p" , "--publicCertificate <path>" },
46
+ validateWith = FileArgumentValidator .class ,
41
47
description = "The public key certificate to embed in the base RIM created by "
42
48
+ "this tool." )
43
49
private String publicCertificate = "" ;
44
50
@ Parameter (names = {"-e" , "--embed-cert" }, order = 7 ,
45
51
description = "Embed the provided certificate in the signed swidtag." )
46
52
private boolean embedded = false ;
47
53
@ Parameter (names = {"-d" , "--default-key" }, order = 8 ,
48
- description = "Use default signing credentials ." )
54
+ description = "Use the JKS keystore installed in /opt/rimtool/data ." )
49
55
private boolean defaultKey = false ;
50
- @ Parameter (names = {"-l" , "--rimel <path>" }, order = 9 ,
56
+ @ Parameter (names = {"-l" , "--rimel <path>" }, validateWith = FileArgumentValidator . class ,
51
57
description = "The TCG eventlog file to use as a support RIM." )
52
58
private String rimEventLog = "" ;
53
59
@ Parameter (names = {"--timestamp" }, order = 10 , variableArity = true ,
@@ -56,6 +62,10 @@ public class Commander {
56
62
"\t RFC3339 [yyyy-MM-ddThh:mm:ssZ]\n \t RFC3852 <counterSignature.bin>" )
57
63
private List <String > timestampArguments = new ArrayList <String >(2 );
58
64
65
+ public List <String > getUnknownOptions () {
66
+ return unknownOptions ;
67
+ }
68
+
59
69
public boolean isHelp () {
60
70
return help ;
61
71
}
@@ -71,6 +81,7 @@ public String getVerifyFile() {
71
81
public boolean isVersion () {
72
82
return version ;
73
83
}
84
+ public boolean isVerbose () { return verbose ; }
74
85
public String getAttributesFile () {
75
86
return attributesFile ;
76
87
}
@@ -101,26 +112,17 @@ public List<String> getTimestampArguments() {
101
112
102
113
public String printHelpExamples () {
103
114
StringBuilder sb = new StringBuilder ();
104
- sb .append ("Create a base RIM using the values in attributes.json; " +
105
- "sign it with the default keystore; " );
106
- sb .append ("and write the data to base_rim.swidtag:\n \n " );
107
- sb .append ("\t \t -c base -a attributes.json -d -l support_rim.bin -o base_rim.swidtag" +
108
- "\n \n \n " );
109
- sb .append ("Create a base RIM using the default attribute values; " );
110
- sb .append ("sign it using privateKey.pem; embed cert.pem in the signature block; " );
111
- sb .append ("and write the data to console output:\n \n " );
112
- sb .append ("\t \t -c base -l support_rim.bin -k privateKey.pem -p cert.pem -e\n \n \n " );
113
- sb .append ("Create a base RIM using the values in attributes.json; " +
114
- "sign it with the default keystore; add a RFC3852 timestamp; " );
115
- sb .append ("and write the data to base_rim.swidtag:\n \n " );
116
- sb .append ("\t \t -c base -a attributes.json -d -l support_rim.bin " +
117
- "--timestamp RFC3852 counterSignature.bin -o base_rim.swidtag\n \n \n " );
118
- sb .append ("Validate a base RIM using an external support RIM to override the " );
119
- sb .append ("payload file:\n \n " );
120
- sb .append ("\t \t -v base_rim.swidtag -l support_rim.bin\n \n \n " );
121
- sb .append ("Validate a base RIM with its own payload file and a PEM truststore " );
122
- sb .append ("containing the signing cert:\n \n " );
123
- sb .append ("\t \t -v base_rim.swidtag -t ca.crt\n \n \n " );
115
+ sb .append ("Create a base RIM: use the values in attributes.json; " );
116
+ sb .append ("add support_rim.bin to the payload; " );
117
+ sb .append ("sign it using privateKey.pem and cert.pem; embed cert.pem in the signature; " );
118
+ sb .append ("add a RFC3852 timestamp; and write the data to base_rim.swidtag:\n \n " );
119
+ sb .append ("\t \t -c base -a attributes.json -l support_rim.bin "
120
+ + "-k privateKey.pem -p cert.pem -e --timestamp RFC3852 counterSignature.bin "
121
+ + "-o base_rim.swidtag\n \n \n " );
122
+ sb .append ("Validate base_rim.swidtag: "
123
+ + "the payload <File> is validated with support_rim.bin; "
124
+ + "and the signature is validated with ca.crt:\n \n " );
125
+ sb .append ("\t \t -v base_rim.swidtag -l support_rim.bin -t ca.crt\n \n \n " );
124
126
125
127
return sb .toString ();
126
128
}
0 commit comments