/* (non-Javadoc)
  * @see uk.ac.ed.epcc.webapp.forms.transition.TransitionFactoryDataProvider#getTargets()
  */
 public Set<TableTransitionTarget> getTargets() {
   HashSet<TableTransitionTarget> result = new HashSet<TableTransitionTarget>();
   AppContext conn = getContext();
   Map<String, Class> classmap = conn.getClassMap(TableTransitionTarget.class);
   for (String key : classmap.keySet()) {
     result.add((TableTransitionTarget) conn.makeObject(classmap.get(key), key));
   }
   return result;
 }
Exemplo n.º 2
0
  @Override
  public ServletSessionService getSessionService(AppContext conn) {

    ServletSessionService sess = super.getSessionService(conn);

    if (sess != null && !sess.haveCurrentUser()) {
      Map<String, Object> params = conn.getService(ServletService.class).getParams();
      AppUserFactory fac = sess.getLoginFactory();
      PasswordAuthComposite<?> composite =
          (PasswordAuthComposite<?>) fac.getComposite(PasswordAuthComposite.class);
      if (composite != null) {
        String user = null;
        Object person = params.get("person");
        if (person != null) {
          user = person.toString();
        }
        String password = null;
        Object pass_obj = params.get("password");
        if (pass_obj != null) {
          password = pass_obj.toString();
        }
        if (user != null && password != null) {
          try {

            AppUser p =
                composite.findByLoginNamePassword(user, password, CHECK_API_FAILS.isEnabled(conn));
            if (p != null && p.canLogin()) {
              sess.setCurrentPerson(p);
            }
          } catch (DataException e) {
            conn.getService(LoggerService.class)
                .getLogger(getClass())
                .error("Error locating person", e);
          }
        }
      }
    }
    return sess;
  }
Exemplo n.º 3
0
  public static void anonymise(AppContext c, String table) throws DataFault {
    try {
      if (Repository.READ_ONLY_FEATURE.isEnabled(c)) {
        return;
      }
      SQLContext conn = c.getService(DatabaseService.class).getSQLContext();
      if (conn == null) {
        throw new DataFault("No connection");
      }

      StringBuilder sb = new StringBuilder();
      sb.append("UPDATE ");
      conn.quote(sb, table);
      sb.append(" SET ");
      conn.quote(sb, MESSAGE);
      sb.append("=null");

      Statement stmt = conn.getConnection().createStatement();
      int results = stmt.executeUpdate(sb.toString());
      stmt.close();
    } catch (SQLException e) {
      throw new DataFault("Error in delete", e);
    }
  }