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/01/10 15:17:04 UTC
svn commit: r367610 - in /maven/continuum/trunk/continuum-core: pom.xml
src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
Author: evenisse
Date: Tue Jan 10 06:16:48 2006
New Revision: 367610
URL: http://svn.apache.org/viewcvs?rev=367610&view=rev
Log:
Convert to OS User Authenticator
Modified:
maven/continuum/trunk/continuum-core/pom.xml
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
Modified: maven/continuum/trunk/continuum-core/pom.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/pom.xml?rev=367610&r1=367609&r2=367610&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/pom.xml (original)
+++ maven/continuum/trunk/continuum-core/pom.xml Tue Jan 10 06:16:48 2006
@@ -43,7 +43,7 @@
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-security-api</artifactId>
+ <artifactId>plexus-security-osuser</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.continuum</groupId>
@@ -168,6 +168,12 @@
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-svn</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java?rev=367610&r1=367609&r2=367610&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/security/ContinuumAuthenticator.java Tue Jan 10 06:16:48 2006
@@ -17,79 +17,75 @@
*
*/
-import org.codehaus.plexus.security.Authentication;
-import org.codehaus.plexus.security.Authenticator;
-import org.codehaus.plexus.security.exception.UnknownEntityException;
-import org.codehaus.plexus.security.exception.AuthenticationException;
-import org.codehaus.plexus.security.exception.UnauthorizedException;
import org.apache.maven.continuum.store.ContinuumStore;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.apache.maven.continuum.model.system.ContinuumUser;
-import java.util.Map;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import com.opensymphony.user.authenticator.AbstractAuthenticator;
+import com.opensymphony.user.authenticator.AuthenticationException;
+
+import javax.servlet.http.HttpServletRequest;
/**
- * 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øl</a>
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
*/
public class ContinuumAuthenticator
- implements Authenticator
+ extends AbstractAuthenticator
{
- /**
- * @plexus.requirement
- */
- private ContinuumStore store;
-
// ----------------------------------------------------------------------
// Authenticator Implementation
// ----------------------------------------------------------------------
- public Authentication authenticate( Map tokens )
- throws UnknownEntityException, AuthenticationException, UnauthorizedException
+ public boolean login(String username, String password, HttpServletRequest req)
+ throws AuthenticationException
{
- String username = (String) tokens.get( "username" );
- String password = (String) tokens.get( "password" );
+ PlexusContainer container = (PlexusContainer) req.getAttribute( PlexusConstants.PLEXUS_KEY );
- ContinuumUser user = getUser( username );
-
- if ( user == null )
+ if ( container == null )
{
- throw new UnknownEntityException();
+ throw new AuthenticationException( "Can't get plexus container in request." );
}
+ ContinuumUser user = getUser( container, username );
+
System.err.println( "username: " + username );
- System.err.println( "password: " + password );
- System.err.println( "user.password: " + user.getPassword() );
- if ( !user.getPassword().equals( password ) )
+ if ( user != null && user.equalsPassword( password ) )
{
- throw new AuthenticationException( "Invalid password." );
+ return true;
+ }
+ else
+ {
+ return false;
}
-
- return null;
- }
-
- public Authentication getAnonymousEntity()
- {
- throw new RuntimeException( "Not implemented" );
}
// ----------------------------------------------------------------------
// Private
// ----------------------------------------------------------------------
- private ContinuumUser getUser( String username )
+ private ContinuumUser getUser( PlexusContainer container, String username )
throws AuthenticationException
{
try
{
+ ContinuumStore store = (ContinuumStore) container.lookup( ContinuumStore.ROLE );
+
return store.getUserByUsername( username );
}
catch ( ContinuumStoreException e )
{
- throw new AuthenticationException( "Error while retreiving user.", e );
+ throw new AuthenticationException( "Error while retreiving user." + e.getMessage() );
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new AuthenticationException( "Can't get store component." + e.getMessage() );
}
}
}