List of usage examples for com.google.gwt.user.client Cookies setCookie
public static void setCookie(String name, String value, Date expires, String domain, String path, boolean secure)
From source file:org.bonitasoft.web.toolkit.client.ParametersStorageWithCookie.java
License:Open Source License
/** * Add a parameter. If this parameter already exists, the value will be changed * /*from w w w . j av a 2s .c o m*/ * @param name * @param value */ public static void addParameter(final String name, final String value) { SINGLETON._addParameter(name, value); // Cookie for the login JSP if (UrlOption.LANG.equals(name)) { // Set the expires date final Date now = new Date(); now.setTime(now.getTime() + COOKIE_EXPIRE); Cookies.setCookie(LOGIN_COOKIE_NAME, value, now, null, "/", false); } }
From source file:org.ednovo.gooru.shared.util.StringUtil.java
License:Open Source License
public static void clearCookies(String key, String path, String domain) { Cookies.setCookie(key, "", new Date(), "." + Window.Location.getHost(), path, false); Cookies.removeCookie(key, "/"); }
From source file:org.gss_project.gss.web.client.GSS.java
License:Open Source License
/** * Clear the cookie and redirect the user to the logout page. *///from w w w . j av a 2 s . c o m void logout() { Configuration conf = (Configuration) GWT.create(Configuration.class); String cookie = conf.authCookie(); String domain = Window.Location.getHostName(); String path = Window.Location.getPath(); Cookies.setCookie(cookie, "", null, domain, path, false); String baseUrl = GWT.getModuleBaseURL(); String homeUrl = baseUrl.substring(0, baseUrl.indexOf(path)); Window.Location.assign(homeUrl + conf.logoutUrl()); }
From source file:org.gss_project.gss.web.client.GSS.java
License:Open Source License
public void refreshWebDAVPassword() { Configuration conf = (Configuration) GWT.create(Configuration.class); String domain = Window.Location.getHostName(); String path = Window.Location.getPath(); String cookie = conf.webdavCookie(); webDAVPassword = Cookies.getCookie(cookie); Cookies.setCookie(cookie, "", null, domain, path, false); }
From source file:org.jboss.errai.enterprise.client.jaxrs.api.RestClient.java
License:Apache License
/** * Set a cookie for the domain and path returned by * {@link #getApplicationRoot()}.//from w w w . j a va 2 s .c om * * @param cookieName * The name of the cookie to set. * @param cookieValue * The value of the cookie to set. */ public static void setCookie(final String cookieName, final String cookieValue) { final AnchorElement anchorElement = Document.get().createAnchorElement(); anchorElement.setHref(RestClient.getApplicationRoot()); final String path = anchorElement.getPropertyString("pathname"); final String domain = anchorElement.getPropertyString("domain"); Cookies.setCookie(cookieName, cookieValue, null, domain, path, false); }
From source file:org.libredraw.client.LoginBox.java
License:Open Source License
private void loginCheck() { LibreRPCService.login(userEmail.getText(), Util.sha1(userPassword.getText()), new AsyncCallback<String>() { public void onFailure(Throwable caught) { Login.registerErrorDialog(new StackTrace(caught)); }/* www.j a v a2 s. c om*/ public void onSuccess(String result) { if (result != null) { errorLabel.setText("Login Sucsess"); long DURATION = 1000 * 60 * 60 * 24 * 14; Date expires = new Date(System.currentTimeMillis() + DURATION); if (rememberCheckbox.getValue()) Cookies.setCookie("SID", result, expires, null, "/", false); TableView.navigateTo(); } else { errorLabel.setText("Bad Login"); } } }); }
From source file:org.obiba.opal.web.gwt.rest.client.RequestCredentials.java
License:Open Source License
/** * Adds credentials to allow making a request to the specified URL without using AJAX. * * @param url the URL to request (GET, POST) *///from w w w . j a v a 2s . co m public void provideCredentials(String url) { if (hasCredentials()) { Md5Digest digest = new Md5Digest(); digest.update(extractOpalCredentials().getBytes()); String urlToHash = url; int queryIdx = url.indexOf('?'); if (queryIdx != -1) { // remove query string urlToHash = url.substring(0, queryIdx); } String urlHash = toHexString(digest.digest(urlToHash.getBytes())); long time = new Date().getTime(); // Cookie will be valid for 1 second Cookies.setCookie(OPALRID, urlHash, new Date(time + 1000), null, "/", false); } }
From source file:org.sigmah.client.security.AuthenticationProvider.java
License:Open Source License
/** * <p>/*from w w w . ja v a 2 s . co m*/ * Logins the given {@code authentication} by setting cookies and updating cached data. * </p> * <p> * <em>Should be called <b>exclusively</b> by {@link LoginPresenter}.</em> * </p> * * @param authentication * The authentication. Its {@code authenticationToken} <b>must</b> be set. */ public void login(final Authentication authentication) { if (authentication == null) { clearAuthentication(); return; } // Cookies properties. final String path = org.sigmah.shared.Cookies.COOKIE_PATH; final String domain = org.sigmah.shared.Cookies.COOKIE_DOMAIN; final boolean secure = org.sigmah.shared.Cookies.COOKIE_SECURED; // Sets the cookies. Cookies.setCookie(org.sigmah.shared.Cookies.AUTH_TOKEN_COOKIE, authentication.getAuthenticationToken(), oneDayLater(), domain, path, secure); Cookies.setCookie(org.sigmah.shared.Cookies.LANGUAGE_COOKIE, authentication.getLanguage().getLocale(), oneDayLater(), domain, path, secure); // Caches the authentication data. this.authentication = authentication; }
From source file:org.spiffyui.client.rest.RESTility.java
License:Apache License
private static void setSessionToken() { if (RESTILITY.m_sessionCookiePath != null) { Cookies.setCookie(RESTILITY.m_sessionCookie, RESTILITY.m_tokenType + "," + RESTILITY.m_userToken + "," + RESTILITY.m_tokenServerUrl + "," + RESTILITY.m_tokenServerLogoutUrl + "," + RESTILITY.m_username, null, null, RESTILITY.m_sessionCookiePath, RESTILITY.m_secureCookies); if (RESTILITY.m_bestLocale != null) { Cookies.setCookie(LOCALE_COOKIE, RESTILITY.m_bestLocale, null, null, RESTILITY.m_sessionCookiePath, RESTILITY.m_secureCookies); }// w w w . j av a 2 s .c o m } else { Cookies.setCookie(RESTILITY.m_sessionCookie, RESTILITY.m_tokenType + "," + RESTILITY.m_userToken + "," + RESTILITY.m_tokenServerUrl + "," + RESTILITY.m_tokenServerLogoutUrl + "," + RESTILITY.m_username, null, null, null, RESTILITY.m_secureCookies); if (RESTILITY.m_bestLocale != null) { Cookies.setCookie(LOCALE_COOKIE, RESTILITY.m_bestLocale, null, null, null, RESTILITY.m_secureCookies); } } }