package com.jivesoftware.os.routing.bird.authentication;

import java.io.IOException;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.NewCookie;

/**
 *
 */
public class AuthRoutingBirdSessionFilter implements ContainerResponseFilter {

    @Override
    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {

        MultivaluedMap<String, Object> headers = responseContext.getHeaders();
        for (String name : requestContext.getPropertyNames()) {
            if (name.startsWith("rb_session_token")) {
                Object rbSessionToken = requestContext.getProperty(name);
                headers.add("Set-Cookie", new NewCookie(name, rbSessionToken.toString()));
            }
        }
    }

}

@@ -242,16 +242,48 @@
 Filter;%0A
+import javax.ws.rs.core.Cookie;%0A
 import j
@@ -899,54 +899,378 @@
 ie%22,
- new NewCookie(name, rbSessionToken.toString()
+%0A                    new NewCookie(name,%0A                        rbSessionToken.toString(),%0A                        %22/%22,%0A                        null,%0A                        Cookie.DEFAULT_VERSION,%0A                        null,%0A                        NewCookie.DEFAULT_MAX_AGE,%0A                        null,%0A                        false,%0A                        false
 ));%0A

use root path in session cookies