List of usage examples for com.google.gwt.user.client Cookies removeCookie
public static void removeCookie(String name)
From source file:org.olanto.mySelfQD.client.MyParseCookies.java
License:Open Source License
public static void updateCookie(String name, String value) { Date expires = new Date(System.currentTimeMillis() + (1000L * 3600L * 24L * (long) GuiConstant.EXP_DAYS)); Cookies.removeCookie(name); Cookies.setCookie(name, value, expires); }
From source file:org.onecmdb.ui.gwt.desktop.client.mvc.contoller.DesktopContoller.java
License:Open Source License
@Override public void handleEvent(AppEvent<?> event) { switch (event.type) { // Main entry point. case CMDBEvents.DESKTOP_CHECK_SESSION: // Save URL arguments urlMap = com.google.gwt.user.client.Window.Location.getParameterMap(); // Check for autologin. List<String> alids = urlMap.get("alid"); if (alids != null && alids.size() > 0) { String alid = alids.get(0); // Need to validate this token. ModelServiceFactory.get().autoLogin(alid, new AsyncCallback<CMDBSession>() { public void onFailure(Throwable arg0) { Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOGIN); return; }/*from ww w . jav a 2 s. co m*/ public void onSuccess(CMDBSession arg0) { arg0.setURLValues(urlMap); CMDBSession.get().setSession(arg0); initDesktop(); setupDesktop(arg0.getDesktopConfig()); } }); return; } // Check if we have a cookie set. String token = Cookies.getCookie("auth_token"); if (token != null) { // Need to validate this token. ModelServiceFactory.get().validateToken(token, new AsyncCallback<CMDBSession>() { public void onFailure(Throwable arg0) { Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOGIN); return; } public void onSuccess(CMDBSession arg0) { arg0.setUsername(Cookies.getCookie("auth_username")); arg0.setURLValues(urlMap); CMDBSession.get().setSession(arg0); initDesktop(); setupDesktop(arg0.getDesktopConfig()); } }); return; } // Normal login. Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOGIN); break; case CMDBEvents.DESKTOP_MENU_SELECTED: CMDBDesktopMenuItem item = (CMDBDesktopMenuItem) event.data; CMDBDesktopWindowItem wItem = item.getWindowItem(); Window window = WindowFactory.showWindow(desktop, wItem); break; case CMDBEvents.DESKTOP_LOCK_TIMEOUT: stopActivityTimer(); LoginWidget.login(true, new AsyncCallback<CMDBSession>() { public void onFailure(Throwable arg0) { if (arg0 instanceof CMDBLoginException) { CMDBLoginException ex = (CMDBLoginException) arg0; MessageBox.alert(ex.getHeader(), ex.getMessage(), new Listener<WindowEvent>() { public void handleEvent(WindowEvent be) { Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOCK_TIMEOUT); } }); return; } ExceptionErrorDialog.showError("Login Failed!", arg0, new Listener<WindowEvent>() { public void handleEvent(WindowEvent be) { } }); } public void onSuccess(CMDBSession arg0) { Date date = new Date(); long dateLong = date.getTime(); dateLong += (1000 * 60 * 60 * 8);// 8h convert days to ms date.setTime(dateLong); // Set the new date Cookies.setCookie("auth_token", arg0.getToken(), date); Cookies.setCookie("auth_username", arg0.getUsername(), date); arg0.setURLValues(urlMap); CMDBSession.get().setSession(arg0); startActivityTimeout(CMDBSession.get().getConfig().getDesktopLockTimeout()); } }); break; case CMDBEvents.DESKTOP_LOGIN: LoginWidget.login(false, new AsyncCallback<CMDBSession>() { public void onFailure(Throwable arg0) { if (arg0 instanceof CMDBLoginException) { CMDBLoginException ex = (CMDBLoginException) arg0; MessageBox.alert(ex.getHeader(), ex.getMessage(), new Listener<WindowEvent>() { public void handleEvent(WindowEvent be) { Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOGIN); } }); return; } ExceptionErrorDialog.showError("Login Failed!", arg0, new Listener<WindowEvent>() { public void handleEvent(WindowEvent be) { } }); } public void onSuccess(CMDBSession arg0) { Date date = new Date(); long dateLong = date.getTime(); dateLong += (1000 * 60 * 60 * 8);// 8h convert days to ms date.setTime(dateLong); // Set the new date Cookies.setCookie("auth_token", arg0.getToken(), date); Cookies.setCookie("auth_username", arg0.getUsername(), date); arg0.setURLValues(urlMap); CMDBSession.get().setSession(arg0); initDesktop(); setupDesktop(arg0.getDesktopConfig()); } }); break; case CMDBEvents.DESKTOP_LOGOUT: // close all windows. clearWindow(); // Logout ModelServiceFactory.get().logout(CMDBSession.get().getToken(), new AsyncCallback<Boolean>() { public void onFailure(Throwable caught) { } public void onSuccess(Boolean result) { } }); // Clear session... CMDBSession.setSession(null); // Stop Lock timer stopActivityTimer(); // Clear Cookies. Cookies.removeCookie("auth_token"); Cookies.removeCookie("auth_username"); // Call login. // Reload application.... reloadApplication(); //Dispatcher.get().dispatch(CMDBEvents.DESKTOP_LOGIN); break; case CMDBEvents.DESKTOP_ABOUT: CMDBDesktopWindowItem about = new CMDBDesktopWindowItem(); about.setID(CMDBURLFrameWidget.ID); about.getParams().set("url", GWT.getModuleBaseURL() + "/about.html"); about.getParams().set("newWindow", "true"); about.setHeading("About - OneCMDB"); WindowFactory.showWindow(desktop, about); break; case CMDBEvents.DESKTOP_CHANGE_ROLE: final String role = (String) event.data; //desktop.getStartMenu().hide(); final MessageBox info = MessageBox.wait("Progress", "Change Role to " + role, "Wait..."); ModelServiceFactory.get().getDesktopConfig(CMDBSession.get().getUsername(), CMDBSession.get().getToken(), role, new CMDBAsyncCallback<CMDBDesktopConfig>() { @Override public void onFailure(Throwable t) { info.close(); super.onFailure(t); } @Override public void onSuccess(CMDBDesktopConfig arg0) { info.close(); clearWindow(); CMDBSession.get().setDesktopConfig(arg0); CMDBSession.get().setDefaultRole(role); initDesktop(); setupDesktop(arg0); } }); break; } }
From source file:org.openremote.manager.client.service.CookieServiceImpl.java
License:Open Source License
@Override public void removeCookie(String name) { Cookies.removeCookie(name); }
From source file:org.openremote.web.console.service.LocalDataServiceImpl.java
License:Open Source License
@Override public void clearData(String dataName) { if (dataName == null || dataName.equals("")) return;//from www.j a va2s . com dataName = buildPathString(dataName); try { if (dataStore != null) { dataStore.removeItem(dataName); } else { Cookies.removeCookie(dataName); } } catch (Exception e) { } initData(); }
From source file:org.rebioma.client.ApplicationView.java
License:Apache License
/** * Signs out the user on the server, invalidates the session, updates content * state, and shows the unauthenticated navigation links. * /*from w w w. ja v a 2 s . c om*/ * @param serverSignOut true to sign out the user on server as well. */ private void signOutUser(boolean serverSignOut) { if (serverSignOut) { signOutOnServer(); } Cookies.removeCookie(SESSION_ID_NAME); setAuthenticatedUser(null); // /currentState = ViewState.UNAUTHENTICATED; links.removeEmail(); links.showLinks(LinksGroup.HOME.toString() + false); activeViewInfo = null; switchView(OCCURRENCES); fireOnStateChange(currentState); // HACK: UserProfilesView maintains a final User reference that is set when // initialized. Need to clobber that user when user logs out we // reinitializing the view. viewInfos.remove(editCollaboratorsViewInfo.getHisTokenName().toLowerCase()); editCollaboratorsViewInfo = UserProfilesView.init(this, constants.UserProfiles(), USER_PROFILES); addViewInfo(editCollaboratorsViewInfo); // ((UserProfilesView) editCollaboratorsViewInfo.getView()).clearUser(); }
From source file:org.rebioma.client.Portal.java
License:Apache License
/** * Checks the current session via RPC. Updates application state. Updates all * tab widgets with new application state. *///from w w w .j av a 2 s . c om private void checkCurrentSession() { final String dev = Window.Location.getParameter("gwt.codesvr") == null ? "" : "Portal.html?gwt.codesvr=" + Window.Location.getParameter("gwt.codesvr"); String from = Window.Location.getParameter("from"); String sign = Window.Location.getParameter("signinc"); if (from != null) { String family = Window.Location.getParameter("family"); family = (family == null || family.isEmpty()) ? "" : "&asearch=AcceptedFamily like " + family.trim(); String genus = Window.Location.getParameter("genus"); String m_search = genus == null ? "" : genus; genus = (genus == null || genus.isEmpty()) ? "" : "&asearch=AcceptedGenus like " + genus.trim(); String species = Window.Location.getParameter("species"); m_search = (species == null || species.trim().isEmpty()) ? m_search : species; species = (species == null || species.isEmpty()) ? "" : "&asearch=AcceptedSpecies like " + species.trim(); String year = Window.Location.getParameter("year"); year = (year == null || year.isEmpty()) ? "" : "&asearch=YearCollected = " + year.trim(); Window.Location.replace(GWT.getHostPageBaseURL() + dev + "#tab=occ&view=Map&zoom=5¢er=-19,47&map_type=terrain&left_tab=1&m_search=" + m_search + "&asearch=AcceptedOrder = PRIMATES&m_page=1&page=1" + family + genus + species + "&error_type=all&type=all occurrences"); } else if (sign != null) { String email = Window.Location.getParameter("emailc"); final String id = Window.Location.getParameter("id"); Cookies.removeCookie(ApplicationView.SESSION_ID_NAME); DataSwitch.get().signInC(email, sign, new AsyncCallback<User>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub } @Override public void onSuccess(User result) { // TODO Auto-generated method stub if (result.getSessionId() == null) initApplication(null); else { Cookies.setCookie(ApplicationView.SESSION_ID_NAME, result.getSessionId(), new Date(System.currentTimeMillis() + 86400000)); Window.Location.replace(GWT.getHostPageBaseURL() + dev + "#tab=occ&view=Detail&id=" + id + "&p=false&page=1&asearch=Id = " + id + "&type=all occurrences"); } } }); } else if (!isSessionIdInBrowser()) { // links.showLinks(HOME_UNAUTHENTICATED_LINKS); initApplication(null); return; } else { String sid = Cookies.getCookie(ApplicationView.SESSION_ID_NAME); DataSwitch.get().isSessionIdValid(sid, new AsyncCallback<User>() { public void onFailure(Throwable caught) { GWT.log(caught.getMessage(), caught); initApplication(null); } public void onSuccess(User result) { if (result != null) { ApplicationView.setSessionId(result.getSessionId()); ApplicationView.refreshSession(); } initApplication(result); } }); } }
From source file:org.rhq.coregui.client.UserSessionManager.java
License:Open Source License
private static void removeDoomedSessionId() { Cookies.removeCookie(DOOMED_SESSION_NAME); }
From source file:org.sigmah.client.offline.OfflineStatus.java
License:Open Source License
/** * Remove any cached state. */ public void flushCache() { // jest remove our cookies Cookies.removeCookie(offlineCookieName); }
From source file:org.sigmah.client.page.app.AppFrameSet.java
License:Open Source License
private void createToolBar() { topBar = new ToolBar(); AppCacheMenu appCacheMenu = new AppCacheMenu(); topBar.add(appCacheMenu);//from www . j av a 2s . c om topBar.add(new SeparatorToolItem()); addNavLink(I18N.CONSTANTS.welcome(), null, new WelcomePageState()); addNavLink(I18N.CONSTANTS.dataEntry(), IconImageBundle.ICONS.dataEntry(), new SiteGridPageState()); addNavLink(I18N.CONSTANTS.reports(), IconImageBundle.ICONS.report(), new ReportListPageState()); addNavLink(I18N.CONSTANTS.charts(), IconImageBundle.ICONS.barChart(), new ChartPageState()); addNavLink(I18N.CONSTANTS.maps(), IconImageBundle.ICONS.map(), new MapPageState()); addNavLink(I18N.CONSTANTS.tables(), IconImageBundle.ICONS.table(), new PivotPageState()); addNavLink(I18N.CONSTANTS.setup(), IconImageBundle.ICONS.setup(), new DbListPageState()); topBar.add(new FillToolItem()); LabelToolItem emailLabel = new LabelToolItem(auth.getEmail()); emailLabel.setStyleAttribute("fontWeight", "bold"); topBar.add(emailLabel); topBar.add(offlineMenu); Button logoutTool = new Button(I18N.CONSTANTS.logout(), new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { // TODO: this needs to go elsewhere Cookies.removeCookie("authToken"); Cookies.removeCookie("email"); Window.Location.reload(); } }); topBar.add(logoutTool); viewport.add(topBar, new RowData(1.0, 30)); }
From source file:org.sigmah.offline.handler.SecureNavigationAsyncHandler.java
License:Open Source License
@Override public void execute(SecureNavigationCommand command, OfflineExecutionContext executionContext, AsyncCallback<SecureNavigationResult> callback) { final SecureNavigationResult result = new SecureNavigationResult(); final RequestManager<SecureNavigationResult> requestManager = new RequestManager<SecureNavigationResult>( result, callback);//from www . j a va2s . c om authenticationAsyncDAO .get(new RequestManagerCallback<SecureNavigationResult, Authentication>(requestManager) { @Override public void onRequestSuccess(Authentication authentication) { result.setAuthentication(authentication); if (authentication == null) { // User is anonymous Cookies.removeCookie(org.sigmah.shared.Cookies.AUTH_TOKEN_COOKIE); // TODO: Create a shared class to avoid code duplicate for server and client. final ProfileDTO aggretatedProfileDTO = new ProfileDTO(); aggretatedProfileDTO.setName("AGGREGATED_PROFILE"); aggretatedProfileDTO.setGlobalPermissions(new HashSet<GlobalPermissionEnum>()); aggretatedProfileDTO .setPrivacyGroups(new HashMap<PrivacyGroupDTO, PrivacyGroupPermissionEnum>()); Language language = Language.fromString(LocaleInfo.getCurrentLocale().getLocaleName()); if (language == null) { language = Language.EN; } result.setAuthentication(new Authentication(null, "anonymous@nowhere.com", "anonymous", null, language, null, null, null, null, aggretatedProfileDTO)); } } }); pageAccessAsyncDAO.get(command.getPage(), new RequestManagerCallback<SecureNavigationResult, PageAccessJS>(requestManager) { @Override public void onRequestSuccess(PageAccessJS pageAccessJS) { result.setGranted(pageAccessJS.isGranted()); } }); requestManager.ready(); }