// Path: core/src/main/java/com/softwaremill/session/javadsl/HttpSessionAwareDirectives.java
// public class HttpSessionAwareDirectives<T> extends AllDirectives {
// 
//     private final SessionManager<T> sessionManager;
// 
//     public HttpSessionAwareDirectives(SessionManager<T> sessionManager) {
//         this.sessionManager = sessionManager;
//     }
// 
//     public Route session(SessionContinuity sc, GetSessionTransport st, Function<SessionResult<T>, Route> continuity) {
//         return SessionDirectives$.MODULE$.session(sc, st, continuity);
//     }
// 
//     public Route setSession(SessionContinuity sc, SetSessionTransport st, T session, Supplier<Route> continuity) {
//         return SessionDirectives$.MODULE$.setSession(sc, st, session, continuity);
//     }
// 
//     public Route optionalSession(SessionContinuity sc, SetSessionTransport st, Function<Optional<T>, Route> continuity) {
//         return SessionDirectives$.MODULE$.optionalSession(sc, st, continuity);
//     }
// 
//     public Route requiredSession(SessionContinuity<T> sc, SetSessionTransport st, Function<T, Route> continuity) {
//         return SessionDirectives$.MODULE$.requiredSession(sc, st, continuity);
//     }
// 
//     public Route touchRequiredSession(SessionContinuity<T> sc, SetSessionTransport st, Function<T, Route> continuity) {
//         return SessionDirectives$.MODULE$.touchRequiredSession(sc, st, continuity);
//     }
// 
//     public Route invalidateSession(SessionContinuity<T> sc, SetSessionTransport st, Supplier<Route> continuity) {
//         return SessionDirectives$.MODULE$.invalidateSession(sc, st, continuity);
//     }
// 
//     public Route setNewCsrfToken(CsrfCheckMode<T> checkHeader, Supplier<Route> continuity) {
//         return CsrfDirectives$.MODULE$.setNewCsrfToken(checkHeader, continuity);
//     }
// 
//     public Route randomTokenCsrfProtection(CsrfCheckMode<T> checkHeader, Supplier<Route> continuity) {
//         return CsrfDirectives$.MODULE$.randomTokenCsrfProtection(checkHeader, continuity);
//     }
// 
//     public SessionManager<T> getSessionManager() {
//         return sessionManager;
//     }
// }
// 
// Path: core/src/main/java/com/softwaremill/session/javadsl/SessionTransports.java
// public static final SetSessionTransport CookieST = CookieST$.MODULE$;


import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.dispatch.MessageDispatcher;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.http.javadsl.server.Route;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import com.softwaremill.session.BasicSessionEncoder;
import com.softwaremill.session.CheckHeader;
import com.softwaremill.session.RefreshTokenStorage;
import com.softwaremill.session.Refreshable;
import com.softwaremill.session.SessionConfig;
import com.softwaremill.session.SessionEncoder;
import com.softwaremill.session.SessionManager;
import com.softwaremill.session.SetSessionTransport;
import com.softwaremill.session.javadsl.HttpSessionAwareDirectives;
import com.softwaremill.session.javadsl.InMemoryRefreshTokenStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.concurrent.CompletionStage;
import static com.softwaremill.session.javadsl.SessionTransports.CookieST;
package com.softwaremill.example.session;




public class SessionInvalidationJava extends HttpSessionAwareDirectives<MyJavaSession> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SessionInvalidationJava.class);
    private static final String SECRET = "c05ll3lesrinf39t7mc5h6un6r0c69lgfno69dsak3vabeqamouq4328cuaekros401ajdpkh60rrtpd8ro24rbuqmgtnd1ebag6ljnb65i8a55d482ok7o0nch0bfbe";
    private static final SessionEncoder<MyJavaSession> BASIC_ENCODER = new BasicSessionEncoder<>(MyJavaSession.getSerializer());

    // in-memory refresh token storage
    private static final RefreshTokenStorage<MyJavaSession> REFRESH_TOKEN_STORAGE = new InMemoryRefreshTokenStorage<MyJavaSession>() {
        @Override
        public void log(String msg) {
            LOGGER.info(msg);
        }
    };

    private Refreshable<MyJavaSession> refreshable;
    private SetSessionTransport sessionTransport;

    public SessionInvalidationJava(MessageDispatcher dispatcher) {
        super(new SessionManager<>(
                SessionConfig.defaultConfig(SECRET),
                BASIC_ENCODER
            )
        );

        // use Refreshable for sessions, which needs to be refreshed or OneOff otherwise
        // using Refreshable, a refresh token is set in form of a cookie or a custom header
        refreshable = new Refreshable<>(getSessionManager(), REFRESH_TOKEN_STORAGE, dispatcher);

        // set the session transport - based on Cookies (or Headers)
// Path: core/src/main/java/com/softwaremill/session/javadsl/HttpSessionAwareDirectives.java
// public class HttpSessionAwareDirectives<T> extends AllDirectives {
// 
//     private final SessionManager<T> sessionManager;
// 
//     public HttpSessionAwareDirectives(SessionManager<T> sessionManager) {
//         this.sessionManager = sessionManager;
//     }
// 
//     public Route session(SessionContinuity sc, GetSessionTransport st, Function<SessionResult<T>, Route> continuity) {
//         return SessionDirectives$.MODULE$.session(sc, st, continuity);
//     }
// 
//     public Route setSession(SessionContinuity sc, SetSessionTransport st, T session, Supplier<Route> continuity) {
//         return SessionDirectives$.MODULE$.setSession(sc, st, session, continuity);
//     }
// 
//     public Route optionalSession(SessionContinuity sc, SetSessionTransport st, Function<Optional<T>, Route> continuity) {
//         return SessionDirectives$.MODULE$.optionalSession(sc, st, continuity);
//     }
// 
//     public Route requiredSession(SessionContinuity<T> sc, SetSessionTransport st, Function<T, Route> continuity) {
//         return SessionDirectives$.MODULE$.requiredSession(sc, st, continuity);
//     }
// 
//     public Route touchRequiredSession(SessionContinuity<T> sc, SetSessionTransport st, Function<T, Route> continuity) {
//         return SessionDirectives$.MODULE$.touchRequiredSession(sc, st, continuity);
//     }
// 
//     public Route invalidateSession(SessionContinuity<T> sc, SetSessionTransport st, Supplier<Route> continuity) {
//         return SessionDirectives$.MODULE$.invalidateSession(sc, st, continuity);
//     }
// 
//     public Route setNewCsrfToken(CsrfCheckMode<T> checkHeader, Supplier<Route> continuity) {
//         return CsrfDirectives$.MODULE$.setNewCsrfToken(checkHeader, continuity);
//     }
// 
//     public Route randomTokenCsrfProtection(CsrfCheckMode<T> checkHeader, Supplier<Route> continuity) {
//         return CsrfDirectives$.MODULE$.randomTokenCsrfProtection(checkHeader, continuity);
//     }
// 
//     public SessionManager<T> getSessionManager() {
//         return sessionManager;
//     }
// }
// 
// Path: core/src/main/java/com/softwaremill/session/javadsl/SessionTransports.java
// public static final SetSessionTransport CookieST = CookieST$.MODULE$;


// Path: example/src/main/java/com/softwaremill/example/session/SessionInvalidationJava.java
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.dispatch.MessageDispatcher;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.http.javadsl.server.Route;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import com.softwaremill.session.BasicSessionEncoder;
import com.softwaremill.session.CheckHeader;
import com.softwaremill.session.RefreshTokenStorage;
import com.softwaremill.session.Refreshable;
import com.softwaremill.session.SessionConfig;
import com.softwaremill.session.SessionEncoder;
import com.softwaremill.session.SessionManager;
import com.softwaremill.session.SetSessionTransport;
import com.softwaremill.session.javadsl.HttpSessionAwareDirectives;
import com.softwaremill.session.javadsl.InMemoryRefreshTokenStorage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.concurrent.CompletionStage;
import static com.softwaremill.session.javadsl.SessionTransports.CookieST;

package com.softwaremill.example.session;




public class SessionInvalidationJava extends HttpSessionAwareDirectives<MyJavaSession> {

    private static final Logger LOGGER = LoggerFactory.getLogger(SessionInvalidationJava.class);
    private static final String SECRET = "c05ll3lesrinf39t7mc5h6un6r0c69lgfno69dsak3vabeqamouq4328cuaekros401ajdpkh60rrtpd8ro24rbuqmgtnd1ebag6ljnb65i8a55d482ok7o0nch0bfbe";
    private static final SessionEncoder<MyJavaSession> BASIC_ENCODER = new BasicSessionEncoder<>(MyJavaSession.getSerializer());

    // in-memory refresh token storage
    private static final RefreshTokenStorage<MyJavaSession> REFRESH_TOKEN_STORAGE = new InMemoryRefreshTokenStorage<MyJavaSession>() {
        @Override
        public void log(String msg) {
            LOGGER.info(msg);
        }
    };

    private Refreshable<MyJavaSession> refreshable;
    private SetSessionTransport sessionTransport;

    public SessionInvalidationJava(MessageDispatcher dispatcher) {
        super(new SessionManager<>(
                SessionConfig.defaultConfig(SECRET),
                BASIC_ENCODER
            )
        );

        // use Refreshable for sessions, which needs to be refreshed or OneOff otherwise
        // using Refreshable, a refresh token is set in form of a cookie or a custom header
        refreshable = new Refreshable<>(getSessionManager(), REFRESH_TOKEN_STORAGE, dispatcher);

        // set the session transport - based on Cookies (or Headers)
        sessionTransport = CookieST;