Пример #1
0
 public static void displayCookies() {
   StringBuilder cookies = new StringBuilder();
   for (String name : Cookies.getCookieNames()) {
     String value = Cookies.getCookie(name);
     cookies.append(name).append(" = ").append(value).append("<br/>");
   }
   Info.display("Cookies", cookies.toString());
 }
Пример #2
0
  /** Clear all cookies provided by federation IDP in user's browser. */
  public static void clearFederationCookies() {

    final String SHIBBOLETH_COOKIE_FORMAT = "^_shib.+$";

    // 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, "/");
      }
    }
  }