Exemplo n.º 1
0
  @Override
  public Promise<SimpleResult> call(Context ctx) throws Throwable {

    Promise<SimpleResult> ret = null;

    // redirect if it's not secure
    if (!isHttpsRequest(ctx.request())) {
      String url = redirectHostHttps(ctx) + ctx.request().uri();
      ret = Promise.pure(redirect(url));
    } else {
      // Let request proceed.
      ret = delegate.call(ctx);
    }

    return ret;
  }
Exemplo n.º 2
0
  public static String redirectHostHttps(Context ctx) {

    String[] pieces = ctx.request().host().split(":");
    String ret = "https://" + pieces[0];

    // In Dev mode we want to append the port.
    // In Prod mode, no need to append the port as we use the standard https port, 443.
    if (isDev()) {
      ret += ":" + getHttpsPort();
    }

    return ret;
  }
Exemplo n.º 3
0
 @Override
 public String getUsername(Context ctx) {
   String cookieValue = ctx.session().get(Application.PASSWORD);
   return validate(cookieValue) ? "okay" : null;
 }
Exemplo n.º 4
0
 @Override
 public String getUsername(Context ctx) {
   return ctx.session().get("email");
 }