You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2005/05/08 22:57:52 UTC
svn commit: r169162 - in /lenya/trunk/src:
java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
webapp/WEB-INF/cocoon-xconf.xsl
Author: gregor
Date: Sun May 8 13:57:51 2005
New Revision: 169162
URL: http://svn.apache.org/viewcvs?rev=169162&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/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
Modified:
lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
Added: lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java?rev=169162&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java Sun May 8 13:57:51 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/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=169162&r1=169161&r2=169162&view=diff
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Sun May 8 13:57:51 2005
@@ -219,6 +219,14 @@
class="org.apache.lenya.ac.impl.UserAuthenticator"
role="org.apache.lenya.ac.Authenticator"/>
+<xsl:comment>
+Enable this authenticator and disable the UserAuthenticator for anonymous authentication (useful for client certs, for instance)
+
+<component logger="lenya.ac.authenticator"
+ class="org.apache.lenya.ac.impl.AnonymousAuthenticator"
+ role="org.apache.lenya.ac.Authenticator"/>
+</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