Example usage for com.google.gwt.user.client Cookies removeCookie

List of usage examples for com.google.gwt.user.client Cookies removeCookie

Introduction

In this page you can find the example usage for com.google.gwt.user.client Cookies removeCookie.

Prototype

public static void removeCookie(String name) 

Source Link

Document

Removes the cookie associated with the given name.

Usage

From source file:org.silverpeas.mobile.client.common.AuthentificationManager.java

License:Open Source License

public void authenticateOnSilverpeas(String login, String password, String domainId, Command attempt) {
    Notification.activityStart();
    ServicesLocator.getRestServiceAuthentication(login, password, domainId).authentication(

            new MethodCallback<UserProfileDTO>() {
                @Override//from   w  w  w  .  j  ava2 s.  com
                public void onFailure(final Method method, final Throwable throwable) {
                    if (method.getResponse().getStatusCode() == 403) {
                        Notification.activityStop();
                        SpMobil.displayMainPage();
                    } else if (method.getResponse().getStatusCode() == 401) {
                        EventBus.getInstance().fireEvent(new AuthenticationErrorEvent(throwable));
                    } else {
                        EventBus.getInstance().fireEvent(new ErrorEvent(throwable));
                    }
                }

                @Override
                public void onSuccess(final Method method, final UserProfileDTO userProfile) {
                    LocalStorageHelper.clear(); // clear offline data
                    AuthentificationManager.getInstance().clearLocalStorage();

                    AuthentificationManager.getInstance().addHeader("X-STKN",
                            method.getResponse().getHeader("X-STKN"));
                    AuthentificationManager.getInstance().addHeader("X-Silverpeas-Session",
                            method.getResponse().getHeader("X-Silverpeas-Session"));

                    Cookies.removeCookie("JSESSIONID");
                    Cookies.setCookie("JSESSIONID", method.getResponse().getHeader("X-Silverpeas-Session"));

                    SpMobil.setUserProfile(userProfile);
                    ServicesLocator.getServiceConnection().login(login, password, domainId,
                            new AsyncCallback<DetailUserDTO>() {

                                @Override
                                public void onFailure(final Throwable throwable) {
                                    if (throwable instanceof AuthenticationException) {
                                        EventBus.getInstance()
                                                .fireEvent(new AuthenticationErrorEvent(throwable));
                                    } else {
                                        EventBus.getInstance().fireEvent(new ErrorEvent(throwable));
                                    }
                                }

                                @Override
                                public void onSuccess(final DetailUserDTO user) {
                                    SpMobil.setUser(user);

                                    Notification.activityStop();
                                    AuthentificationManager.getInstance().storeUser(user, userProfile, login,
                                            password, domainId);

                                    if (attempt == null) {
                                        SpMobil.displayMainPage();
                                    } else {
                                        attempt.execute();
                                    }
                                }
                            });
                }
            });
}

From source file:org.sonatype.nexus.ext.gwt.ui.client.ApplicationContext.java

License:Open Source License

public void removeCookie(String name) {
    Cookies.removeCookie("st-" + name);
}

From source file:org.spiffyui.client.rest.RESTility.java

License:Apache License

/**
 * The normal GWT mechanism for removing cookies will remove a cookie at the path
 * the page is on.  The is a possibility that the session cookie was set on the
 * server with a slightly different path.  In that case we need to try to delete
 * the cookie on all the paths of the current URL.  This method handles that case.
 * /*from   w ww. j  av a 2  s . com*/
 * @param name   the name of the cookie to remove
 */
private static void removeCookie(String name) {
    Cookies.removeCookie(name);
    if (Cookies.getCookie(name) != null) {
        /*
         * This could mean that the cookie was there,
         * but was on a different path than the one that
         * we get by default.
         */
        removeCookie(name, Window.Location.getPath());
    }
}

From source file:org.talend.mdm.webapp.base.client.SessionAwareAsyncCallback.java

License:Open Source License

public final void onFailure(Throwable caught) {
    if (Log.isErrorEnabled()) {
        Log.error(caught.toString());/*  w w  w. ja va2s . co m*/
    }
    if (sessionExpired(caught)) {
        MessageBox.alert(BaseMessagesFactory.getMessages().warning_title(),
                BaseMessagesFactory.getMessages().session_timeout_error(), new Listener<MessageBoxEvent>() {

                    public void handleEvent(MessageBoxEvent be) {
                        Cookies.removeCookie("JSESSIONID"); //$NON-NLS-1$
                        Cookies.removeCookie("JSESSIONIDSSO"); //$NON-NLS-1$
                        Window.Location.replace(GWT.getHostPageBaseURL());
                    }
                });
    } else {
        doOnFailure(caught);
    }
}

From source file:org.talend.mdm.webapp.browserecords.client.widget.GenerateContainer.java

License:Open Source License

public static void setDefaultView() {
    String parameter = Cookies.getCookie(PortletConstants.PARAMETER_ENTITY);
    Cookies.removeCookie(PortletConstants.PARAMETER_ENTITY);
    setDefaultViewPk(parameter == null ? "" : parameter); //$NON-NLS-1$
    if (parameter != null) {
        BrowseRecordsServiceAsync service = (BrowseRecordsServiceAsync) Registry
                .get(BrowseRecords.BROWSERECORDS_SERVICE);
        service.getAppHeader(new SessionAwareAsyncCallback<AppHeader>() {

            @Override//www.j  a  v  a2s. com
            public void onSuccess(AppHeader header) {
                if (header.getDatacluster() == null || header.getDatamodel() == null) {
                    MessageBox.alert(MessagesFactory.getMessages().error_title(),
                            MessagesFactory.getMessages().data_model_not_specified(), null);
                    return;
                }
                BrowseRecords.getSession().put(UserSession.APP_HEADER, header);
                Dispatcher dispatcher = Dispatcher.get();
                dispatcher.dispatch(BrowseRecordsEvents.DefaultView);
            }
        });
    }
}

From source file:org.talend.mdm.webapp.browserecords.client.widget.NavigatorPanel.java

License:Open Source License

public void sessionExpired() {
    MessageBox.alert(BaseMessagesFactory.getMessages().warning_title(),
            BaseMessagesFactory.getMessages().session_timeout_error(), new Listener<MessageBoxEvent>() {
                public void handleEvent(MessageBoxEvent be) {
                    Cookies.removeCookie("JSESSIONID"); //$NON-NLS-1$
                    Cookies.removeCookie("JSESSIONIDSSO"); //$NON-NLS-1$
                    com.google.gwt.user.client.Window.Location.replace(GWT.getHostPageBaseURL());
                }//from www . j  a v  a2  s . c  o m
            });
}

From source file:org.talend.mdm.webapp.general.client.layout.BrandingBar.java

License:Open Source License

private void initEvent() {

    languageBox.addChangeHandler(new ChangeHandler() {

        @Override/*w w  w  .ja va  2 s.  com*/
        public void onChange(ChangeEvent event) {

            if (languageBoxEnable) {
                changeLanguage();
            }
        }
    });

    languageBox.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(FocusEvent event) {
            if (languageBox != null) {
                languageSeleted = languageBox.getSelectedIndex();
            }

            String languageSelected = languageBox.getValue(languageBox.getSelectedIndex());
            if (languageSelected == null || "".equals(languageSelected.trim())) { //$NON-NLS-1$
                languageSelected = UrlUtil.getLanguage();
            }

            service.isExpired(languageSelected, new SessionAwareAsyncCallback<Boolean>() {

                @Override
                public void onSuccess(Boolean result) {
                    languageBoxEnable = true;
                }

                @Override
                protected void doOnFailure(final Throwable caught) {
                    languageBoxEnable = false;
                    languageBox.setSelectedIndex(languageSeleted);
                    super.doOnFailure(caught);
                }
            });
        }
    });

    logout.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            GeneralServiceAsync service = (GeneralServiceAsync) Registry.get(General.OVERALL_SERVICE);
            service.logout(new SessionAwareAsyncCallback<Void>() {

                @Override
                public void onSuccess(Void result) {
                    Cookies.removeCookie("JSESSIONID"); //$NON-NLS-1$
                    Cookies.removeCookie("JSESSIONIDSSO"); //$NON-NLS-1$
                    Window.Location.replace(GWT.getHostPageBaseURL());
                }
            });
        }
    });
}

From source file:rtdc.web.client.impl.GwtStorage.java

License:Open Source License

/**
 * {@inheritDoc}
 */
@Override
public void remove(String key) {
    Cookies.removeCookie(key);
}

From source file:scrum.client.ScrumGwtApplication.java

License:Open Source License

public void logout() {
    log.info("Logging out");

    Cookies.removeCookie(LOGIN_TOKEN_COOKIE);

    Scope.get().getComponent(Ui.class).lock("Logging out...");
    Scope.get().getComponent(Auth.class).logout();
    Scope.get().getComponent(Pinger.class).shutdown();
    Scope.get().getComponent(Dao.class).clearAllEntities();

    new LogoutServiceCall().execute(new Runnable() {

        @Override//from w ww . ja v  a 2  s  .c  om
        public void run() {
            String url = GWT.getHostPageBaseURL();
            if (!GWT.isScript())
                url += "index.html?gwt.codesvr=localhost:9997";
            Window.Location.replace(url);
        }
    });

}

From source file:votes.client.oauth.CookieStoreImpl.java

License:Apache License

@Override
public void clear() {
    for (String key : Cookies.getCookieNames()) {
        if (key.startsWith(COOKIE_PREFIX)) {
            Cookies.removeCookie(key);
        }/*  w  w w.j a  v  a 2 s . com*/
    }
}