List of usage examples for com.google.gwt.user.client Cookies getCookie
public static String getCookie(String name)
From source file:com.blackducksoftware.tools.commonframework.core.gwt.ui.StandardLoginScreen.java
License:Open Source License
/** * Load field from cookie./*from ww w.j ava 2 s . co m*/ * * @param field * the field * @param cookieName * the cookie name * @param memorize * the memorize */ private void loadFieldFromCookie(TextBox field, String cookieName, boolean memorize) { String cookieValue = Cookies.getCookie(cookieName); if (memorize) { if (rememberMeCheckBox.isEnabled()) { Cookies.setCookie(cookieName, field.getValue()); } } else if (cookieValue != null) { field.setValue(cookieValue); } }
From source file:com.calclab.emite.browser.AutoConfigBoot.java
License:Open Source License
/** * Try to resume the given session.//from w ww. ja v a 2 s .c om * * @return true if the cookie is present (and therefore the session is * resumed), false otherwise. True doesn't mean the sessions is * <b>succesfully</b> resumed. */ private final boolean resumeSession() { final String pause = Cookies.getCookie(PAUSE_COOKIE); if (pause == null) return false; logger.finer("Resume session: " + pause); Cookies.removeCookie(PAUSE_COOKIE); final Map<String, String> map = cookieSplitter.split(pause); final StreamSettings stream = new StreamSettings(); stream.rid = Integer.parseInt(map.get("rid")); stream.sid = map.get("sid"); stream.wait = map.get("wait"); stream.setInactivity(map.get("inactivity")); stream.setMaxPause(map.get("maxPause")); final XmppURI user = uri(map.get("user")); session.resume(user, stream); return true; }
From source file:com.calclab.emite.browser.client.PageAssist.java
License:Open Source License
/** * Try to resume the given session.//ww w .j av a2s .c om * * @param session * the session to be resumed * @return true if the cookie is present (and therefore the session is * resumed), false otherwise. True doesn't mean the sessions is * <b>succesfully</b> resumed. */ public static final boolean resumeSession(final XmppSession session) { final String pause = Cookies.getCookie(PAUSE_COOKIE); if (pause == null) return false; logger.finer("Resume session: " + pause); Cookies.removeCookie(PAUSE_COOKIE); final SerializableMap map = SerializableMap.restore(pause); final StreamSettings stream = new StreamSettings(); stream.rid = Integer.parseInt(map.get("rid")); stream.sid = map.get("sid"); stream.setWait(map.get("wait")); stream.setInactivity(map.get("inactivity")); stream.setMaxPause(map.get("maxPause")); final XmppURI user = uri(map.get("user")); session.resume(user, stream); return true; }
From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java
public void bind() { GWT.log("SessionManager Bind"); String token = Cookies.getCookie("token"); if (token != null) { // userService.reauthenticate(token, new AsyncCallback<String>() { // public void onFailure(Throwable e) { // Window.alert("Login Error: " + e.getMessage()); // tokenObtained(null); // // no login token in cookie // eventBus.fireEvent(new LoginEvent( // LoginEvent.LoginStatus.LOGIN_EXPIRED)); // }//from ww w.j a va 2 s.c o m // // public void onSuccess(String token) { // tokenObtained(token); // eventBus.fireEvent(new LoginEvent( // LoginEvent.LoginStatus.LOGIN_OK)); // } // }); eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGOUT)); } else { eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGOUT)); } }
From source file:com.chinarewards.gwt.license.client.support.impl.CookieSessionManager.java
@Override public void initialize() { // Check Cookie Validity GWT.log("Initializing SessionManager..."); String token = Cookies.getCookie("token"); System.out.println("token==========" + token); if (null != token && !token.trim().equals("")) { // check the token value. dispatchAsync.execute(new TokenValidRequest(token), new AsyncCallback<TokenValidResponse>() { @Override/* w w w .j a v a2 s .co m*/ public void onFailure(Throwable e) { tokenObtained(null); eventBus.fireEvent(new PlatformInitEvent(false)); } @Override public void onSuccess(TokenValidResponse resp) { tokenObtainedToo(resp); UserRoleVo role = resp.getLastLoginRole(); // ???? List<UserRoleVo> roleslt = new ArrayList<UserRoleVo>(); UserRoleVo[] roles = resp.getUserRoles(); if (roles.length > 0) { for (UserRoleVo r : roles) { roleslt.add(r); } if (role != null && roleslt.contains(role)) { if (role == UserRoleVo.CORP_ADMIN) eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK)); else if (role == UserRoleVo.STAFF) eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF)); } else { if (roleslt.contains(UserRoleVo.CORP_ADMIN)) { role = UserRoleVo.CORP_ADMIN; session.setLastLoginRole(role); eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK)); } else if (roleslt.contains(UserRoleVo.STAFF)) { role = UserRoleVo.STAFF; session.setLastLoginRole(role); eventBus.fireEvent(new LoginEvent(LoginEvent.LoginStatus.LOGIN_OK_STAFF)); } else Window.alert(""); } if (role != null) { dispatchAsync.execute(new LastLoginRoleRequest(resp.getToken(), role), new AsyncCallback<LastLoginRoleResponse>() { @Override public void onFailure(Throwable e) { tokenObtained(null); eventBus.fireEvent(new PlatformInitEvent(false)); } @Override public void onSuccess(LastLoginRoleResponse resp) { // ? if ("success".equals(resp.getFal())) GWT.log("success update last login role "); } }); } } } }); } else { eventBus.fireEvent(new PlatformInitEvent(false)); } }
From source file:com.cognitivemedicine.metricsdashboard.client.Md_sandbox.java
License:Apache License
public void siteListLoaded(List<Site> siteList) { if (siteList != null && siteList.size() > 0) { authDialog = new AuthenticationDialog(this, siteList); String cookie = Cookies.getCookie(MdConstants.RDK_COOKIE); System.err.println(cookie); if (cookie == null) { authDialog.center();/*from w w w . ja v a 2 s .c o m*/ } else { controller.reauthenticate(); } } else { siteListLoadFailed(); } }
From source file:com.data2semantics.yasgui.client.helpers.LocalStorageHelper.java
License:Open Source License
public static String getAsCookie(String key) { String domain = Helper.getCurrentHost(); if (Cookies.getCookie(domain + "_" + key) != null) { return Cookies.getCookie(domain + "_" + key); } else if (Cookies.getCookie(key) != null) { //for backwards compatability (i.e. the time when we didnt use the basedomain as part of the key) String value = Cookies.getCookie(key); setAsCookie(key, value, UNKNOWN_EXPIRE_DAYS); //now store it under correct key Cookies.removeCookie(key);//remove old key return value; }//from w w w . java 2 s . co m return null; }
From source file:com.dawg6.web.dhcalc.client.BasePanel.java
License:Open Source License
protected String getCookie(String name, String defaultValue) { String value = Cookies.getCookie(name); if (value == null) value = defaultValue;//from www . ja v a 2s . com return value; }
From source file:com.ephesoft.gxt.core.client.ui.widget.util.CookieUtil.java
License:Open Source License
public static String getCookieValue(String cookieName) { return Cookies.getCookie(cookieName); }
From source file:com.eucalyptus.webui.client.session.LocalSessionImpl.java
License:Open Source License
@Override public Session getSession() { if (this.session == null) { String sessionId = Cookies.getCookie(SESSION_COOKIE_NAME); if (sessionId != null) { this.session = new Session(sessionId); }/* www . ja va2s . c o m*/ } return this.session; }