Return-Path: Delivered-To: apmail-lenya-commits-archive@www.apache.org Received: (qmail 61806 invoked from network); 8 May 2005 20:57:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 May 2005 20:57:54 -0000 Received: (qmail 99723 invoked by uid 500); 8 May 2005 21:00:56 -0000 Delivered-To: apmail-lenya-commits-archive@lenya.apache.org Received: (qmail 99647 invoked by uid 500); 8 May 2005 21:00:55 -0000 Mailing-List: contact commits-help@lenya.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lenya.apache.org Delivered-To: mailing list commits@lenya.apache.org Received: (qmail 99633 invoked by uid 99); 8 May 2005 21:00:55 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 08 May 2005 14:00:55 -0700 Received: (qmail 61743 invoked by uid 65534); 8 May 2005 20:57:52 -0000 Message-ID: <20050508205752.61742.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r169162 - in /lenya/trunk/src: java/org/apache/lenya/ac/impl/AnonymousAuthenticator.java webapp/WEB-INF/cocoon-xconf.xsl Date: Sun, 08 May 2005 20:57:52 -0000 To: commits@lenya.apache.org From: gregor@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: gregor Date: Sun May 8 13:57:51 2005 New Revision: 169162 URL: http://svn.apache.org/viewcvs?rev=3D169162&view=3Drev Log: Added anonymous authenticator (useful for client certs) based on work by Mi= ke Moretti. This resolves http://issues.apache.org/bugzilla/show_bug.cgi?id= =3D34253 Added: lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.ja= va 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=3D169162&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.ja= va (added) +++ lenya/trunk/src/java/org/apache/lenya/ac/impl/AnonymousAuthenticator.ja= va Sun May 8 13:57:51 2005 @@ -0,0 +1,81 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation + *=20 + * 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 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software dis= tributed 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 permiss= ions and limitations under + * the License. + * =20 + */ + +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=20 + * (you just have to add a user named 'anonymous' with an arbitrary passwo= rd and the permissions + * you'd like via the admin screen). This is useful in conjunction with cl= ient certificates. + * @version $Id: UserAuthenticator.java 43241 2004-08-16 16:36:57Z andreas= $ + */ +public class AnonymousAuthenticator extends AbstractLogEnabled implements = Authenticator { + + =20 + /** + * @see org.apache.lenya.ac.Authenticator#authenticate(org.apache.leny= a=2Eac.AccreditableManager, + * org.apache.cocoon.environment.Request) + */ + public boolean authenticate(AccreditableManager accreditableManager, R= equest request) + throws AccessControlException { + + String username =3D "anonymous"; + + if (getLogger().isDebugEnabled()) { + getLogger().debug( + "Authenticating username [" + username + "]"); + } + + Identity identity =3D (Identity) request.getSession(false).getAttr= ibute(Identity.class.getName()); + + User user =3D accreditableManager.getUserManager().getUser(usernam= e); + + boolean authenticated =3D false; + if (user !=3D null) { + if (getLogger().isDebugEnabled()) { + getLogger().debug("User [" + user + "] authenticated."); + } + + if (!identity.contains(user)) { + User oldUser =3D identity.getUser(); + if (oldUser !=3D null) { + if (getLogger().isDebugEnabled()) { + getLogger().debug("Removing user [" + oldUser + "]= from identity."); + } + identity.removeIdentifiable(oldUser); + } + identity.addIdentifiable(user); + } + authenticated =3D true; + } else { + if (getLogger().isDebugEnabled()) { + if (user =3D=3D null) { + getLogger().debug("No such user: [" + username + "]"); + } + getLogger().debug("User [" + username + "] not authenticat= ed."); + } + } + 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-xc= onf.xsl?rev=3D169162&r1=3D169161&r2=3D169162&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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=3D"org.apache.lenya.ac.impl.UserAuthenticator" role=3D"org.apache.lenya.ac.Authenticator"/> =20 + +Enable this authenticator and disable the UserAuthenticator for anonymous = authentication (useful for client certs, for instance) + +<component logger=3D"lenya.ac.authenticator" + class=3D"org.apache.lenya.ac.impl.AnonymousAuthenticator" + role=3D"org.apache.lenya.ac.Authenticator"/> =20 + +=20 --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org For additional commands, e-mail: commits-help@lenya.apache.org