Exemplo n.º 1
0
  /** Logout method, erases the cookies and calls RPC logout to invalidate session. */
  private void logout() {

    Logout call =
        new Logout(
            new JsonCallbackEvents() {
              @Override
              public void onFinished(JavaScriptObject jso) {

                // retrieves all the cookies
                Collection<String> cookies = Cookies.getCookieNames();

                // regexp
                RegExp regExp = RegExp.compile(SHIBBOLETH_COOKIE_FORMAT);

                for (String cookie : cookies) {
                  // shibboleth cookie?
                  MatchResult matcher = regExp.exec(cookie);
                  boolean matchFound = (matcher != null); // equivalent to regExp.test(inputStr);
                  if (matchFound) {
                    // remove it
                    Cookies.removeCookieNative(cookie, "/");
                  }
                }

                button.setProcessing(false);
                RootLayoutPanel.get().clear();
                RootLayoutPanel.get().add(new LogoutWidget());
              }

              @Override
              public void onError(PerunError error) {
                button.setProcessing(false);
              }

              @Override
              public void onLoadingStart() {
                button.setProcessing(true);
              }
            });
    // do the logout
    call.retrieveData();
  }