incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ke...@apache.org
Subject svn commit: r1143484 - in /incubator/isis/trunk/framework/security: ./ dflt/src/site/ dflt/src/site/apt/ file/src/site/ file/src/site/apt/ ldap/src/site/ ldap/src/site/apt/ sql/ sql/src/ sql/src/apt/ sql/src/main/ sql/src/main/java/ sql/src/main/java/o...
Date Wed, 06 Jul 2011 16:15:17 GMT
Author: kevin
Date: Wed Jul  6 16:15:16 2011
New Revision: 1143484

URL: http://svn.apache.org/viewvc?rev=1143484&view=rev
Log:
Added sql authentication basics, and updated documentation of other security classes to reference
it.

Added:
    incubator/isis/trunk/framework/security/sql/
    incubator/isis/trunk/framework/security/sql/NOTICE   (with props)
    incubator/isis/trunk/framework/security/sql/pom.xml   (with props)
    incubator/isis/trunk/framework/security/sql/src/
    incubator/isis/trunk/framework/security/sql/src/apt/
    incubator/isis/trunk/framework/security/sql/src/apt/index.apt   (with props)
    incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt   (with props)
    incubator/isis/trunk/framework/security/sql/src/main/
    incubator/isis/trunk/framework/security/sql/src/main/java/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java
  (with props)
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
  (with props)
    incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
  (with props)
    incubator/isis/trunk/framework/security/sql/src/site.xml   (with props)
    incubator/isis/trunk/framework/security/sql/src/test/
    incubator/isis/trunk/framework/security/sql/src/test/java/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/
    incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
  (with props)
Modified:
    incubator/isis/trunk/framework/security/dflt/src/site/apt/index.apt
    incubator/isis/trunk/framework/security/dflt/src/site/site.xml
    incubator/isis/trunk/framework/security/file/src/site/apt/index.apt
    incubator/isis/trunk/framework/security/file/src/site/site.xml
    incubator/isis/trunk/framework/security/ldap/src/site/apt/index.apt
    incubator/isis/trunk/framework/security/ldap/src/site/site.xml
    incubator/isis/trunk/framework/security/pom.xml

Modified: incubator/isis/trunk/framework/security/dflt/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/dflt/src/site/apt/index.apt?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/dflt/src/site/apt/index.apt (original)
+++ incubator/isis/trunk/framework/security/dflt/src/site/apt/index.apt Wed Jul  6 16:15:16
2011
@@ -36,5 +36,7 @@ Alternatives
 
   * the {{{../ldap/index.html}LDAP}} security
 
+  * the {{{../sql/index.html}SQL}} security (reading from simple SQL tables)
+
   []
- 
\ No newline at end of file
+ 

Modified: incubator/isis/trunk/framework/security/dflt/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/dflt/src/site/site.xml?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/dflt/src/site/site.xml (original)
+++ incubator/isis/trunk/framework/security/dflt/src/site/site.xml Wed Jul  6 16:15:16 2011
@@ -17,24 +17,25 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project>
-
-	<body>
-		<breadcrumbs>
-			<item name="Default"  href="index.html"/>
-		</breadcrumbs>
-
-		<menu name="Default Security">
-			<item name="About" href="index.html" />
-            <item name="Jottings" href="jottings.html" />
-		</menu>
-
-        <menu name="Security Modules">
-            <item name="Default (No-op)" href="../dflt/index.html" />
-            <item name="File" href="../file/index.html" />
-            <item name="LDAP" href="../ldap/index.html" />
-        </menu>
-
-		<menu name="Maven Reports" ref="reports"/>
-	</body>
-</project>
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="Default"  href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="Default Security">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Security Modules">
+            <item name="Default (No-op)" href="../dflt/index.html" />
+            <item name="File" href="../file/index.html" />
+            <item name="LDAP" href="../ldap/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+        </menu>
+
+		<menu name="Maven Reports" ref="reports"/>
+	</body>
+</project>

Modified: incubator/isis/trunk/framework/security/file/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/site/apt/index.apt?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/site/apt/index.apt (original)
+++ incubator/isis/trunk/framework/security/file/src/site/apt/index.apt Wed Jul  6 16:15:16
2011
@@ -37,5 +37,7 @@ Alternatives
 
   * the {{{../ldap/index.html}LDAP}} security
 
+  * the {{{../sql/index.html}SQL}} security (reading from simple SQL tables)
+
   []
- 
\ No newline at end of file
+ 

Modified: incubator/isis/trunk/framework/security/file/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/file/src/site/site.xml?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/file/src/site/site.xml (original)
+++ incubator/isis/trunk/framework/security/file/src/site/site.xml Wed Jul  6 16:15:16 2011
@@ -17,24 +17,25 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project>
-
-	<body>
-		<breadcrumbs>
-			<item name="File" href="index.html"/>
-		</breadcrumbs>
-
-		<menu name="File Security">
-			<item name="About" href="index.html" />
-            <item name="Jottings" href="jottings.html" />
-		</menu>
-
-        <menu name="Security Modules">
-            <item name="Default (No-op)" href="../dflt/index.html" />
-            <item name="File" href="../file/index.html" />
-            <item name="LDAP" href="../ldap/index.html" />
-        </menu>
-
-        <menu name="Maven Reports" ref="reports" />
-	</body>
-</project>
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="File" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="File Security">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Security Modules">
+            <item name="Default (No-op)" href="../dflt/index.html" />
+            <item name="File" href="../file/index.html" />
+            <item name="LDAP" href="../ldap/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

Modified: incubator/isis/trunk/framework/security/ldap/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/site/apt/index.apt?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/site/apt/index.apt (original)
+++ incubator/isis/trunk/framework/security/ldap/src/site/apt/index.apt Wed Jul  6 16:15:16
2011
@@ -35,5 +35,7 @@ Alternatives
 
   * the {{{../file/index.html}file-based}} security (reading from simple flat files)
 
+  * the {{{../sql/index.html}SQL}} security (reading from simple SQL tables)
+
   []
-  
\ No newline at end of file
+  

Modified: incubator/isis/trunk/framework/security/ldap/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/ldap/src/site/site.xml?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/ldap/src/site/site.xml (original)
+++ incubator/isis/trunk/framework/security/ldap/src/site/site.xml Wed Jul  6 16:15:16 2011
@@ -17,24 +17,25 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<project>
-
-	<body>
-		<breadcrumbs>
-			<item name="LDAP" href="index.html"/>
-		</breadcrumbs>
-
-		<menu name="LDAP Security">
-			<item name="About" href="index.html" />
-            <item name="Jottings" href="jottings.html" />
-		</menu>
-
-        <menu name="Security Modules">
-            <item name="Default (No-op)" href="../dflt/index.html" />
-            <item name="File" href="../file/index.html" />
-            <item name="LDAP" href="../ldap/index.html" />
-        </menu>
-
-        <menu name="Maven Reports" ref="reports" />
-	</body>
-</project>
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="LDAP" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="LDAP Security">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Security Modules">
+            <item name="Default (No-op)" href="../dflt/index.html" />
+            <item name="File" href="../file/index.html" />
+            <item name="LDAP" href="../ldap/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

Modified: incubator/isis/trunk/framework/security/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/pom.xml?rev=1143484&r1=1143483&r2=1143484&view=diff
==============================================================================
--- incubator/isis/trunk/framework/security/pom.xml (original)
+++ incubator/isis/trunk/framework/security/pom.xml Wed Jul  6 16:15:16 2011
@@ -63,6 +63,7 @@
 		<module>dflt</module>
         <module>file</module>
         <module>ldap</module>
+        <module>sql</module>
 	</modules>
 
 	<reporting>
@@ -134,6 +135,18 @@
                 <type>test-jar</type>
             </dependency>
 
+            <dependency>
+                <groupId>org.apache.isis.security</groupId>
+                <artifactId>sql</artifactId>
+                <version>0.1.2-incubating-SNAPSHOT</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.isis.security</groupId>
+                <artifactId>sql</artifactId>
+                <version>0.1.2-incubating-SNAPSHOT</version>
+                <type>test-jar</type>
+            </dependency>
+
 		</dependencies>
 	</dependencyManagement>
 

Added: incubator/isis/trunk/framework/security/sql/NOTICE
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/NOTICE?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/NOTICE (added)
+++ incubator/isis/trunk/framework/security/sql/NOTICE Wed Jul  6 16:15:16 2011
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Propchange: incubator/isis/trunk/framework/security/sql/NOTICE
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/isis/trunk/framework/security/sql/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/pom.xml?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/pom.xml (added)
+++ incubator/isis/trunk/framework/security/sql/pom.xml Wed Jul  6 16:15:16 2011
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.isis</groupId>
+		<artifactId>security</artifactId>
+		<version>0.1.2-incubating-SNAPSHOT</version>
+	</parent>
+
+	<groupId>org.apache.isis.security</groupId>
+	<artifactId>sql</artifactId>
+	<version>0.1.2-incubating-SNAPSHOT</version>
+
+	<name>SQL Security Implementation</name>
+
+	<properties>
+        <siteBaseDir>../..</siteBaseDir>
+		<relativeUrl>security/sql/</relativeUrl>
+	</properties>
+
+    <!-- used in Site generation for relative references. -->
+    <url>http://incubator.apache.org/isis/${relativeUrl}</url>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-project-info-reports-plugin</artifactId>
+				<version>${maven-project-info-reports-plugin}</version>
+                <inherited>false</inherited>
+                <configuration>
+                	<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+                </configuration>
+                <reportSets>
+                    <reportSet>
+                        <inherited>false</inherited>
+                        <reports>
+                            <report>dependencies</report>
+                            <report>dependency-convergence</report>
+                            <report>plugins</report>
+                            <report>summary</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+        </plugins>
+    </reporting>
+
+    <dependencyManagement>
+        <dependencies>
+			<dependency>
+				<groupId>org.hsqldb</groupId>
+				<artifactId>hsqldb</artifactId>
+				<version>1.8.0.10</version>
+				<scope>test</scope>
+			</dependency>
+
+            <!-- TODO: remove this dependency -->
+            <dependency>
+                <groupId>org.apache.isis.runtimes</groupId>
+                <artifactId>dflt</artifactId>
+                <version>0.1.2-incubating-SNAPSHOT</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.hsqldb</groupId>
+			<artifactId>hsqldb</artifactId>
+			<scope>test</scope>
+		</dependency>
+		
+        <!-- TODO: move this dependency to core -->
+		<dependency>
+		    <groupId>org.apache.isis.runtimes.dflt</groupId>
+		    <artifactId>runtime</artifactId>
+		</dependency>
+        <!-- TODO: move this dependency to core -->
+		<dependency>
+		    <groupId>org.apache.isis.runtimes.dflt</groupId>
+		    <artifactId>runtime</artifactId>
+		    <type>test-jar</type>
+		    <scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

Propchange: incubator/isis/trunk/framework/security/sql/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/isis/trunk/framework/security/sql/src/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/apt/index.apt?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/apt/index.apt (added)
+++ incubator/isis/trunk/framework/security/sql/src/apt/index.apt Wed Jul  6 16:15:16 2011
@@ -0,0 +1,43 @@
+~~  Licensed to the Apache Software Foundation (ASF) under one
+~~  or more contributor license agreements.  See the NOTICE file
+~~  distributed with this work for additional information
+~~  regarding copyright ownership.  The ASF licenses this file
+~~  to you 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.
+
+
+
+Security SQL Implementation
+ 
+ The <SQL security> module is a simple implementation of Isis' authentication and
+ authorization APIs, that uses flat SQL tables to store user/passwords/roles (for authentication)
+ and role-based permissions (for authorization).
+ 
+ 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.
+ 
+ 
+Alternatives
+
+  Alternatives include:
+  
+  * the {{{../dflt/index.html}default}} (no-op) security implementation, for prototyping
use only
+
+  * the {{{../file/index.html}file}} security
+
+  * the {{{../ldap/index.html}LDAP}} security
+
+  []
+ 

Propchange: incubator/isis/trunk/framework/security/sql/src/apt/index.apt
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt (added)
+++ incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt Wed Jul  6 16:15:16 2011
@@ -0,0 +1,24 @@
+~~  Licensed to the Apache Software Foundation (ASF) under one
+~~  or more contributor license agreements.  See the NOTICE file
+~~  distributed with this work for additional information
+~~  regarding copyright ownership.  The ASF licenses this file
+~~  to you 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.
+
+
+
+Jottings
+ 
+  This page is to capture any random jottings relating to this module prior 
+  to being moved into formal documentation. 
+ 

Propchange: incubator/isis/trunk/framework/security/sql/src/apt/jottings.apt
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java
(added)
+++ incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java
Wed Jul  6 16:15:16 2011
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.isis.security.sql.authentication;
+
+public class SqlAuthenticationConstants {
+
+    private SqlAuthenticationConstants() {
+    }
+
+}

Propchange: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationConstants.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
(added)
+++ incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
Wed Jul  6 16:15:16 2011
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.isis.security.sql.authentication;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.isis.applib.ApplicationException;
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.runtime.authentication.standard.Authenticator;
+import org.apache.isis.runtimes.dflt.runtime.authentication.AuthenticationManagerStandardInstallerAbstractForDfltRuntime;
+
+public class SqlAuthenticationManagerInstaller extends AuthenticationManagerStandardInstallerAbstractForDfltRuntime
{
+
+    public static final String NAME = "sql";
+
+    public SqlAuthenticationManagerInstaller() {
+        super(NAME);
+    }
+
+    @Override
+    protected Authenticator createAuthenticator(final IsisConfiguration configuration) {
+        String className = configuration.getString("isis.authentication.authenticator");
+        if (className == null) {
+            return new SqlAuthenticator(configuration);
+        } else {
+            try {
+                Class<?> authenticatorClass = Class.forName(className);
+                return (Authenticator) authenticatorClass.getConstructor(IsisConfiguration.class).newInstance(
+                    configuration);
+            } catch (ClassNotFoundException e) {
+                throw new ApplicationException("Unable to find authenticator class", e);
+            } catch (IllegalArgumentException e) {
+                throw new ApplicationException("IllegalArgumentException creating authenticator
class", e);
+            } catch (SecurityException e) {
+                throw new ApplicationException("SecurityException creating authenticator
class", e);
+            } catch (InstantiationException e) {
+                throw new ApplicationException("InstantiationException creating authenticator
class", e);
+            } catch (IllegalAccessException e) {
+                throw new ApplicationException("IllegalAccessException creating authenticator
class", e);
+            } catch (InvocationTargetException e) {
+                throw new ApplicationException("InvocationTargetException creating authenticator
class", e);
+            } catch (NoSuchMethodException e) {
+                throw new ApplicationException("NoSuchMethodException creating authenticator
class", e);
+            }
+        }
+    }
+
+}

Propchange: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticationManagerInstaller.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
(added)
+++ incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
Wed Jul  6 16:15:16 2011
@@ -0,0 +1,322 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.isis.security.sql.authentication;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+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;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+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;
+
+public class SqlAuthenticator extends PasswordRequestAuthenticatorAbstract {
+    private static final Logger LOG = Logger.getLogger(SqlAuthenticator.class);
+
+    static SqlAuthenticator instance;
+
+    public static SqlAuthenticator getInstance() {
+        return instance;
+    }
+
+    // Override this method
+    protected ResultSet postProcessLogin(final String user, final String password, final
ResultSet results) {
+        return results;
+    }
+
+    // override this method
+    protected String getRoles(final ResultSet results, final String roles) {
+        try {
+            if (userRoleField != null) {
+                String dbRoles = results.getString(userRoleField);
+                return roles + "|" + dbRoles;
+            }
+        } catch (SQLException e) {
+            LOG.warn("Error fetching role", e);
+        }
+        return roles;
+    }
+
+    // Override this method, if you want to create data.
+    public void initialise() {
+    }
+
+    static final String PROPERTY_BASE = "isis.authentication.sql";
+    static final String USER_TABLE = PROPERTY_BASE + ".userTable";
+    static final String USER_TABLE_NAME_FIELD = PROPERTY_BASE + ".userNameField";
+    static final String USER_TABLE_PASSWORD_FIELD = PROPERTY_BASE + ".passwordField";
+    static final String USER_TABLE_ROLE_FIELD = PROPERTY_BASE + ".roleField";
+
+    private Connection connection;
+
+    final String passwordField;
+    final String userTable;
+    final String userNameField;
+    final String userRoleField;
+
+    public static String getPropertyBase() {
+        return PROPERTY_BASE;
+    }
+
+    public static String getPropertyUserTable() {
+        return USER_TABLE;
+    }
+
+    public static String getPropertyUserTableNameField() {
+        return USER_TABLE_NAME_FIELD;
+    }
+
+    public static String getPropertyUserTablePasswordField() {
+        return USER_TABLE_PASSWORD_FIELD;
+    }
+
+    public static String getPropertyUserTableRoleField() {
+        return USER_TABLE_ROLE_FIELD;
+    }
+
+    @Inject
+    public SqlAuthenticator(final IsisConfiguration configuration) {
+        super(configuration);
+
+        userTable = configuration.getString(USER_TABLE);
+        userNameField = configuration.getString(USER_TABLE_NAME_FIELD);
+        passwordField = configuration.getString(USER_TABLE_PASSWORD_FIELD);
+        userRoleField = configuration.getString(USER_TABLE_ROLE_FIELD);
+
+        instance = this;
+    }
+
+    @Override
+    public void init() {
+        if (connection != null) {
+            LOG.info("close");
+        }
+
+        final String BASE = PROPERTY_BASE + ".jdbc.";
+        final IsisConfiguration params = IsisContext.getConfiguration().getProperties(BASE);
+
+        try {
+            final String driver = params.getString(BASE + "driver");
+            final String url = params.getString(BASE + "connection");
+            final String user = params.getString(BASE + "user");
+            final String password = params.getString(BASE + "password");
+
+            if (connection != null) {
+                throw new ApplicationException("Connection already established");
+            }
+
+            if (driver == null) {
+                throw new ApplicationException("No driver specified for database connection");
+            }
+            if (url == null) {
+                throw new ApplicationException("No connection URL specified to database");
+            }
+            if (user == null) {
+                throw new ApplicationException("No user specified for database connection");
+            }
+            if (password == null) {
+                throw new ApplicationException("No password specified for database connection");
+            }
+
+            Class.forName(driver);
+            LOG.info("Connecting to " + url + " as " + user);
+            connection = DriverManager.getConnection(url, user, password);
+            if (connection == null) {
+                throw new ApplicationException("No connection established to " + url);
+            }
+        } catch (final SQLException e) {
+            throw new ApplicationException("Failed to start", e);
+        } catch (final ClassNotFoundException e) {
+            throw new ApplicationException("Could not find database driver", e);
+        }
+
+    }
+
+    @Override
+    public void shutdown() {
+        String sql;
+        sql = "SHUTDOWN";
+        update(sql);
+        closeConnection();
+    }
+
+    private void closeConnection() {
+        try {
+            connection.close();
+            connection = null;
+        } catch (final SQLException e) {
+            LOG.warn("Failed to close connection:" + e);
+        }
+    }
+
+    @Override
+    public final boolean isValid(final AuthenticationRequest request) {
+        final AuthenticationRequestPassword passwordRequest = (AuthenticationRequestPassword)
request;
+        final String username = passwordRequest.getName();
+        if (Strings.isNullOrEmpty(username)) {
+            return false;
+        }
+        final String password = passwordRequest.getPassword();
+        Assert.assertNotNull(password);
+
+        return isPasswordValidForUser(passwordRequest, username, password);
+
+    }
+
+    private boolean isPasswordValidForUser(final AuthenticationRequest request, final String
user, final String password) {
+        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");
+            setRoles(request, roles);
+
+            return true;
+        }
+        return false;
+    }
+
+    protected ResultSet loadUserDetails(final String user, final String password) {
+        String sql = "SELECT * FROM " + userTable + " WHERE UPPER(" + userNameField + ")
= ?";
+        addToQueryValues(user.toUpperCase());
+        ResultSet results = select(sql);
+        try {
+            while (results.next()) {
+                String dbPassword = results.getString(passwordField);
+                if (dbPassword.equals(password)) {
+                    return postProcessLogin(user, password, results);
+                }
+            }
+        } catch (SQLException e) {
+            LOG.error("Error loading user details: " + sql);
+            throw new ApplicationException("Error loading user details", e);
+        }
+
+        return null;
+    }
+
+    private final void setRoles(final AuthenticationRequest request, final String line) {
+        final StringTokenizer tokens = new StringTokenizer(line, "|", false);
+        final String[] roles = new String[tokens.countTokens()];
+        for (int i = 0; tokens.hasMoreTokens(); i++) {
+            roles[i] = tokens.nextToken();
+        }
+        request.setRoles(Arrays.asList(roles));
+    }
+
+    public boolean isSetup() {
+        return hasTable(userTable);
+    }
+
+    // {{ JDBC Connection SQL helpers
+    protected int update(String sql) {
+        LOG.debug("SQL: " + sql);
+        PreparedStatement statement;
+        try {
+            statement = connection.prepareStatement(sql);
+            addPreparedValues(statement);
+            final int updateCount = statement.executeUpdate();
+            statement.close();
+            return updateCount;
+        } catch (final SQLException e) {
+            LOG.error("failed to execute " + sql, e);
+            throw new ApplicationException("Error executing update", e);
+        } finally {
+            clearPreparedValues();
+        }
+
+    }
+
+    private ResultSet select(String sql) {
+        LOG.debug("SQL: " + sql);
+        PreparedStatement statement;
+        try {
+            statement = connection.prepareStatement(sql);
+            addPreparedValues(statement);
+            return (statement.executeQuery());
+        } catch (final SQLException e) {
+            LOG.error("failed to execte select: " + sql, e);
+            throw new ApplicationException("Error executing select", e);
+        } finally {
+            clearPreparedValues();
+        }
+    }
+
+    private final List<Object> queryValues = new ArrayList<Object>();
+
+    public String addToQueryValues(final Object o) {
+        queryValues.add(o);
+        return "?";
+    }
+
+    private void clearPreparedValues() {
+        queryValues.clear();
+    }
+
+    private void addPreparedValues(final PreparedStatement statement) throws SQLException
{
+        if (queryValues.size() > 0) {
+            int i = 1;
+            try {
+                for (final Object value : queryValues) {
+                    statement.setObject(i, value);
+                    i++;
+                }
+            } catch (final SQLException e) {
+                LOG.error("Error adding prepared value " + i + " of type "
+                    + queryValues.get(i - 1).getClass().getSimpleName(), e);
+                throw e;
+            }
+        }
+    }
+
+    private boolean hasTable(final String tableName) {
+        try {
+            final ResultSet set = connection.getMetaData().getTables(null, null, tableName,
null);
+            if (set.next()) {
+                LOG.debug("Found " + set.getString("TABLE_NAME"));
+                set.close();
+                return true;
+            } else {
+                set.close();
+                return false;
+            }
+        } catch (final SQLException e) {
+            LOG.error("failed to find table: " + tableName, e);
+            throw new ApplicationException("Error checking for table: " + tableName, e);
+        }
+    }
+
+    // }}
+
+}

Propchange: incubator/isis/trunk/framework/security/sql/src/main/java/org/apache/isis/security/sql/authentication/SqlAuthenticator.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/isis/trunk/framework/security/sql/src/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/security/sql/src/site.xml?rev=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/site.xml (added)
+++ incubator/isis/trunk/framework/security/sql/src/site.xml Wed Jul  6 16:15:16 2011
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.
+-->
+<project>
+
+	<body>
+		<breadcrumbs>
+			<item name="SQL" href="index.html"/>
+		</breadcrumbs>
+
+		<menu name="SQL Security">
+			<item name="About" href="index.html" />
+            <item name="Jottings" href="jottings.html" />
+		</menu>
+
+        <menu name="Security Modules">
+            <item name="Default (No-op)" href="../dflt/index.html" />
+            <item name="File" href="../file/index.html" />
+            <item name="LDAP" href="../ldap/index.html" />
+            <item name="SQL" href="../sql/index.html" />
+        </menu>
+
+        <menu name="Maven Reports" ref="reports" />
+	</body>
+</project>

Propchange: incubator/isis/trunk/framework/security/sql/src/site.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: 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=1143484&view=auto
==============================================================================
--- incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
(added)
+++ incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
Wed Jul  6 16:15:16 2011
@@ -0,0 +1,96 @@
+package org.apache.isis.security.sql.authentication;
+
+import java.util.Properties;
+
+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;
+
+    private static final String PASSWORD_FIELD = "password";
+    private static final String USERNAME_FIELD = "email";
+    private static final String USERS = "USERS";
+
+    @Before
+    public void setUp() {
+        // Setup properties files
+        final Properties properties = new Properties();
+        properties.setProperty(SqlAuthenticator.USER_TABLE, USERS);
+        properties.setProperty(SqlAuthenticator.USER_TABLE_NAME_FIELD, USERNAME_FIELD);
+        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.user", "sa");
+        properties.put(SqlAuthenticator.PROPERTY_BASE + ".jdbc.password", "");
+
+        configuration = new IsisConfigurationDefault();
+        configuration.add(properties);
+
+        // setup configuration
+        IsisContext.setConfiguration(configuration);
+
+        // Setup database
+        String sql;
+
+        saipSqlAuthenticator = new SqlAuthenticator(configuration);
+        saipSqlAuthenticator.init();
+
+        if (saipSqlAuthenticator.isSetup()) { // clear existing data
+            sql = "DROP TABLE " + USERS;
+            saipSqlAuthenticator.update(sql);
+        }
+
+        sql = "CREATE TABLE " + USERS + " (" + USERNAME_FIELD + " VARCHAR(32), " + PASSWORD_FIELD
+ " VARCHAR(32)) ";
+        saipSqlAuthenticator.update(sql);
+
+        // create data
+        sql = "INSERT INTO " + USERS + " VALUES ('user1','password1')";
+        saipSqlAuthenticator.update(sql);
+
+    }
+
+    @Test
+    public void VerifyThatIsValidReturnsTrue() {
+        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password1");
+        Assert.assertTrue(saipSqlAuthenticator.isValid(request));
+    }
+
+    @Test
+    public void VerifyThatIsValidReturnsTrueInMixedCase() {
+        AuthenticationRequestPassword request = new AuthenticationRequestPassword("uSer1",
"password1");
+        Assert.assertTrue(saipSqlAuthenticator.isValid(request));
+    }
+
+    @Test
+    public void VerifyThatIsValidReturnsFalseForNoPassword() {
+        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"");
+        Assert.assertFalse(saipSqlAuthenticator.isValid(request));
+    }
+
+    @Test
+    public void VerifyThatIsValidReturnsFalseForWrongPassword() {
+        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user1",
"password12");
+        Assert.assertFalse(saipSqlAuthenticator.isValid(request));
+    }
+
+    @Test
+    public void VerifyThatIsValidReturnsFalseForWrongUsername() {
+        AuthenticationRequestPassword request = new AuthenticationRequestPassword("user",
"password1");
+        Assert.assertFalse(saipSqlAuthenticator.isValid(request));
+    }
+
+    @After
+    public void tearDown() {
+        saipSqlAuthenticator.shutdown();
+    }
+}

Propchange: incubator/isis/trunk/framework/security/sql/src/test/java/org/apache/isis/security/sql/authentication/SqlAuthenticatorTest.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message