You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ke...@apache.org on 2011/07/07 14:47:10 UTC
svn commit: r1143797 - in /incubator/isis/trunk/framework/security/sql/src:
main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
site/apt/index.apt
Author: kevin
Date: Thu Jul 7 12:47:10 2011
New Revision: 1143797
URL: http://svn.apache.org/viewvc?rev=1143797&view=rev
Log:
Updated documentation and added verifyPasswordsAreEqual method to support encrypted passwords.
Modified:
incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
incubator/isis/trunk/framework/security/sql/src/site/apt/index.apt
Modified: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java?rev=1143797&r1=1143796&r2=1143797&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java (original)
+++ incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java Thu Jul 7 12:47:10 2011
@@ -51,6 +51,11 @@ public class SqlAuthenticator extends Pa
return instance;
}
+ // Override this method if dbPasswords are encoded.
+ protected boolean verifyPasswordsAreEqual(String loginPassword, String dbPassword) {
+ return dbPassword.equals(loginPassword);
+ }
+
// Override this method
protected ResultSet postProcessLogin(final String user, final String password, final ResultSet results) {
return results;
@@ -214,7 +219,7 @@ public class SqlAuthenticator extends Pa
try {
while (results.next()) {
String dbPassword = results.getString(passwordField);
- if (dbPassword.equals(password)) {
+ if (verifyPasswordsAreEqual(password, dbPassword)) {
return postProcessLogin(user, password, results);
}
}
Modified: incubator/isis/trunk/framework/security/sql/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/site/apt/index.apt?rev=1143797&r1=1143796&r2=1143797&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/site/apt/index.apt (original)
+++ incubator/isis/trunk/framework/security/sql/src/site/apt/index.apt Thu Jul 7 12:47:10 2011
@@ -26,7 +26,10 @@ Security SQL Implementation
No additional helpers are provided to maintain the SQL tables used, so you will have
to find your own table viewers/editors to maintain them.
- At the moment, authorization learning has not been implemented.
+ At the moment, authorisation learning has not been implemented.
+
+ The SqlAuthenticator classes use jdbc to access the database tables, with no reliance on the
+ Isis SqlObjectStore.
Alternatives
@@ -63,30 +66,55 @@ Setup
# Roles are of the forms ROLE1|ROLE2|ROLE3
isis.authentication.sql.roleField=RealFieldThatContainsRoles
- # Optional: If you wish to override the default SqlAuthenticator, you can specify your own,
- # with a fully qualified classname:
+ # Optional: If you wish to override the default SqlAuthenticator, you can specify
+ # your own, by providing the fully qualified class name of your class that extends
+ # PasswordRequestAuthenticatorAbstract:
isis.authentication.authenticator=domain.package.MyCustomSqlAuthenticator
+--
- * Custom Authenticator
+ * Operation
+
+ The default SqlAuthenticator loads the record set from <<isis.authentication.sql.userTable>> with
+ values where <<isis.authentication.sql.userNameField>> matches the login form's username (converted to
+ upper-case, so the match is case-<<in>>sensitive).
+
+ A simple case-sensitive string comparison is performed to match the login form's password with the value
+ in <<isis.authentication.sql.passwordField>>.
+
+ If a match is found, the user roles are loaded from the field
+ <<isis.authentication.sql.roleField>>, if specified.
+
+Custom Authenticator
- Extend "org.apache.isis.security.sql.authentication.SqlAuthenticator" and override the following methods:
+ If you want to replace or extend the current behaviour, you need to
+ extend <<org.apache.isis.security.sql.authentication.SqlAuthenticator>> and optionally override
+ whichever of the following methods you need to:
+--
- protected ResultSet postProcessLogin(String user, String password, ResultSet results)
- protected String getRoles(final ResultSet results, final String roles)
+ boolean verifyPasswordsAreEqual(String userPassword, String dbPassword)
+ ResultSet postProcessLogin(String user, String password, ResultSet results)
+ String getRoles(final ResultSet results, final String roles)
+--
- ** postProcessLogin
+ * <<verifyPasswordsAreEqual>>
+
+ Lets you override the default password comparison check, which is a simple <loginPassword.equals(dbPassword)> check.
+
+ Use this if your database passwords are encrypted.
+
+ This method is called before postProcessLogin, which is only called if this method returns true.
+
+ * <<postProcessLogin>>
Lets you perform additional processing to see if the found RecordSet (which has already been verified to match the
provided username and password, should be allowed to login.
Simply return the results RecordSet, if so, else return null.
- ** getRoles
+ * <<getRoles>>
- Lets you add additional roles to the default. Simply return your custom roles appended to the provided roles String.
+ Lets you add additional roles to the default. Simply return your custom roles appended to the provided roles String.
+ Separate roles with a "|", e.g. <return roles+"|ROLE1|ROLE2">.
[]