Esempio n. 1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  private void setNamePassword(final User inUser, final String inName, final String inPass) {
    if (inUser == null) {
      return;
    }

    Dictionary lProperties = inUser.getProperties();
    lProperties.put(Constants.KEY_USER, inName);

    lProperties = inUser.getCredentials();
    lProperties.put(Constants.KEY_PW, inPass);
  }
Esempio n. 2
0
  private boolean allowUser(String username, String password) {
    if (userAdmin != null) {
      User user = userAdmin.getUser("org.energy_home.jemma.username", username);
      if (user == null) {
        return false;
      }
      if (!user.hasCredential("org.energy_home.jemma.password", password)) {
        return false;
      }

      return true;
    }
    return false;
  }
Esempio n. 3
0
  private Authorization login(
      HttpServletRequest request, final String username, final String password)
      throws LoginException {
    Authorization a = (Authorization) request.getAttribute(HttpContext.AUTHORIZATION);
    if (a != null) {
      return a;
    }

    if (userAdmin != null) {
      User user = userAdmin.getUser("it.telecomitalia.username", username);
      if (user == null) {
        throw new LoginException();
      }
      if (!user.hasCredential("it.telecomitalia.password", password)) {
        throw new LoginException();
      }

      return userAdmin.getAuthorization(user);
    }

    throw new LoginException();
  }