22
33import com .structurizr .Workspace ;
44import com .structurizr .api .WorkspaceApiClient ;
5+ import com .structurizr .encryption .AesEncryptionStrategy ;
56import com .structurizr .util .StringUtils ;
67import com .structurizr .util .WorkspaceUtils ;
78import org .apache .commons .cli .*;
@@ -40,6 +41,10 @@ public void run(String... args) throws Exception {
4041 option .setRequired (false );
4142 options .addOption (option );
4243
44+ option = new Option ("passphrase" , "passphrase" , true , "Client-side encryption passphrase" );
45+ option .setRequired (false );
46+ options .addOption (option );
47+
4348 CommandLineParser commandLineParser = new DefaultParser ();
4449 HelpFormatter formatter = new HelpFormatter ();
4550
@@ -48,6 +53,7 @@ public void run(String... args) throws Exception {
4853 String apiKey = "" ;
4954 String apiSecret = "" ;
5055 String branch = "" ;
56+ String passphrase = "" ;
5157
5258 try {
5359 CommandLine cmd = commandLineParser .parse (options , args );
@@ -57,6 +63,7 @@ public void run(String... args) throws Exception {
5763 apiKey = cmd .getOptionValue ("apiKey" );
5864 apiSecret = cmd .getOptionValue ("apiSecret" );
5965 branch = cmd .getOptionValue ("branch" );
66+ passphrase = cmd .getOptionValue ("passphrase" );
6067 } catch (ParseException e ) {
6168 log .error (e .getMessage ());
6269 formatter .printHelp ("pull" , options );
@@ -76,6 +83,12 @@ public void run(String... args) throws Exception {
7683 WorkspaceApiClient client = new WorkspaceApiClient (apiUrl , apiKey , apiSecret );
7784 client .setBranch (branch );
7885 client .setAgent (getAgent ());
86+
87+ if (!StringUtils .isNullOrEmpty (passphrase )) {
88+ log .info (" - using client-side encryption" );
89+ client .setEncryptionStrategy (new AesEncryptionStrategy (passphrase ));
90+ }
91+
7992 Workspace workspace = client .getWorkspace (workspaceId );
8093
8194 WorkspaceUtils .saveWorkspaceToJson (workspace , file );
0 commit comments