You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2006/02/09 18:27:33 UTC

svn commit: r376357 - in /maven/continuum/branches/continuum-1.0.x: continuum-core/pom.xml continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java continuum-web/pom.xml pom.xml

Author: evenisse
Date: Thu Feb  9 09:27:27 2006
New Revision: 376357

URL: http://svn.apache.org/viewcvs?rev=376357&view=rev
Log:
[CONTINUUM-371] Don't print an exception when user/password is wrong but an error message

Added:
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java   (with props)
Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-core/pom.xml
    maven/continuum/branches/continuum-1.0.x/continuum-web/pom.xml
    maven/continuum/branches/continuum-1.0.x/pom.xml

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/pom.xml?rev=376357&r1=376356&r2=376357&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/pom.xml (original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/pom.xml Thu Feb  9 09:27:27 2006
@@ -35,6 +35,10 @@
       <artifactId>plexus-mail-sender-api</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-security-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven.continuum</groupId>
       <artifactId>continuum-test</artifactId>
       <scope>test</scope>

Added: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java?rev=376357&view=auto
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java (added)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java Thu Feb  9 09:27:27 2006
@@ -0,0 +1,95 @@
+package org.apache.maven.continuum.security;
+
+/*
+ * Copyright 2005 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.
+ *
+ */
+
+import org.apache.maven.continuum.model.system.ContinuumUser;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.security.Authentication;
+import org.codehaus.plexus.security.Authenticator;
+import org.codehaus.plexus.security.exception.AuthenticationException;
+import org.codehaus.plexus.security.exception.UnauthorizedException;
+import org.codehaus.plexus.security.exception.UnknownEntityException;
+
+import java.util.Map;
+
+/**
+ * TODO: Move this to o.a.m.c.security once plexus-security doesn't depend on plexus-summit.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class ContinuumAuthenticator
+    implements Authenticator
+{
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumStore store;
+
+    // ----------------------------------------------------------------------
+    // Authenticator Implementation
+    // ----------------------------------------------------------------------
+
+    public Authentication authenticate( Map tokens )
+        throws UnknownEntityException, AuthenticationException, UnauthorizedException
+    {
+        String username = (String) tokens.get( "username" );
+        String password = (String) tokens.get( "password" );
+
+        ContinuumUser user = getUser( username );
+
+        if ( user == null )
+        {
+            throw new UnknownEntityException();
+        }
+
+        System.err.println( "username: " + username );
+        //System.err.println( "password: " + password );
+        //System.err.println( "user.password: " + user.getPassword() );
+
+        if ( !user.equalsPassword( password ) )
+        {
+            throw new AuthenticationException( "Invalid password." );
+        }
+
+        return null;
+    }
+
+    public Authentication getAnonymousEntity()
+    {
+        throw new RuntimeException( "Not implemented" );
+    }
+
+    // ----------------------------------------------------------------------
+    // Private
+    // ----------------------------------------------------------------------
+
+    private ContinuumUser getUser( String username )
+        throws AuthenticationException
+    {
+        try
+        {
+            return store.getUserByUsername( username );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new AuthenticationException( "Error while retreiving user.", e );
+        }
+    }
+}

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/pom.xml?rev=376357&r1=376356&r2=376357&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/pom.xml (original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/pom.xml Thu Feb  9 09:27:27 2006
@@ -80,10 +80,9 @@
       <artifactId>plexus-formica-web</artifactId>
       <version>1.0-beta-1</version>
     </dependency>
-      <dependency>
-        <groupId>org.codehaus.plexus</groupId>
-        <artifactId>plexus-security-summit</artifactId>
-        <version>1.0-alpha-3-SNAPSHOT</version>
-      </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-security-summit</artifactId>
+    </dependency>
   </dependencies>
 </project>

Modified: maven/continuum/branches/continuum-1.0.x/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/pom.xml?rev=376357&r1=376356&r2=376357&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/pom.xml (original)
+++ maven/continuum/branches/continuum-1.0.x/pom.xml Thu Feb  9 09:27:27 2006
@@ -395,6 +395,16 @@
         <artifactId>quartz</artifactId>
         <version>1.4.5</version>
       </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-security-api</artifactId>
+        <version>1.0-alpha-3-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-security-summit</artifactId>
+        <version>1.0-alpha-3-SNAPSHOT</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   <distributionManagement>