package org.apache.geronimo.tomcat.valve;

import org.apache.catalina.valves.ValveBase;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;

import javax.servlet.ServletException;
import javax.security.jacc.PolicyContext;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: jeffgenender
 * Date: Feb 5, 2005
 * Time: 6:00:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class PolicyContextValve extends ValveBase{

    private final String policyContextID;

    public PolicyContextValve(String policyContextID){
        this.policyContextID = policyContextID;
    }

    public void invoke(Request request, Response response) throws IOException, ServletException {

        String oldId = PolicyContext.getContextID();

        PolicyContext.setContextID(policyContextID);

        // Pass this request on to the next valve in our pipeline
        getNext().invoke(request, response);

        PolicyContext.setContextID(oldId);
    }
}

@@ -1,8 +1,639 @@
+/**%0A *%0A * Copyright 2003-2004 The Apache Software Foundation%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  you may not use this file except in compliance with the License.%0A *  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A
 package 
@@ -927,165 +927,38 @@
 %0A * 
-Created by IntelliJ IDEA.%0A * User: jeffgenender%0A * Date: Feb 5, 2005%0A * Time: 6:00:02 PM%0A * To change this template use File %7C Settings %7C File Templates.%0A */
+@version $Rev: $ $Date: $%0A */%0A
 %0Apub

Add proper headers