/**
  * The authentication result is written to a request attribute called "loginResult".
  *
  * <p>Its value is "true" if login succeeded and "false" if not. Note that a successful login does
  * not ensure that that authorisation will succeed.
  *
  * <p>If rendering a login page based on authentication and authorisation you should also look at
  * the "authReason" attribute set by the LoginResponseHandler which gives the reason for an
  * authorisation failure
  *
  * @param resource
  * @param request
  * @return
  */
 @Override
 public Object authenticate(Resource resource, Request request) {
   String userName = request.getParams().get(userNameParam);
   String pwd = request.getParams().get(passwordParam);
   Object o = resource.authenticate(userName, pwd);
   // set a request attribute that can be used when rendering
   if (o == null) {
     log.trace("Form authentication failed");
     request.getAttributes().put("loginResult", Boolean.FALSE);
   } else {
     log.trace("Form authentication succeeded");
     request.getAttributes().put("loginResult", Boolean.TRUE);
   }
   return o;
 }
 private ExternalIdentityProvider getSelectedIP(Request request) {
   List<ExternalIdentityProvider> list = authenticationService.getExternalIdentityProviders();
   if (list.size() == 1) {
     return list.get(0);
   } else {
     String ipName = request.getParams().get("_ip");
     if (ipName != null && ipName.length() > 0) {
       for (ExternalIdentityProvider eip : list) {
         if (ipName.equals(eip.getName())) {
           return eip;
         }
       }
     }
     return null;
   }
 }
示例#3
0
  public static ReplicaInfo forRequest(Request request) {
    Map<String, String> parameters = request.getParams();

    if (parameters == null) {
      return EMPTY_INFO;
    }

    String r1 = parameters.get("r1");

    if (isNullOrEmpty(parameters.get("rid")) || isNullOrEmpty(r1) || r1.indexOf(',') == -1) {
      LOG.trace("returning empty QueryStringInfo for request");
      return EMPTY_INFO;
    } else {
      LOG.trace("returning non-empty QueryStringInfo for request");
      return new ReplicaInfo(request);
    }
  }
示例#4
0
 private ReplicaInfo(Request request) {
   _parameters = request.getParams();
 }
 private boolean isLogin(Request request) {
   return (request.getMethod() == Method.POST && request.getParams().get(userNameParam) != null);
 }
 @Override
 public boolean credentialsPresent(Request request) {
   return request.getParams() != null && request.getParams().containsKey(userNameParam);
 }