List of usage examples for org.apache.wicket.request.http WebRequest getCookie
public Cookie getCookie(final String cookieName)
From source file:net.databinder.auth.AuthDataSessionBase.java
License:Open Source License
/** * Attempts cookie sign in, which will set usename field but not user. * @return true if signed in, false if credentials incorrect or unavailable */// www . j a v a 2s . c o m protected boolean cookieSignIn() { WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); Cookie userCookie = webRequest.getCookie(getUserCookieName()); Cookie token = webRequest.getCookie(getAuthCookieName()); if (userCookie != null && token != null) { T potential; try { potential = getUser(URLDecoder.decode(userCookie.getValue(), CHARACTER_ENCODING)); } catch (UnsupportedEncodingException e) { throw new WicketRuntimeException(e); } if (potential != null && potential instanceof DataUser) { String correctToken = getApp().getToken(potential); if (correctToken.equals(token.getValue())) signIn(potential, false); } } return userModel != null; }
From source file:net.databinder.auth.AuthDataSessionBase.java
License:Open Source License
/** Nullifies userModela nd clears authentication cookies. */ protected void clearUser() { userModel = null;//from w ww.jav a2 s. c o m WebResponse webResponse = (WebResponse) RequestCycle.get().getResponse(); WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest(); Cookie userCookie = webRequest.getCookie(getUserCookieName()); Cookie token = webRequest.getCookie(getAuthCookieName()); webResponse.clearCookie(userCookie); webResponse.clearCookie(token); }
From source file:org.artifactory.common.wicket.util.CookieUtils.java
License:Open Source License
public static String getCookie(String name) { WebRequest request = (WebRequest) RequestCycle.get().getRequest(); Cookie cookie = request.getCookie(name); if (cookie == null) { return null; }//from www . j a v a 2s . c o m return cookie.getValue(); }
From source file:org.brixcms.web.BrixRequestCycleProcessor.java
License:Apache License
public String getWorkspace() { String workspace = getWorkspaceFromUrl(); if (workspace != null) { return workspace; }//from www . j a v a2 s . c om RequestCycle rc = RequestCycle.get(); workspace = rc.getMetaData(WORKSPACE_METADATA); if (workspace == null) { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); WebResponse resp = (WebResponse) RequestCycle.get().getResponse(); Cookie cookie = req.getCookie(COOKIE_NAME); workspace = getDefaultWorkspaceName(); if (cookie != null) { if (cookie.getValue() != null) workspace = cookie.getValue(); } if (!checkSession(workspace)) { workspace = getDefaultWorkspaceName(); } if (workspace == null) { throw new IllegalStateException("Could not resolve jcr workspace to use for this request"); } Cookie c = new Cookie(COOKIE_NAME, workspace); c.setPath("/"); if (workspace.toString().equals(getDefaultWorkspaceName()) == false) resp.addCookie(c); else if (cookie != null) resp.clearCookie(cookie); rc.setMetaData(WORKSPACE_METADATA, workspace); } return workspace; }
From source file:org.brixcms.web.BrixRequestMapper.java
License:Apache License
public String getWorkspace() { String workspace = getWorkspaceFromUrl(); if (workspace != null) { return workspace; }/*w w w . j a v a 2 s . c o m*/ RequestCycle rc = RequestCycle.get(); workspace = rc.getMetaData(WORKSPACE_METADATA); if (workspace == null) { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); WebResponse resp = (WebResponse) RequestCycle.get().getResponse(); Cookie cookie = req.getCookie(COOKIE_NAME); workspace = getDefaultWorkspaceName(); if (cookie != null) { if (cookie.getValue() != null) { workspace = cookie.getValue(); } } if (!checkSession(workspace)) { workspace = getDefaultWorkspaceName(); } if (workspace == null) { throw new IllegalStateException("Could not resolve jcr workspace to use for this request"); } Cookie c = new Cookie(COOKIE_NAME, workspace); c.setPath("/"); if (workspace.toString().equals(getDefaultWorkspaceName()) == false) { resp.addCookie(c); } else if (cookie != null) { resp.clearCookie(cookie); } rc.setMetaData(WORKSPACE_METADATA, workspace); } return workspace; }
From source file:org.brixcms.workspace.WorkspaceUtils.java
License:Apache License
public static String getWorkspace() { String workspace = getWorkspaceFromUrl(); if (workspace != null) { return workspace; }/*from ww w. ja v a 2 s.co m*/ RequestCycle rc = RequestCycle.get(); workspace = rc.getMetaData(WORKSPACE_METADATA); if (workspace == null) { WebRequest req = (WebRequest) RequestCycle.get().getRequest(); WebResponse resp = (WebResponse) RequestCycle.get().getResponse(); Cookie cookie = req.getCookie(COOKIE_NAME); workspace = getDefaultWorkspaceName(); if (cookie != null) { if (cookie.getValue() != null) workspace = cookie.getValue(); } if (!checkSession(workspace)) { workspace = getDefaultWorkspaceName(); } if (workspace == null) { throw new IllegalStateException("Could not resolve jcr workspace to use for this request"); } Cookie c = new Cookie(COOKIE_NAME, workspace); c.setPath("/"); if (workspace.toString().equals(getDefaultWorkspaceName()) == false) resp.addCookie(c); else if (cookie != null) resp.clearCookie(cookie); rc.setMetaData(WORKSPACE_METADATA, workspace); } return workspace; }
From source file:org.wicketstuff.rest.utils.reflection.MethodParameter.java
License:Apache License
/** * Extract method parameter's value from cookies. * * @param cookieParam the cookie param/*www . ja v a 2 s. com*/ * @return the extracted value converted to argClass. */ private Object extractParameterFromCookies(CookieParam cookieParam) { String value = cookieParam.value(); WebRequest webRequest = AbstractRestResource.getCurrentWebRequest(); if (webRequest.getCookie(value) == null) return null; return AbstractRestResource.toObject(parameterClass, webRequest.getCookie(value).getValue()); }