Ejemplo n.º 1
0
  /**
   * 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();
  }
Ejemplo n.º 2
0
  /**
   * Creates a list of CliCommandActions for adding a Security-Domain
   *
   * @param domain Security-Domain
   * @return created list containing CliCommandActions for adding the Security-Domain
   * @throws CliScriptException if required attributes for a creation of the CLI command of the
   *     Security-Domain are missing or are empty (security-domain-name)
   */
  public static List<CliCommandAction> createSecurityDomainCliAction(SecurityDomainBean domain)
      throws CliScriptException {
    String errMsg = " in security-domain must be set.";
    Utils.throwIfBlank(domain.getSecurityDomainName(), errMsg, "Security name");

    List<CliCommandAction> actions = new ArrayList();

    ModelNode domainCmd = new ModelNode();
    domainCmd.get(ClientConstants.OP).set(ClientConstants.ADD);
    domainCmd.get(ClientConstants.OP_ADDR).add("subsystem", "security");
    domainCmd.get(ClientConstants.OP_ADDR).add("security-domain", domain.getSecurityDomainName());

    actions.add(
        new CliCommandAction(
            SecurityMigrator.class, createSecurityDomainScript(domain), domainCmd));

    if (domain.getLoginModules() != null) {
      for (LoginModuleAS7Bean module : domain.getLoginModules()) {
        actions.add(createLoginModuleCliAction(domain, module));
      }
    }

    return actions;
  }