You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by vt...@apache.org on 2005/03/21 16:43:41 UTC

svn commit: r158470 - in directory/authx/trunk: ./ core/src/java/org/apache/authx/authentication/ core/src/java/org/apache/authx/authentication/realm/ core/src/test/org/apache/authx/authentication/realm/ jdbc/src/java/org/apache/authx/authentication/realm/ jdbc/src/test/org/apache/authx/authentication/realm/ xdocs/

Author: vtence
Date: Mon Mar 21 07:43:35 2005
New Revision: 158470

URL: http://svn.apache.org/viewcvs?view=rev&rev=158470
Log:
Reworked JDBC module and Selector concepts. Credential now immutable as it should be

Added:
    directory/authx/trunk/core/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java   (with props)
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java   (with props)
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java   (with props)
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java   (with props)
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java   (with props)
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java   (with props)
    directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java   (with props)
Removed:
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/ExpressionBuilder.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/AndExpression.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Converter.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/DefaultConverter.java
    directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java
Modified:
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/Credential.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/AuthenticationMethod.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/PasswordCredential.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SameCredentialsBuilder.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/Selector.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SelectorBuilder.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernameCredential.java
    directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernamePasswordAuthentication.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Column.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/EqExpression.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/InstantiationException.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCException.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCRealm.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCSelector.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpression.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpressionBuilder.java
    directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Table.java
    directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/Columns.java
    directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/JDBCSelectorTest.java
    directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/MemoryDatabase.java
    directory/authx/trunk/project.xml
    directory/authx/trunk/xdocs/roadmap.xml

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/Credential.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/Credential.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/Credential.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/Credential.java Mon Mar 21 07:43:35 2005
@@ -22,14 +22,8 @@
  * <p>
  * A {@link CredentialSet} groups together related <code>Credential</code>s
  * for subject authentication purposes.
- * <p>
- * <b>Note:</b> <code>setValue()</code> will most likely disappear.
- * It is currently used by to load credential objects from the database in
- * the JDBC module, but there are better ways to do this.
  */
 public interface Credential
 {
     Object getValue();
-
-    void setValue( Object value );
 }

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/AuthenticationMethod.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/AuthenticationMethod.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/AuthenticationMethod.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/AuthenticationMethod.java Mon Mar 21 07:43:35 2005
@@ -44,5 +44,5 @@
 
     CredentialsMatcher getIdentificationMatcher( CredentialSet credentials );
 
-    SelectorBuilder getAuthenticationSelector( CredentialSet credentials );
+    SelectorBuilder getAuthenticationBuilder( CredentialSet credentials );
 }

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/PasswordCredential.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/PasswordCredential.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/PasswordCredential.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/PasswordCredential.java Mon Mar 21 07:43:35 2005
@@ -25,10 +25,6 @@
 {
     private String m_password;
 
-    public PasswordCredential()
-    {
-    }
-
     public PasswordCredential( String password )
     {
         m_password = password;
@@ -37,11 +33,6 @@
     public Object getValue()
     {
         return m_password;
-    }
-
-    public void setValue( Object value )
-    {
-        m_password = (String) value;
     }
 
     public boolean equals( Object o )

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SameCredentialsBuilder.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SameCredentialsBuilder.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SameCredentialsBuilder.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SameCredentialsBuilder.java Mon Mar 21 07:43:35 2005
@@ -30,12 +30,12 @@
         m_credentials = credentials;
     }
 
-    public void build( ExpressionBuilder builder, Selector selector )
+    public void build( Selector selector )
     {
         for ( Iterator it = m_credentials.elements().iterator(); it.hasNext(); )
         {
             Credential credential = (Credential) it.next();
-            selector.addExpression( builder.eq( credential.getClass(), credential.getValue() ));
+            selector.eq( credential.getClass(), credential );
         }
     }
 }

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/Selector.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/Selector.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/Selector.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/Selector.java Mon Mar 21 07:43:35 2005
@@ -16,7 +16,9 @@
  */
 package org.apache.authx.authentication.realm;
 
+import org.apache.authx.authentication.Credential;
+
 public interface Selector
 {
-    void addExpression( Object expression );
+    Selector eq( Class type, Credential c );
 }

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SelectorBuilder.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SelectorBuilder.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SelectorBuilder.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/SelectorBuilder.java Mon Mar 21 07:43:35 2005
@@ -18,5 +18,5 @@
 
 public interface SelectorBuilder
 {
-    void build( ExpressionBuilder builder, Selector selector );
+    void build( Selector selector );
 }

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernameCredential.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernameCredential.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernameCredential.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernameCredential.java Mon Mar 21 07:43:35 2005
@@ -25,10 +25,6 @@
 {
     private String m_username;
 
-    public UsernameCredential()
-    {
-    }
-
     public UsernameCredential( String name )
     {
         m_username = name;
@@ -42,11 +38,6 @@
     public String getUsername()
     {
         return m_username;
-    }
-
-    public void setValue( Object value )
-    {
-        m_username = (String) value;
     }
 
     public boolean equals( Object o )

Modified: directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernamePasswordAuthentication.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernamePasswordAuthentication.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernamePasswordAuthentication.java (original)
+++ directory/authx/trunk/core/src/java/org/apache/authx/authentication/realm/UsernamePasswordAuthentication.java Mon Mar 21 07:43:35 2005
@@ -56,7 +56,7 @@
         return new ContainsCredentialsMatcher( credentials.getCredentials( UsernameCredential.class ) );
     }
 
-    public SelectorBuilder getAuthenticationSelector( CredentialSet credentials )
+    public SelectorBuilder getAuthenticationBuilder( CredentialSet credentials )
     {
         return new SameCredentialsBuilder( credentials );
     }

Added: directory/authx/trunk/core/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/core/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/core/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java (added)
+++ directory/authx/trunk/core/src/test/org/apache/authx/authentication/realm/SameCredentialsBuilderTest.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,48 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import org.apache.authx.authentication.CredentialSet;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+public class SameCredentialsBuilderTest extends MockObjectTestCase
+{
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( SameCredentialsBuilderTest.class );
+    }
+
+    protected void setUp() throws Exception
+    {
+    }
+
+    public void testBuildsSelectorLookingForEqualMatchOnAllCredentials()
+    {
+        CredentialSet creds = new CredentialSet();
+        creds.add( new UsernameCredential( "joe" ) );
+        creds.add( new PasswordCredential( "foo" ) );
+        SameCredentialsBuilder builder = new SameCredentialsBuilder( creds );
+
+        Mock mockSelector = new Mock( Selector.class );
+
+        mockSelector.expects( once() ).method( "eq" ).with( eq( UsernameCredential.class), eq( new UsernameCredential( "joe" ) ) );
+        mockSelector.expects( once() ).method( "eq" ).with( eq( PasswordCredential.class), eq( new PasswordCredential( "foo" ) ) );
+        builder.build( ( Selector ) mockSelector.proxy() );
+        mockSelector.verify();
+    }
+}

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Column.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Column.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Column.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Column.java Mon Mar 21 07:43:35 2005
@@ -24,19 +24,12 @@
 public class Column
 {
     private final String m_name;
-    private final Class m_type;
-    private final Converter m_converter;
+    private final Persister m_persister;
 
-    public Column( String name, Class type )
-    {
-        this( name, type, new DefaultConverter() );
-    }
-
-    public Column( String name, Class type, Converter converter )
+    public Column( String name, Persister converter )
     {
         m_name = name;
-        m_type = type;
-        m_converter = converter;
+        m_persister = converter;
     }
 
     public String getName()
@@ -46,12 +39,12 @@
 
     public Class getMappedType()
     {
-        return m_type;
+        return m_persister.getCredentialType();
     }
 
-    public String getValue( Object value )
+    public void setCredential( SQLStatement statement, Credential c )
     {
-        return m_converter.convert( value );
+        m_persister.setCredential( statement, c );
     }
 
     public boolean equals( Object o )
@@ -74,25 +67,20 @@
 
     public String toString()
     {
-        return "m_name=" + m_name + ", m_type=" + m_type;
+        return "m_name=" + m_name + ", m_type=" + m_persister.getCredentialType();
     }
 
-    public Object getObject( ResultSet rs ) throws JDBCException
+    public Credential getCredential( ResultSet rs ) throws JDBCException
     {
-        Credential value = null;
+        Credential credential = null;
         try
         {
-            value = (Credential) m_type.newInstance();
-            value.setValue( rs.getString( m_name ));
+            credential = m_persister.getCredential( rs, m_name );
         }
         catch ( SQLException e )
         {
             throw new JDBCException( e );
         }
-        catch ( Exception e )
-        {
-            throw new InstantiationException( "Cannot create credential instance: " + m_type.getName(), e );
-        }
-        return value;
+        return credential;
     }
 }

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,63 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import org.apache.authx.authentication.Credential;
+
+import java.lang.reflect.Constructor;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class ConstructorInstantiationPersister implements Persister
+{
+    private final Class m_credentialType;
+    private final SQLType m_sqlType;
+
+    public ConstructorInstantiationPersister( Class credentialType, SQLType sqlType )
+    {
+        if ( !Credential.class.isAssignableFrom( credentialType ) ) throw new IllegalArgumentException( "Should implement the Credential interface: " + credentialType.getName() );
+        m_credentialType = credentialType;
+        m_sqlType = sqlType;
+    }
+
+    public Class getCredentialType()
+    {
+        return m_credentialType;
+    }
+
+    public void setCredential( SQLStatement st, Credential c )
+    {
+        m_sqlType.setValue( st, c.getValue() );
+    }
+
+    public Credential getCredential( ResultSet rs, String columnName ) throws SQLException
+    {
+        Credential c = null;
+        try
+        {
+            Constructor constructor = m_credentialType.getConstructor( new Class[] { m_sqlType.getJavaType() } );
+            Object value = m_sqlType.getValue( rs, columnName );
+            c = (Credential) constructor.newInstance( new Object[] { value } );
+        }
+        catch ( Exception e )
+        {
+            throw new InstantiationException( m_credentialType, e );
+        }
+
+        return c;
+    }
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/ConstructorInstantiationPersister.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/EqExpression.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/EqExpression.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/EqExpression.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/EqExpression.java Mon Mar 21 07:43:35 2005
@@ -16,59 +16,29 @@
  */
 package org.apache.authx.authentication.realm;
 
-import java.util.Collection;
+import org.apache.authx.authentication.Credential;
 
 public class EqExpression implements SQLExpression
 {
     private final Column m_column;
-    private final Object m_value;
+    private final Credential m_value;
 
-    public EqExpression( Column column, Object value )
+    // TODO: check that column supports credential type
+    public EqExpression( Column column, Credential c )
     {
         m_column = column;
-        m_value = value;
+        m_value = c;
     }
 
-    public void appendQueryString( StringBuffer query )
+    public void prepare( SQLStatement statement )
     {
-        query.append( m_column.getName() );
-        query.append( operator() );
-        query.append( "?" );
-    }
-
-    public void bindParameters( Collection parameters )
-    {
-        parameters.add( m_column.getValue( m_value ) );
+        statement.append( m_column.getName() );
+        statement.append( operator() );
+        m_column.setCredential( statement, m_value );
     }
 
     protected String operator()
     {
         return "=";
-    }
-
-    public boolean equals( Object o )
-    {
-        if ( this == o ) return true;
-        if ( !( o instanceof EqExpression ) ) return false;
-
-        final EqExpression eqExpression = ( EqExpression ) o;
-
-        if ( !m_column.equals( eqExpression.m_column ) ) return false;
-        if ( !m_value.equals( eqExpression.m_value ) ) return false;
-
-        return true;
-    }
-
-    public int hashCode()
-    {
-        int result;
-        result = m_column.hashCode();
-        result = 29 * result + m_value.hashCode();
-        return result;
-    }
-
-    public String toString()
-    {
-        return "eq(" + m_column.getName() + ", " + m_value.toString() + ")";
     }
 }

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/InstantiationException.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/InstantiationException.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/InstantiationException.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/InstantiationException.java Mon Mar 21 07:43:35 2005
@@ -16,20 +16,25 @@
  */
 package org.apache.authx.authentication.realm;
 
-public class InstantiationException extends RuntimeException
+import org.apache.authx.AuthXException;
+
+public class InstantiationException extends AuthXException
 {
-    public InstantiationException( String message )
+    private final Class m_type;
+
+    public InstantiationException( Class type, Throwable cause )
     {
-        super( message );
+        super( cause );
+        m_type = type;
     }
 
-    public InstantiationException( Throwable cause )
+    public Class getType()
     {
-        super( cause );
+        return m_type;
     }
 
-    public InstantiationException( String message, Throwable cause )
+    public String getMessage()
     {
-        super( message, cause );
+        return "Cannot create credential instance of type: " + m_type.getName();
     }
 }

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCException.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCException.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCException.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCException.java Mon Mar 21 07:43:35 2005
@@ -16,9 +16,11 @@
  */
 package org.apache.authx.authentication.realm;
 
+import org.apache.authx.AuthXException;
+
 import java.sql.SQLException;
 
-public class JDBCException extends RuntimeException
+public class JDBCException extends AuthXException
 {
     private final SQLException m_cause;
 

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCRealm.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCRealm.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCRealm.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCRealm.java Mon Mar 21 07:43:35 2005
@@ -52,9 +52,9 @@
 
     private CredentialSet findAuthenticatedMatch( CredentialSet credentialSet )
     {
-        SelectorBuilder selectorBuilder = m_authenticationMethod.getAuthenticationSelector( credentialSet );
+        SelectorBuilder selectorBuilder = m_authenticationMethod.getAuthenticationBuilder( credentialSet );
         JDBCSelector selector = new JDBCSelector( m_table );
-        selectorBuilder.build( new SQLExpressionBuilder( m_table ), selector );
+        selectorBuilder.build( selector );
 
         CredentialSet creds = find( selector );
         return creds;
@@ -68,10 +68,12 @@
         {
             conn = m_ds.getConnection();
             creds = selector.select( conn );
-        } catch ( SQLException e )
+        }
+        catch ( SQLException e )
         {
             throw new JDBCException( e );
-        } finally
+        }
+        finally
         {
             closeConnection( conn );
         }
@@ -86,7 +88,8 @@
         try
         {
             conn.close();
-        } catch ( SQLException ignored )
+        }
+        catch ( SQLException ignored )
         {
         }
     }

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCSelector.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCSelector.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCSelector.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/JDBCSelector.java Mon Mar 21 07:43:35 2005
@@ -17,6 +17,7 @@
 package org.apache.authx.authentication.realm;
 
 import org.apache.authx.authentication.CredentialSet;
+import org.apache.authx.authentication.Credential;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -30,74 +31,59 @@
 {
     private final Table m_table;
     private final Collection m_expressions;
+    private final SQLExpressionBuilder m_builder;
 
     public JDBCSelector( Table table )
     {
         m_table = table;
         m_expressions = new ArrayList();
+        m_builder = new SQLExpressionBuilder( table );
     }
 
-    public void addExpression( Object expression )
+    public Selector eq( Class type, Credential c )
+    {
+        addExpression( m_builder.eq( type, c ) );
+        return this;
+    }
+
+    private void addExpression( SQLExpression expression )
     {
-        if (!(expression instanceof SQLExpression)) throw new IllegalArgumentException( "Expecting SQLExpression; unsupported: " + expression.getClass().getName() );
         m_expressions.add( expression );
     }
 
     public CredentialSet select( Connection c ) throws SQLException
     {
-        PreparedStatement statement = null;
+        PreparedStatement st = null;
         CredentialSet creds = null;
         try
         {
-            statement = c.prepareStatement( buildQueryString() );
-            bindParameterValues( statement, getParameterValues() );
-            ResultSet rs = statement.executeQuery();
+            PreparedSQLStatement statement = new PreparedSQLStatement( "select * from " );
+            statement.append( m_table.getName() );
+            statement.append( " where " );
+            prepare( statement );
+            st = statement.create( c );
+            ResultSet rs = st.executeQuery();
             if ( rs.next() )
             {
-                creds = m_table.instanciate( rs );
+                creds = m_table.instantiate( rs );
             }
             rs.close();
         }
         finally
         {
-            if (statement != null) statement.close();
+            if (st != null) st.close();
         }
 
         return creds;
     }
 
-    private String[] getParameterValues()
+    private void prepare( SQLStatement statement )
     {
-        Collection parameters = new ArrayList();
         for ( Iterator it = m_expressions.iterator(); it.hasNext(); )
         {
-            SQLExpression expression = ( SQLExpression ) it.next();
-            expression.bindParameters( parameters );
-        }
-
-        return ( String[] ) parameters.toArray( new String[parameters.size()] );
-    }
-
-    private String buildQueryString()
-    {
-        StringBuffer query = new StringBuffer();
-        query.append( "select * from " ).append( m_table.getName() ).append( " where " );
-
-        for ( Iterator it = m_expressions.iterator(); it.hasNext(); )
-        {
-            SQLExpression expression = ( SQLExpression ) it.next();
-            expression.appendQueryString( query );
-            if ( it.hasNext() ) query.append( " and " );
-        }
-
-        return query.toString();
-    }
-
-    private void bindParameterValues( PreparedStatement statement, String[] parameters ) throws SQLException
-    {
-        for ( int i = 0; i < parameters.length; i++ )
-        {
-            statement.setString( i + 1, parameters[i] );
+            SQLExpression expression = (SQLExpression) it.next();
+            expression.prepare( statement );
+            if ( it.hasNext() ) statement.append( " and " );
         }
     }
 }

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,31 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import org.apache.authx.authentication.Credential;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public interface Persister
+{
+    Class getCredentialType();
+
+    Credential getCredential( ResultSet rs, String columnName ) throws SQLException;
+
+    void setCredential( SQLStatement st, Credential c );
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Persister.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,63 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class PreparedSQLStatement implements SQLStatement
+{
+    private final StringBuffer m_query = new StringBuffer();
+    private final List m_parameters = new ArrayList();
+
+    public PreparedSQLStatement()
+    {
+    }
+
+    public PreparedSQLStatement( String query )
+    {
+        m_query.append( query );
+    }
+
+    public SQLStatement append( String sqlFragment )
+    {
+        m_query.append( sqlFragment );
+        return this;
+    }
+
+    public SQLStatement setString( String value )
+    {
+        m_query.append( "?" );
+        m_parameters.add( value );
+        return this;
+    }
+
+    public PreparedStatement create( Connection c ) throws SQLException
+    {
+        PreparedStatement st = c.prepareStatement( m_query.toString() );
+        for ( int i = 0; i < m_parameters.size(); i++ )
+        {
+            String s = (String) m_parameters.get( i );
+            st.setString( i + 1, s );
+        }
+
+        return st;
+    }
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/PreparedSQLStatement.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpression.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpression.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpression.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpression.java Mon Mar 21 07:43:35 2005
@@ -16,11 +16,7 @@
  */
 package org.apache.authx.authentication.realm;
 
-import java.util.Collection;
-
 public interface SQLExpression
 {
-    void appendQueryString( StringBuffer query );
-
-    void bindParameters( Collection parameters );
+    void prepare( SQLStatement statement );
 }

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpressionBuilder.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpressionBuilder.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpressionBuilder.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLExpressionBuilder.java Mon Mar 21 07:43:35 2005
@@ -16,7 +16,9 @@
  */
 package org.apache.authx.authentication.realm;
 
-public class SQLExpressionBuilder implements ExpressionBuilder
+import org.apache.authx.authentication.Credential;
+
+public class SQLExpressionBuilder
 {
     private final Table m_table;
 
@@ -25,13 +27,8 @@
         m_table = table;
     }
 
-    public Object eq( Class type, Object value )
-    {
-        return new EqExpression( m_table.getColumn( type ), value );
-    }
-
-    public Object and( Object left, Object right )
+    public SQLExpression eq( Class type, Credential c )
     {
-        return new AndExpression( left, right );
+        return new EqExpression( m_table.getColumn( type ), c );
     }
 }

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,24 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+public interface SQLStatement
+{
+    SQLStatement append( String sqlFragment );
+
+    SQLStatement setString( String value );
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStatement.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,38 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class SQLStringType implements SQLType
+{
+    public Class getJavaType()
+    {
+        return String.class;
+    }
+
+    public void setValue( SQLStatement st, Object value )
+    {
+        st.setString( value.toString() );
+    }
+
+    public Object getValue( ResultSet rs, String columnName ) throws SQLException
+    {
+        return rs.getString( columnName );
+    }
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLStringType.java
------------------------------------------------------------------------------
    svn:executable = *

Added: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java (added)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,29 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public interface SQLType
+{
+    Class getJavaType();
+
+    void setValue( SQLStatement st, Object value );
+
+    Object getValue( ResultSet rs, String columnName ) throws SQLException;
+}

Propchange: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/SQLType.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Table.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Table.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Table.java (original)
+++ directory/authx/trunk/jdbc/src/java/org/apache/authx/authentication/realm/Table.java Mon Mar 21 07:43:35 2005
@@ -57,25 +57,19 @@
         return column != null ? column.getName() : null;
     }
 
-    public String getColumnValue( Class type, Object value )
-    {
-        Column column = getColumn( type );
-        return column != null ? column.getValue( value ) : null;
-    }
-
     public Column getColumn( Class type )
     {
         Column column = ( Column ) m_columns.get( type );
         return column;
     }
 
-    public CredentialSet instanciate( ResultSet rs )
+    public CredentialSet instantiate( ResultSet rs )
     {
         CredentialSet creds = new CredentialSet();
         for ( Iterator it = m_columns.values().iterator(); it.hasNext(); )
         {
             Column column = ( Column ) it.next();
-            creds.add( column.getObject( rs ) );
+            creds.add( column.getCredential( rs ) );
         }
 
         return creds;

Modified: directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/Columns.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/Columns.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/Columns.java (original)
+++ directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/Columns.java Mon Mar 21 07:43:35 2005
@@ -22,11 +22,11 @@
 
     public static Column username()
     {
-        return new Column( "USERNAME", UsernameCredential.class );
+        return new Column( "USERNAME", new ConstructorInstantiationPersister( UsernameCredential.class, new SQLStringType() ) );
     }
 
     public static Column password()
     {
-        return new Column( "PASSWORD", PasswordCredential.class );
+        return new Column( "PASSWORD", new ConstructorInstantiationPersister( PasswordCredential.class, new SQLStringType() ) );
     }
 }

Added: directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java?view=auto&rev=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java (added)
+++ directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java Mon Mar 21 07:43:35 2005
@@ -0,0 +1,50 @@
+/*
+ *   Copyright 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.authx.authentication.realm;
+
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+import java.sql.ResultSet;
+
+public class ConstructorInstantiatingPersisterTest extends MockObjectTestCase
+{
+    public static void main( String[] args )
+    {
+        junit.textui.TestRunner.run( ConstructorInstantiatingPersisterTest.class );
+    }
+
+    public void testInstantiatesClassUsingConstructorWithSingleArgument() throws Exception
+    {
+        String columnName = "username";
+        UsernameCredential expected = new UsernameCredential( "jblow" );
+
+        ConstructorInstantiationPersister converter = new ConstructorInstantiationPersister( UsernameCredential.class, new SQLStringType() );
+
+        Mock mockResultSet = new Mock( ResultSet.class );
+        mockResultSet.stubs().method( "getString" ).with( eq( columnName ) ).will( returnValue( expected.getUsername() ) );
+
+        Object actual = converter.getCredential( resultSet( mockResultSet ), columnName );
+        assertEquals( expected, actual );
+    }
+
+    private ResultSet resultSet( Mock mockResultSet )
+    {
+        return (ResultSet) mockResultSet.proxy();
+    }
+
+}

Propchange: directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/ConstructorInstantiatingPersisterTest.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/JDBCSelectorTest.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/JDBCSelectorTest.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/JDBCSelectorTest.java (original)
+++ directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/JDBCSelectorTest.java Mon Mar 21 07:43:35 2005
@@ -29,11 +29,11 @@
     protected void setUp() throws Exception
     {
         m_db = new MemoryDatabase();
-        Table table = Tables.users();
-        m_db.create( table );
-        m_db.insertInto( table, Creds.joe() );
-        m_db.insertInto( table, Creds.jane() );
-        m_selector = new JDBCSelector( table );
+        Table users = Tables.users();
+        m_db.create( users );
+        m_db.insertInto( users, Creds.joe() );
+        m_db.insertInto( users, Creds.jane() );
+        m_selector = new JDBCSelector( users );
 
         m_connection = m_db.getDataSource().getConnection();
     }
@@ -44,40 +44,16 @@
         m_db.dropAll();
     }
 
-    /**
-     * conversion of credential object values to string values
-     */
     public void testFindsDataBasedOnCredentialExpression() throws Exception
     {
-        m_selector.addExpression( new EqExpression( Columns.username(), "joe" ) );
+        m_selector.eq( UsernameCredential.class, new UsernameCredential( "joe" ) );
         assertEquals( Creds.joe(), m_selector.select( m_connection ) );
     }
 
     public void testSupportsMultipleCredentialExpressions() throws Exception
     {
-        m_selector.addExpression( new EqExpression( Columns.username(), "joe" ) );
-        m_selector.addExpression( new EqExpression( Columns.password(), "foo" ) );
-
+        m_selector.eq( UsernameCredential.class, new UsernameCredential( "joe" ) );
+        m_selector.eq( PasswordCredential.class, new PasswordCredential( "foo" ) );
         assertEquals( Creds.joe(), m_selector.select( m_connection ) );
     }
-
-    public void testSupportsAndExpressions() throws Exception
-    {
-        m_selector.addExpression( new AndExpression( new EqExpression( Columns.username(), "joe" ),
-                new EqExpression( Columns.password(), "foo" ) ) );
-        assertEquals( Creds.joe(), m_selector.select( m_connection ) );
-    }
-
-    public void testRejectsNonSQLExpressions()
-    {
-        try
-        {
-            m_selector.addExpression( new Object() );
-            fail( "Unsupported expression type accepted" );
-        }
-        catch ( IllegalArgumentException expected )
-        {
-            assertTrue( true );
-        }
-    }    
 }

Modified: directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/MemoryDatabase.java
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/MemoryDatabase.java?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/MemoryDatabase.java (original)
+++ directory/authx/trunk/jdbc/src/test/org/apache/authx/authentication/realm/MemoryDatabase.java Mon Mar 21 07:43:35 2005
@@ -25,6 +25,7 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.PreparedStatement;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -84,28 +85,27 @@
 
     public void insertInto( Table table, CredentialSet creds ) throws SQLException
     {
-        Connection c = m_ds.getConnection();
-        Statement statement = c.createStatement();
-        StringBuffer sb = new StringBuffer( );
-
-        sb.append( "insert into ").append( table.getName() ).append( "(");
+        PreparedSQLStatement statement = new PreparedSQLStatement( "insert into " );
+        statement.append( table.getName() ).append( "(" );
         for ( Iterator it = creds.elements().iterator(); it.hasNext(); )
         {
             Credential credential = ( Credential ) it.next();
-            sb.append( table.getColumnName( credential.getClass() ));
-            if ( it.hasNext() ) sb.append( ",");
+            statement.append( table.getColumnName( credential.getClass() ) );
+            if ( it.hasNext() ) statement.append( "," );
         }
-
-        sb.append( ") values( ");
+        statement.append( ") values( " );
         for ( Iterator it = creds.elements().iterator(); it.hasNext(); )
         {
             Credential credential = ( Credential ) it.next();
-            sb.append( "'" ).append( table.getColumnValue( credential.getClass(), credential.getValue() ) ).append( "'" );
-            if ( it.hasNext() ) sb.append( ",");
+            table.getColumn( credential.getClass() ).setCredential( statement, credential );
+            if ( it.hasNext() ) statement.append( "," );
         }
-        sb.append( ")");
-        statement.executeUpdate( sb.toString() );
-        statement.close();
+        statement.append( ")" );
+
+        Connection c = m_ds.getConnection();
+        PreparedStatement st = statement.create( c );
+        st.executeUpdate();
+        st.close();
         c.close();
     }
 

Modified: directory/authx/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/project.xml?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/project.xml (original)
+++ directory/authx/trunk/project.xml Mon Mar 21 07:43:35 2005
@@ -24,8 +24,8 @@
     <logo>http://directory.apache.org/images/apache-directory-logo.png</logo>
     <url>http://directory.apache.org/subprojects/protocols/authx</url>
     <siteAddress>minotaur.apache.org</siteAddress>
-    <siteDirectory>/www/incubator.apache.org/directory/subprojects/authx</siteDirectory>
-    <distributionDirectory>/www/cvs.apache.org/dist/incubator/directory</distributionDirectory>
+    <siteDirectory>/www/directory.apache.org/subprojects/authx</siteDirectory>
+    <distributionDirectory>/www/cvs.apache.org/dist/directory</distributionDirectory>
 
     <gumpRepositoryId>directory</gumpRepositoryId>
 

Modified: directory/authx/trunk/xdocs/roadmap.xml
URL: http://svn.apache.org/viewcvs/directory/authx/trunk/xdocs/roadmap.xml?view=diff&r1=158469&r2=158470
==============================================================================
--- directory/authx/trunk/xdocs/roadmap.xml (original)
+++ directory/authx/trunk/xdocs/roadmap.xml Mon Mar 21 07:43:35 2005
@@ -44,14 +44,6 @@
         </p>
       </subsection>
 
-        <subsection name="0.5">
-          <p>
-          <ul>
-                  <li>Read-only Hibernate realm backend</li>
-          </ul>
-          </p>
-        </subsection>
-
         <subsection name="And then ...">
           <p>
           <ul>
@@ -61,6 +53,7 @@
                   <li>Read-only JDBC role provider backend</li>
                   <li>Read-only JDBC group provider backend</li>
                   <li>Read-only JDBC role provider backend</li>
+                  <li>Read-only Hibernate realm backend</li>
                   <li>...</li>
           </ul>
           </p>