2
2
3
3
import com .structurizr .Workspace ;
4
4
import com .structurizr .api .WorkspaceApiClient ;
5
+ import com .structurizr .encryption .AesEncryptionStrategy ;
5
6
import com .structurizr .util .StringUtils ;
6
7
import com .structurizr .util .WorkspaceUtils ;
7
8
import org .apache .commons .cli .*;
@@ -40,6 +41,10 @@ public void run(String... args) throws Exception {
40
41
option .setRequired (false );
41
42
options .addOption (option );
42
43
44
+ option = new Option ("passphrase" , "passphrase" , true , "Client-side encryption passphrase" );
45
+ option .setRequired (false );
46
+ options .addOption (option );
47
+
43
48
CommandLineParser commandLineParser = new DefaultParser ();
44
49
HelpFormatter formatter = new HelpFormatter ();
45
50
@@ -48,6 +53,7 @@ public void run(String... args) throws Exception {
48
53
String apiKey = "" ;
49
54
String apiSecret = "" ;
50
55
String branch = "" ;
56
+ String passphrase = "" ;
51
57
52
58
try {
53
59
CommandLine cmd = commandLineParser .parse (options , args );
@@ -57,6 +63,7 @@ public void run(String... args) throws Exception {
57
63
apiKey = cmd .getOptionValue ("apiKey" );
58
64
apiSecret = cmd .getOptionValue ("apiSecret" );
59
65
branch = cmd .getOptionValue ("branch" );
66
+ passphrase = cmd .getOptionValue ("passphrase" );
60
67
} catch (ParseException e ) {
61
68
log .error (e .getMessage ());
62
69
formatter .printHelp ("pull" , options );
@@ -76,6 +83,12 @@ public void run(String... args) throws Exception {
76
83
WorkspaceApiClient client = new WorkspaceApiClient (apiUrl , apiKey , apiSecret );
77
84
client .setBranch (branch );
78
85
client .setAgent (getAgent ());
86
+
87
+ if (!StringUtils .isNullOrEmpty (passphrase )) {
88
+ log .info (" - using client-side encryption" );
89
+ client .setEncryptionStrategy (new AesEncryptionStrategy (passphrase ));
90
+ }
91
+
79
92
Workspace workspace = client .getWorkspace (workspaceId );
80
93
81
94
WorkspaceUtils .saveWorkspaceToJson (workspace , file );
0 commit comments