@Override public int getPort(HttpsConfig config) { return config.getHttpPort(); } },
@Override public boolean usesStandardPort(HttpsConfig config) { return getPort(config) == 443; }
@Override public boolean usesStandardPort(HttpsConfig config) { return getPort(config) == 80; }
@Override public final IRequestHandler mapRequest(Request request) { IRequestHandler handler = delegate.mapRequest(request); Scheme desired = getDesiredSchemeFor(handler); Scheme current = getSchemeOf(request); if (!desired.isCompatibleWith(current)) { // we are currently on the wrong scheme for this handler // construct a url for the handler on the correct scheme String url = createRedirectUrl(handler, request, desired); // replace handler with one that will redirect to the created url handler = createRedirectHandler(url); } return handler; }
/** {@inheritDoc} */ @Override public IRequestTarget resolve(RequestCycle rc, RequestParameters rp) { if (portConfig != null && portConfig.isPreferStateful()) { // we need to persist the session before a redirect to https so the session lasts across // both http and https calls. Session.get().bind(); } IRequestTarget target = super.resolve(rc, rp); return checkSecure(target); }
/** * Creates the {@link IRequestHandler} that will be responsible for the * redirect * * @param url * @return request handler */ protected IRequestHandler createRedirectHandler(String url) { return new HttpsMapper.RedirectHandler(url, config); }
@Override public int getPort(HttpsConfig config) { return config.getHttpsPort(); } },
/** * @return scheme's url name */ public String urlName() { return name().toLowerCase(Locale.ROOT); }
@Override public final Url mapHandler(IRequestHandler handler) { return mapHandler(handler, RequestCycle.get().getRequest()); }
/** * Implement this interface if webpages should be accessible only over ssl(https). You can secure * webpages by implementing this interface. * * @author Asterios Raptis */ @RequireHttps public interface SSLable { }
/** * Returns a target that can be used to redirect to the specified protocol. If no change is * required null will be returned. * * @param protocol * required protocol * @return request target or null */ public static IRequestTarget requireProtocol(Protocol protocol) { return requireProtocol(protocol, null); }
@Override public final IRequestHandler mapRequest(Request request) { IRequestHandler handler = delegate.mapRequest(request); Scheme desired = getDesiredSchemeFor(handler); Scheme current = getSchemeOf(request); if (!desired.isCompatibleWith(current)) { // we are currently on the wrong scheme for this handler // construct a url for the handler on the correct scheme String url = createRedirectUrl(handler, request, desired); // replace handler with one that will redirect to the created url handler = createRedirectHandler(url); } return handler; }
/** * Creates the {@link IRequestHandler} that will be responsible for the redirect * * @param url * @return request handler */ protected IRequestHandler createRedirectHandler(String url) { return new RedirectHandler(url, config); }
@Override public int getPort(HttpsConfig config) { return config.getHttpPort(); } },
@Override public int getPort(HttpsConfig config) { return config.getHttpsPort(); } },
@Override public boolean usesStandardPort(HttpsConfig config) { return getPort(config) == 443; }
@Override public boolean usesStandardPort(HttpsConfig config) { return getPort(config) == 80; }
/** * @return scheme's url name */ public String urlName() { return name().toLowerCase(Locale.ROOT); }
@Override public final Url mapHandler(IRequestHandler handler) { return mapHandler(handler, RequestCycle.get().getRequest()); }
/** * Creates the {@link IRequestHandler} that will be responsible for the redirect * * @param url * @return request handler */ protected IRequestHandler createRedirectHandler(String url) { return new RedirectHandler(url, config); }