lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gre...@apache.org
Subject svn commit: r169160 - in /lenya/branches/BRANCH_1_2_X/src: java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java webapp/WEB-INF/cocoon-xconf.xsl
Date Sun, 08 May 2005 20:57:38 GMT
Author: gregor
Date: Sun May  8 13:57:38 2005
New Revision: 169160

URL: http://svn.apache.org/viewcvs?rev=169160&view=rev
Log:
Added anonymous authenticator (useful for client certs) based on work by Mike Moretti. This
resolves http://issues.apache.org/bugzilla/show_bug.cgi?id=34253

Added:
    lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
Modified:
    lenya/branches/BRANCH_1_2_X/src/webapp/WEB-INF/cocoon-xconf.xsl

Added: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java?rev=169160&view=auto
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
(added)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
Sun May  8 13:57:38 2005
@@ -0,0 +1,81 @@
+/*
+ * Copyright 1999-2004 The 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.lenya.ac.impl;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.environment.Request;
+import org.apache.lenya.ac.AccessControlException;
+import org.apache.lenya.ac.AccreditableManager;
+import org.apache.lenya.ac.Authenticator;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
+
+
+/**
+ * The anonymous authenticator authenticates to an anonymous user with no password 
+ * (you just have to add a user named 'anonymous' with an arbitrary password and the permissions
+ * you'd like via the admin screen). This is useful in conjunction with client certificates.
+ * @version $Id: UserAuthenticator.java 43241 2004-08-16 16:36:57Z andreas $
+ */
+public class AnonymousAuthenticator extends AbstractLogEnabled implements Authenticator {
+
+    
+    /**
+     * @see org.apache.lenya.ac.Authenticator#authenticate(org.apache.lenya.ac.AccreditableManager,
+     *      org.apache.cocoon.environment.Request)
+     */
+    public boolean authenticate(AccreditableManager accreditableManager, Request request)
+            throws AccessControlException {
+
+	String username = "anonymous";
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug(
+                    "Authenticating username [" + username + "]");
+        }
+
+        Identity identity = (Identity) request.getSession(false).getAttribute(Identity.class.getName());
+
+        User user = accreditableManager.getUserManager().getUser(username);
+
+        boolean authenticated = false;
+        if (user != null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("User [" + user + "] authenticated.");
+            }
+
+            if (!identity.contains(user)) {
+                User oldUser = identity.getUser();
+                if (oldUser != null) {
+                    if (getLogger().isDebugEnabled()) {
+                        getLogger().debug("Removing user [" + oldUser + "] from identity.");
+                    }
+                    identity.removeIdentifiable(oldUser);
+                }
+                identity.addIdentifiable(user);
+            }
+            authenticated = true;
+        } else {
+            if (getLogger().isDebugEnabled()) {
+                if (user == null) {
+                    getLogger().debug("No such user: [" + username + "]");
+                }
+                getLogger().debug("User [" + username + "] not authenticated.");
+            }
+        }
+        return authenticated;
+    }
+}
\ No newline at end of file

Modified: lenya/branches/BRANCH_1_2_X/src/webapp/WEB-INF/cocoon-xconf.xsl
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=169160&r1=169159&r2=169160&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/WEB-INF/cocoon-xconf.xsl Sun May  8 13:57:38 2005
@@ -205,8 +205,16 @@
   <component logger="lenya.ac.authenticator"
       class="org.apache.lenya.ac.impl.UserAuthenticator"
       role="org.apache.lenya.ac.Authenticator"/>
-      
-  <component logger="lenya.ac.cache"
+
+<xsl:comment>
+Enable this authenticator and disable the UserAuthenticator for anonymous authentication
(useful for client certs, for instance)
+
+&lt;component logger="lenya.ac.authenticator"
+      class="org.apache.lenya.ac.impl.AnonymousAuthenticator"
+      role="org.apache.lenya.ac.Authenticator"/&gt;      
+</xsl:comment>
+ 
+ <component logger="lenya.ac.cache"
      	class="org.apache.lenya.ac.cache.SourceCacheImpl"
      	role="org.apache.lenya.ac.cache.SourceCache"/>
      	



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org


Mime
View raw message