directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r123107 - in incubator/directory/janus/trunk/core: api/src/java/org/apache/janus/authentication impl/src/java/org/apache/janus/authentication impl/src/test/org/apache/janus/authentication
Date Wed, 22 Dec 2004 15:06:30 GMT
Author: vtence
Date: Wed Dec 22 07:06:28 2004
New Revision: 123107

URL: http://svn.apache.org/viewcvs?view=rev&rev=123107
Log:
Authenticator returns null instead of throwing exception when authentication fails
Modified:
   incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java
   incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
   incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java

Modified: incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java?view=diff&rev=123107&p1=incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java&r1=123106&p2=incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java&r2=123107
==============================================================================
--- incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java
(original)
+++ incubator/directory/janus/trunk/core/api/src/java/org/apache/janus/authentication/Authenticator.java
Wed Dec 22 07:06:28 2004
@@ -36,10 +36,8 @@
      * authenticator may choose to add a principal for each group the user is a member of.
      *
      * @param credentials A collection of credential objects provided as proof of identity
-     * @return a Subject populated with appropriate principals
-     * @throws AuthenticationException thrown if there is a problem during authentication
+     * @return a Subject populated with appropriate principals or null if authentication
fails
      */
-    Subject authenticate( CredentialSet credentials )
-            throws AuthenticationException;
+    Subject authenticate( CredentialSet credentials );
 }
 

Modified: incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java?view=diff&rev=123107&p1=incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java&r1=123106&p2=incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java&r2=123107
==============================================================================
--- incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
(original)
+++ incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authentication/DefaultAuthenticator.java
Wed Dec 22 07:06:28 2004
@@ -42,13 +42,9 @@
     }
 
     public Subject authenticate( CredentialSet credentials )
-            throws AuthenticationException
     {
         Principal p = m_realm.validateCredentials( credentials );
-        if ( p == null )
-        {
-            throw new AuthenticationException( "Credentials rejected" );
-        }
+        if ( p == null ) return null;
 
         Subject subject = new Subject();
         subject.getPrincipals().add( p );

Modified: incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java?view=diff&rev=123107&p1=incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java&r1=123106&p2=incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java&r2=123107
==============================================================================
--- incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java
(original)
+++ incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authentication/DefaultAuthenticatorTest.java
Wed Dec 22 07:06:28 2004
@@ -55,32 +55,18 @@
     {
         m_mockRealm.stubs().method( "validateCredentials" ).with( eq( Creds.banana() ) ).will(
returnValue( Fruits.banana() ) );
 
-        Subject subject = null;
-        try
-        {
-            subject = m_authenticator.authenticate( Creds.banana() );
-        }
-        catch ( AuthenticationException e )
-        {
-            fail( "Login failed" );
-        }
+        Subject subject = m_authenticator.authenticate( Creds.banana() );
+        assertNotNull( subject );
         assertTrue( "Principal was not added to subject",
                 subject.getPrincipals().contains( Fruits.banana() ) );
     }
 
-    public void testThrowsAuthenticationExceptionIfAuthenticationFails()
+    public void testReturnsNullSubjectIfAuthenticationFails()
     {
         m_mockRealm.stubs().method( "validateCredentials" ).will( returnValue( null ) );
 
-        try
-        {
-            m_authenticator.authenticate( new CredentialSet() );
-            fail( "Login has not failed" );
-        }
-        catch ( AuthenticationException expected )
-        {
-            assertTrue( true );
-        }
+        Subject s = m_authenticator.authenticate( new CredentialSet() );
+        assertNull( s );
     }
 
     public void testBuildsUpSubjectWithEntityAttributes() throws Exception

Mime
View raw message