/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.gravitee.am.management.handlers.admin.handler;

import io.gravitee.common.http.HttpHeaders;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutHandler;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Titouan COMPIEGNE (titouan.compiegne at graviteesource.com)
 * @author GraviteeSource Team
 */
public class CookieClearingLogoutHandler implements LogoutHandler {

    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        Cookie cookie = new Cookie(HttpHeaders.AUTHORIZATION, null);
        cookie.setPath("/");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }
}

@@ -727,16 +727,128 @@
 eaders;%0A
+import org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.core.env.Environment;%0A
 import o
@@ -1289,227 +1289,753 @@
     
-@Override%0A    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) %7B%0A        Cookie cookie = new Cookie(HttpHeaders.AUTHORIZATION, null);%0A        cookie.setPath(%22/%22
+private static final boolean DEFAULT_JWT_COOKIE_SECURE = false;%0A    private static final String DEFAULT_JWT_COOKIE_PATH = %22/%22;%0A    private static final String DEFAULT_JWT_COOKIE_DOMAIN = %22%22;%0A%0A    @Autowired%0A    private Environment environment;%0A%0A    @Override%0A    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) %7B%0A        Cookie cookie = new Cookie(HttpHeaders.AUTHORIZATION, null);%0A        cookie.setSecure(environment.getProperty(%22jwt.cookie-secure%22, Boolean.class, DEFAULT_JWT_COOKIE_SECURE));%0A        cookie.setPath(environment.getProperty(%22jwt.cookie-path%22, DEFAULT_JWT_COOKIE_PATH));%0A        cookie.setDomain(environment.getProperty(%22jwt.cookie-domain%22, DEFAULT_JWT_COOKIE_DOMAIN)
 );%0A 

clear cookies with custom path, domain, secure flag ... during logout process