notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1400 - in development/main/planet/facilities/http: blocks/hash-basic blocks/hash-clientcert blocks/hash-digest blocks/hash-form blocks/static examples/hello examples/hello/etc/deliverables/confs examples/hello/etc/deliverables/realms examples/hello/src/main/net/dpml/playground impl/etc/deliverables/realms impl/src/main/net/dpml/http/impl impl/src/main/org/mortbay/http spi/src/main/net/dpml/http
- From: niclas AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1400 - in development/main/planet/facilities/http: blocks/hash-basic blocks/hash-clientcert blocks/hash-digest blocks/hash-form blocks/static examples/hello examples/hello/etc/deliverables/confs examples/hello/etc/deliverables/realms examples/hello/src/main/net/dpml/playground impl/etc/deliverables/realms impl/src/main/net/dpml/http/impl impl/src/main/org/mortbay/http spi/src/main/net/dpml/http
- Date: Fri, 07 Jan 2005 09:40:00 +0100
Author: niclas
Date: Fri Jan 7 09:40:00 2005
New Revision: 1400
Added:
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.java
(contents, props changed)
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.xprofile
(contents, props changed)
Removed:
development/main/planet/facilities/http/examples/hello/etc/deliverables/realms/
Modified:
development/main/planet/facilities/http/blocks/hash-basic/build.xml
development/main/planet/facilities/http/blocks/hash-clientcert/build.xml
development/main/planet/facilities/http/blocks/hash-digest/build.xml
development/main/planet/facilities/http/blocks/hash-form/build.xml
development/main/planet/facilities/http/blocks/static/build.xml
development/main/planet/facilities/http/examples/hello/README.TXT
development/main/planet/facilities/http/examples/hello/build.xml
development/main/planet/facilities/http/examples/hello/etc/deliverables/confs/hello.conf
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
development/main/planet/facilities/http/impl/etc/deliverables/realms/default.realm
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityHandler.java
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/BasicAuthenticator.xinfo
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/DigestAuthenticator.xinfo
development/main/planet/facilities/http/spi/src/main/net/dpml/http/HttpContextService.java
Log:
More fixes to the Http Facility. Authentication should now be supported
without Webapp setup, and the Hello demo has been upgraded to work and
highlight how to use authentication.
Modified: development/main/planet/facilities/http/blocks/hash-basic/build.xml
==============================================================================
--- development/main/planet/facilities/http/blocks/hash-basic/build.xml
(original)
+++ development/main/planet/facilities/http/blocks/hash-basic/build.xml Fri
Jan 7 09:40:00 2005
@@ -23,14 +23,13 @@
<target name="build" depends="standard.build">
<x:block name="hash-basic-auth">
- <x:service type="org.mortbay.http.Authenticator"
source="authenticator" />
+ <x:service type="org.mortbay.http.UserRealm" source="realm" />
<x:component name="realm" class="net.dpml.http.impl.HashUserRealm" >
<x:parameters>
<x:parameter name="name" value="Metro" />
<x:parameter name="realm-uri"
value="artifact:realm:dpml/http/default" />
</x:parameters>
</x:component>
- <x:component name="authenticator"
class="org.mortbay.http.BasicAuthenticator" />
</x:block>
</target>
Modified:
development/main/planet/facilities/http/blocks/hash-clientcert/build.xml
==============================================================================
--- development/main/planet/facilities/http/blocks/hash-clientcert/build.xml
(original)
+++ development/main/planet/facilities/http/blocks/hash-clientcert/build.xml
Fri Jan 7 09:40:00 2005
@@ -23,14 +23,13 @@
<target name="build" depends="standard.build">
<x:block name="hash-clientcert-auth">
- <x:service type="org.mortbay.http.Authenticator"
source="authenticator" />
+ <x:service type="org.mortbay.http.UserRealm" source="realm" />
<x:component name="realm" class="net.dpml.http.impl.HashUserRealm" >
<x:parameters>
<x:parameter name="name" value="Metro" />
<x:parameter name="realm-uri"
value="artifact:realm:dpml/http/default" />
</x:parameters>
</x:component>
- <x:component name="authenticator"
class="net.dpml.http.impl.ClientCertAuthenticator" />
</x:block>
</target>
Modified: development/main/planet/facilities/http/blocks/hash-digest/build.xml
==============================================================================
--- development/main/planet/facilities/http/blocks/hash-digest/build.xml
(original)
+++ development/main/planet/facilities/http/blocks/hash-digest/build.xml
Fri Jan 7 09:40:00 2005
@@ -23,14 +23,13 @@
<target name="build" depends="standard.build">
<x:block name="hash-digest-auth">
- <x:service type="org.mortbay.http.Authenticator"
source="authenticator" />
+ <x:service type="org.mortbay.http.UserRealm" source="realm" />
<x:component name="realm" class="net.dpml.http.impl.HashUserRealm" >
<x:parameters>
<x:parameter name="name" value="Metro" />
<x:parameter name="realm-uri"
value="artifact:realm:dpml/http/default" />
</x:parameters>
</x:component>
- <x:component name="authenticator"
class="org.mortbay.http.DigestAuthenticator" />
</x:block>
</target>
Modified: development/main/planet/facilities/http/blocks/hash-form/build.xml
==============================================================================
--- development/main/planet/facilities/http/blocks/hash-form/build.xml
(original)
+++ development/main/planet/facilities/http/blocks/hash-form/build.xml Fri
Jan 7 09:40:00 2005
@@ -23,19 +23,21 @@
<target name="build" depends="standard.build">
<x:block name="hash-form-auth">
- <x:service type="org.mortbay.http.Authenticator"
source="authenticator" />
+ <x:service type="org.mortbay.http.UserRealm" source="realm" />
<x:component name="realm" class="net.dpml.http.impl.HashUserRealm" >
<x:parameters>
<x:parameter name="name" value="Metro" />
<x:parameter name="realm-uri"
value="artifact:realm:dpml/http/default" />
</x:parameters>
</x:component>
+<!-- need to be exported, which Magic doesn't support.. :o(
<x:component name="authenticator"
class="net.dpml.http.impl.FormAuthenticator" >
<x:parameters>
<x:parameter name="login-page" value="/login.html" />
<x:parameter name="error-page" value="/login_error.html" />
</x:parameters>
</x:component>
+-->
</x:block>
</target>
Modified: development/main/planet/facilities/http/blocks/static/build.xml
==============================================================================
--- development/main/planet/facilities/http/blocks/static/build.xml
(original)
+++ development/main/planet/facilities/http/blocks/static/build.xml Fri
Jan 7 09:40:00 2005
@@ -26,13 +26,13 @@
<x:service type="net.dpml.http.HttpContextService" source="context" />
<x:component name="context" class="net.dpml.http.impl.HttpContextImpl"
/>
<x:component name="security-handler"
class="net.dpml.http.impl.SecurityHandler" />
+ <x:component name="forward-handler"
class="net.dpml.http.impl.ForwardHandler" />
<x:component name="resource-handler"
class="net.dpml.http.impl.ResourceHandler" >
<x:parameters>
<x:parameter name="allow-directory" value="true"/>
<x:parameter name="allow-methods" value="GET"/>
</x:parameters>
</x:component>
- <x:component name="forward-handler"
class="net.dpml.http.impl.ForwardHandler" />
<x:component name="notfound-handler"
class="net.dpml.http.impl.NotFoundHandler" />
<x:component name="request-log"
class="net.dpml.http.impl.NcsaRequestLog" >
<x:parameters>
@@ -41,6 +41,7 @@
<x:parameter name="extended" value="true"/>
</x:parameters>
</x:component>
+ <x:component name="authenticator"
class="org.mortbay.http.BasicAuthenticator" />
</x:block>
</target>
Modified: development/main/planet/facilities/http/examples/hello/README.TXT
==============================================================================
--- development/main/planet/facilities/http/examples/hello/README.TXT
(original)
+++ development/main/planet/facilities/http/examples/hello/README.TXT Fri
Jan 7 09:40:00 2005
@@ -1,101 +1,131 @@
-
-HTTP HELLO DEMO README
-----------------------
-
- The "hello" project demonstrates the setup of a http server and context
- within which it handles the serving of static and dynamic content. The
- block for this project is declared with the build.xml file and covers the
- inclusion of the http server block, the inclusion of a context containing
- a static handler, redirect handler, model handler and a number of error
- handlers. Finally, the block contains a component that we use to handle
- some dynamic content:
-
- <target name="build" depends="standard.build">
- <x:property name="server.uri" key="dpml-http-server" feature="uri"/>
- <x:property name="static.uri" key="dpml-http-static" feature="uri"/>
- <x:property name="hash.uri" key="dpml-http-hash-basic" feature="uri"/>
-
- <x:block name="demo">
- <x:include name="server" uri="${server.uri}"/>
- <x:include name="static-context" uri="${static.uri}"/>
- <x:component name="hello" class="net.dpml.playground.HelloComponent" />
- <x:include name="authentication" uri="${hash.uri}"/>
- </x:block>
- </target>
-
- The block is configured using the a targets file. The file includes
three
- target overrides, one dealing with the context definition, the second
- demonstrating some redirection capability, and the third demonstrating
http
- path to component path mapping.
-
- The static content handler is configured to use the current directory as
the
- default root content basedir (signified by the context-path and
- resource-base element value).
-
- <target path="/demo/static-context/context">
- <configuration>
- <context-path>/</context-path>
- <resource-base>.</resource-base>
- </configuration>
- </target>
-
- The following target overrides the configuration for a url forwarding
- handler. It simply forwards a 'from' path to a 'to' path. For example,
if
- you enter a url such as http://localhost/hello you will be redirected to
- http://localhost/demo/hello.
-
- <target path="/demo/static-context/forward-handler">
- <configuration>
- <forwards>
- <forward>
- <from>/hello</from>
- <to>/demo/hello</to>
- </forward>
- </forwards>
- </configuration>
- </target>
-
- The following target override directs incomming urls with the path
'/hello'
- to the component at the address '/demo/hello'.
-
- <target path="/demo/static-context/model-handler">
- <parameters>
- <parameter name="context-path" value="/demo/hello"/>
- <parameter name="target" value="/demo/hello"/>
- </parameters>
- </target>
-
-
- To build the server do the following:
-
- $ cd dpml.net <--- your root svn/development/main/ directory
- $ ant -f setup.xml <--- build Magic/Transit bootstrap code, if not
done
- $ ant <--- build all of Metro, if not done
-
- $ cd planet/facilities/http/examples/demo
-
- To test the server you can either execute the generated block from the
local
- file system of from magic's repository.
-
- Executing the block from the local filesystem:
-
- $ metro target/deliverables/blocks/dpml-http-hello-2.0.0.block
-config target/deliverables/confs/hello.conf
-
- But why not utilize the extremely powerful artifact: protocol, and the
fact
- that everything is built as artifacts. This provides command-lines that
are
- independent of where on the local file system the command is executed;
-
- $ metro
artifact:block:dpml/http/examples/hello/dpml-http-hello#2.0.0 -config
artifact:conf:dpml/http/examples/hello/hello
-
- To check the running applicaion, open a browser and enter the following
url;
-
- http://localhost:8080
-
- You should see the contents of the local directory in your browser.
-
- http://localhost:8080/hello
-
- You should see a simple "Hello" message created by the HelloComponent.
-
-<The DPML documentation team>
-
+
+HTTP HELLO DEMO README
+----------------------
+
+ The "hello" project demonstrates the setup of a http server and context
+ within which it handles the serving of static and dynamic content. The
+ block for this project is declared with the build.xml file and covers the
+ inclusion of the http server block, the inclusion of a context containing
+ a security handler, a static resources handler, redirect handler, and a
+ "not found error" handler. The block contains a component
(HelloComponent)
+ that we use to handle some dynamic content, and includes user
authentication
+ with basic authentication and a hashed user realm:
+
+ <target name="build" depends="standard.build">
+
+ <x:property name="server.uri" key="dpml-http-server" feature="uri"/>
+ <x:property name="static.uri" key="dpml-http-static" feature="uri"/>
+ <x:property name="hash.uri" key="dpml-http-hash-basic" feature="uri"/>
+
+ <x:block name="demo">
+ <x:include name="server" uri="${server.uri}"/>
+ <x:include name="static-context" uri="${static.uri}"/>
+ <x:component name="hello" class="net.dpml.playground.HelloComponent" />
+ <x:include name="authentication" uri="${hash.uri}"/>
+ <x:component name="constraint"
class="net.dpml.http.impl.SecurityConstraint" />
+ </x:block>
+
+ </target>
+
+ The block is configured using the a targets file. The file includes
three
+ target overrides, one dealing with the context definition, the second
+ demonstrating some redirection capability, and the third demonstrating
+ user authentication handling.
+
+ The static content handler is configured to use the current directory as
the
+ default root content basedir and that the entire context is mapped
against
+ the /demo URL.
+
+ <target path="/demo/static-context/context">
+ <configuration>
+ <context-path>/demo</context-path>
+ <resource-base>.</resource-base>
+ </configuration>
+ </target>
+
+ The following target overrides the configuration for url forwarding, so
+ that when the /demo URL (which looks like the root to the Forwardhandler)
+ is requested, it is forwarded to the /demo/hello. The "/hello" path
+ is what the HelloComponent is looking for, and again, don't forget that
+ the whole http context is mapped to the /demo path, so the resulting
+ URL for the HelloComponent is /demo/hello.
+
+ <target path="/demo/static-context/forward-handler">
+ <parameters>
+ <parameter name="root-forward" value="/hello" />
+ </parameters>
+ </target>
+
+ The following target override defines the requirements for the
+ authentication. The constraint defined, says that for "/hello/secure"
+ authentication is required
+
+ <target path="/demo/constraint">
+ <configuration>
+ <path>/hello/secure</path>
+ <authenticate>true</authenticate>
+ <roles>
+ <role>user</role>
+ <role>admin</role>
+ <role>content-admininistrator</role>
+ <role>server-admininistrator</role>
+ </roles>
+ <methods>
+ <method>GET</method>
+ </methods>
+ </configuration>
+ </target>
+
+
+ To build the server do the following:
+
+ $ cd dpml.net <--- your root svn/development/main/ directory
+ $ ant -f setup.xml <--- build Magic/Transit bootstrap code, if not
done
+ $ ant <--- build all of Metro, if not done
+
+ $ cd planet/facilities/http/examples/hello
+
+ To test the server you can either execute the generated block from the
local
+ file system of from magic's repository.
+
+ Executing the block from the local filesystem:
+
+ $ metro target/deliverables/blocks/dpml-http-hello-2.0.0.block
-config target/deliverables/confs/hello.conf
+
+ But why not utilize the extremely powerful artifact: protocol, and the
fact
+ that everything is built as artifacts. This provides command-lines that
are
+ independent of where on the local file system the command is executed;
+
+ $ metro
artifact:block:dpml/http/examples/hello/dpml-http-hello#2.0.0 -config
artifact:conf:dpml/http/examples/hello/hello
+
+ To check the running applicaion, open a browser and enter the following
url;
+
+ http://localhost:8080/demo
+
+ You should see a simple "Hello" message created by the HelloComponent.
The
+ top level root of the Http context has been forwarded to the /demo/hello
+ URL which the HelloComponent react to.
+
+ Now, enter this instead;
+
+ http://localhost:8080/demo/hello/secure
+
+ You will be requested to enter a username and password. Try "niclas" and
+ "dropdead" as the password (no quotes).
+ The user realm configuration (i.e. the users and which roles they are
+ assigned) is the default artifact:realm:dpml/http/default, but can be
+ easily overridden by a new target,
+
+ <target path="/demo/authentication
+ <parameters>
+ <parameter name="name" value="Metro" />
+ <parameter name="realm-uri" value="somedir/somefile" /> <!-- or
artifact: URI -->
+ </parameters>
+ </target>
+
+
+ We hope that this demo have shown some of the powers of the HTTP
Facility.
+
+
+<The DPML documentation team>
+
Modified: development/main/planet/facilities/http/examples/hello/build.xml
==============================================================================
--- development/main/planet/facilities/http/examples/hello/build.xml
(original)
+++ development/main/planet/facilities/http/examples/hello/build.xml Fri
Jan 7 09:40:00 2005
@@ -32,6 +32,7 @@
<x:include name="static-context" uri="${static.uri}"/>
<x:component name="hello" class="net.dpml.playground.HelloComponent" />
<x:include name="authentication" uri="${hash.uri}"/>
+ <x:component name="constraint"
class="net.dpml.http.impl.SecurityConstraint" />
</x:block>
</target>
Modified:
development/main/planet/facilities/http/examples/hello/etc/deliverables/confs/hello.conf
==============================================================================
---
development/main/planet/facilities/http/examples/hello/etc/deliverables/confs/hello.conf
(original)
+++
development/main/planet/facilities/http/examples/hello/etc/deliverables/confs/hello.conf
Fri Jan 7 09:40:00 2005
@@ -4,33 +4,31 @@
<target path="/demo/static-context/context">
<configuration>
- <context-path>/</context-path>
+ <context-path>/demo</context-path>
<resource-base>.</resource-base>
</configuration>
</target>
<target path="/demo/static-context/forward-handler">
- <configuration>
- <forwards>
- <forward>
- <from>/hello</from>
- <to>/demo/hello</to>
- </forward>
- </forwards>
- </configuration>
- </target>
-
- <target path="/demo/static-context/model-handler">
<parameters>
- <parameter name="context-path" value="/demo/hello"/>
- <parameter name="target" value="/demo/hello"/>
+ <parameter name="root-forward" value="/hello" />
</parameters>
</target>
- <target path="/demo/authentication/realm">
- <parameters>
- <parameter name="filename" value="user.realm" />
- </parameters>
+ <target path="/demo/constraint">
+ <configuration>
+ <path>/hello/secure</path>
+ <authenticate>true</authenticate>
+ <roles>
+ <role>user</role>
+ <role>admin</role>
+ <role>content-admininistrator</role>
+ <role>server-admininistrator</role>
+ </roles>
+ <methods>
+ <method>GET</method>
+ </methods>
+ </configuration>
</target>
</targets>
Modified:
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
==============================================================================
---
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
(original)
+++
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
Fri Jan 7 09:40:00 2005
@@ -23,6 +23,8 @@
import java.io.PrintWriter;
import java.util.Date;
+import net.dpml.activity.Startable;
+
import net.dpml.context.Context;
import net.dpml.context.ContextException;
import net.dpml.logging.Logger;
@@ -44,7 +46,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
*/
public class HelloComponent
- implements HttpHandler
+ implements HttpHandler, Startable
{
private Logger m_logger;
private boolean m_Started;
@@ -61,9 +63,9 @@
throws ContextException, ServiceException
{
m_logger = logger;
+ m_Name = (String) ctx.get( "urn:metro:name" );
HttpContextService httpCtx = (HttpContextService) man.lookup(
"context" );
httpCtx.addHandler( 2, this );
- m_Name = (String) ctx.get( "urn:metro:name" );
}
//----------------------------------------------------------
@@ -80,8 +82,12 @@
HttpRequest request, HttpResponse response )
throws IOException
{
- m_logger.debug( "Hello - Handling HTTP: " + path );
-
+ if( ! path.startsWith( "/hello" ) )
+ return;
+
+ if( m_logger.isDebugEnabled() )
+ m_logger.debug( "Hello - Handling HTTP: " + path );
+
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter( out, "ISO8859-1" );
@@ -89,15 +95,27 @@
writer.println("<html>");
writer.println("<head>");
- writer.println("<title>" + "Hello" + "</title>" );
+ writer.print("<title>" );
+ writer.print( "Hello " );
+ if( request.hasUserPrincipal() )
+ writer.print( request.getUserPrincipal() );
+ else
+ writer.print( "stranger" );
+ writer.println( " !!</title>" );
writer.println("</head>");
writer.println("<body>" );
writer.println("<hr/>");
- writer.println("<h3>Hello</h3>");
+ writer.print("<h3>Hello " );
+ if( request.hasUserPrincipal() )
+ writer.print( request.getUserPrincipal() );
+ else
+ writer.print( "stranger" );
+ writer.println( " !!</h3>");
writer.println("<hr/>");
writer.println("</body>");
writer.println("</html>");
writer.flush();
+ request.setHandled( true );
}
public String getName()
Modified:
development/main/planet/facilities/http/impl/etc/deliverables/realms/default.realm
==============================================================================
---
development/main/planet/facilities/http/impl/etc/deliverables/realms/default.realm
(original)
+++
development/main/planet/facilities/http/impl/etc/deliverables/realms/default.realm
Fri Jan 7 09:40:00 2005
@@ -13,14 +13,14 @@
#
# password for admin = yabadabadoo
-admin: CRYPT:mdMT8jT.4cbd6,server-administrator,content-administrator,admin
+admin = CRYPT:mdMT8jT.4cbd6,server-administrator,content-administrator,admin
# password for metro = yabadabadoo
-metro: CRYPT:CEHcfuUVr1oQs,server-administrator,content-administrator,admin
+metro = CRYPT:CEHcfuUVr1oQs,server-administrator,content-administrator,admin
# password for niclas = dropdead
-niclas: CRYPT:/JclO8RNM.J/M,user
+niclas = CRYPT:/JclO8RNM.J/M,user
# password for mcconnell = oxymoron
-mcconnell: CRYPT:UScm1BBmnFmG6,user
+mcconnell = CRYPT:UScm1BBmnFmG6,user
Modified:
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
==============================================================================
---
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
(original)
+++
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
Fri Jan 7 09:40:00 2005
@@ -16,25 +16,36 @@
package net.dpml.http.impl;
import java.io.File;
+import java.io.IOException;
+
import net.dpml.activity.Disposable;
import net.dpml.activity.Startable;
+
import net.dpml.configuration.Configurable;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.ConfigurationException;
+
import net.dpml.context.Context;
import net.dpml.context.ContextException;
import net.dpml.context.Contextualizable;
+
import net.dpml.logging.LogEnabled;
import net.dpml.logging.Logger;
+
import net.dpml.http.HttpContextService;
import net.dpml.http.HttpService;
import net.dpml.http.MimeTypes;
+
import net.dpml.service.ServiceException;
import net.dpml.service.ServiceManager;
import net.dpml.service.Serviceable;
+
import org.mortbay.http.Authenticator;
+import org.mortbay.http.HttpException;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpHandler;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
import org.mortbay.http.RequestLog;
import org.mortbay.http.UserRealm;
@@ -104,8 +115,9 @@
UserRealm userRealm = (UserRealm) man.lookup( "realm" );
if( userRealm != null )
{
+System.out.println( "Setting REALM!!!!" + userRealm );
setRealm( userRealm );
- setRealmName( userRealm.getName() ); // Is this necessary?
+ setRealmName( userRealm.getName() ); // this IS necessary.
}
}
@@ -218,8 +230,8 @@
{
if( m_Logger.isDebugEnabled() )
m_Logger.debug( "Stopping context: " + this );
- m_HttpServer.removeContext( this );
super.doStop();
+ m_HttpServer.removeContext( this );
}
public void dispose()
@@ -229,4 +241,29 @@
destroy();
m_HttpServer = null;
}
+
+ public void handle( String pathInContext, String pathParams, HttpRequest
request, HttpResponse response)
+ throws IOException, HttpException
+ {
+ if( m_Logger.isDebugEnabled() )
+ {
+ m_Logger.debug( "Path: " + pathInContext );
+ m_Logger.debug( "Parameters: " + pathParams );
+ m_Logger.debug( "Request:\n" + request );
+ HttpHandler[] handlers = getHandlers();
+ for( int i=0 ; i < handlers.length ; i++ )
+ {
+ HttpHandler handler = handlers[i];
+ String warning;
+ if( handler.isStarted() )
+ warning = "";
+ else
+ warning = " : NOT STARTED.";
+ m_Logger.debug( "Handler[" + i + "] = " + handler + warning
);
+ }
+ }
+ super.handle( pathInContext, pathParams, request, response );
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Response:\n" + response );
+ }
}
Added:
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.java
==============================================================================
--- (empty file)
+++
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.java
Fri Jan 7 09:40:00 2005
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2004 Niclas Hedman.
+ *
+ * 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 net.dpml.http.impl;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.ConfigurationException;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameters;
+
+import net.dpml.http.HttpContextService;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="http-security-constraint" lifestyle="singleton"
+ */
+public class SecurityConstraint
+ extends org.mortbay.http.SecurityConstraint
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+
+ /**
+ * @metro.logger name="http"
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.dependency type="net.dpml.http.HttpContextService"
+ * key="http-context"
+ */
+ public SecurityConstraint( Logger logger, Context ctx, ServiceManager
man, Configuration conf )
+ throws ContextException, ServiceException, ConfigurationException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+
+ m_Logger = logger;
+ String name = (String) ctx.get( "urn:metro:name" );
+ setName( name );
+ String path = conf.getChild( "path" ).getValue( "/" );
+ boolean authenticate = conf.getChild( "authenticate"
).getValueAsBoolean( false );
+ setAuthenticate( authenticate );
+ String dcValue = conf.getChild( "data-constraint" ).getValue( "none"
);
+ int dc = DC_UNSET;
+ if( "none".equals( dcValue ) )
+ dc = DC_NONE;
+ else if( "integral".equals( dcValue ) )
+ dc = DC_INTEGRAL;
+ else if( "confidential".equals( dcValue ) )
+ dc = DC_CONFIDENTIAL;
+ else
+ {
+ String error = "Illegal value: \"" + dcValue +
+ "\". Only \"none\", \"integral\" or \"confidential\" is
allowed.";
+ throw new ConfigurationException( error );
+ }
+ Configuration roles = conf.getChild( "roles" );
+ configureRoles( roles );
+ Configuration methods = conf.getChild( "methods" );
+ configureMethods( methods );
+
+ m_Context.addSecurityConstraint( path, this );
+ }
+
+ private void configureRoles( Configuration rolesConf )
+ throws ConfigurationException
+ {
+ Configuration[] roles = rolesConf.getChildren( "role" );
+ for( int i = 0 ; i < roles.length ; i++ )
+ addRole( roles[i].getValue() );
+ }
+
+ private void configureMethods( Configuration methodsConf )
+ throws ConfigurationException
+ {
+ Configuration[] methods = methodsConf.getChildren( "method" );
+ for( int i = 0 ; i < methods.length ; i++ )
+ addMethod( methods[i].getValue() );
+ }
+}
+
Added:
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.xprofile
==============================================================================
--- (empty file)
+++
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityConstraint.xprofile
Fri Jan 7 09:40:00 2005
@@ -0,0 +1,2 @@
+<profiles>
+</profiles>
Modified:
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityHandler.java
==============================================================================
---
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityHandler.java
(original)
+++
development/main/planet/facilities/http/impl/src/main/net/dpml/http/impl/SecurityHandler.java
Fri Jan 7 09:40:00 2005
@@ -50,12 +50,13 @@
* @metro.dependency type="org.mortbay.http.Authenticator"
* key="authenticator"
*/
+ // The dependency on Authenticator is to ensure that the Authenticator
+ // has been assigned to the HttpContext before the SecurityHandler
+ // is being started, since it otherwise will set another Authenticator.
+
public SecurityHandler( Logger logger, Context ctx, Parameters params,
ServiceManager man )
throws ContextException, ServiceException
{
- // The dependency on Authenticator is to ensure that the
Authenticator
- // has been assigned to the HttpContext before the SecurityHandler
- // is being started, since it otherwise will set another
Authenticator.
m_Context = (HttpContextService) man.lookup( "http-context" );
m_Logger = logger;
Modified:
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/BasicAuthenticator.xinfo
==============================================================================
---
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/BasicAuthenticator.xinfo
(original)
+++
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/BasicAuthenticator.xinfo
Fri Jan 7 09:40:00 2005
@@ -11,5 +11,8 @@
<loggers>
<logger name="http"/>
</loggers>
+ <services>
+ <service type="org.mortbay.http.Authenticator"/>
+ </services>
</type>
Modified:
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/DigestAuthenticator.xinfo
==============================================================================
---
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/DigestAuthenticator.xinfo
(original)
+++
development/main/planet/facilities/http/impl/src/main/org/mortbay/http/DigestAuthenticator.xinfo
Fri Jan 7 09:40:00 2005
@@ -11,6 +11,9 @@
<loggers>
<logger name="http"/>
</loggers>
+ <services>
+ <service type="org.mortbay.http.Authenticator"/>
+ </services>
</type>
Modified:
development/main/planet/facilities/http/spi/src/main/net/dpml/http/HttpContextService.java
==============================================================================
---
development/main/planet/facilities/http/spi/src/main/net/dpml/http/HttpContextService.java
(original)
+++
development/main/planet/facilities/http/spi/src/main/net/dpml/http/HttpContextService.java
Fri Jan 7 09:40:00 2005
@@ -18,6 +18,7 @@
import org.mortbay.http.Authenticator;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpHandler;
+import org.mortbay.http.SecurityConstraint;
/**
* @metro.service type="net.dpml.http.HttpContextService" version="1.0"
@@ -26,6 +27,8 @@
{
HttpContext getHttpContext();
+ void addSecurityConstraint( String path, SecurityConstraint sc );
+
void addHandler( HttpHandler handler );
void addHandler( int index, HttpHandler handler );
- svn commit: r1400 - in development/main/planet/facilities/http: blocks/hash-basic blocks/hash-clientcert blocks/hash-digest blocks/hash-form blocks/static examples/hello examples/hello/etc/deliverables/confs examples/hello/etc/deliverables/realms examples/hello/src/main/net/dpml/playground impl/etc/deliverables/realms impl/src/main/net/dpml/http/impl impl/src/main/org/mortbay/http spi/src/main/net/dpml/http, niclas, 01/07/2005
Archive powered by MHonArc 2.6.24.