Ejemplo n.º 1
0
  /** Creates the actions. */
  @Override
  public void createActions(MigrationContext ctx) throws MigrationException {

    // Config fragments
    for (IConfigFragment fragment :
        ctx.getMigrationData().get(SecurityMigrator.class).getConfigFragments()) {
      if (fragment instanceof ApplicationPolicyBean) {
        try {
          SecurityDomainBean appPolicy = migrateAppPolicy((ApplicationPolicyBean) fragment, ctx);
          ctx.getActions().addAll(createSecurityDomainCliAction(appPolicy));
        } catch (CliScriptException e) {
          throw new MigrationException(
              "Migration of application-policy failed: " + e.getMessage(), e);
        }
        continue;
      }
      throw new MigrationException(
          "Config fragment unrecognized by " + this.getClass().getSimpleName() + ": " + fragment);
    }

    // Files to copy
    File as5profileDir = getGlobalConfig().getAS5Config().getProfileDir();
    String as7Dir = getGlobalConfig().getAS7Config().getDir();

    for (String fileName : this.fileNames) {
      File src;
      try {
        // TODO: MIGR-54 The paths in AS 5 config relate to some base dir. Find out which and use
        // that, instead of searching.
        //       Then, create the actions directly in the code creating this "files to copy"
        // collection.
        src = Utils.searchForFile(fileName, as5profileDir).iterator().next();
      } catch (CopyException ex) {
        // throw new ActionException("Failed copying a security file: " + ex.getMessage(), ex);
        // Some files referenced in security may not exist. (?)
        log.warn("Couldn't find file referenced in AS 5 security config: " + fileName);
        continue;
      }

      File target = Utils.createPath(as7Dir, "standalone", "configuration", src.getName());

      // Default value for overwrite => false
      ctx.getActions().add(new CopyFileAction(this.getClass(), src, target, false));
    }
  }
Ejemplo n.º 2
0
  /** Loads the AS 5 data. */
  @Override
  public void loadAS5Data(MigrationContext ctx) throws LoadMigrationException {
    try {
      File file = new File(getGlobalConfig().getAS5Config().getConfDir(), "login-config.xml");
      if (!file.canRead()) {
        throw new LoadMigrationException("Can't read: " + file.getAbsolutePath());
      }

      Unmarshaller unmarshaller =
          JAXBContext.newInstance(SecurityAS5Bean.class).createUnmarshaller();
      SecurityAS5Bean securityAS5 = (SecurityAS5Bean) unmarshaller.unmarshal(file);

      MigrationData mData = new MigrationData();
      mData.getConfigFragments().addAll(securityAS5.getApplicationPolicies());

      ctx.getMigrationData().put(SecurityMigrator.class, mData);
    } catch (JAXBException e) {
      throw new LoadMigrationException(e);
    }
  }