isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1234458 - in /incubator/isis/trunk/framework/security: dflt/src/main/java/org/apache/isis/security/dflt/authentication/ file/src/main/java/org/apache/isis/security/file/authentication/ file/src/main/java/org/apache/isis/security/file/autho...
Date Sun, 22 Jan 2012 07:41:18 GMT
Author: danhaywood
Date: Sun Jan 22 07:41:17 2012
New Revision: 1234458

URL: http://svn.apache.org/viewvc?rev=1234458&view=rev
Log:
ISIS-165: code cleanup for security

Modified:
    incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticatorNoop.java
    incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/NoopAuthenticationManagerInstaller.java
    incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticationManagerInstaller.java
    incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticator.java
    incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizationConstants.java
    incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizor.java
    incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationConstants.java
    incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationManagerInstaller.java
    incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticator.java
    incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizationConstants.java
    incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizor.java
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java

Modified: incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticatorNoop.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticatorNoop.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticatorNoop.java
(original)
+++ incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/AuthenticatorNoop.java
Sun Jan 22 07:41:17 2012
@@ -36,7 +36,7 @@ public class AuthenticatorNoop extends A
     }
 
     @Override
-    public boolean canAuthenticate(Class<? extends AuthenticationRequest> authenticationRequestClass)
{
+    public boolean canAuthenticate(final Class<? extends AuthenticationRequest> authenticationRequestClass)
{
         return true;
     }
 

Modified: incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/NoopAuthenticationManagerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/NoopAuthenticationManagerInstaller.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/NoopAuthenticationManagerInstaller.java
(original)
+++ incubator/isis/trunk/framework/security/dflt/src/main/java/org/apache/isis/security/dflt/authentication/NoopAuthenticationManagerInstaller.java
Sun Jan 22 07:41:17 2012
@@ -35,7 +35,7 @@ public class NoopAuthenticationManagerIn
 
     @Override
     protected List<Authenticator> createAuthenticators(final IsisConfiguration configuration)
{
-        return Lists.<Authenticator>newArrayList(new AuthenticatorNoop(configuration));
+        return Lists.<Authenticator> newArrayList(new AuthenticatorNoop(configuration));
     }
 
 }

Modified: incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticationManagerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticationManagerInstaller.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticationManagerInstaller.java
(original)
+++ incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticationManagerInstaller.java
Sun Jan 22 07:41:17 2012
@@ -37,7 +37,7 @@ public class FileAuthenticationManagerIn
 
     @Override
     protected List<Authenticator> createAuthenticators(final IsisConfiguration configuration)
{
-        return Lists.<Authenticator>newArrayList(new FileAuthenticator(configuration));
+        return Lists.<Authenticator> newArrayList(new FileAuthenticator(configuration));
     }
 
 }

Modified: incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticator.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticator.java
(original)
+++ incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authentication/FileAuthenticator.java
Sun Jan 22 07:41:17 2012
@@ -60,11 +60,9 @@ public class FileAuthenticator extends P
 
         BufferedReader reader = null;
         try {
-            final InputStream readStream =
-                resourceStreamSource.readResource(FileAuthenticationConstants.PASSWORDS_FILE);
+            final InputStream readStream = resourceStreamSource.readResource(FileAuthenticationConstants.PASSWORDS_FILE);
             if (readStream == null) {
-                throw new IsisException("Failed to open password file: " + FileAuthenticationConstants.PASSWORDS_FILE
-                    + " from " + resourceStreamSource.getName());
+                throw new IsisException("Failed to open password file: " + FileAuthenticationConstants.PASSWORDS_FILE
+ " from " + resourceStreamSource.getName());
             }
             reader = new BufferedReader(new InputStreamReader(readStream));
             String line;
@@ -84,8 +82,7 @@ public class FileAuthenticator extends P
             }
             return false;
         } catch (final IOException e) {
-            throw new IsisException("Failed to read password file: " + FileAuthenticationConstants.PASSWORDS_FILE
-                + " from " + resourceStreamSource.getName());
+            throw new IsisException("Failed to read password file: " + FileAuthenticationConstants.PASSWORDS_FILE
+ " from " + resourceStreamSource.getName());
         } finally {
             IoUtils.closeSafely(reader);
         }

Modified: incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizationConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizationConstants.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizationConstants.java
(original)
+++ incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizationConstants.java
Sun Jan 22 07:41:17 2012
@@ -25,8 +25,7 @@ import org.apache.isis.core.runtime.auth
 
 public final class FileAuthorizationConstants {
 
-    private static final String ROOT = ConfigurationConstants.ROOT + AuthorizationManagerInstaller.TYPE
+ "."
-        + FileAuthorizationManagerInstaller.NAME + ".";
+    private static final String ROOT = ConfigurationConstants.ROOT + AuthorizationManagerInstaller.TYPE
+ "." + FileAuthorizationManagerInstaller.NAME + ".";
 
     public static final String WHITELIST_RESOURCE_KEY = ROOT + "whitelist";
     public static final String WHITELIST_RESOURCE_DEFAULT = "security_file.allow";

Modified: incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizor.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizor.java
(original)
+++ incubator/isis/trunk/framework/security/file/src/main/java/org/apache/isis/security/file/authorization/FileAuthorizor.java
Sun Jan 22 07:41:17 2012
@@ -76,15 +76,10 @@ public class FileAuthorizor extends Auth
         // read from config
         this.resourceStreamSource = getConfiguration().getResourceStreamSource();
 
-        this.learn =
-            getConfiguration().getBoolean(FileAuthorizationConstants.LEARN, FileAuthorizationConstants.LEARN_DEFAULT);
-        whiteListResourceName =
-            getConfiguration().getString(FileAuthorizationConstants.WHITELIST_RESOURCE_KEY,
-                FileAuthorizationConstants.WHITELIST_RESOURCE_DEFAULT);
+        this.learn = getConfiguration().getBoolean(FileAuthorizationConstants.LEARN, FileAuthorizationConstants.LEARN_DEFAULT);
+        whiteListResourceName = getConfiguration().getString(FileAuthorizationConstants.WHITELIST_RESOURCE_KEY,
FileAuthorizationConstants.WHITELIST_RESOURCE_DEFAULT);
         Assert.assertTrue(whiteListResourceName.length() > 0);
-        blackListResourceName =
-            getConfiguration().getString(FileAuthorizationConstants.BLACKLIST_RESOURCE_KEY,
-                FileAuthorizationConstants.BLACKLIST_RESOURCE_DEFAULT);
+        blackListResourceName = getConfiguration().getString(FileAuthorizationConstants.BLACKLIST_RESOURCE_KEY,
FileAuthorizationConstants.BLACKLIST_RESOURCE_DEFAULT);
 
         findResources();
     }
@@ -98,8 +93,7 @@ public class FileAuthorizor extends Auth
         if (blackListResourceName.length() > 0) {
             this.blackListInputResource = resourceStreamSource.readResource(blackListResourceName);
             if (blackListInputResource == null) {
-                throw new IsisException("Blacklist authorization file exists, but it cannot
be read: "
-                    + blackListResourceName);
+                throw new IsisException("Blacklist authorization file exists, but it cannot
be read: " + blackListResourceName);
             }
         } else {
             blackListInputResource = null;
@@ -239,11 +233,11 @@ public class FileAuthorizor extends Auth
     }
 
     /*
-     * Work through the available entries from most specific to least. When one exists then
determine the result of this
-     * method by looking for a compatible role between the entry and required role.
+     * Work through the available entries from most specific to least. When one
+     * exists then determine the result of this method by looking for a
+     * compatible role between the entry and required role.
      */
-    private boolean isListed(final Map<String, List<String>> map, final String
role, final Identifier identifier,
-        final List<String> qualifiers) {
+    private boolean isListed(final Map<String, List<String>> map, final String
role, final Identifier identifier, final List<String> qualifiers) {
         if (map.isEmpty()) {// quick fail
             return false;
         }

Modified: incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationConstants.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationConstants.java
(original)
+++ incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationConstants.java
Sun Jan 22 07:41:17 2012
@@ -24,8 +24,7 @@ import org.apache.isis.core.runtime.auth
 
 public final class LdapAuthenticationConstants {
 
-    public static final String ROOT = ConfigurationConstants.ROOT + AuthenticationManagerInstaller.TYPE
+ "."
-        + LdapAuthenticationManagerInstaller.NAME + ".";
+    public static final String ROOT = ConfigurationConstants.ROOT + AuthenticationManagerInstaller.TYPE
+ "." + LdapAuthenticationManagerInstaller.NAME + ".";
 
     public static final String SERVER_KEY = ROOT + "server";
     public static final String SERVER_DEFAULT = "com.sun.jndi.ldap.LdapCtxFactory";

Modified: incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationManagerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationManagerInstaller.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationManagerInstaller.java
(original)
+++ incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticationManagerInstaller.java
Sun Jan 22 07:41:17 2012
@@ -37,6 +37,6 @@ public class LdapAuthenticationManagerIn
 
     @Override
     protected List<Authenticator> createAuthenticators(final IsisConfiguration configuration)
{
-        return Lists.<Authenticator>newArrayList(new LdapAuthenticator(configuration));
+        return Lists.<Authenticator> newArrayList(new LdapAuthenticator(configuration));
     }
 }

Modified: incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticator.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticator.java
(original)
+++ incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authentication/LdapAuthenticator.java
Sun Jan 22 07:41:17 2012
@@ -58,15 +58,13 @@ public class LdapAuthenticator extends A
         return AuthenticationRequestPassword.class.isAssignableFrom(authenticationRequestClass);
     }
 
-    private void setRoles(final DirContext authContext, final AuthenticationRequest request,
final String username)
-        throws NamingException {
+    private void setRoles(final DirContext authContext, final AuthenticationRequest request,
final String username) throws NamingException {
         final List<String> roles = new ArrayList<String>();
         final SearchControls controls = new SearchControls();
         controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
         controls.setReturningAttributes(new String[] { "cn" });
         final String name = "uid=" + username + ", " + ldapDn;
-        final NamingEnumeration<SearchResult> answer =
-            authContext.search(name, LdapAuthenticationConstants.FILTER, controls);
+        final NamingEnumeration<SearchResult> answer = authContext.search(name, LdapAuthenticationConstants.FILTER,
controls);
         while (answer.hasMore()) {
             final SearchResult result = answer.nextElement();
             final String roleName = (String) result.getAttributes().get("cn").get(0);

Modified: incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizationConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizationConstants.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizationConstants.java
(original)
+++ incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizationConstants.java
Sun Jan 22 07:41:17 2012
@@ -26,8 +26,7 @@ import org.apache.isis.security.ldap.aut
 
 public final class LdapAuthorizationConstants {
 
-    private static final String ROOT = ConfigurationConstants.ROOT + AuthorizationManagerInstaller.TYPE
+ "."
-        + LdapAuthorizationManagerInstaller.NAME + ".";
+    private static final String ROOT = ConfigurationConstants.ROOT + AuthorizationManagerInstaller.TYPE
+ "." + LdapAuthorizationManagerInstaller.NAME + ".";
 
     public static final String SERVER_KEY = ROOT + "server";
     public static final String SERVER_DEFAULT = LdapAuthenticationConstants.SERVER_DEFAULT;

Modified: incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizor.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizor.java
(original)
+++ incubator/isis/trunk/framework/security/ldap/src/main/java/org/apache/isis/security/ldap/authorization/LdapAuthorizor.java
Sun Jan 22 07:41:17 2012
@@ -61,9 +61,7 @@ public class LdapAuthorizor extends Auth
         ldapProvider = getConfiguration().getString(LdapAuthorizationConstants.SERVER_KEY);
         ldapDn = getConfiguration().getString(LdapAuthorizationConstants.LDAPDN_KEY);
         appDn = getConfiguration().getString(LdapAuthorizationConstants.APP_DN_KEY);
-        learn =
-            getConfiguration().getBoolean(LdapAuthorizationConstants.LEARN_KEY,
-                LdapAuthorizationConstants.LEARN_DEFAULT);
+        learn = getConfiguration().getBoolean(LdapAuthorizationConstants.LEARN_KEY, LdapAuthorizationConstants.LEARN_DEFAULT);
     }
 
     // ////////////////////////////////////////////////////////
@@ -130,8 +128,7 @@ public class LdapAuthorizor extends Auth
         }
     }
 
-    private boolean isPermitted(final DirContext authContext, final String role, final Identifier
member,
-        final String flag) throws NamingException {
+    private boolean isPermitted(final DirContext authContext, final String role, final Identifier
member, final String flag) throws NamingException {
         final String cls = member.toIdentityString(Identifier.CLASS);
         final String name = member.toIdentityString(Identifier.MEMBERNAME_ONLY);
         final String parms = member.toIdentityString(Identifier.PARAMETERS_ONLY);
@@ -143,11 +140,13 @@ public class LdapAuthorizor extends Auth
         final NamingEnumeration<SearchResult> answer = authContext.search(searchName,
FILTER, args, controls);
         while (answer.hasMore()) {
             // if we have a class match must be OK
-            // if we have a name match must be OK (parent must be class by definition)
+            // if we have a name match must be OK (parent must be class by
+            // definition)
             // but parm matches need to check that parent = name
             final SearchResult result = answer.nextElement();
             final String cn = (String) result.getAttributes().get("cn").get(0);
-            // result.getname gives relative path from class - so if contains 'name' it is
parent of parms
+            // result.getname gives relative path from class - so if contains
+            // 'name' it is parent of parms
             // entry
             if (cn.equals(cls) || cn.equals(name) || ((cn.equals(parms) && result.getName().contains(name))))
{
                 // last check if there is a flag attribute
@@ -201,8 +200,7 @@ public class LdapAuthorizor extends Auth
         return bindName.toString();
     }
 
-    private void bindClass(final DirContext authContext, final String role, final Identifier
member)
-        throws NamingException {
+    private void bindClass(final DirContext authContext, final String role, final Identifier
member) throws NamingException {
         final String cls = member.toIdentityString(Identifier.CLASS);
         final Attributes attrs = createCommonAttributes(cls, role, true);
         try {
@@ -221,8 +219,7 @@ public class LdapAuthorizor extends Auth
         return bindName.toString();
     }
 
-    private void bindName(final DirContext authContext, final String role, final Identifier
member)
-        throws NamingException {
+    private void bindName(final DirContext authContext, final String role, final Identifier
member) throws NamingException {
         final String cls = member.toIdentityString(Identifier.CLASS);
         final String name = member.toIdentityString(Identifier.MEMBERNAME_ONLY);
         final Attributes attrs = createCommonAttributes(name, role, false);
@@ -242,8 +239,7 @@ public class LdapAuthorizor extends Auth
         return bindName.toString();
     }
 
-    private void bindParms(final DirContext authContext, final String role, final Identifier
member)
-        throws NamingException {
+    private void bindParms(final DirContext authContext, final String role, final Identifier
member) throws NamingException {
         final String cls = member.toIdentityString(Identifier.CLASS);
         final String name = member.toIdentityString(Identifier.MEMBERNAME_ONLY);
         // have to escape any commas in parms string or ldap parser is not happy
@@ -261,8 +257,7 @@ public class LdapAuthorizor extends Auth
         }
     }
 
-    private boolean bindNames(final DirContext authContext, final String role, final Identifier
member)
-        throws NamingException {
+    private boolean bindNames(final DirContext authContext, final String role, final Identifier
member) throws NamingException {
         bindClass(authContext, role, member);
         bindName(authContext, role, member);
         bindParms(authContext, role, member);

Modified: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
(original)
+++ incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
Sun Jan 22 07:41:17 2012
@@ -24,7 +24,6 @@ import java.util.List;
 
 import org.apache.isis.applib.ApplicationException;
 import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.factory.InstanceUtil;
 import org.apache.isis.core.runtime.authentication.standard.Authenticator;
 import org.apache.isis.runtimes.dflt.runtime.authentication.AuthenticationManagerStandardInstallerAbstractForDfltRuntime;
 
@@ -40,31 +39,30 @@ public class SqlAuthenticationManagerIns
 
     @Override
     protected List<Authenticator> createAuthenticators(final IsisConfiguration configuration)
{
-        return Lists.<Authenticator>newArrayList(createAuthenticator(configuration));
+        return Lists.<Authenticator> newArrayList(createAuthenticator(configuration));
     }
 
     protected Authenticator createAuthenticator(final IsisConfiguration configuration) {
-        String className = configuration.getString("isis.authentication.authenticator");
+        final String className = configuration.getString("isis.authentication.authenticator");
         if (className == null) {
             return new SqlAuthenticator(configuration);
-        } 
+        }
         try {
-            Class<?> authenticatorClass = Class.forName(className);
-            return (Authenticator) authenticatorClass.getConstructor(IsisConfiguration.class).newInstance(
-                configuration);
-        } catch (ClassNotFoundException e) {
+            final Class<?> authenticatorClass = Class.forName(className);
+            return (Authenticator) authenticatorClass.getConstructor(IsisConfiguration.class).newInstance(configuration);
+        } catch (final ClassNotFoundException e) {
             throw new ApplicationException("Unable to find authenticator class", e);
-        } catch (IllegalArgumentException e) {
+        } catch (final IllegalArgumentException e) {
             throw new ApplicationException("IllegalArgumentException creating authenticator
class", e);
-        } catch (SecurityException e) {
+        } catch (final SecurityException e) {
             throw new ApplicationException("SecurityException creating authenticator class",
e);
-        } catch (InstantiationException e) {
+        } catch (final InstantiationException e) {
             throw new ApplicationException("InstantiationException creating authenticator
class", e);
-        } catch (IllegalAccessException e) {
+        } catch (final IllegalAccessException e) {
             throw new ApplicationException("IllegalAccessException creating authenticator
class", e);
-        } catch (InvocationTargetException e) {
+        } catch (final InvocationTargetException e) {
             throw new ApplicationException("InvocationTargetException creating authenticator
class", e);
-        } catch (NoSuchMethodException e) {
+        } catch (final NoSuchMethodException e) {
             throw new ApplicationException("NoSuchMethodException creating authenticator
class", e);
         }
     }

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=1234458&r1=1234457&r2=1234458&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
Sun Jan 22 07:41:17 2012
@@ -29,11 +29,6 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.StringTokenizer;
 
-import com.google.common.base.Strings;
-import com.google.inject.Inject;
-
-import org.apache.log4j.Logger;
-
 import org.apache.isis.applib.ApplicationException;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.ensure.Assert;
@@ -41,6 +36,10 @@ import org.apache.isis.core.runtime.auth
 import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
 import org.apache.isis.core.runtime.authentication.standard.PasswordRequestAuthenticatorAbstract;
 import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.log4j.Logger;
+
+import com.google.common.base.Strings;
+import com.google.inject.Inject;
 
 public class SqlAuthenticator extends PasswordRequestAuthenticatorAbstract {
     private static final Logger LOG = Logger.getLogger(SqlAuthenticator.class);
@@ -52,7 +51,7 @@ public class SqlAuthenticator extends Pa
     }
 
     // Override this method if dbPasswords are encoded.
-    protected boolean verifyPasswordsAreEqual(String loginPassword, String dbPassword) {
+    protected boolean verifyPasswordsAreEqual(final String loginPassword, final String dbPassword)
{
         return dbPassword.equals(loginPassword);
     }
 
@@ -65,10 +64,10 @@ public class SqlAuthenticator extends Pa
     protected String getRoles(final ResultSet results, final String roles) {
         try {
             if (userRoleField != null) {
-                String dbRoles = results.getString(userRoleField);
+                final String dbRoles = results.getString(userRoleField);
                 return roles + "|" + dbRoles;
             }
-        } catch (SQLException e) {
+        } catch (final SQLException e) {
             LOG.warn("Error fetching role", e);
         }
         return roles;
@@ -201,10 +200,9 @@ public class SqlAuthenticator extends Pa
     }
 
     private boolean isPasswordValidForUser(final AuthenticationRequest request, final String
user, final String password) {
-        ResultSet results = loadUserDetails(user, password);
+        final ResultSet results = loadUserDetails(user, password);
         if (results != null) {
-            final String roles =
-                getRoles(results, "org.apache.isis.viewer.wicket.roles.USER|org.starobjects.wicket.roles.USER");
+            final String roles = getRoles(results, "org.apache.isis.viewer.wicket.roles.USER|org.starobjects.wicket.roles.USER");
             setRoles(request, roles);
 
             return true;
@@ -213,17 +211,17 @@ public class SqlAuthenticator extends Pa
     }
 
     protected ResultSet loadUserDetails(final String user, final String password) {
-        String sql = "SELECT * FROM " + userTable + " WHERE UPPER(" + userNameField + ")
= ?";
+        final String sql = "SELECT * FROM " + userTable + " WHERE UPPER(" + userNameField
+ ") = ?";
         addToQueryValues(user.toUpperCase());
-        ResultSet results = select(sql);
+        final ResultSet results = select(sql);
         try {
             while (results.next()) {
-                String dbPassword = results.getString(passwordField);
+                final String dbPassword = results.getString(passwordField);
                 if (verifyPasswordsAreEqual(password, dbPassword)) {
                     return postProcessLogin(user, password, results);
                 }
             }
-        } catch (SQLException e) {
+        } catch (final SQLException e) {
             LOG.error("Error loading user details: " + sql);
             throw new ApplicationException("Error loading user details", e);
         }
@@ -245,7 +243,7 @@ public class SqlAuthenticator extends Pa
     }
 
     // {{ JDBC Connection SQL helpers
-    protected int update(String sql) {
+    protected int update(final String sql) {
         LOG.debug("SQL: " + sql);
         PreparedStatement statement;
         try {
@@ -263,7 +261,7 @@ public class SqlAuthenticator extends Pa
 
     }
 
-    private ResultSet select(String sql) {
+    private ResultSet select(final String sql) {
         LOG.debug("SQL: " + sql);
         PreparedStatement statement;
         try {
@@ -298,8 +296,7 @@ public class SqlAuthenticator extends Pa
                     i++;
                 }
             } catch (final SQLException e) {
-                LOG.error("Error adding prepared value " + i + " of type "
-                    + queryValues.get(i - 1).getClass().getSimpleName(), e);
+                LOG.error("Error adding prepared value " + i + " of type " + queryValues.get(i
- 1).getClass().getSimpleName(), e);
                 throw e;
             }
         }

Modified: incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java?rev=1234458&r1=1234457&r2=1234458&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
(original)
+++ incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
Sun Jan 22 07:41:17 2012
@@ -21,15 +21,14 @@ package org.apache.isis.security.sql.aut
 
 import java.util.Properties;
 
+import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
-import org.apache.isis.core.commons.config.IsisConfigurationDefault;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
-import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
-
 public class SqlAuthenticatorTest {
     IsisConfigurationDefault configuration;
     SqlAuthenticator saipSqlAuthenticator;
@@ -47,8 +46,7 @@ public class SqlAuthenticatorTest {
         properties.setProperty(SqlAuthenticator.USER_TABLE_PASSWORD_FIELD, PASSWORD_FIELD);
 
         properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.driver", "org.hsqldb.jdbcDriver");
-        properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.connection",
-            "jdbc:hsqldb:file:hsql-db/authenticator-tests");
+        properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.connection", "jdbc:hsqldb:file:hsql-db/authenticator-tests");
         properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.user", "sa");
         properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.password", "");
 
@@ -80,31 +78,31 @@ public class SqlAuthenticatorTest {
 
     @Test
     public void VerifyThatIsValidReturnsTrue() {
-        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password1");
+        final AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password1");
         Assert.assertTrue(saipSqlAuthenticator.isValid(request));
     }
 
     @Test
     public void VerifyThatIsValidReturnsTrueInMixedCase() {
-        AuthenticationRequestPassword request = new AuthenticationRequestPassword("uSer1",
"password1");
+        final AuthenticationRequestPassword request = new AuthenticationRequestPassword("uSer1",
"password1");
         Assert.assertTrue(saipSqlAuthenticator.isValid(request));
     }
 
     @Test
     public void VerifyThatIsValidReturnsFalseForNoPassword() {
-        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"");
+        final AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"");
         Assert.assertFalse(saipSqlAuthenticator.isValid(request));
     }
 
     @Test
     public void VerifyThatIsValidReturnsFalseForWrongPassword() {
-        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password12");
+        final AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password12");
         Assert.assertFalse(saipSqlAuthenticator.isValid(request));
     }
 
     @Test
     public void VerifyThatIsValidReturnsFalseForWrongUsername() {
-        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user",
"password1");
+        final AuthenticationRequestPassword request = new AuthenticationRequestPassword("user",
"password1");
         Assert.assertFalse(saipSqlAuthenticator.isValid(request));
     }
 



Mime
View raw message