コード例 #1
0
  /**
   * Login the user.
   *
   * @param username, the username.
   * @param password, the password, may not be required (depends on the LoginSettings flags).
   * @return true if the user is successfully logged in.
   */
  public boolean login(String username, String password) {
    Log.debug("UserState.login");

    // perform the login
    try {
      _user = getCache().getUser(username);
      if (_user == null) {
        Log.log(
            User.ERR_USER_NOT_FOUND1.getText()
                + " ["
                + username
                + "] "
                + User.ERR_USER_NOT_FOUND2.getText());
        return false;
      }

      // validate password
      if (getLoginSettings().getFlags(LoginSettings.FLAG_REQUIRE_PASSWORD)) {
        // test the user against the security id
        SecurityId sid = new SecurityId(username, password);
        if (!_user.identityCheck(sid)) {
          _user = null;
          Log.log(User.ERR_INCORRECT_PASSWORD.getText() + " [" + sid.getName() + "]");
        }
      }
    } catch (Exception e) {
      _user = null;
    }
    return (_user != null);
  }
コード例 #2
0
  /**
   * Construct the RMI server. This parses command arguments [-host <hostname>] [-regport <bootstrap
   * registry port>] [ -context <ctx>] Note that this sets the singleton LocalServerFactory and adds
   * the context information to the Config singleton. The RMIServer will use the default, context,
   * commandline or Config information to locate the Secure registry. The Config singleton should be
   * properly initialized with any extra information before creating and running the server.
   *
   * @param args, the command line arguments.
   * @see LocalServerFactory.setArgs.
   * @see Config.addContext
   * @param loadContext, if false then the default server context or context specified in args is
   *     not loaded.
   */
  public RmiServer(String args[], boolean loadContext) {
    // create list to hold our servants
    _servants = new LinkedList();

    // default security uses the system ID created from Config data
    if (loadContext) {
      // load the rmi server context, or that in the command line
      Config.getSingleton().addContext(args, CKfw.RMISERVER_CONTEXT);
    }

    // load rebind period from Config, else default rebind every 30 seconds
    _rebindMS = Config.getProp(CKfw.RMISERVER_MS_REBIND, 30000);

    // send the args to LocalServerFactory so it can parse them
    LocalServerFactory.setArgs(args);

    // do this after the context is loaded so the config entries for
    // getSystemId have been set
    _securityId = SecurityId.getSystemId();

    // load servant ports from Config
    String servantPortKey = CKfw.RMISERVANT_PORTRANGE_PREFIX + getClass().getName();
    String servantPorts = Config.getProp(servantPortKey);
    // if there is a port range specified parse and set it
    if (servantPorts != null)
      try {
        StringTokenizer st = new StringTokenizer(servantPorts, "-");
        String sMin = st.nextToken();
        String sMax = st.nextToken();
        int min = Integer.parseInt(sMin);
        int max = Integer.parseInt(sMax);

        // check for validity
        if (min <= 0 || max <= 0 || max < min)
          Log.error(servantPortKey + "=" + servantPorts + " " + ERR_PORT_RANGE.getText());
        else {
          // valid, set the range
          _nextServantPort = min;
          _maxServantPort = max;
        }
      } catch (Exception e) {
        // parsing failed, log it
        Log.error(
            EXCEPTION_NOT_PARSE1.getText()
                + " "
                + servantPortKey
                + "="
                + servantPorts
                + ", "
                + EXCEPTION_NOT_PARSE2.getText()
                + " "
                + e.toString());
      }
  }
コード例 #3
0
 /**
  * Get the system id for authenticating with the secure registry.
  *
  * @return a system id loaded from Config data.
  */
 private static synchronized SecurityId getSystemId() {
   if (s_systemId == null) s_systemId = SecurityId.getSystemId();
   return s_systemId;
 }