geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r882333 [8/11] - in /geronimo/server/trunk/plugins: ./ jetty7/ jetty8/ jetty8/geronimo-jetty7-builder/ jetty8/geronimo-jetty7-clustering-builder-wadi/ jetty8/geronimo-jetty7-clustering-wadi/ jetty8/geronimo-jetty7/ jetty8/geronimo-jetty8-bu...
Date Thu, 19 Nov 2009 22:21:55 GMT
Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,53 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.handler;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.geronimo.webservices.WebServiceContainer;
+import org.apache.geronimo.jetty8.security.SecurityHandlerFactory;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.http.HttpException;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.security.SecurityHandler;
+
+/**
+ * Specialization of ContextHandler that just has a security and servlet handler.
+ * @version $Rev$ $Date$
+ */
+public class EJBWebServiceContext extends ServletContextHandler {
+
+    public EJBWebServiceContext(String contextPath, SecurityHandler securityHandler, ServletHandler servletHandler, ClassLoader classLoader) {
+        super(null, contextPath, null, securityHandler, servletHandler, null);
+        this.setContextPath(contextPath);
+        setClassLoader(classLoader);
+        this.setAllowNullPathInfo(true);
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.handler;
+
+import java.io.IOException;
+import java.security.Permissions;
+import java.security.AccessControlContext;
+
+import javax.security.jacc.WebUserDataPermission;
+
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.UserIdentity;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class EJBWebServiceSecurityHandler extends JaccSecurityHandler {
+
+    public EJBWebServiceSecurityHandler(String policyContextID, Authenticator authenticator, LoginService loginService, IdentityService identityService, AccessControlContext defaultAcc) {
+        super(policyContextID, authenticator, loginService, identityService, defaultAcc);
+    }
+
+    protected boolean checkWebResourcePermissions(String pathInContext, Request request, Response response, Object constraintInfo, UserIdentity userIdentity) throws IOException {
+        return true;
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/EJBWebServiceSecurityHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.handler;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.jetty.security.RunAsToken;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoRunAsToken implements RunAsToken {
+
+    private final Subject runAsSubject;
+
+    public GeronimoRunAsToken(Subject runAsSubject) {
+        this.runAsSubject = runAsSubject;
+    }
+
+    public Subject getRunAsSubject() {
+        return runAsSubject;
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoRunAsToken.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.handler;
+
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.Principal;
+
+import javax.security.jacc.WebRoleRefPermission;
+import javax.security.auth.Subject;
+
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.server.UserIdentity;
+import org.eclipse.jetty.security.RunAsToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.geronimo.security.ContextManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoUserIdentity implements UserIdentity {
+    private final Logger log = LoggerFactory.getLogger(GeronimoUserIdentity.class);
+
+    private final Subject subject;
+    private final Principal userPrincipal;
+    private final AccessControlContext acc;
+    private RunAsToken runAsToken;
+    private ServletHolder servletHolder;
+
+    public GeronimoUserIdentity(Subject subject, Principal userPrincipal, AccessControlContext acc) {
+//        if ((subject == null) != (userPrincipal == null)) throw new IllegalArgumentException("both or neither of subject (" + subject + ") and userPrincipal (" + userPrincipal + ") must be null");
+        if (acc == null) throw new NullPointerException("AccessControlContext acc required");
+        this.subject = subject;
+        this.userPrincipal = userPrincipal;
+        this.acc = acc;
+    }
+
+    public Subject getSubject() {
+        return subject;
+    }
+
+    public Principal getUserPrincipal() {
+        //not clear whether this should reflect any run-as identity.  Currently it does not.
+        return userPrincipal;
+    }
+
+    public String[] getRoles() {
+        RuntimeException e = new RuntimeException("Not implemented");
+        log.info("getRoles called on identity " + this, e);
+        throw e;
+    }
+
+    public boolean isUserInRole(String role, Scope scope) {
+
+        String servletName = scope.getName();
+        if (servletName == null || servletName.equals("jsp")) {
+            servletName = "";
+        }
+        try {
+            //correct run-as identity available from context manager.
+            AccessControlContext acc = ContextManager.getCurrentContext();
+            acc.checkPermission(new WebRoleRefPermission(servletName, role));
+            return true;
+        } catch (AccessControlException e) {
+            return false;
+        }
+    }
+
+    //jaspi called from FormAuthenticator.valueUnbound (when session is unbound)
+    //TODO usable???
+    public void logout(Principal user) {
+    }
+
+    public AccessControlContext getAccessControlContext() {
+        return acc;
+    }
+
+    @Override
+    public String toString() {
+        return "GeronimoUserIdentity[Subject: " + subject + ", Principal: " + userPrincipal + ", acc: " + acc + "]";
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoUserIdentity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,180 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.handler;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.handler.ErrorHandler;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoWebAppContext extends WebAppContext {
+
+    private Handler handler;
+    protected final IntegrationContext integrationContext;
+
+
+    public GeronimoWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler, IntegrationContext integrationContext, ClassLoader classLoader) {
+        super(sessionHandler, securityHandler, servletHandler, errorHandler);
+        this.integrationContext = integrationContext;
+        setClassLoader(classLoader);
+    }
+
+    public void setTwistyHandler(Handler handler) {
+        this.handler = handler;
+    }
+
+    public Handler newTwistyHandler() {
+        return new TwistyHandler();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        javax.naming.Context context = integrationContext.setContext();
+        boolean txActive = integrationContext.isTxActive();
+        SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
+        ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
+        try {
+            try {
+                super.doStart();
+            } finally {
+                integrationContext.restoreConnectorContext(connectorContext, null, newContext);
+            }
+        } finally {
+            integrationContext.restoreContext(context);
+            integrationContext.completeTx(txActive, null);
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        javax.naming.Context context = integrationContext.setContext();
+        boolean txActive = integrationContext.isTxActive();
+        SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
+        ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
+        try {
+            try {
+                super.doStop();
+            } finally {
+                integrationContext.restoreConnectorContext(connectorContext, null, newContext);
+            }
+        } finally {
+            integrationContext.restoreContext(context);
+            integrationContext.completeTx(txActive, null);
+        }
+    }
+
+    @Override
+    public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+        javax.naming.Context context = integrationContext.setContext();
+        boolean txActive = integrationContext.isTxActive();
+        SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(baseRequest);
+        ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(baseRequest, newContext);
+        try {
+            try {
+                super.doScope(target, baseRequest, request, response);
+            } finally {
+                integrationContext.restoreConnectorContext(connectorContext, baseRequest, newContext);
+            }
+        } finally {
+            integrationContext.restoreContext(context);
+            integrationContext.completeTx(txActive, baseRequest);
+        }
+    }
+
+
+//    @Override
+//    public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+//        handler.handle(target, baseRequest, request, response);
+//    }
+
+    private class TwistyHandler implements Handler {
+
+        public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+            GeronimoWebAppContext.super.doHandle(target, baseRequest, request, response);
+        }
+
+        public void setServer(Server server) {
+             GeronimoWebAppContext.super.setServer(server);
+        }
+
+        public Server getServer() {
+            return GeronimoWebAppContext.super.getServer();
+        }
+
+        public void destroy() {
+            GeronimoWebAppContext.super.destroy();
+        }
+
+        public void start() throws Exception {
+            GeronimoWebAppContext.super.start();
+        }
+
+        public void stop() throws Exception {
+            GeronimoWebAppContext.super.stop();
+        }
+
+        public boolean isRunning() {
+            return GeronimoWebAppContext.super.isRunning();
+        }
+
+        public boolean isStarted() {
+            return GeronimoWebAppContext.super.isStarted();
+        }
+
+        public boolean isStarting() {
+            return GeronimoWebAppContext.super.isStarting();
+        }
+
+        public boolean isStopping() {
+            return GeronimoWebAppContext.super.isStopping();
+        }
+
+        public boolean isStopped() {
+            return GeronimoWebAppContext.super.isStopped();
+        }
+
+        public boolean isFailed() {
+            return GeronimoWebAppContext.super.isFailed();
+        }
+
+        public void addLifeCycleListener(Listener listener) {
+        }
+
+        public void removeLifeCycleListener(Listener listener) {
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.geronimo.jetty8.handler;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.EJB;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.servlet.Servlet;
+
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.geronimo.j2ee.annotation.Injection;
+
+/**
+ * @version $Rev$ $Date$
+ */
+class InjectionServletHandler extends ServletHandler {
+    private static final Logger log = LoggerFactory.getLogger(InjectionServletHandler.class);
+
+    private final Map<String, List<Injection>> injections;
+
+
+    public InjectionServletHandler(Map<String, List<Injection>> injections) {
+        this.injections = injections;
+    }
+
+    public Servlet customizeServlet(Servlet servlet) throws Exception {
+        List<Injection> classInjections = injections.get(servlet.getClass().getName());
+        if (classInjections != null) {
+            for (Injection injection: classInjections) {
+                
+            }
+        }
+        servlet = super.customizeServlet(servlet);
+        processAnnotations(servlet);
+        return servlet;
+    }
+
+    /**
+     * Inject resources in specified instance.
+     */
+    public void processAnnotations(Object instance) {
+        Context context = null;
+        try {
+            context = (Context) new InitialContext().lookup("java:comp/env");
+        } catch (Exception e) {
+            return;
+        }
+        if (context == null) {
+            // No resource injection
+            return;
+        }
+
+        // Initialize fields annotations
+        Field[] fields = instance.getClass().getDeclaredFields();
+        for (int i = 0; i < fields.length; i++) {
+            if (fields[i].isAnnotationPresent(EJB.class)) {
+                EJB annotation = fields[i].getAnnotation(EJB.class);
+                lookupFieldResource(context, instance, fields[i], annotation.name());
+            }
+        }
+
+        // Initialize methods annotations
+        Method[] methods = instance.getClass().getDeclaredMethods();
+        for (int i = 0; i < methods.length; i++) {
+            if (methods[i].isAnnotationPresent(EJB.class)) {
+                EJB annotation = methods[i].getAnnotation(EJB.class);
+                lookupMethodResource(context, instance, methods[i], annotation.name());
+            }
+        }
+
+    }
+
+
+    /**
+     * Inject resources in specified field.
+     */
+    protected static void lookupFieldResource(javax.naming.Context context, Object instance, Field field, String name) {
+        try {
+            Object lookedupResource = null;
+            boolean accessibility = false;
+
+            if ((name != null) && (name.length() > 0)) {
+                lookedupResource = context.lookup(name);
+            } else {
+                lookedupResource = context.lookup(instance.getClass().getName() + "/" + field.getName());
+            }
+
+            accessibility = field.isAccessible();
+            field.setAccessible(true);
+            field.set(instance, lookedupResource);
+            field.setAccessible(accessibility);
+        } catch (Exception e) {
+            log.error("Error injecting into " + instance.getClass().getName() + "." + field.getName(), e);
+        }
+    }
+
+
+    /**
+     * Inject resources in specified method.
+     */
+    protected static void lookupMethodResource(javax.naming.Context context, Object instance, Method method, String name) {
+        try {
+            if (!method.getName().startsWith("set")
+                    || method.getParameterTypes().length != 1
+                    || !method.getReturnType().getName().equals("void")) {
+                throw new IllegalArgumentException("Invalid method resource injection annotation");
+            }
+
+            Object lookedupResource = null;
+            boolean accessibility = false;
+
+            if ((name != null) && (name.length() > 0)) {
+                lookedupResource = context.lookup(name);
+            } else {
+                lookedupResource = context.lookup(instance.getClass().getName() + "/" + method.getName().substring(3));
+            }
+
+            accessibility = method.isAccessible();
+            method.setAccessible(true);
+            method.invoke(instance, lookedupResource);
+            method.setAccessible(accessibility);
+        } catch (Exception e) {
+            log.error("Error injecting into " + instance.getClass().getName() + "." + method.getName()  + "()", e);
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/InjectionServletHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.handler;
+
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.transaction.UserTransaction;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.servlet.ServletException;
+import javax.servlet.DispatcherType;
+import javax.resource.ResourceException;
+
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.naming.java.RootContext;
+import org.eclipse.jetty.server.Request;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IntegrationContext {
+
+    private final Context componentContext;
+    private final Set<String> unshareableResources;
+    private final Set<String> applicationManagedSecurityResources;
+    private final TrackedConnectionAssociator trackedConnectionAssociator;
+    private final UserTransaction userTransaction;
+
+    public IntegrationContext(Context componentContext, Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator, UserTransaction userTransaction) {
+        this.componentContext = componentContext;
+        this.unshareableResources = unshareableResources;
+        this.applicationManagedSecurityResources = applicationManagedSecurityResources;
+        this.trackedConnectionAssociator = trackedConnectionAssociator;
+        this.userTransaction = userTransaction;
+    }
+
+    public Context getComponentContext() {
+        return componentContext;
+    }
+
+    public Set<String> getUnshareableResources() {
+        return unshareableResources;
+    }
+
+    public Set<String> getApplicationManagedSecurityResources() {
+        return applicationManagedSecurityResources;
+    }
+
+    public TrackedConnectionAssociator getTrackedConnectionAssociator() {
+        return trackedConnectionAssociator;
+    }
+
+    public UserTransaction getUserTransaction() {
+        return userTransaction;
+    }
+    
+    public SharedConnectorInstanceContext newConnectorInstanceContext(Request baseRequest) {
+        return new SharedConnectorInstanceContext(getUnshareableResources(),
+                getApplicationManagedSecurityResources(),
+                !isDispatch(baseRequest));
+    }
+
+    private boolean isDispatch(Request baseRequest) {
+        if (baseRequest == null) return true;
+        return DispatcherType.REQUEST.equals(baseRequest.getDispatcherType());
+    }
+
+    public ConnectorInstanceContext setConnectorInstance(Request baseRequest, SharedConnectorInstanceContext newContext) throws ServletException {
+        try {
+            SharedConnectorInstanceContext oldContext = (SharedConnectorInstanceContext) getTrackedConnectionAssociator().enter(newContext);
+            if (oldContext != null && !isDispatch(baseRequest)) {
+                newContext.share(oldContext);
+            }
+            return oldContext;
+        } catch (ResourceException e) {
+            throw new ServletException(e);
+        }
+    }
+
+    public void restoreConnectorContext(ConnectorInstanceContext oldConnectorContext, Request baseRequest, SharedConnectorInstanceContext newContext) throws ServletException {
+        try {
+            if (isDispatch(baseRequest)) {
+                getTrackedConnectionAssociator().exit(oldConnectorContext);
+            } else {
+                newContext.hide();
+                getTrackedConnectionAssociator().exit(oldConnectorContext);
+            }
+        } catch (ResourceException e) {
+            throw new ServletException(e);
+        }
+    }
+
+
+    public javax.naming.Context setContext() {
+        javax.naming.Context oldContext = RootContext.getComponentContext();
+        RootContext.setComponentContext(getComponentContext());
+        return oldContext;
+    }
+
+    public void restoreContext(javax.naming.Context context) {
+        RootContext.setComponentContext(context);
+    }
+
+    public boolean isTxActive() throws ServletException {
+        try {
+            return !(getUserTransaction().getStatus() == Status.STATUS_NO_TRANSACTION
+                    || getUserTransaction().getStatus() == Status.STATUS_COMMITTED);
+        } catch (SystemException e) {
+            throw new ServletException("Could not determine transaction status", e);
+        }
+    }
+
+    private boolean isMarkedRollback() throws ServletException {
+        try {
+            return getUserTransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK;
+        } catch (SystemException e) {
+            throw new ServletException("Could not determine transaction status", e);
+        }
+    }
+
+
+    public void completeTx(boolean txActive, Request baseRequest) throws ServletException {
+        if ((!txActive && isMarkedRollback()) || (isDispatch(baseRequest) && isTxActive())) {
+            try {
+                getUserTransaction().rollback();
+            } catch (SystemException e) {
+                throw new ServletException("Error rolling back transaction left open by user program", e);
+            }
+        }
+    }
+    
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,157 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.handler;
+
+import java.io.IOException;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+
+import javax.security.jacc.PolicyContext;
+import javax.security.jacc.WebResourcePermission;
+import javax.security.jacc.WebUserDataPermission;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.geronimo.jetty8.JettyContainer;
+import org.apache.geronimo.security.Callers;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.jacc.PolicyContextHandlerHttpServletRequest;
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.UserIdentity;
+
+public class JaccSecurityHandler extends SecurityHandler {
+
+    private final String policyContextID;
+
+    private final AccessControlContext defaultAcc;
+
+    public JaccSecurityHandler(
+            String policyContextID,
+            Authenticator authenticator,
+            final LoginService loginService,
+            IdentityService identityService,
+            AccessControlContext defaultAcc) {
+        setAuthenticator(authenticator);
+        this.policyContextID = policyContextID;
+        this.defaultAcc = defaultAcc;
+
+        loginService.setIdentityService(identityService);
+        setLoginService(loginService);
+        setIdentityService(identityService);
+    }
+
+
+    public void doStop(JettyContainer jettyContainer) throws Exception {
+        try {
+            super.doStop();
+        }
+        finally {
+            //ignore
+        }
+    }
+
+    /* ------------------------------------------------------------ */
+    /*
+     * @see org.eclipse.jetty.security.SecurityHandler#handle(java.lang.String,
+     *      javax.servlet.http.HttpServletRequest,
+     *      javax.servlet.http.HttpServletResponse, int)
+     */
+    public void handle(String target, Request baseRequest, HttpServletRequest request,
+                       HttpServletResponse response) throws IOException,
+            ServletException {
+        String old_policy_id = PolicyContext.getContextID();
+        Callers oldCallers = ContextManager.getCallers();
+        HttpServletRequest oldRequest = PolicyContextHandlerHttpServletRequest.pushContextData(request);
+        try {
+            PolicyContext.setContextID(policyContextID);
+
+
+            super.handle(target, baseRequest, request, response);
+        } finally {
+            PolicyContext.setContextID(old_policy_id);
+            ContextManager.popCallers(oldCallers);
+            PolicyContextHandlerHttpServletRequest.popContextData(oldRequest);
+        }
+    }
+
+    protected Object prepareConstraintInfo(String pathInContext, Request request) {
+        return null;
+    }
+
+    protected boolean checkUserDataPermissions(String pathInContext, Request request, Response response, Object constraintInfo) throws IOException {
+        boolean notIntegral = request.isSecure() || !request.getConnection().isIntegral(request);
+
+        try {
+            /**
+             * JACC v1.0 section 4.1.1
+             */
+            WebUserDataPermission wudp;
+            if (notIntegral) {
+                wudp = new WebUserDataPermission(request);
+            } else {
+                wudp = new WebUserDataPermission(encodeColons(request), new String[]{request.getMethod()}, "INTEGRAL");
+            }
+            defaultAcc.checkPermission(wudp);
+            return true;
+        } catch (AccessControlException e) {
+            //TODO redirect to secure port.
+            return false;
+        }
+    }
+
+    private static String encodeColons(HttpServletRequest request) {
+        String result = request.getServletPath() + (request.getPathInfo() == null ? "" : request.getPathInfo());
+
+        if (result.indexOf(":") > -1) result = result.replaceAll(":", "%3A");
+
+        return result;
+    }
+
+    protected boolean isAuthMandatory(Request base_request, Response base_response, Object constraintInfo) {
+        return !checkWebResourcePermission(base_request, defaultAcc);
+    }
+
+    protected boolean checkWebResourcePermissions(String pathInContext, Request request, Response response, Object constraintInfo, UserIdentity userIdentity) throws IOException {
+        if (!(userIdentity instanceof GeronimoUserIdentity)){
+            //we already checked against default_acc and got false
+            return false;
+        }
+        AccessControlContext acc = ((GeronimoUserIdentity)userIdentity).getAccessControlContext();
+        return checkWebResourcePermission(request, acc);
+    }
+
+    private boolean checkWebResourcePermission(Request request, AccessControlContext acc) {
+        WebResourcePermission webResourcePermission = new WebResourcePermission(request);
+        /**
+         * JACC v1.0 section 4.1.2
+         */
+        //user is not logged in: if access denied, try to log them in.
+        try {
+            acc.checkPermission(webResourcePermission);
+            return true;
+        } catch (AccessControlException e) {
+            return false;
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/JaccSecurityHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,27 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.requestlog;
+
+import org.apache.geronimo.management.geronimo.WebAccessLog;
+
+/**
+ * Token interface to distinguish Jetty implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JettyLogManager extends WebAccessLog {
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,299 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.requestlog;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.RandomAccessFile;
+import java.nio.CharBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * Jetty implementation of the WebAccessLog management interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyLogManagerImpl implements JettyLogManager {
+    private static final Logger log = LoggerFactory.getLogger(JettyLogManagerImpl.class);
+
+    // Pattern that matches the date in the logfile name
+    private final static Pattern FILENAME_DATE_PATTERN = Pattern.compile("[-_ /.](((19|20)\\d\\d)[-_ /.](0[1-9]|1[012])[-_ /.](0[1-9]|[12][0-9]|3[01]))");
+    private final static int GROUP_FILENAME_FULL_DATE = 1;
+    private final static int GROUP_FILENAME_YEAR  = 2;
+    private final static int GROUP_FILENAME_MONTH = 4;
+    private final static int GROUP_FILENAME_DAY   = 5;
+    // NOTE:  The file separators are specified here rather than using something like File.separator because
+    //        they are hard coded in config plans and sometimes in java code itself rather than being dependent
+    //        upon the OS.  This should be fixed someday, but for now we will manually check for either format.
+    private final static String FILE_SEPARATOR_UNIX_STYLE = "/";
+    private final static String FILE_SEPARATOR_WIN_STYLE = "\\";
+
+    // Pattern that matches a single line  (used to calculate line numbers)
+    private final static Pattern FULL_LINE_PATTERN = Pattern.compile("^.*", Pattern.MULTILINE);
+    private final static Pattern ACCESS_LOG_PATTERN = Pattern.compile("(\\S*) (\\S*) (\\S*) \\[(.*)\\] \\\"(\\S*) (\\S*).*?\\\" (\\S*) (\\S*).*");
+    private final static int GROUP_HOST = 1;
+    private final static int GROUP_USER = 3;
+    private final static int GROUP_DATE = 4;
+    private final static int GROUP_METHOD = 5;
+    private final static int GROUP_URI = 6;
+    private final static int GROUP_RESPONSE_CODE = 7;
+    private final static int GROUP_RESPONSE_LENGTH = 8;
+    private final static String ACCESS_LOG_DATE_FORMAT = "dd/MMM/yyyy:HH:mm:ss ZZZZ";
+    private final static String LOG_FILE_NAME_FORMAT = "yyyy_MM_dd";
+    private final Collection logGbeans;   
+    private final ServerInfo serverInfo;  
+
+    public JettyLogManagerImpl(ServerInfo serverInfo, Collection logGbeans) {
+        this.serverInfo = serverInfo;
+        this.logGbeans = logGbeans;
+    }
+
+    /**
+     * Gets the name of all logs used by this system.  Typically there
+     * is only one, but specialized cases may use more.
+     *
+     * @return An array of all log names
+     *
+     */
+    public String[] getLogNames() {
+        List logNames = new ArrayList();
+        for (Iterator it = logGbeans.iterator(); it.hasNext();) {
+            JettyRequestLog jettyLog = (JettyRequestLog) it.next();
+            if(jettyLog.getFilename() != null) {
+                logNames.add(jettyLog.getFilename());
+            }
+        }
+        return (String[]) logNames.toArray(new String[logNames.size()]);
+    }
+
+    /**
+     * Gets the names of all log files for this log name.  
+     *
+     * @param logName The name of the log for which to return the specific file names.
+     *
+     * @return An array of log file names
+     *
+     */
+    public String[] getLogFileNames(String logName) {
+        List names = new ArrayList();
+
+        // Find all the files for this logName
+        File[] logFiles = getLogFiles(logName);
+
+        if (logFiles !=null) {
+            for (int i = 0; i < logFiles.length; i++) {
+                names.add(logFiles[i].getName());
+            }
+        }
+        return (String[]) names.toArray(new String[names.size()]);
+    }
+
+    /**
+     * Gets the name of all log files used by this log.  Typically there
+     * is only one, but specialized cases may use more.
+     *
+     * @param logName The name of the log for which to return the specific files.
+     *
+     * @return An array of all log file names
+     *
+     */
+    private File[] getLogFiles(String logName) {
+        File[] logFiles = null;
+
+        try {
+            String fileNamePattern = logName;
+            if (fileNamePattern.indexOf(FILE_SEPARATOR_UNIX_STYLE) > -1) {
+                fileNamePattern = fileNamePattern.substring(fileNamePattern.lastIndexOf(FILE_SEPARATOR_UNIX_STYLE) + 1);
+            } else if (fileNamePattern.indexOf(FILE_SEPARATOR_WIN_STYLE) > -1) {
+                fileNamePattern = fileNamePattern.substring(fileNamePattern.lastIndexOf(FILE_SEPARATOR_WIN_STYLE) + 1);
+            }
+
+            String logFile = serverInfo.resolveServerPath(logName);
+
+            File parent = new File(logFile).getParentFile();
+
+            if (parent != null) {
+                logFiles = parent.listFiles(new PatternFilenameFilter(fileNamePattern));
+            }
+        } catch (Exception e) {
+            log.error("Exception attempting to locate Jetty log files", e);
+            logFiles = new File[0];
+        }
+        return logFiles;
+    }
+
+    /**
+     * Searches the log for records matching the specified parameters.  The
+     * maximum results returned will be the lesser of 1000 and the
+     * provided maxResults argument.
+     *
+     * @see #MAX_SEARCH_RESULTS
+     */
+    public SearchResults getMatchingItems(String logName, String host, String user, String method, String uri, Date startDate,
+                                          Date endDate, Integer skipResults, Integer maxResults) {
+
+        // Clean up the arguments so we know what we've really got
+        if(host != null && host.equals("")) host = null;
+        if(user != null && user.equals("")) user = null;
+        if(method != null && method.equals("")) method = null;
+        if(uri != null && uri.equals("")) uri = null;
+
+        long start = startDate == null ? 0 : startDate.getTime();
+        long end = endDate == null ? 0 : endDate.getTime();
+
+        List list = new LinkedList();
+        boolean capped = false;
+        int lineCount = 0, fileCount = 0;
+
+        // Find all the files for this logName
+        File logFiles[] = getLogFiles(logName);
+
+        if (logFiles !=null) {
+            for (int i = 0; i < logFiles.length; i++) {
+                fileCount = 0;
+                try {
+                    // Obtain the date for the current log file
+                    String fileName = logFiles[i].getName();
+                    Matcher fileDate = FILENAME_DATE_PATTERN.matcher(fileName);
+                    fileDate.find();
+                    SimpleDateFormat simpleFileDate = new SimpleDateFormat(LOG_FILE_NAME_FORMAT);
+                    long logFileTime = simpleFileDate.parse(fileDate.group(GROUP_FILENAME_FULL_DATE)).getTime();
+
+                    // Check if the dates are null (ignore) or fall within the search range
+                    if (  (start==0 && end==0)
+                       || (start>0 && start<=logFileTime && end>0 && end>=logFileTime)) {
+
+                        // It's in the range, so process the file
+                        RandomAccessFile raf = new RandomAccessFile(logFiles[i], "r");
+                        FileChannel fc = raf.getChannel();
+                        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
+                        CharBuffer cb = Charset.forName("US-ASCII").decode(bb); //todo: does Jetty use a different charset on a foreign PC?
+                        Matcher lines = FULL_LINE_PATTERN.matcher(cb);
+                        Matcher target = ACCESS_LOG_PATTERN.matcher("");
+                        SimpleDateFormat format = (start == 0 && end == 0) ? null : new SimpleDateFormat(ACCESS_LOG_DATE_FORMAT);
+                        int max = maxResults == null ? MAX_SEARCH_RESULTS : Math.min(maxResults.intValue(), MAX_SEARCH_RESULTS);
+
+                        while(lines.find()) {
+                            ++lineCount;
+                            ++fileCount;
+                            if(capped) {
+                                continue;
+                            }
+                            CharSequence line = cb.subSequence(lines.start(), lines.end());
+                            target.reset(line);
+                            if(target.find()) {
+                                if(host != null && !host.equals(target.group(GROUP_HOST))) {
+                                    continue;
+                                }
+                                if(user != null && !user.equals(target.group(GROUP_USER))) {
+                                    continue;
+                                }
+                                if(method != null && !method.equals(target.group(GROUP_METHOD))) {
+                                    continue;
+                                }
+                                if(uri != null && !target.group(GROUP_URI).startsWith(uri)) {
+                                    continue;
+                                }
+                                if(format != null) {
+                                    try {
+                                        long entry = format.parse(target.group(GROUP_DATE)).getTime();
+                                        if(start > entry) {
+                                            continue;
+                                        }
+                                        if(end > 0 && end < entry) {
+                                            continue;
+                                        }
+                                    } catch (ParseException e) {
+                                        // can't read the date, guess this record counts.
+                                    }
+                                }
+                                if(skipResults != null && skipResults.intValue() > lineCount) {
+                                    continue;
+                                }
+                                if(list.size() > max) {
+                                    capped = true;
+                                    continue;
+                                }
+                                list.add(new LogMessage(fileCount,line.toString()));
+                            }
+                        }
+                        fc.close();
+                        raf.close();
+                    }
+                } catch (Exception e) {
+                    log.error("Unexpected error processing logs", e);
+                }
+            }
+        }
+        return new SearchResults(lineCount, (LogMessage[]) list.toArray(new LogMessage[list.size()]), capped);
+    }
+
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Jetty Log Manager", JettyLogManagerImpl.class);
+        infoFactory.addReference("LogGBeans", JettyRequestLog.class);
+        infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+        infoFactory.addInterface(JettyLogManager.class);
+
+        infoFactory.setConstructor(new String[]{"ServerInfo","LogGBeans"});  
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+    /*
+     * Static inner class implementation of java.io.Filename. This will help us
+     * filter for only the files that we are interested in.
+     */
+    static class PatternFilenameFilter implements FilenameFilter {
+        Pattern pattern;
+        //todo: put this pattern in a GBean parameter?
+        PatternFilenameFilter(String fileNamePattern) {
+            fileNamePattern = fileNamePattern.replaceAll("yyyy", "\\\\d{4}");
+            fileNamePattern = fileNamePattern.replaceAll("yy", "\\\\d{2}");
+            fileNamePattern = fileNamePattern.replaceAll("mm", "\\\\d{2}");
+            fileNamePattern = fileNamePattern.replaceAll("dd", "\\\\d{2}");
+            this.pattern = Pattern.compile(fileNamePattern);
+        }
+
+        public boolean accept(File file, String fileName) {
+            return pattern.matcher(fileName).matches();
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyLogManagerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,58 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.requestlog;
+
+/**
+ * Interface for the NCSARequestLog GBean
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JettyRequestLog {
+    void setFilename(String filename);
+
+    String getFilename();
+
+    String getAbsoluteFilePath();
+
+    void setLogDateFormat(String format);
+
+    String getLogDateFormat();
+
+    void setLogTimeZone(String tz);
+
+    String getLogTimeZone();
+
+    int getRetainDays();
+
+    void setRetainDays(int retainDays);
+
+    boolean isExtended();
+
+    void setExtended(boolean e);
+
+    boolean isAppend();
+
+    void setAppend(boolean a);
+
+    void setIgnorePaths(String[] ignorePaths);
+
+    String[] getIgnorePaths();
+
+    void setPreferProxiedForAddress(boolean value);
+
+    boolean isPreferProxiedForAddress();
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/JettyRequestLog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,141 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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 org.apache.geronimo.jetty8.requestlog;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.jetty8.JettyContainer;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NCSARequestLog implements GBeanLifecycle, JettyRequestLog {
+    private final JettyContainer container;
+    private final ServerInfo serverInfo;
+    private final org.eclipse.jetty.server.NCSARequestLog requestLog;
+    private boolean preferProxiedForAddress;
+    private String filename;
+
+    public NCSARequestLog(JettyContainer container, ServerInfo serverInfo) {
+        this.container = container;
+        this.serverInfo = serverInfo;
+        requestLog = new org.eclipse.jetty.server.NCSARequestLog();
+    }
+
+    public void setFilename(String filename) {
+        this.filename = filename;
+    }
+
+    public String getFilename() {
+        return filename;
+    }
+
+    public void setLogDateFormat(String format) {
+        requestLog.setLogDateFormat(format);
+    }
+
+    public String getLogDateFormat() {
+        return requestLog.getLogDateFormat();
+    }
+
+    public void setLogTimeZone(String tz) {
+        requestLog.setLogTimeZone(tz);
+    }
+
+    public String getLogTimeZone() {
+        return requestLog.getLogTimeZone();
+    }
+
+    public int getRetainDays() {
+        return requestLog.getRetainDays();
+    }
+
+    public void setRetainDays(int retainDays) {
+        requestLog.setRetainDays(retainDays);
+    }
+
+    public boolean isExtended() {
+        return requestLog.isExtended();
+    }
+
+    public void setExtended(boolean e) {
+        requestLog.setExtended(e);
+    }
+
+    public boolean isAppend() {
+        return requestLog.isAppend();
+    }
+
+    public void setAppend(boolean a) {
+        requestLog.setAppend(a);
+    }
+
+    public void setIgnorePaths(String[] ignorePaths) {
+        requestLog.setIgnorePaths(ignorePaths);
+    }
+
+    public String[] getIgnorePaths() {
+        return requestLog.getIgnorePaths();
+    }
+
+    public void setPreferProxiedForAddress(boolean value) {
+        this.preferProxiedForAddress = value;
+        requestLog.setPreferProxiedForAddress(value);
+    }
+
+    public boolean isPreferProxiedForAddress() {
+        return preferProxiedForAddress;
+    }
+
+    public String getAbsoluteFilePath() {
+        return requestLog == null ? null : requestLog.getDatedFilename();
+    }
+
+    public void doStart() throws Exception {
+        requestLog.setFilename(serverInfo.resolveServerPath(filename));
+        container.setRequestLog(requestLog);
+        requestLog.start();
+    }
+
+    public void doStop() throws Exception {
+        container.setRequestLog(null);
+    }
+
+    public void doFail() {
+        container.setRequestLog(null);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("NCSA Request Log", NCSARequestLog.class);
+        infoFactory.addReference("JettyContainer", JettyContainer.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
+        infoFactory.addReference("ServerInfo", ServerInfo.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
+
+        infoFactory.addInterface(JettyRequestLog.class, new String[]{"filename", "logDateFormat", "logTimeZone",
+                "retainDays", "extended", "append", "ignorePaths", "preferProxiedForAddress", });
+
+        infoFactory.setConstructor(new String[]{"JettyContainer", "ServerInfo"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/requestlog/NCSARequestLog.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.security;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.security.AccessControlContext;
+
+import javax.security.auth.Subject;
+import javax.security.auth.message.AuthException;
+import javax.security.auth.message.config.AuthConfigFactory;
+import javax.security.auth.message.config.AuthConfigProvider;
+import javax.security.auth.message.config.RegistrationListener;
+import javax.security.auth.message.config.ServerAuthConfig;
+
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.jetty8.handler.JaccSecurityHandler;
+import org.apache.geronimo.jetty8.security.auth.JAASLoginService;
+import org.apache.geronimo.security.jacc.RunAsSource;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.jaas.ConfigurationFactory;
+import org.eclipse.jetty.security.Authenticator;
+import org.eclipse.jetty.security.LoginService;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.security.jaspi.JaspiAuthenticator;
+import org.eclipse.jetty.security.jaspi.ServletCallbackHandler;
+
+/**
+ * Fetches a ServerAuthConfig out of the AuthConfigFactory
+ * 
+ * @version $Rev$ $Date$
+ */
+
+@GBean
+public class AuthConfigProviderHandlerFactory implements SecurityHandlerFactory {
+
+    private static final String POLICY_CONTEXT_ID_KEY = "javax.security.jacc.PolicyContext";
+
+    private final Map authConfigProperties = new HashMap<Object, Object>();
+    private final Subject serviceSubject = null;
+    private final String appContext;
+    private final boolean allowLazyAuthentication;
+//    private final Authenticator authenticator;
+    private final LoginService loginService;
+    private final ServerAuthConfig serverAuthConfig;
+    private final ServletCallbackHandler servletCallbackHandler;
+
+
+    public AuthConfigProviderHandlerFactory(@ParamAttribute(name = "messageLayer")String messageLayer,
+                                            @ParamAttribute(name = "appContext")String appContext,
+                                            @ParamAttribute(name = "allowLazyAuthentication") boolean allowLazyAuthentication,
+                                            @ParamReference(name = "ConfigurationFactory") ConfigurationFactory configurationFactory
+    ) throws AuthException {
+        this.appContext = appContext;
+        this.allowLazyAuthentication = allowLazyAuthentication;
+        AuthConfigFactory authConfigFactory = AuthConfigFactory.getFactory();
+        RegistrationListener listener = new RegistrationListener() {
+
+            public void notify(String layer, String appContext) {
+            }
+        };
+        AuthConfigProvider authConfigProvider = authConfigFactory.getConfigProvider(messageLayer, appContext, listener);
+        this.loginService = new JAASLoginService(configurationFactory, null);
+        servletCallbackHandler = new ServletCallbackHandler(loginService);
+        serverAuthConfig = authConfigProvider.getServerAuthConfig(messageLayer, appContext, servletCallbackHandler);
+        //TODO appContext is supposed to be server-name<space>context-root
+
+    }
+
+    public SecurityHandler buildSecurityHandler(String policyContextID, Subject defaultSubject, RunAsSource runAsSource, boolean checkRolePermissions) {
+        if (defaultSubject == null) {
+            defaultSubject = ContextManager.EMPTY;
+        }
+        AccessControlContext defaultAcc = ContextManager.registerSubjectShort(defaultSubject, null, null);
+        IdentityService identityService = new JettyIdentityService(defaultAcc, defaultSubject, runAsSource);
+        authConfigProperties.put(POLICY_CONTEXT_ID_KEY, policyContextID);
+        Authenticator authenticator = new JaspiAuthenticator(serverAuthConfig, authConfigProperties, servletCallbackHandler, serviceSubject, allowLazyAuthentication, identityService);
+        //login service functionality is already inside the servletCallbackHandler
+        return new JaccSecurityHandler(policyContextID, authenticator, loginService, identityService, defaultAcc);
+    }
+
+}
\ No newline at end of file

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/AuthConfigProviderHandlerFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.security;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public enum BuiltInAuthMethod {
+
+    NONE("NONE"), BASIC("BASIC"), DIGEST("DIGEST"), FORM("FORM"), CLIENTCERT("CLIENT-CERT");
+
+    private String value;
+
+    private BuiltInAuthMethod(String value) {
+        this.value = value;
+    }
+
+    public String toString() {
+        return value;
+    }
+
+    public static BuiltInAuthMethod getValueOf(String name) {
+        for (BuiltInAuthMethod method : BuiltInAuthMethod.values()) {
+            if (method.toString().equals(name)) {
+                return method;
+            }
+        }
+        throw new IllegalArgumentException("No enum for " + name);
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/BuiltInAuthMethod.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java?rev=882333&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java (added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java Thu Nov 19 22:21:48 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.geronimo.jetty8.security;
+
+import java.security.AccessControlContext;
+import java.security.Principal;
+import java.util.Arrays;
+
+import javax.security.auth.Subject;
+
+import org.apache.geronimo.jetty8.handler.GeronimoRunAsToken;
+import org.apache.geronimo.jetty8.handler.GeronimoUserIdentity;
+import org.apache.geronimo.security.Callers;
+import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.security.jacc.RunAsSource;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.RunAsToken;
+import org.eclipse.jetty.server.UserIdentity;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JettyIdentityService implements IdentityService {
+
+    private final AccessControlContext defaultAcc;
+    private final Subject defaultSubject;
+    private final RunAsSource runAsSource;
+
+    public JettyIdentityService(AccessControlContext defaultAcc, Subject defaultSubject, RunAsSource runAsSource) {
+        this.defaultAcc = defaultAcc;
+        this.defaultSubject = defaultSubject;
+        this.runAsSource = runAsSource;
+    }
+
+    public Object associate(UserIdentity user) {
+        Callers oldCallers = ContextManager.getCallers();
+        if (user == null) {
+            //exit
+            ContextManager.setCallers(defaultSubject, defaultSubject);
+        } else {
+            //enter
+            ContextManager.setCallers(user.getSubject(), user.getSubject());
+        }
+        return oldCallers;
+    }
+
+    public void disassociate(Object previousIdentity) {
+        ContextManager.popCallers((Callers) previousIdentity);
+
+    }
+
+    public Object setRunAs(UserIdentity userIdentity, RunAsToken token) {
+        GeronimoRunAsToken geronimoRunAsToken = (GeronimoRunAsToken) token;
+        Subject runAsSubject = geronimoRunAsToken == null? null: geronimoRunAsToken.getRunAsSubject();
+        return ContextManager.pushNextCaller(runAsSubject);
+    }
+
+    public void unsetRunAs(Object previousToken) {
+        ContextManager.popCallers((Callers) previousToken);
+    }
+
+    public UserIdentity newUserIdentity(Subject subject, Principal userPrincipal, String[] roles) {
+        if (subject != null) {
+            AccessControlContext acc = ContextManager.registerSubjectShort(subject, userPrincipal, roles == null? null: Arrays.asList(roles));
+            return new GeronimoUserIdentity(subject, userPrincipal, acc);
+        }
+        return new GeronimoUserIdentity(null, null, defaultAcc);
+    }
+
+    public RunAsToken newRunAsToken(String runAsName) {
+        Subject runAsSubject = runAsSource.getSubjectForRole(runAsName);
+        return new GeronimoRunAsToken(runAsSubject);
+    }
+
+    public UserIdentity getSystemUserIdentity() {
+        return new GeronimoUserIdentity(null, null, defaultAcc);
+    }
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/security/JettyIdentityService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message