JDBCAuthenticatorpublic class JDBCAuthenticator extends Object implements com.imaginary.lwp.AuthenticatorImplements the Authenticator interface to authenticate
a user ID/password against values stored in a database. This class
expects the following table structure:
LWP_USER |
USER_ID (VARCHAR(25)) |
PASSWORD (VARCHAR(25)) |
If you want a more complex authentication scheme, you should
write your own Authenticator implementation.
This implementation ignores all role information and just authenticates
base on UID/PW.
Last modified $Date: 1999/11/07 19:32:30 $ |
Fields Summary |
---|
public static final String | SELECTThe SQL SELECT statement. |
Methods Summary |
---|
public void | authenticate(java.lang.String uid, java.lang.String pw)Authenticates the specified user ID against the specified
password.
Connection conn = null;
try {
PreparedStatement stmt;
String actual;
ResultSet rs;
conn = JDBCTransactionImpl.getJDBCConnection();
stmt = conn.prepareStatement(SELECT);
stmt.setString(1, uid);
rs = stmt.executeQuery();
if( !rs.next() ) {
throw new AuthenticationException("Invalid user ID or " +
"password.");
}
actual = rs.getString(1);
if( rs.wasNull() ) {
throw new AuthenticationException("No password specified for "+
uid);
}
if( !actual.equals(pw) ) {
throw new AuthenticationException("Invalid user ID or " +
"password.");
}
conn.commit();
}
catch( SQLException e ) {
e.printStackTrace();
throw new AuthenticationException(e);
}
finally {
if( conn != null ) {
try { conn.close(); }
catch( SQLException e ) { }
}
}
| public void | authenticate(java.lang.String uid, java.lang.String pw, com.imaginary.lwp.AuthenticationRole r)Authenticates the specified user ID against the specified
password.
authenticate(uid, pw);
|
|