@BeforeMethod
  public void beforeTestMethods() {
    connection = SolarisTestCommon.getSolarisConn();
    configuration = connection.getConfiguration();
    facade = SolarisTestCommon.createConnectorFacade(getConfiguration());

    System.out.println("TEST HOST: " + connection.getConfiguration().getHost());

    generateUsers();
    generateGroup(CollectionUtil.newList("root"));
  }
예제 #2
0
  private Map<NativeAttribute, String> buildPasswdSwitches(
      SolarisEntry entry, SolarisConnection conn) {
    Map<NativeAttribute, String> passwdSwitches =
        new EnumMap<NativeAttribute, String>(NativeAttribute.class);
    passwdSwitches.put(NativeAttribute.PWSTAT, "-f");
    // passwdSwitches.put(NativeAttribute.PW_LAST_CHANGE, null); // this is
    // not used attribute (see LoginsCommand and its SVIDRA counterpart).
    // TODO erase this comment.
    passwdSwitches.put(NativeAttribute.MIN_DAYS_BETWEEN_CHNG, "-n");
    passwdSwitches.put(NativeAttribute.MAX_DAYS_BETWEEN_CHNG, "-x");
    passwdSwitches.put(NativeAttribute.DAYS_BEFORE_TO_WARN, "-w");

    String lockFlag = null;
    Attribute lock = entry.searchForAttribute(NativeAttribute.LOCK);
    if (lock != null) {
      Object lockValue = AttributeUtil.getSingleValue(lock);
      if (lockValue == null) {
        throw new IllegalArgumentException("missing value for attribute LOCK");
      }
      boolean isLock = (Boolean) lockValue;
      if (isLock) {
        lockFlag = "-l";
      } else {
        // *unlocking* differs in Solaris 8,9 and in Solaris 10+:
        lockFlag = (conn.isVersionLT10()) ? "-df" : "-u";
        passwdSwitches.put(NativeAttribute.LOCK, lockFlag);
      }
    }
    if (lockFlag != null) {
      passwdSwitches.put(NativeAttribute.LOCK, lockFlag);
    }
    return passwdSwitches;
  }
 @AfterMethod
 public void afterTestMethods() {
   cleanUpUsers();
   cleanupGroup();
   try {
     if (connection != null) {
       connection.dispose();
     }
   } catch (Exception ex) {
     // OK
   }
 }
예제 #4
0
  @Override
  public void configurePasswordProperties(SolarisEntry entry, SolarisConnection conn) {
    Map<NativeAttribute, String> passwdSwitches = buildPasswdSwitches(entry, conn);
    final String cmdSwitches = CommandSwitches.formatCommandSwitches(entry, conn, passwdSwitches);
    if (cmdSwitches.length() == 0) {
      return; // no password related attribute present in the entry.
    }

    try {
      final String command = conn.buildCommand(true, "passwd", cmdSwitches, entry.getName());
      final String out = conn.executeCommand(command);
      final String loweredOut = out.toLowerCase();
      if (loweredOut.contains("usage:")
          || loweredOut.contains("password aging is disabled")
          || loweredOut.contains("command not found")) {
        throw new ConnectorException(
            "Error during configuration of password related attributes. Buffer content: <"
                + out
                + ">");
      }
    } catch (Exception ex) {
      throw ConnectorException.wrap(ex);
    }
  }