avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 30832 - avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl
Date Wed, 28 Jul 2004 07:45:16 GMT
Author: niclas
Date: Wed Jul 28 00:45:14 2004
New Revision: 30832

Added:
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ClientCertAuthenticator.java
  (contents, props changed)
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ConfigurationMimeTypes.java
  (contents, props changed)
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DigestAuthenticator.java
  (contents, props changed)
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/FormAuthenticator.java
  (contents, props changed)
Modified:
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/BasicAuthenticator.java
   avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SystemMimeTypes.java
Log:
Added the additional Authenticators (Form, Digest & ClientCert), plus a MimeTypes class
that picks up the mimetypes from its own configuration, and not depending on the system/file
to provide it.

Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/BasicAuthenticator.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/BasicAuthenticator.java
(original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/BasicAuthenticator.java
Wed Jul 28 00:45:14 2004
@@ -28,10 +28,10 @@
 
 import org.mortbay.http.Authenticator;
 
-/** Wrapper for the Jetty SocketListener.
+/** Wrapper for the Jetty BasicAuthenticator.
  *
- * @avalon.component name="http-socket-listener" lifestyle="singleton"
- * @avalon.service type="org.mortbay.http.HttpListener"
+ * @avalon.component name="http-authenticator-basic" lifestyle="singleton"
+ * @avalon.service type="org.mortbay.http.Authenticator"
  */
 public class BasicAuthenticator extends org.mortbay.http.BasicAuthenticator
     implements Serviceable, LogEnabled

Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ClientCertAuthenticator.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ClientCertAuthenticator.java
Wed Jul 28 00:45:14 2004
@@ -0,0 +1,84 @@
+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+import org.mortbay.http.Authenticator;
+
+/** Wrapper for the Jetty ClientCertAuthenticator
+ *
+ * @avalon.component name="http-authenticator-clientcert" lifestyle="singleton"
+ * @avalon.service type="org.mortbay.http.Authenticator"
+ */
+public class ClientCertAuthenticator extends org.mortbay.http.ClientCertAuthenticator
+    implements Serviceable, LogEnabled
+{
+    private HttpContextService  m_Context;
+    private Logger              m_Logger;
+    
+    public ClientCertAuthenticator()
+    {
+    }
+    
+    /**
+     * Enable the logging system.
+     *
+     * @avalon.logger name="http"
+     */
+    public void enableLogging( Logger logger )
+    {
+        m_Logger = logger;
+    }
+    
+    public Logger getLogger()
+    {
+        return m_Logger;
+    }
+    
+    /**  
+     * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+     *                    key="httpcontext" 
+     */
+    public void service( ServiceManager man )
+        throws ServiceException
+    {
+        m_Context = (HttpContextService) man.lookup( "httpcontext" );
+        m_Context.setAuthenticator( this );
+    }
+
+    public void parameterize( Parameters params )
+        throws ParameterException
+    {
+        int maxHandshakeSec = params.getParameterAsInteger( "max-handshake-sec", -1 );
+        if( maxHandshakeSec >= 0 )
+            setMaxHandShakeSeconds( maxHandshakeSec );
+    }
+} 
+ 

Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ConfigurationMimeTypes.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ConfigurationMimeTypes.java
Wed Jul 28 00:45:14 2004
@@ -0,0 +1,93 @@
+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.avalon.http.MimeTypes;
+
+/**
+ * @avalon.component name="mimetypes-configuration" lifestyle="singleton"
+ * @avalon.service  type="org.apache.avalon.http.MimeTypes"
+ */
+public class ConfigurationMimeTypes
+    implements Configurable, MimeTypes
+{
+    private HashMap m_MimeTypeToExtMap;
+    private HashMap m_ExtToMimeTypeMap;
+    
+    public ConfigurationMimeTypes()
+    {
+    }
+    
+    public void configure( Configuration conf )
+        throws ConfigurationException
+    {
+        Configuration typesConf = conf.getChild( "mimetypes" );
+        configureTypes( typesConf );
+    }
+    
+    private void configureTypes( Configuration conf )
+        throws ConfigurationException
+    {
+        Configuration[] children = conf.getChildren( "type" );
+        for( int i=0 ; i < children.length ; i++ )
+        {
+            configureType( children[i] );
+        }
+    }
+    
+    private void configureType( Configuration conf )
+        throws ConfigurationException
+    {
+        ArrayList extList = new ArrayList();
+        String mime = conf.getChild( "mime" ).getValue();
+        Configuration[] extConfs = conf.getChildren( "ext" );
+        for( int i = 0 ; i < extConfs.length ; i++ )
+        {
+            String ext = extConfs[i].getValue();
+            extList.add( ext );
+            m_ExtToMimeTypeMap.put( ext, mime );
+        }
+        String[] exts = new String[ extList.size() ];
+        extList.toArray( exts );
+        m_MimeTypeToExtMap.put( mime, exts );
+    }
+    
+    public Map getExtensionMap()
+    {
+        return m_ExtToMimeTypeMap;
+    }
+    
+    public String getMimeType( String extension )
+    {
+        return (String) m_ExtToMimeTypeMap.get( extension );
+    }
+    
+    public String[] getExtensions( String mimetype )
+    {
+        return (String[]) m_MimeTypeToExtMap.get( mimetype );
+    }
+} 
+ 

Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DigestAuthenticator.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DigestAuthenticator.java
Wed Jul 28 00:45:14 2004
@@ -0,0 +1,72 @@
+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+import org.mortbay.http.Authenticator;
+
+/** Wrapper for the Jetty DigestAuthenticator.
+ *
+ * @avalon.component name="http-authenticator-digest" lifestyle="singleton"
+ * @avalon.service type="org.mortbay.http.Authenticator"
+ */
+public class DigestAuthenticator extends org.mortbay.http.DigestAuthenticator
+    implements Serviceable, LogEnabled
+{
+    private HttpContextService  m_Context;
+    private Logger              m_Logger;
+    
+    public DigestAuthenticator()
+    {
+    }
+    
+    /**
+     * Enable the logging system.
+     *
+     * @avalon.logger name="http"
+     */
+    public void enableLogging( Logger logger )
+    {
+        m_Logger = logger;
+    }
+    
+    public Logger getLogger()
+    {
+        return m_Logger;
+    }
+    
+    /**  
+     * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+     *                    key="httpcontext" 
+     */
+    public void service( ServiceManager man )
+        throws ServiceException
+    {
+        m_Context = (HttpContextService) man.lookup( "httpcontext" );
+        m_Context.setAuthenticator( this );
+    }
+} 
+ 

Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/FormAuthenticator.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/FormAuthenticator.java
Wed Jul 28 00:45:14 2004
@@ -0,0 +1,88 @@
+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+import org.mortbay.http.Authenticator;
+
+/** Wrapper for the Jetty FormAuthenticator.
+ *
+ * @avalon.component name="http-authenticator-form" lifestyle="singleton"
+ * @avalon.service type="org.mortbay.http.Authenticator"
+ */
+public class FormAuthenticator extends org.mortbay.jetty.servlet.FormAuthenticator
+    implements Serviceable, LogEnabled, Parameterizable
+{
+    private HttpContextService  m_Context;
+    private Logger              m_Logger;
+    
+    public FormAuthenticator()
+    {
+    }
+    
+    /**
+     * Enable the logging system.
+     *
+     * @avalon.logger name="http"
+     */
+    public void enableLogging( Logger logger )
+    {
+        m_Logger = logger;
+    }
+    
+    public Logger getLogger()
+    {
+        return m_Logger;
+    }
+    
+    /**  
+     * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+     *                    key="httpcontext" 
+     */
+    public void service( ServiceManager man )
+        throws ServiceException
+    {
+        m_Context = (HttpContextService) man.lookup( "httpcontext" );
+        m_Context.setAuthenticator( this );
+    }
+    
+    public void parameterize( Parameters params )
+        throws ParameterException
+    {
+        String loginPage = params.getParameter( "login-page", null );
+        if( loginPage != null )
+            setLoginPage( loginPage );
+        
+        String errorPage = params.getParameter( "error-page", null );
+        if( errorPage != null )
+            setErrorPage( errorPage );
+    }
+} 
+ 

Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SystemMimeTypes.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SystemMimeTypes.java
(original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SystemMimeTypes.java
Wed Jul 28 00:45:14 2004
@@ -36,7 +36,7 @@
 import org.apache.avalon.http.MimeTypes;
 
 /**
- * @avalon.component name="mimetypes" lifestyle="singleton"
+ * @avalon.component name="mimetypes-system" lifestyle="singleton"
  * @avalon.service  type="org.apache.avalon.http.MimeTypes"
  */
 public class SystemMimeTypes

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message