@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; }
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; }
@Override public String getUsername(Context ctx) { String cookieValue = ctx.session().get(Application.PASSWORD); return validate(cookieValue) ? "okay" : null; }
@Override public String getUsername(Context ctx) { return ctx.session().get("email"); }