You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by re...@locus.apache.org on 2000/06/02 01:47:34 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/content Content.java
remm 00/06/01 16:47:34
Modified: . STATUS.html build.xml
src/examples/xml XML.xml
src/share/org/apache/slide/common Domain.java
src/share/org/apache/slide/content Content.java
Added: src/clients/tomcat/org/apache/tomcat/realm SlideRealm.java
Log:
Added a Catalina realm which uses Slide as the user repository.
Revision Changes Path
1.8 +1 -8 jakarta-slide/STATUS.html
Index: STATUS.html
===================================================================
RCS file: /home/cvs/jakarta-slide/STATUS.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- STATUS.html 2000/05/25 22:58:07 1.7
+++ STATUS.html 2000/06/01 23:47:32 1.8
@@ -159,13 +159,6 @@
<th width="30%">Volunteers</th>
</tr>
<tr>
- <td align="center">High</td>
- <td>
- Develop a Catalina Realm.
- </td>
- <td>---</td>
- </tr>
- <tr>
<td align="center">Medium</td>
<td>
Design and develop a compact and easy to use client library for
@@ -355,7 +348,7 @@
<br>
<div align="center"><hr width="75%"><font size="2">
- $Id: STATUS.html,v 1.7 2000/05/25 22:58:07 remm Exp $
+ $Id: STATUS.html,v 1.8 2000/06/01 23:47:32 remm Exp $
</font></div>
</body>
1.9 +16 -21 jakarta-slide/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-slide/build.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- build.xml 2000/05/25 22:54:53 1.8
+++ build.xml 2000/06/01 23:47:33 1.9
@@ -42,15 +42,15 @@
<!-- Build all the sources with debug and deprecation -->
<target name="main" depends="prepare,static">
<javac srcdir="src/share" destdir="${slide.build}/classes"
- debug="on" deprecation="on" excludes="**/CVS/**,**/package.html,**/apache/tomcat/**" />
- <javac srcdir="src/share" destdir="${catalina.build}/classes"
- debug="on" deprecation="on" excludes="**/CVS/**,**/package.html,**/apache/slide/**" />
+ debug="on" deprecation="on"
+ excludes="**/CVS/**,**/package.html,**/apache/tomcat/**" />
</target>
-
+
<!-- Same as main, but no debug and no deprecation -->
<target name="no-debug" depends="prepare">
<javac srcdir="src/share" destdir="${slide.build}/classes"
- debug="off" deprecation="off" excludes="**/CVS/**,**/package.html,**/slide/webdav/**" />
+ debug="off" deprecation="off"
+ excludes="**/CVS/**,**/package.html,**/slide/webdav/**" />
<javac srcdir="src/share" destdir="${catalina.build}/classes"
debug="off" deprecation="off" excludes="**/CVS/**,**/package.html"
includes="**/slide/webdav/**" />
@@ -64,22 +64,17 @@
<!-- Build a standalone DAV server, based on Catalina -->
<target name="catalinadav" depends="main">
- <mkdir dir="${dav.build}" />
- <mkdir dir="${dav.build}/conf" />
- <copydir src="lib" dest="${dav.build}/lib" />
- <copydir src="${catalina.build}" dest="${dav.build}" excludes="**/conf/**" />
- <copydir src="${tomcat.build}/classes" dest="${dav.build}/classes" />
- <copydir src="src/conf/catalina/standalone" dest="${dav.build}" />
- <mkdir dir="${dav.build}/files" />
- </target>
-
- <!-- Build a standalone DAV server, based on Tomcat (untested) -->
- <target name="tomcatdav" depends="main">
- <mkdir dir="${dav.build}"/>
- <copydir src="src/conf/tomcat/standalone" dest="${dav.build}"/>
- <copydir src="lib" dest="${dav.build}/lib"/>
- <copydir src="${tomcat.build}" dest="${dav.build}"/>
- <mkdir dir="${dav.build}/files"/>
+ <mkdir dir="${dav.build}" />
+ <mkdir dir="${dav.build}/conf" />
+ <mkdir dir="${dav.build}/classes" />
+ <copydir src="lib" dest="${dav.build}/lib" />
+ <copydir src="${catalina.build}" dest="${dav.build}"
+ excludes="**/conf/**" />
+ <javac srcdir="src/clients/tomcat" destdir="${dav.build}/classes"
+ debug="off" deprecation="off" excludes="**/CVS/**,**/package.html" />
+ <!--copydir src="${tomcat.build}/classes" dest="${dav.build}/classes" /-->
+ <copydir src="src/conf/catalina/standalone" dest="${dav.build}" />
+ <mkdir dir="${dav.build}/files" />
</target>
<!-- Kill all the directories created in prepare -->
1.1 jakarta-slide/src/clients/tomcat/org/apache/tomcat/realm/SlideRealm.java
Index: SlideRealm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-slide/src/clients/tomcat/org/apache/tomcat/realm/SlideRealm.java,v 1.1 2000/06/01 23:47:33 remm Exp $
* $Revision: 1.1 $
* $Date: 2000/06/01 23:47:33 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.tomcat.realm;
import java.security.Principal;
import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.tomcat.Container;
import org.apache.tomcat.Logger;
import org.apache.tomcat.Realm;
import org.apache.tomcat.util.LifecycleSupport;
import org.apache.tomcat.util.StringManager;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.Domain;
import org.apache.slide.common.SlideException;
import org.apache.slide.content.Content;
import org.apache.slide.content.NodeRevisionDescriptors;
import org.apache.slide.content.NodeRevisionDescriptor;
import org.apache.slide.content.NodeProperty;
import org.apache.slide.authenticate.CredentialsToken;
import org.apache.slide.authenticate.SecurityToken;
/**
* Implemetation of a Catalina realm which authenticates users defined
* in a Slide namespace.
* <p>
* The namespace used will have the same name as the container to which the
* realm is associated. If such a namespace doesn't exist, it falls back
* to tomcat, webdav or default.
*
* @author Remy Maucherat
* @version $Revision: 1.1 $ $Date: 2000/06/01 23:47:33 $
*/
public final class SlideRealm
extends RealmBase {
// ----------------------------------------------------- Instance Variables
/**
* Descriptive information about this Realm implementation.
*/
private static final String info =
"org.apache.tomcat.realm.SlideRealm/1.0";
/**
* Set of access tokens.
*/
private NamespaceAccessToken accessToken;
/**
* Content helper.
*/
private Content contentHelper;
/**
* Users path.
*/
private String usersPath;
/**
* Root credentials token.
*/
private CredentialsToken rootCredentials;
// ------------------------------------------------------------- Properties
/**
* Set the Container with which this Realm has been associated.
*
* @param container The associated Container
*/
public void setContainer(Container container) {
super.setContainer(container);
accessToken = Domain.accessNamespace(new SecurityToken(container),
container.getName());
if (accessToken == null)
accessToken = Domain.accessNamespace(new SecurityToken(container),
"tomcat");
if (accessToken == null)
accessToken = Domain.accessNamespace(new SecurityToken(container),
"webdav");
if (accessToken == null)
accessToken = Domain.accessNamespace(new SecurityToken(container),
"default");
contentHelper = accessToken.getContentHelper();
usersPath = accessToken.getNamespaceConfig().getUsersPath();
}
// --------------------------------------------------------- Public Methods
/**
* Return <code>true</code> if the specified Principal has the specified
* security role, within the context of this Realm; otherwise return
* <code>false</code>.
*
* @param principal Principal for whom the role is to be checked
* @param role Security role to be checked
*/
public boolean hasRole(Principal principal, String role) {
// FIXME !
// Use role resolution ...
if (principal.getName().equals(role))
return true;
return (false);
}
// ------------------------------------------------------ Protected Methods
/**
* Return the password associated with the given principal's user name.
*/
protected String getPassword(String username) {
// Fetch the Slide object representing the user.
try {
Principal userPrincipal = getPrincipal(username);
CredentialsToken credToken = new CredentialsToken(userPrincipal);
NodeRevisionDescriptors revisionDescriptors =
contentHelper.retrieve(credToken, usersPath + "/" + username);
NodeRevisionDescriptor revisionDescriptor =
contentHelper.retrieve(credToken, revisionDescriptors);
NodeProperty password =
revisionDescriptor.getProperty("password");
if (password == null)
return null;
else
return (String) password.getValue();
} catch (SlideException e) {
// Whatever happens doesn't really matter
// The stack trace is displayed for now for debug purposes
e.printStackTrace();
}
return null;
}
/**
* Return the Principal associated with the given user name.
*/
protected Principal getPrincipal(String username) {
return new SlideRealmPrincipal(username);
}
}
/**
* Private class representing an individual user's Principal object.
*/
final class SlideRealmPrincipal implements Principal {
/**
* The username for this Principal.
*/
private String username = null;
/**
* Construct a new MemoryRealmPrincipal instance.
*
* @param username The username for this Principal
*/
public SlideRealmPrincipal(String username) {
this.username = username;
}
/**
* Return the name of this Principal.
*/
public String getName() {
return (username);
}
}
1.3 +1 -1 jakarta-slide/src/examples/xml/XML.xml
Index: XML.xml
===================================================================
RCS file: /home/cvs/jakarta-slide/src/examples/xml/XML.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XML.xml 2000/05/25 22:54:05 1.2
+++ XML.xml 2000/06/01 23:47:33 1.3
@@ -15,7 +15,7 @@
<s:parameter name="rootpath">files</s:parameter>
</s:contentstore>
- <s:scope match="/" descriptorsstore="memory" contentstore="file"/>
+ <s:scope match="/" descriptorsstore="database" contentstore="file"/>
<!--s:scope match="/toto" descriptorsstore="memory" store="pageman"/-->
1.4 +11 -6 jakarta-slide/src/share/org/apache/slide/common/Domain.java
Index: Domain.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Domain.java 2000/05/16 23:58:23 1.3
+++ Domain.java 2000/06/01 23:47:34 1.4
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v 1.3 2000/05/16 23:58:23 remm Exp $
- * $Revision: 1.3 $
- * $Date: 2000/05/16 23:58:23 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/Domain.java,v 1.4 2000/06/01 23:47:34 remm Exp $
+ * $Revision: 1.4 $
+ * $Date: 2000/06/01 23:47:34 $
*
* ====================================================================
*
@@ -85,7 +85,7 @@
* For now, does not implement access control on Namespaces.
*
* @author <a href="mailto:remm@exoffice.com">Remy Maucherat</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public final class Domain {
@@ -148,8 +148,13 @@
*/
public static NamespaceAccessToken accessNamespace(SecurityToken token,
String namespaceName) {
- return new NamespaceAccessTokenImpl
- ((Namespace) namespaces.get(namespaceName));
+
+ Namespace namespace = (Namespace) namespaces.get(namespaceName);
+ if (namespace == null)
+ return null;
+ else
+ return new NamespaceAccessTokenImpl(namespace);
+
}
1.3 +6 -6 jakarta-slide/src/share/org/apache/slide/content/Content.java
Index: Content.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/Content.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Content.java 2000/05/16 23:07:37 1.2
+++ Content.java 2000/06/01 23:47:34 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/Content.java,v 1.2 2000/05/16 23:07:37 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2000/05/16 23:07:37 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/content/Content.java,v 1.3 2000/06/01 23:47:34 remm Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/06/01 23:47:34 $
*
* ====================================================================
*
@@ -77,7 +77,7 @@
* Content.
*
* @author <a href="mailto:remm@exoffice.com">Remy Maucherat</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface Content {
@@ -126,8 +126,8 @@
*
* @param revisionDescriptors Node revision descriptors
*/
- NodeRevisionDescriptor retrieve(CredentialsToken token,
- NodeRevisionDescriptors revision)
+ NodeRevisionDescriptor retrieve
+ (CredentialsToken token, NodeRevisionDescriptors revisionDescriptors)
throws ObjectNotFoundException, AccessDeniedException,
LinkedObjectNotFoundException, ServiceAccessException,
RevisionDescriptorNotFoundException, ObjectLockedException;