88import sys
99
1010from java .io import File
11+ from java .io import IOException
1112from java .lang import IllegalArgumentException
1213from java .lang import IllegalStateException
14+ from java .lang import String
1315from java .lang import System
1416from oracle .weblogic .deploy .aliases import AliasException
1517from oracle .weblogic .deploy .discover import DiscoverException
3941from wlsdeploy .tool .discover .deployments_discoverer import DeploymentsDiscoverer
4042from wlsdeploy .tool .discover .domain_info_discoverer import DomainInfoDiscoverer
4143from wlsdeploy .tool .discover .multi_tenant_discoverer import MultiTenantDiscoverer
44+ from wlsdeploy .tool .discover .opss_wallet_discoverer import OpssWalletDiscoverer
4245from wlsdeploy .tool .discover .resources_discoverer import ResourcesDiscoverer
4346from wlsdeploy .tool .discover .security_provider_data_discoverer import SecurityProviderDataDiscoverer
4447from wlsdeploy .tool .discover .topology_discoverer import TopologyDiscoverer
5255from wlsdeploy .util import cla_helper
5356from wlsdeploy .util import cla_utils
5457from wlsdeploy .util import env_helper
58+ from wlsdeploy .util import getcreds
5559from wlsdeploy .util import model_translator
5660from wlsdeploy .util import path_helper
5761from wlsdeploy .util import tool_main
6064from wlsdeploy .util .exit_code import ExitCode
6165from wlsdeploy .util .model import Model
6266from wlsdeploy .util import target_configuration_helper
67+ from wlsdeploy .util import unicode_helper as str_helper
6368
6469wlst_helper .wlst_functions = globals ()
6570
96101 CommandLineArgUtil .PASSPHRASE_FILE_SWITCH ,
97102 CommandLineArgUtil .PASSPHRASE_PROMPT_SWITCH ,
98103 CommandLineArgUtil .DISCOVER_SECURITY_PROVIDER_DATA_SWITCH ,
104+ CommandLineArgUtil .DISCOVER_OPSS_WALLET_SWITCH ,
105+ CommandLineArgUtil .OPSS_WALLET_PASSPHRASE_SWITCH ,
106+ CommandLineArgUtil .OPSS_WALLET_PASSPHRASE_ENV_SWITCH ,
107+ CommandLineArgUtil .OPSS_WALLET_PASSPHRASE_FILE_SWITCH ,
99108 CommandLineArgUtil .TARGET_SWITCH ,
100109 CommandLineArgUtil .REMOTE_SWITCH ,
101110 CommandLineArgUtil .SSH_HOST_SWITCH ,
@@ -140,6 +149,7 @@ def __process_args(args, is_encryption_supported):
140149
141150 model_context = model_context_helper .create_context (_program_name , argument_map )
142151 __validate_discover_passwords_and_security_data_args (model_context , argument_map , is_encryption_supported )
152+ __validate_discover_opss_wallet_args (model_context , argument_map , is_encryption_supported )
143153 model_context .get_validate_configuration ().set_disregard_version_invalid_elements (True )
144154 return model_context
145155
@@ -280,13 +290,22 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
280290 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
281291 raise ex
282292 elif model_context .is_discover_security_provider_data ():
293+ if model_context .get_target_wlst_mode () == WlstModes .OFFLINE :
294+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR , 'WLSDPLY-06059' ,_program_name ,
295+ CommandLineArgUtil .DISCOVER_SECURITY_PROVIDER_DATA_SWITCH )
296+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
297+ raise ex
298+
283299 # -remote cannot be supported because we need access to the exported data files and possibly SSI.dat.
284300 if model_context .is_remote ():
285301 ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR , 'WLSDPLY-06058' ,_program_name ,
286302 CommandLineArgUtil .DISCOVER_SECURITY_PROVIDER_DATA_SWITCH ,
287303 CommandLineArgUtil .REMOTE_SWITCH )
288304 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
289305 raise ex
306+ elif model_context .is_discover_opss_wallet ():
307+ # Allow the encryption passphrase
308+ pass
290309 elif model_context .get_encryption_passphrase () is not None :
291310 # Don't allow the passphrase arg unless we are discovering passwords or security provider data.
292311 if CommandLineArgUtil .PASSPHRASE_ENV_SWITCH in argument_map :
@@ -323,7 +342,8 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
323342 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
324343 raise ex
325344
326- if model_context .is_discover_passwords () or model_context .is_discover_security_provider_data ():
345+ if model_context .is_discover_passwords () or model_context .is_discover_security_provider_data () or \
346+ model_context .is_discover_opss_wallet ():
327347 if not model_context .is_encrypt_discovered_passwords () and model_context .get_encryption_passphrase () is not None :
328348 # don't allow turning off encryption and supplying an encryption passphrase
329349 if model_context .is_discover_passwords ():
@@ -345,6 +365,36 @@ def __validate_discover_passwords_and_security_data_args(model_context, argument
345365 __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
346366 raise ex
347367
368+
369+ def __validate_discover_opss_wallet_args (model_context , argument_map , is_encryption_supported ):
370+ _method_name = '__validate_discover_opss_wallet_args'
371+
372+ if CommandLineArgUtil .DISCOVER_OPSS_WALLET_SWITCH in argument_map :
373+ if model_context .get_target_wlst_mode () == WlstModes .OFFLINE :
374+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR , 'WLSDPLY-06060' ,_program_name ,
375+ CommandLineArgUtil .DISCOVER_OPSS_WALLET_SWITCH )
376+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
377+ raise ex
378+
379+ # Cannot verify that JRF is installed because the model_content is not fully
380+ # initialized at this point so the domain typedef is not available.
381+ if model_context .get_opss_wallet_passphrase () is None :
382+ try :
383+ passphrase_char_array = getcreds .getpass ('WLSDPLY-06061' )
384+ except IOException , ioe :
385+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,'WLSDPLY-06062' ,
386+ ioe .getLocalizedMessage (), error = ioe )
387+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
388+ raise ex
389+
390+ if passphrase_char_array is not None :
391+ opss_wallet_passphrase = str_helper .to_string (String (passphrase_char_array ))
392+ model_context .set_opss_wallet_passphrase (opss_wallet_passphrase )
393+ else :
394+ ex = exception_helper .create_cla_exception (ExitCode .ARG_VALIDATION_ERROR ,'WLSDPLY-06063' )
395+ __logger .throwing (ex , class_name = _class_name , method_name = _method_name )
396+ raise ex
397+
348398def __discover (model_context , aliases , credential_injector , helper , extra_tokens ):
349399 """
350400 Populate the model from the domain.
@@ -378,6 +428,8 @@ def __discover(model_context, aliases, credential_injector, helper, extra_tokens
378428 extra_tokens = extra_tokens ).discover ()
379429 SecurityProviderDataDiscoverer (model_context , model , base_location , wlst_mode = __wlst_mode , aliases = aliases ,
380430 credential_injector = credential_injector ).discover (security_provider_map )
431+ OpssWalletDiscoverer (model_context , model .get_model_domain_info (), base_location , wlst_mode = __wlst_mode ,
432+ aliases = aliases , credential_injector = credential_injector ).discover ()
381433 __discover_multi_tenant (model , model_context , base_location , aliases , credential_injector )
382434 except AliasException , ae :
383435 wls_version = model_context .get_effective_wls_version ()
0 commit comments