List of usage examples for com.google.gwt.user.client Cookies setCookie
public static void setCookie(String name, String value, Date expires)
From source file:olanto.myTerm.client.CookiesManager.MyTermCookies.java
License:Open Source License
public static void initCookie(String name, String value) { Date expires = new Date(System.currentTimeMillis() + (1000L * 3600L * 24L * (long) GuiConstant.EXP_DAYS)); if ((Cookies.getCookie(name) == null) || (Cookies.getCookie(name).equalsIgnoreCase("null"))) { Cookies.setCookie(name, value, expires); }/* ww w. j a va2 s .c o m*/ }
From source file:org.activityinfo.ui.client.inject.ClientSideAuthProvider.java
License:Open Source License
/** * unless the user requests to stay logged in, the authToken is set to expire at the end of the user's session, * which means that it won't be available if the user opens the app via the appcache later on. Since * BootstrapScriptServlet relies on the token to select the appropriate locale, without the cookie set, trying to * retrieve the latest manifest will fail *//*from w w w . ja v a 2s . co m*/ public static void persistAuthentication() { AuthenticatedUser user = new ClientSideAuthProvider().get(); Cookies.setCookie(AuthenticatedUser.AUTH_TOKEN_COOKIE, user.getAuthToken(), oneYearLater()); Cookies.setCookie(AuthenticatedUser.USER_ID_COOKIE, Integer.toString(user.getUserId()), oneYearLater()); Cookies.setCookie(AuthenticatedUser.EMAIL_COOKIE, user.getEmail(), oneYearLater()); }
From source file:org.activityinfo.ui.client.page.HistoryManager.java
License:Open Source License
private void onNavigationCompleted(PageState place) { String token = PageStateSerializer.serialize(place); /*// w w w . j a va 2s .c o m * If it's a duplicate, we're not totally interested */ if (!token.equals(History.getToken())) { /* * Lodge in the browser's history */ History.newItem(token, false); /* * ... And save as a cookie so we know where to pick up next time */ Cookies.setCookie("lastPlace", token, (new DateWrapper()).addDays(30).asDate()); } }
From source file:org.bonitasoft.console.client.model.reporting.ReportingDataSourceImpl.java
License:Open Source License
/** * Serialize parameters of reports The format in the cookie is * reportId=paramName:value;paramName:value;...;paramName:value##reportId=... */// w w w . ja v a2 s . com private void updateCookie() { StringBuffer cookieValue = new StringBuffer(); for (int i = 0; i < reportsParameters.size(); i++) { cookieValue.append(i); cookieValue.append(REPORT_PARAM_SEPARATOR); HashMap<String, String> parameters = reportsParameters.get(i); for (String paramName : parameters.keySet()) { cookieValue.append(paramName); cookieValue.append(VALUE_SEPARATOR); cookieValue.append(parameters.get(paramName)); cookieValue.append(PARAMS_SEPARATOR); } cookieValue.append(REPORT_SEPARATOR); } String cookieStr = cookieValue.toString(); Cookies.removeCookie(COOKIE_NAME); if (reportsParameters.size() > 0) { // Calendar cal = Calendar.getInstance(); // cal.set(Calendar.YEAR, 9999); Date exp = new Date(); exp.setYear(9999); Cookies.setCookie(COOKIE_NAME, cookieStr.substring(0, cookieStr.length() - REPORT_SEPARATOR.length()), exp); } GWT.log("updateCookie - cookieValue:" + cookieStr); }
From source file:org.bonitasoft.forms.client.view.common.URLUtils.java
License:Open Source License
public void saveLocale(final String localeName) { final Date now = new Date(); // Expiration in 120 days. final Date theExpirationTime = new Date(now.getTime() + 1000 * 60 * 60 * 24 * 120); Cookies.setCookie(FORM_LOCALE_COOKIE_NAME, localeName, theExpirationTime); }
From source file:org.celstec.arlearn2.gwtcommonlib.client.auth.OauthClient.java
License:Open Source License
private static OauthClient readFromUrl() { String accessToken = null;/*from w w w . j ava 2 s.c o m*/ int type = 0; int exp = 0; if (Window.Location.getParameter("accessToken") != null) { accessToken = Window.Location.getParameter("accessToken"); } if (Window.Location.getParameter("type") != null) { type = Integer.parseInt(Window.Location.getParameter("type")); } if (Window.Location.getParameter("exp") != null) { exp = Integer.parseInt(Window.Location.getParameter("exp")); } OauthClient client = null; switch (type) { case AccountJDO.FBCLIENT: client = new OauthFbClient(); break; case AccountJDO.GOOGLECLIENT: client = new OauthGoogleClient(); break; case AccountJDO.LINKEDINCLIENT: client = new OauthLinkedIn(); break; case AccountJDO.ECOCLIENT: client = new OauthECO(); break; default: break; } client.accessToken = accessToken; long expires = System.currentTimeMillis() + (exp * 1000); Date d = new Date(expires); System.out.println("expires at" + d); Cookies.setCookie(COOKIE_TOKEN_NAME, accessToken, d); Cookies.setCookie(COOKIE_OAUTH_TYPE, type + ""); return client; }
From source file:org.clevermore.monitor.client.utils.LocalStorage.java
License:Apache License
public static void storeItem(final String key, final String value) { if (Storage.isSupported()) { Log.debug("Storing value:" + value + ", with key:" + key + ", to local storage"); Storage.getLocalStorageIfSupported().setItem(key, value); } else {//from www.j av a2 s.co m // store to cookies Log.debug("Storing value:" + value + ", with key:" + key + ", to cookie"); Cookies.setCookie(key, value, new Date(Long.MAX_VALUE)); } }
From source file:org.ebayopensource.turmeric.policy.adminui.client.PolicyAdminUI.java
License:Open Source License
/** * This is the entry point method./*from w w w .ja v a 2s.co m*/ */ public void onModuleLoad() { Window.setTitle(PolicyAdminUIUtil.constants.title()); Window.addCloseHandler(new CloseHandler<Window>() { public void onClose(CloseEvent<Window> event) { //briefly save the login/password combo //NOTE when using gwt hosted mode, which is sloooow, the //cookie will already have expired before the reload is //completed, so don't expect this to work in hosted mode Date expiry = new Date(System.currentTimeMillis() + 1000); //TODO change to using secure cookies only! String cookie = AppUser.toCookie(); if (cookie != null) { Cookies.setCookie(AppKeyUtil.COOKIE_SESSID_KEY, cookie, expiry); //expiry, null, null, false); } } }); final HandlerManager eventBus = new HandlerManager(null); Map<SupportedService, PolicyAdminUIService> serviceMap = createServiceMap(); AppController pageController = new AppController(eventBus, RootLayoutPanel.get(), serviceMap); pageController.start(); }
From source file:org.ednovo.gooru.application.client.wrap.WrapPresenter.java
License:Open Source License
private void registerWindowEvents() { nativePreviewHandlerRegistration = Event.addNativePreviewHandler(new NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (event.getTypeInt() == Event.ONMOUSEOVER) { if (AppClientFactory.getUserStatus() != null) { Cookies.setCookie("gooru-active-user", AppClientFactory.getUserStatus(), getCurrentDateAndTime()); }//w w w. j a v a 2 s .c o m if ((AppClientFactory.getUserStatus() == null || AppClientFactory.getUserStatus().trim().equals(GOORU_USER_INACTIVE)) && AppClientFactory.isUserflag()) { AppClientFactory.setUserflag(false); if (AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.HOME) || AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.SEARCH_RESOURCE) || AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.FOLDER_TOC) || AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.SEARCH_COLLECTION) || AppClientFactory.getCurrentPlaceToken().equals(PlaceTokens.STUDY)) { userLoggedOutheader(); } else { redirectToLandingPage(); } } } } }); }
From source file:org.gk.engine.client.Engine.java
License:Open Source License
private static void setCookie(String name, String value) { long timestamp = new Date().getTime() + (1000 * 86400) * 14; // 2 week Cookies.setCookie(name, value, new Date(timestamp)); }