List of usage examples for org.apache.wicket.request Request getContainerRequest
public abstract Object getContainerRequest();
From source file:RedisSessionStore.java
License:Apache License
@Override public String getSessionId(Request request, boolean create) { String id = null;//from www .ja v a 2s.c o m HttpSession httpSession = getHttpSession(request, false); if (httpSession != null) { id = httpSession.getId(); } else { //Just because this server doesn't have a session doesn't mean the session doesn't already exist //see if the jsession id is being passed in String uri = ((HttpServletRequest) request.getContainerRequest()).getRequestURI(); String[] split = uri.split(";"); String jsessionid = null; if (split.length > 1 && split[1].contains("jsessionid=")) { //session exists, first check if it's already mapped: jsessionid = split[1].replace("jsessionid=", ""); } if (create || jsessionid != null) { //create a new session on this server httpSession = getHttpSession(request, true); id = httpSession.getId(); //now check whether this is a real new session or just a session that needs to be mapped if (jsessionid != null) { //session already exist in redis, but this tomcat needs to map back to it, so look up //the original session Object o = redisCache.getCacheObject(getKeyMapKey(jsessionid)); while (o != null) { //make sure this is the top jsessionid jsessionid = (String) o; o = redisCache.getCacheObject(getKeyMapKey(jsessionid)); } //we have the top session, so map it to this server's session id redisCache.storeCacheObject(getKeyMapKey(id), jsessionid); httpSession.setAttribute(KEY_REDIS_SESSION, jsessionid); } else { //no session being passed in and no existing session on this server, create a new one! log.info("New SessionId: " + id); IRequestLogger logger = Application.get().getRequestLogger(); if (logger != null) { logger.sessionCreated(id); } httpSession.setAttribute(KEY_REDIS_SESSION, id); } } } return id; }
From source file:RedisSessionStore.java
License:Apache License
protected final HttpServletRequest getHttpServletRequest(final Request request) { Object containerRequest = request.getContainerRequest(); if (containerRequest == null || (containerRequest instanceof HttpServletRequest) == false) { throw new IllegalArgumentException("Request must be ServletWebRequest"); }/*from ww w . j a v a 2 s.c o m*/ return (HttpServletRequest) containerRequest; }
From source file:at.molindo.wicketutils.utils.WicketUtils.java
License:Apache License
public static HttpServletRequest getHttpServletRequest(Request request) { Object cr = request != null ? request.getContainerRequest() : null; return cr instanceof HttpServletRequest ? (HttpServletRequest) cr : null; }
From source file:bugs.HttpSessionStoreModified.java
License:Apache License
/** * @param request//from ww w . j av a 2s. c o m * @return The http servlet request */ protected final HttpServletRequest getHttpServletRequest(final Request request) { Object containerRequest = request.getContainerRequest(); if (containerRequest == null || (containerRequest instanceof HttpServletRequest) == false) { throw new IllegalArgumentException("Request must be ServletWebRequest"); } return (HttpServletRequest) containerRequest; }
From source file:com.copperarrow.auth.SecureWebSession.java
License:Apache License
public SecureWebSession(Request request) { super(request); this.httpSession = ((HttpServletRequest) request.getContainerRequest()).getSession(); Injector.get().inject(this); }
From source file:com.evolveum.midpoint.web.security.SecurityUtils.java
License:Apache License
public static CsrfToken getCsrfToken() { Request req = RequestCycle.get().getRequest(); HttpServletRequest httpReq = (HttpServletRequest) req.getContainerRequest(); return (CsrfToken) httpReq.getAttribute("_csrf"); }
From source file:com.jolira.wicket.guicier.GuicierWebSession.java
License:Open Source License
private static Map<Key<?>, Provider<?>> getCachedProviders() { final RequestCycle requestCycle = RequestCycle.get(); final Request webRequest = requestCycle.getRequest(); final HttpServletRequest httpServletRequest = (HttpServletRequest) webRequest.getContainerRequest(); final HttpSession session = httpServletRequest.getSession(true); @SuppressWarnings("unchecked") Map<Key<?>, Provider<?>> cachedProviders = (Map<Key<?>, Provider<?>>) session .getAttribute(GUICIER_CHACHED_PROVIDERS); if (cachedProviders != null) { return cachedProviders; }/*w w w. j a v a2 s .c om*/ cachedProviders = new HashMap<Key<?>, Provider<?>>(); session.setAttribute(GUICIER_CHACHED_PROVIDERS, cachedProviders); return cachedProviders; }
From source file:com.mastfrog.acteur.wicket.ActeurSessionStore.java
License:Apache License
/** * * @param request//from w w w . j a v a2 s.c om * @return The http servlet request */ protected final HttpEvent getHttpServletRequest(final Request request) { Object containerRequest = request.getContainerRequest(); if (containerRequest == null || (containerRequest instanceof HttpEvent) == false) { throw new IllegalArgumentException("Request must be ServletWebRequest"); } return (HttpEvent) containerRequest; }
From source file:com.pushinginertia.wicket.core.RequestCycleUtils.java
License:Open Source License
/** * Obtains the HttpServletRequest from the request cycle. * @return null if the servlet request cannot be retrieved *//*from www . ja v a2 s. com*/ public static HttpServletRequest getHttpServletRequest() { final RequestCycle rc = RequestCycle.get(); if (rc == null) return null; final Request r = rc.getRequest(); return (HttpServletRequest) r.getContainerRequest(); }
From source file:com.pushinginertia.wicket.core.util.ComponentUtils.java
License:Open Source License
/** * Constructs a URL by using the same port and scheme/protocol as what was used to request the current page. * @param request object encapsulating the request to the server (used to obtain the container request) * @param hostName host name to use in the constructed URL * @param absolutePath absolute path to append after the host name (can be null), a leading '/' will be added if * omitted/* w w w .j av a 2s. c om*/ * @return */ public static String constructUrl(final Request request, final String hostName, final String absolutePath) { ValidateAs.notNull(request, "request"); ValidateAs.notEmpty(hostName, "hostName"); final HttpServletRequest req = (HttpServletRequest) request.getContainerRequest(); final String scheme = req.getScheme(); final int port = req.getServerPort(); final StringBuilder sb = new StringBuilder(scheme); sb.append("://"); sb.append(hostName); if (port > 0 && !PROTO_TO_PORT.get(scheme).equals(port)) { sb.append(':').append(port); } if (absolutePath != null && absolutePath.length() > 0) { if (!absolutePath.startsWith("/")) { sb.append('/'); } sb.append(absolutePath); } return sb.toString(); }