コード例 #1
0
  public Request init(Request request) {
    // see if we have an env map already parsed in the request
    Object obj = request.getKvp().get("env");
    Map<String, Object> envVars = null;
    if (obj instanceof Map) {
      envVars = (Map) obj;
    }

    // inject the current user in it
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth != null && !(auth instanceof AnonymousAuthenticationToken)) {
      String name = auth.getName();
      if (envVars == null) {
        envVars = new HashMap<String, Object>();
      }
      envVars.put("GSUSER", name);
    }

    // set it into the EnvFunction
    if (envVars != null) {
      EnvFunction.setLocalValues(envVars);
    }

    return request;
  }
コード例 #2
0
 public void finished(Request request) {
   // clean up when we're done
   EnvFunction.clearLocalValues();
 }