/** * Creates a CLI script for adding Security-Domain to AS7 * * @param securityDomain object representing migrated security-domain * @return created string containing the CLI script for adding the Security-Domain * @throws CliScriptException if required attributes are missing */ private static String createSecurityDomainScript(SecurityDomainBean securityDomain) throws CliScriptException { String errMsg = " in security-domain must be set."; Utils.throwIfBlank(securityDomain.getSecurityDomainName(), errMsg, "Security name"); CliAddScriptBuilder builder = new CliAddScriptBuilder(); StringBuilder resultScript = new StringBuilder("/subsystem=security/security-domain="); resultScript.append(securityDomain.getSecurityDomainName()).append(":add("); builder.addProperty("cache-type", securityDomain.getCacheType()); resultScript.append(builder.asString()).append(")"); return resultScript.toString(); }
/** * Creates a CLI script for adding a Login-Module of the specific Security-Domain * * @param domain Security-Domain containing Login-Module * @param module Login-Module * @return created string containing the CLI script for adding the Login-Module */ private static String createLoginModuleScript( SecurityDomainBean domain, LoginModuleAS7Bean module) { StringBuilder resultScript = new StringBuilder("/subsystem=security/security-domain=" + domain.getSecurityDomainName()); resultScript.append("/authentication=classic:add(login-modules=[{"); if ((module.getLoginModuleCode() != null) && !(module.getLoginModuleCode().isEmpty())) { resultScript.append("\"code\"=>\"").append(module.getLoginModuleCode()).append("\""); } if ((module.getLoginModuleFlag() != null) && !(module.getLoginModuleFlag().isEmpty())) { resultScript.append(", \"flag\"=>\"").append(module.getLoginModuleFlag()).append("\""); } if ((module.getModuleOptions() != null) && !(module.getModuleOptions().isEmpty())) { StringBuilder modulesBuilder = new StringBuilder(); for (ModuleOptionAS7Bean moduleOptionAS7 : module.getModuleOptions()) { modulesBuilder.append(", (\"").append(moduleOptionAS7.getModuleOptionName()).append("\"=>"); modulesBuilder.append("\"").append(moduleOptionAS7.getModuleOptionValue()).append("\")"); } String modules = modulesBuilder.toString().replaceFirst(",", ""); modules = modules.replaceFirst(" ", ""); if (!modules.isEmpty()) { resultScript.append(", \"module-option\"=>[").append(modules).append("]"); } } return resultScript.toString(); }