roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r695329 [1/3] - in /roller/trunk: ./ apps/weblogger/ apps/weblogger/nbproject/ apps/weblogger/src/java/META-INF/ apps/weblogger/src/java/org/apache/roller/weblogger/business/ apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/...
Date Mon, 15 Sep 2008 02:49:18 GMT
Author: snoopdave
Date: Sun Sep 14 19:49:10 2008
New Revision: 695329

URL: http://svn.apache.org/viewvc?rev=695329&view=rev
Log:
OpenID implementation, as described in this proposal:
   http://cwiki.apache.org/confluence/display/ROLLER/Proposal+OpenID+Support

And in this JIRA issue:
   https://issues.apache.org/roller/browse/ROL-1733

Added:
    roller/trunk/apps/weblogger/src/java/META-INF/spring.schemas
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.orm.xml
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/CustomOpenIDAuthenticationProcessingFilter.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserAttributeTest.java
    roller/trunk/apps/weblogger/velocity.log.1
    roller/trunk/apps/weblogger/web/WEB-INF/classes/spring-security-2.0.1-openidfix.xsd   (with props)
    roller/trunk/apps/weblogger/web/images/openid-logo-small.gif   (with props)
    roller/trunk/tools/spring-2.5/apache-xml-security.jar   (with props)
    roller/trunk/tools/spring-2.5/dom3-xercesImpl.jar   (with props)
    roller/trunk/tools/spring-2.5/dom3-xml-apis.jar   (with props)
    roller/trunk/tools/spring-2.5/ehcache-1.4.1.jar   (with props)
    roller/trunk/tools/spring-2.5/java-openid-sxip.jar   (with props)
    roller/trunk/tools/spring-2.5/nekohtml.jar   (with props)
    roller/trunk/tools/spring-2.5/openxri-client.jar   (with props)
    roller/trunk/tools/spring-2.5/openxri-syntax.jar   (with props)
    roller/trunk/tools/spring-2.5/spring-security-acl-2.0.3.jar   (with props)
    roller/trunk/tools/spring-2.5/spring-security-core-2.0.3.jar   (with props)
    roller/trunk/tools/spring-2.5/spring-security-openid-2.0.3.jar   (with props)
    roller/trunk/tools/spring-2.5/spring-security-taglibs-2.0.3.jar   (with props)
Removed:
    roller/trunk/tools/spring-2.5/spring-security-acl-2.0.1.jar
    roller/trunk/tools/spring-2.5/spring-security-core-2.0.1.jar
    roller/trunk/tools/spring-2.5/spring-security-openid-2.0.1.jar
    roller/trunk/tools/spring-2.5/spring-security-taglibs-2.0.1.jar
Modified:
    roller/trunk/   (props changed)
    roller/trunk/apps/weblogger/   (props changed)
    roller/trunk/apps/weblogger/build.xml
    roller/trunk/apps/weblogger/nbproject/project.xml
    roller/trunk/apps/weblogger/src/java/META-INF/persistence.xml
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/UserManager.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.orm.xml
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerSession.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Login.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ProfileBean.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Register.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIAction.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIUtils.java
    roller/trunk/apps/weblogger/src/sql/400-to-410-migration.vm
    roller/trunk/apps/weblogger/src/sql/createdb.vm
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Login.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Profile.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/core/Register.jsp
    roller/trunk/apps/weblogger/web/WEB-INF/security.xml
    roller/trunk/apps/weblogger/web/WEB-INF/web.xml
    roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css

Propchange: roller/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Sep 14 19:49:10 2008
@@ -1,4 +1,5 @@
 velocity.log
+roller-startup.log
+tomcat
 classes.eclipse
 build
-roller-startup.log

Propchange: roller/trunk/apps/weblogger/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Sep 14 19:49:10 2008
@@ -1,2 +1,3 @@
+velocity.log
 build
 dist

Modified: roller/trunk/apps/weblogger/build.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/build.xml?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/build.xml (original)
+++ roller/trunk/apps/weblogger/build.xml Sun Sep 14 19:49:10 2008
@@ -302,12 +302,26 @@
         
         <!-- distributable WAR file -->
         <mkdir dir="${ro.dist}/webapp" />
+        <!--
         <jar destfile="${ro.dist}/webapp/roller-weblogger.war"
              basedir="${build.webapp}" />
-             
+        -->     
     </target>
     
     
+    <!-- Development only target: copy JSPs and other web files -->
+    <target name="dev-copy-web">
+        <copy todir="${build.webapp}">
+            <fileset dir="./web">
+                <include name="**/*"/>
+                <exclude name="**/codewright*/**"/>
+                <exclude name="**/*.bak"/>
+                <exclude name="**/*~"/>
+            </fileset>
+        </copy>
+    </target>
+        
+        
     <!-- ********************************************************************* -->
     <!-- Create different versions of database setup script                    -->
     <!-- With this approach we won't have to expand the script all the time.   -->

Modified: roller/trunk/apps/weblogger/nbproject/project.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/nbproject/project.xml?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/nbproject/project.xml (original)
+++ roller/trunk/apps/weblogger/nbproject/project.xml Sun Sep 14 19:49:10 2008
@@ -4,22 +4,12 @@
     <configuration>
         <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
             <!-- Do not use Project Properties customizer when editing this file manually. -->
-            <name>roller_weblogger</name>
+            <name>roller_weblogger_openid</name>
             <properties>
                 <property name="ant.script">build.xml</property>
             </properties>
             <folders>
                 <source-folder>
-                    <label>web</label>
-                    <type>doc_root</type>
-                    <location>web</location>
-                </source-folder>
-                <source-folder>
-                    <label>WEB-INF</label>
-                    <type>web_inf</type>
-                    <location>web/WEB-INF</location>
-                </source-folder>
-                <source-folder>
                     <label>src/sql</label>
                     <type>java</type>
                     <location>src/sql</location>
@@ -39,6 +29,16 @@
                     <type>java</type>
                     <location>docs/examples/plugins/pluginmodel/src</location>
                 </source-folder>
+                <source-folder>
+                    <label>web</label>
+                    <type>doc_root</type>
+                    <location>web</location>
+                </source-folder>
+                <source-folder>
+                    <label>WEB-INF</label>
+                    <type>web_inf</type>
+                    <location>web/WEB-INF</location>
+                </source-folder>
             </folders>
             <ide-actions>
                 <action name="build">
@@ -132,13 +132,14 @@
                 <package-root>src/java</package-root>
                 <package-root>test/java</package-root>
                 <package-root>docs/examples/plugins/pluginmodel/src</package-root>
-                <classpath mode="compile">../../tools/lib/commons-codec-1.3.jar:../../tools/lib/commons-collections-3.2.jar:../../tools/lib/commons-digester-1.6.jar:../../tools/lib/commons-id-0.1-SNAPSHOT.jar:../../tools/lib/commons-lang-2.1.jar:../../tools/lib/commons-logging-1.0.4.jar:../../tools/lib/concurrent-1.3.2.jar:../../tools/lib/guice-1.0.jar:../../tools/lib/jaxen-full.jar:../../tools/lib/jdom.jar:../../tools/lib/log4j-1.2.11.jar:../../tools/lib/lucene-1.4.3.jar:../../tools/lib/rome-0.9.1-dev.jar:../../tools/lib/rome-fetcher-0.9.jar:../../tools/lib/saxpath.jar:../../tools/lib/taglibs-string.jar:../../tools/lib/velocity-1.5.jar:../../tools/hibernate-3.1/hibernate3.jar:../../tools/openjpa-0.9.7/geronimo-j2ee-connector_1.5_spec-1.0.1.jar:../../tools/openjpa-0.9.7/geronimo-jpa_3.0_spec-1.0.jar:../../tools/openjpa-0.9.7/geronimo-jta_1.0.1B_spec-1.0.1.jar:../../tools/openjpa-0.9.7/openjpa-0.9.7-incubating.jar:../../tools/openjpa-0.9.7/serp-1.11.0.jar:../../tools/xmlrpc-3
 .0/lib/ws-commons-util-1.0.1.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-client-3.0.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-common-3.0.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-server-3.0.jar:../../tools/roller-core/roller-core.jar:../../tools/roller-planet/roller-planet-business.jar:../../tools/buildtime/tomcat-5.0.28/jsp-api.jar:../../tools/buildtime/tomcat-5.0.28/servlet-api.jar:../../tools/buildtime/activation.jar:../../tools/buildtime/mail.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/jstl.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/serializer.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/standard.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/xalan.jar:../../tools/hibernate-3.1/lib/asm-attrs.jar:../../tools/hibernate-3.1/lib/asm.jar:../../tools/hibernate-3.1/lib/cglib-2.1.3.jar:../../tools/hibernate-3.1/lib/dom4j-1.6.1.jar:../../tools/hibernate-3.1/lib/ehcache-1.1.jar:../../tools/hibernate-3.1/lib/jdbc2_0-stdext.jar:../../tools/hibernate-3.1/lib/jta.jar:../../
 tools/buildtime/junit-4.1.jar:../../tools/buildtime/ant-1.7.0/ant.jar:../../tools/buildtime/derbyclient.jar:../../tools/buildtime/derby.jar:../../tools/buildtime/derbynet.jar:../../tools/buildtime/mockrunner-0.35/lib/mockrunner-servlet.jar:../../tools/buildtime/mockrunner-0.35/lib/mockrunner-struts.jar:../../tools/buildtime/mockrunner-0.35/lib/mockrunner.jar:../../tools/buildtime/mockrunner-0.35/lib/nekohtml.jar:../../tools/struts-2.0.9/lib/antlr-2.7.2.jar:../../tools/struts-2.0.9/lib/commons-beanutils-1.6.jar:../../tools/struts-2.0.9/lib/commons-chain-1.1.jar:../../tools/struts-2.0.9/lib/commons-fileupload-1.2.jar:../../tools/struts-2.0.9/lib/commons-io-1.3.1.jar:../../tools/struts-2.0.9/lib/commons-validator-1.3.0.jar:../../tools/struts-2.0.9/lib/freemarker-2.3.8.jar:../../tools/struts-2.0.9/lib/ognl-2.6.11.jar:../../tools/struts-2.0.9/lib/oro-2.0.8.jar:../../tools/struts-2.0.9/lib/struts2-core-2.0.9.jar:../../tools/struts-2.0.9/lib/struts2-spring-plugin-2.0.9.jar:../../to
 ols/struts-2.0.9/lib/struts2-tiles-plugin-2.0.9.jar:../../tools/struts-2.0.9/lib/tiles-api-2.0.4.jar:../../tools/struts-2.0.9/lib/tiles-core-2.0.4.jar:../../tools/struts-2.0.9/lib/tiles-jsp-2.0.4.jar:../../tools/struts-2.0.9/lib/xwork-2.0.4.jar:../../tools/lib/commons-httpclient-3.0.1.jar:../../tools/lib/rome-propono-0.7.jar:../../tools/spring-2.5/spring-2.5.4.jar:../../tools/spring-2.5/spring-security-core-2.0.1.jar:../../tools/spring-2.5/spring-ldap-1.2.1.jar:../../tools/spring-2.5/spring-web-2.5.4.jar</classpath>
+                <classpath mode="compile">../../tools/roller-core/roller-core.jar:../../tools/roller-planet/roller-planet-business.jar:../../tools/buildtime/activation.jar:../../tools/buildtime/mail.jar:../../tools/buildtime/tomcat-5.0.28/jsp-api.jar:../../tools/buildtime/tomcat-5.0.28/servlet-api.jar:../../tools/lib/commons-codec-1.3.jar:../../tools/lib/commons-collections-3.2.jar:../../tools/lib/commons-digester-1.6.jar:../../tools/lib/commons-id-0.1-SNAPSHOT.jar:../../tools/lib/commons-lang-2.1.jar:../../tools/lib/commons-logging-1.0.4.jar:../../tools/lib/concurrent-1.3.2.jar:../../tools/lib/guice-1.0.jar:../../tools/lib/jaxen-full.jar:../../tools/lib/jdom.jar:../../tools/lib/log4j-1.2.11.jar:../../tools/lib/lucene-1.4.3.jar:../../tools/lib/rome-0.9.1-dev.jar:../../tools/lib/rome-fetcher-0.9.jar:../../tools/lib/saxpath.jar:../../tools/lib/taglibs-string.jar:../../tools/lib/velocity-1.5.jar:../../tools/openjpa-0.9.7/geronimo-j2ee-connector_1.5_spec-1.0.1.jar:../../tools/op
 enjpa-0.9.7/geronimo-jpa_3.0_spec-1.0.jar:../../tools/openjpa-0.9.7/geronimo-jta_1.0.1B_spec-1.0.1.jar:../../tools/openjpa-0.9.7/openjpa-0.9.7-incubating.jar:../../tools/openjpa-0.9.7/serp-1.11.0.jar:../../tools/xmlrpc-3.0/lib/ws-commons-util-1.0.1.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-client-3.0.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-common-3.0.jar:../../tools/xmlrpc-3.0/lib/xmlrpc-server-3.0.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/jstl.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/serializer.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/standard.jar:../../tools/jakarta-taglibs-standard-1.1.2/lib/xalan.jar:../../tools/buildtime/junit-4.1.jar:../../tools/buildtime/ant-1.7.0/ant.jar:../../tools/buildtime/derbyclient.jar:../../tools/buildtime/derby.jar:../../tools/buildtime/derbynet.jar:../../tools/buildtime/mockrunner-0.35/lib/mockrunner-servlet.jar:../../tools/buildtime/mockrunner-0.35/lib/mockrunner-struts.jar:../../tools/buildtime/mockrunner-0.35/lib/mo
 ckrunner.jar:../../tools/buildtime/mockrunner-0.35/lib/nekohtml.jar:../../tools/struts-2.0.9/lib/antlr-2.7.2.jar:../../tools/struts-2.0.9/lib/commons-beanutils-1.6.jar:../../tools/struts-2.0.9/lib/commons-chain-1.1.jar:../../tools/struts-2.0.9/lib/commons-fileupload-1.2.jar:../../tools/struts-2.0.9/lib/commons-io-1.3.1.jar:../../tools/struts-2.0.9/lib/commons-validator-1.3.0.jar:../../tools/struts-2.0.9/lib/freemarker-2.3.8.jar:../../tools/struts-2.0.9/lib/ognl-2.6.11.jar:../../tools/struts-2.0.9/lib/oro-2.0.8.jar:../../tools/struts-2.0.9/lib/struts2-core-2.0.9.jar:../../tools/struts-2.0.9/lib/struts2-spring-plugin-2.0.9.jar:../../tools/struts-2.0.9/lib/struts2-tiles-plugin-2.0.9.jar:../../tools/struts-2.0.9/lib/tiles-api-2.0.4.jar:../../tools/struts-2.0.9/lib/tiles-core-2.0.4.jar:../../tools/struts-2.0.9/lib/tiles-jsp-2.0.4.jar:../../tools/struts-2.0.9/lib/xwork-2.0.4.jar:../../tools/lib/commons-httpclient-3.0.1.jar:../../tools/lib/rome-propono-0.7.jar:../../tools/lib/dom3-
 xercesImpl.jar:../../tools/lib/nekohtml.jar:../../tools/lib/openxri-syntax.jar:../../tools/lib/apache-xml-security.jar:../../tools/lib/dom3-xml-apis.jar:../../tools/lib/openxri-client.jar:../../tools/spring-2.5/spring-2.5.4.jar:../../tools/spring-2.5/spring-security-openid-2.0.3.jar:../../tools/spring-2.5/spring-ldap-1.2.1.jar:../../tools/spring-2.5/spring-security-taglibs-2.0.3.jar:../../tools/spring-2.5/spring-security-acl-2.0.3.jar:../../tools/spring-2.5/spring-web-2.5.4.jar:../../tools/spring-2.5/spring-security-core-2.0.3.jar</classpath>
                 <source-level>1.5</source-level>
             </compilation-unit>
         </java-data>
         <web-data xmlns="http://www.netbeans.org/ns/freeform-project-web/2">
             <web-module>
                 <doc-root>web</doc-root>
+                <classpath/>
                 <context-path>/roller</context-path>
                 <j2ee-spec-level>1.5</j2ee-spec-level>
                 <web-inf>web/WEB-INF</web-inf>

Modified: roller/trunk/apps/weblogger/src/java/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/META-INF/persistence.xml?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/META-INF/persistence.xml (original)
+++ roller/trunk/apps/weblogger/src/java/META-INF/persistence.xml Sun Sep 14 19:49:10 2008
@@ -27,6 +27,7 @@
         <mapping-file>org/apache/roller/weblogger/pojos/ObjectPermission.orm.xml               </mapping-file>
         <mapping-file>org/apache/roller/weblogger/pojos/WeblogPermission.orm.xml               </mapping-file>
         <mapping-file>org/apache/roller/weblogger/pojos/Weblog.orm.xml                         </mapping-file>
+        <mapping-file>org/apache/roller/weblogger/pojos/UserAttribute.orm.xml                  </mapping-file>	
     </persistence-unit> 
     
 </persistence>

Added: roller/trunk/apps/weblogger/src/java/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/META-INF/spring.schemas?rev=695329&view=auto
==============================================================================
--- roller/trunk/apps/weblogger/src/java/META-INF/spring.schemas (added)
+++ roller/trunk/apps/weblogger/src/java/META-INF/spring.schemas Sun Sep 14 19:49:10 2008
@@ -0,0 +1 @@
+http\://www.springframework.org/schema/security/spring-security-2.0.1-openidfix.xsd=/spring-security-2.0.1-openidfix.xsd

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/UserManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/UserManager.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/UserManager.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/UserManager.java Sun Sep 14 19:49:10 2008
@@ -24,6 +24,7 @@
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.pojos.RollerPermission;
 import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.UserAttribute;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
 
@@ -32,10 +33,8 @@
  * Interface to user, role and permissions management.
  */
 public interface UserManager {
-        
-    
-    //--------------------------------------------------------------- user CRUD
     
+    //--------------------------------------------------------------- user CRUD    
     
     /**
      * Add a new user.
@@ -99,19 +98,17 @@
      */
     public User getUserByUserName(String userName) throws WebloggerException;
     
-    
     /**
      * Lookup a user by UserName with the given enabled status.
      * 
      * @param userName User Name of user to lookup.
-     * @returns UsUserhe user, or null if not found or doesn't match 
-     *   the proper enabled status.
+     * @returns The user, or null if not found or doesn't match the proper enabled status.
      * @throws WebloggerException If there is a problem.
      */
     public User getUserByUserName(String userName, Boolean enabled)
         throws WebloggerException;
     
-    
+
     /**
      * Lookup a group of users.
      * 
@@ -164,6 +161,59 @@
         throws WebloggerException;
     
         
+    //----------------------------------------------------- user attribute CRUD
+
+    
+    /**
+     * Lookup a user by User attribute
+     * 
+     * @param name attribute name
+     * @param value sttribute value
+     * @return UsUserhe user, or null if not found or is disabled.
+     * @throws WebloggerException If there is a problem
+     */
+    public User getUserByAttribute(String name, String value) throws WebloggerException;
+    
+    /**
+     * Lookup a user by User attribute
+     * 
+     * @param name     Attribute name
+     * @param value    Attribute value
+     * @param enabled  True if only enable user should be returned
+     * @return The user, or null if not found or is disabled.
+     * @throws WebloggerException If there is a problem
+     */
+    public User getUserByAttribute(String name, String value, Boolean enabled) throws WebloggerException;
+    
+    
+    /**
+     * Get user atribute value
+     * @param user User
+     * @param attribute Atribute name
+     * @return List of user attributes
+     */
+    public UserAttribute getUserAttribute(String userName, String attribute) throws WebloggerException;
+    
+    
+    /**
+     * Set user atribute value
+     * @param user User
+     * @param attribute Atribute name     
+     * @param value Atribute value
+     * @throws org.apache.roller.weblogger.WebloggerException
+     */
+    public void setUserAttribute(String userName, String attribute, String value) throws WebloggerException;
+    
+    
+    /**
+     * Get attribributes for a user. 
+     * @param userName Username that uniquely idenifies user.
+     * @return List of attributes.
+     * @throws org.apache.roller.weblogger.WebloggerException
+     */
+    public List<UserAttribute> getUserAttributes(String userName) throws WebloggerException;
+    
+    
     //-------------------------------------------------------- permissions CRUD
 
     

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.java Sun Sep 14 19:49:10 2008
@@ -28,14 +28,12 @@
 import org.apache.roller.weblogger.pojos.*;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
-import java.util.Comparator;
 import javax.persistence.Query;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.config.WebloggerConfig;
@@ -43,31 +41,21 @@
 
 @com.google.inject.Singleton
 public class JPAUserManagerImpl implements UserManager {
-    
-    /** The logger instance for this class. */
     private static Log log = LogFactory.getLog(JPAUserManagerImpl.class);
-    
-    private static final Comparator statCountCountReverseComparator =
-            Collections.reverseOrder(StatCountCountComparator.getInstance());
-    
-    private final Weblogger roller;
+
     private final JPAPersistenceStrategy strategy;
     
-    // cached mapping of weblogHandles -> weblogIds
-    private Map weblogHandleToIdMap = new Hashtable();
-    
     // cached mapping of userNames -> userIds
     private Map userNameToIdMap = new Hashtable();
     
-    
+
     @com.google.inject.Inject
-    protected JPAUserManagerImpl(Weblogger roller, JPAPersistenceStrategy strat) {
+    protected JPAUserManagerImpl(JPAPersistenceStrategy strat) {
         log.debug("Instantiating JPA User Manager");
-        this.roller = roller;
         this.strategy = strat;
     }
-    
-    
+
+
     public void release() {}
     
     
@@ -76,27 +64,31 @@
     public void saveUser(User data) throws WebloggerException {
         this.strategy.store(data);
     }
-    
+
     
     public void removeUser(User user) throws WebloggerException {
-        //remove permissions
-        // make sure that both sides of the relationship are maintained
+        String userName = user.getUserName();
+        
+        // remove permissions, maintaining both sides of relationship
         List<WeblogPermission> perms = getWeblogPermissions(user);
         for (WeblogPermission perm : perms) {
-           
-            //Remove it from database
             this.strategy.remove(perms);
         }
-        
         this.strategy.remove(user);
-        
+
         // remove entry from cache mapping
-        this.userNameToIdMap.remove(user.getUserName());
+        this.userNameToIdMap.remove(userName);
+        
+        // remove all associated attributes
+        List<UserAttribute> atts = getUserAttributes(userName);
+        for (UserAttribute att : atts) {
+            this.strategy.remove(att);
+        }
     }
-    
+
     
     public void addUser(User newUser) throws WebloggerException {
-        
+
         if(newUser == null)
             throw new WebloggerException("cannot add null user");
         
@@ -107,49 +99,49 @@
         if (existingUsers.size() == 0 && firstUserAdmin) {
             // Make first user an admin
             adminUser = true;
-            
+
             //if user was disabled (because of activation user 
             // account with e-mail property), enable it for admin user
             newUser.setEnabled(Boolean.TRUE);
             newUser.setActivationCode(null);
         }
-        
+
         if (getUserByUserName(newUser.getUserName()) != null ||
                 getUserByUserName(newUser.getUserName().toLowerCase()) != null) {
             throw new WebloggerException("error.add.user.userNameInUse");
         }
-                
+
         this.strategy.store(newUser);
-        
+
         grantRole("editor", newUser);
         if (adminUser) {
             grantRole("admin", newUser);
         }
     }
-    
+
     
     public User getUser(String id) throws WebloggerException {
         return (User)this.strategy.load(User.class, id);
     }
-    
+
     
     //------------------------------------------------------------ user queries
 
     public User getUserByUserName(String userName) throws WebloggerException {
         return getUserByUserName(userName, Boolean.TRUE);
     }
-    
+
     
     public User getUserByUserName(String userName, Boolean enabled)
-    throws WebloggerException {
-        
+            throws WebloggerException {
+
         if (userName==null )
             throw new WebloggerException("userName cannot be null");
         
         // check cache first
         // NOTE: if we ever allow changing usernames then this needs updating
         if(this.userNameToIdMap.containsKey(userName)) {
-            
+
             User user = this.getUser(
                     (String) this.userNameToIdMap.get(userName));
             if(user != null) {
@@ -163,7 +155,7 @@
                 this.userNameToIdMap.remove(userName);
             }
         }
-        
+
         // cache failed, do lookup
         Query query;
         Object[] params;
@@ -185,23 +177,22 @@
         } catch (NoResultException e) {
             user = null;
         }
-        
+
         // add mapping to cache
         if(user != null) {
             log.debug("userNameToIdMap CACHE MISS - "+userName);
             this.userNameToIdMap.put(user.getUserName(), user.getId());
         }
-        
+
         return user;
     }
-    
-    
+
     public List getUsers(Weblog weblog, Boolean enabled, Date startDate,
             Date endDate, int offset, int length)
             throws WebloggerException {
         Query query = null;
         List results = null;
-        
+
         // if we are doing date range then we must have an end date
         if (startDate != null && endDate == null) {
             endDate = new Date();
@@ -211,14 +202,14 @@
         int size = 0;
         StringBuffer queryString = new StringBuffer();
         StringBuffer whereClause = new StringBuffer();
-                            
+
         if (weblog != null) {
             queryString.append("SELECT u FROM User u JOIN u.permissions p ");
             params.add(size++, weblog);
-            whereClause.append(" WHERE p.website = ?" + size);   
+            whereClause.append(" WHERE p.website = ?" + size);
         } else {
             queryString.append("SELECT u FROM User u ");
-        }         
+        }
 
         if (enabled != null) {
             if (whereClause.length() == 0) {
@@ -227,7 +218,7 @@
                 whereClause.append(" AND ");
             }
             params.add(size++, enabled);
-            whereClause.append("u.enabled = ?" + size);  
+            whereClause.append("u.enabled = ?" + size);
         }
 
         if (startDate != null) {
@@ -262,12 +253,12 @@
         }
         return query.getResultList();
     }
-    
+
     
     public List getUsers(int offset, int length) throws WebloggerException {
         return getUsers(Boolean.TRUE, null, null, offset, length);
     }
-    
+
     
     public List getUsers(Boolean enabled, Date startDate, Date endDate,
             int offset, int length)
@@ -275,7 +266,7 @@
         Query query = null;
         List results = null;
         boolean setRange = offset != 0 || length != -1;
-        
+
         if (endDate == null) endDate = new Date();
         
         if (enabled != null) {
@@ -317,7 +308,7 @@
         }
         return query.getResultList();
     }
-    
+
     
     /**
      * Get users of a website
@@ -326,11 +317,11 @@
         Query query = null;
         List results = null;
         boolean setRange = offset != 0 || length != -1;
-        
+
         if (length == -1) {
             length = Integer.MAX_VALUE - offset;
         }
-        
+
         if (enabled != null) {
             if (website != null) {
                 query = strategy.getNamedQuery("User.getByEnabled&Permissions.website");
@@ -356,12 +347,12 @@
         }
         return query.getResultList();
     }
-    
+
     
     public List getUsersStartingWith(String startsWith, Boolean enabled,
             int offset, int length) throws WebloggerException {
         Query query = null;
-        
+
         if (enabled != null) {
             if (startsWith != null) {
                 query = strategy.getNamedQuery(
@@ -391,7 +382,7 @@
         }
         return query.getResultList();
     }
-    
+
     
     public Map getUserNameLetterMap() throws WebloggerException {
         String lc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -407,10 +398,10 @@
         }
         return results;
     }
-    
+
     
     public List getUsersByLetter(char letter, int offset, int length)
-    throws WebloggerException {
+            throws WebloggerException {
         Query query = strategy.getNamedQuery(
                 "User.getByUserNameOrderByUserName");
         query.setParameter(1, letter + "%");
@@ -422,7 +413,7 @@
         }
         return query.getResultList();
     }
-    
+
     
     /**
      * Get count of users, enabled only
@@ -433,29 +424,124 @@
         q.setParameter(1, Boolean.TRUE);
         List results = q.getResultList();
         ret =((Long)results.get(0)).longValue(); 
-        
+
         return ret;
     }
+
     
+    public User getUserByAttribute(String name, String value) throws WebloggerException {
+        return getUserByAttribute(name, value, Boolean.TRUE);
+    }
+
     
-	public User getUserByActivationCode(String activationCode) throws WebloggerException {
-		if (activationCode == null)
-			throw new WebloggerException("activationcode is null");
+    public User getUserByAttribute(String name, String value, Boolean enabled) throws WebloggerException {
+        
+        if (value == null) {
+            throw new WebloggerException("user attribute cannot be null!");
+        }
+
+        String[] parts = value.split("&");
+        value = parts[0];
+
+        Query query;
+        query = strategy.getNamedQuery("UserAttribute.getByAttrNameAndAttrValue");
+        query.setParameter(1, name);
+        query.setParameter(2, value);
+        UserAttribute attribute = null;
+
+        try {
+            attribute = (UserAttribute) query.getSingleResult();
+        } catch (NoResultException e) {
+            return null;
+        }
+
+        Object[] params;
+        if (enabled != null) {
+            query = strategy.getNamedQuery("User.getByUserName&Enabled");
+            params = new Object[]{attribute.getUserName(), enabled};
+        } else {
+            query = strategy.getNamedQuery("User.getByUserName");
+            params = new Object[]{attribute.getUserName()};
+        }
+        for (int i = 0; i < params.length; i++) {
+            query.setParameter(i + 1, params[i]);
+        }
+        User user = null;
+        try {
+            user = (User) query.getSingleResult();
+        } catch (NoResultException e) {
+            user = null;
+        }
+
+        return user;
+    }
+
+    
+    public UserAttribute getUserAttribute(String userName, String attribute) throws WebloggerException {
+        Query q = strategy.getNamedQuery("UserAttribute.getByUserNameAndAttrName");
+        q.setParameter(1, userName);
+        q.setParameter(2, attribute);
+        try {
+            return (UserAttribute) q.getSingleResult();
+        } catch (NoResultException e) {            
+            return null;
+        }
+    }
+
+    
+    public List<UserAttribute> getUserAttributes(String userName) throws WebloggerException {
+        Query q = strategy.getNamedQuery("UserAttribute.getByUserName");
+        q.setParameter(1, userName);
+        try {
+            return (List<UserAttribute>)q.getResultList();
+        } catch (NoResultException e) {            
+            return null;
+        }
+    }
+
+    
+    public void setUserAttribute(String userName, String attribute, String value) throws WebloggerException {
+        UserAttribute userAttribute = null;
+        Query q = strategy.getNamedQuery("UserAttribute.getByUserNameAndAttrName");
+        q.setParameter(1, userName);
+        q.setParameter(2, attribute);
+        try {
+            userAttribute = (UserAttribute) q.getSingleResult();
+        } catch (NoResultException ignored) {
+        }
+        if (userAttribute != null) {
+            if (value.equals("")) {
+                this.strategy.remove(userAttribute);
+            } else {
+                userAttribute.setValue(value);
+                this.strategy.store(userAttribute);
+            }
+        } else {
+            userAttribute = new UserAttribute(userName, attribute, value);
+            this.strategy.store(userAttribute);
+        }
+    }
+
+    
+    public User getUserByActivationCode(String activationCode) throws WebloggerException {
+        if (activationCode == null) {
+            throw new WebloggerException("activationcode is null");
+        }
         Query q = strategy.getNamedQuery("User.getUserByActivationCode");
         q.setParameter(1, activationCode);
         try {
             return (User)q.getSingleResult();
         } catch (NoResultException e) {
             return null;
-        }		
-	}   
-        
+        }
+    }
+    
     
     //-------------------------------------------------------- permissions CRUD
  
     public boolean checkPermission(RollerPermission perm, User user) throws WebloggerException {
         RollerPermission existingPerm = null;
-        
+
         // if permission a weblog permission
         if (perm instanceof WeblogPermission) {
             // if user has specified permission in weblog return true
@@ -463,7 +549,7 @@
             try {
                 existingPerm = getWeblogPermission(permToCheck.getWeblog(), user);
             } catch (WebloggerException ignored) {}        
-        }
+            }
         if (existingPerm != null && existingPerm.implies(perm)) return true;  
         
         // user has no existing perm in a weblog, so try his global perms
@@ -490,7 +576,7 @@
 
     
     public void grantWeblogPermission(Weblog weblog, User user, List<String> actions) throws WebloggerException {
-        
+
         // first, see if user already has a permission for the specified object
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&WeblogId");
         q.setParameter(1, user.getUserName());
@@ -499,21 +585,21 @@
         try {
             existingPerm = (WeblogPermission)q.getSingleResult();
         } catch (NoResultException ignored) {}
-        
+
         // permission already exists, so add any actions specified in perm argument
         if (existingPerm != null) {
             existingPerm.addActions(actions);
-            this.strategy.store(existingPerm);          
+            this.strategy.store(existingPerm);
         } else {
             // it's a new permission, so store it
             WeblogPermission perm = new WeblogPermission(weblog, user, actions);
             this.strategy.store(perm);
         }
     }
-    
+
     
     public void grantWeblogPermissionPending(Weblog weblog, User user, List<String> actions) throws WebloggerException {
-        
+
         // first, see if user already has a permission for the specified object
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&WeblogId");
         q.setParameter(1, user.getUserName());
@@ -522,11 +608,11 @@
         try {
             existingPerm = (WeblogPermission)q.getSingleResult();
         } catch (NoResultException ignored) {}
-        
+
         // permission already exists, so complain 
         if (existingPerm != null) {
             throw new WebloggerException("Cannot make existing permission into pending permission");
-            
+
         } else {
             // it's a new permission, so store it
             WeblogPermission perm = new WeblogPermission(weblog, user, actions);
@@ -534,10 +620,10 @@
             this.strategy.store(perm);
         }
     }
-    
+
     
     public void confirmWeblogPermission(Weblog weblog, User user) throws WebloggerException {
-        
+
         // get specified permission
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&WeblogId");
         q.setParameter(1, user.getUserName());
@@ -545,7 +631,7 @@
         WeblogPermission existingPerm = null;
         try {
             existingPerm = (WeblogPermission)q.getSingleResult();
-            
+
         } catch (NoResultException ignored) {
             throw new WebloggerException("ERROR: permission not found");
         }
@@ -556,14 +642,14 @@
 
     
     public void declineWeblogPermission(Weblog weblog, User user) throws WebloggerException {
-        
+
         // get specified permission
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&WeblogId");
         q.setParameter(1, user.getUserName());
         q.setParameter(2, weblog.getHandle());
         WeblogPermission existingPerm = null;
         try {
-            existingPerm = (WeblogPermission)q.getSingleResult();           
+            existingPerm = (WeblogPermission)q.getSingleResult();
         } catch (NoResultException ignored) {
             throw new WebloggerException("ERROR: permission not found");
         }
@@ -573,7 +659,7 @@
 
     
     public void revokeWeblogPermission(Weblog weblog, User user, List<String> actions) throws WebloggerException {
-        
+
         // get specified permission
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&WeblogId");
         q.setParameter(1, user.getUserName());
@@ -584,10 +670,10 @@
         } catch (NoResultException ignored) {
             throw new WebloggerException("ERROR: permission not found");
         }
-        
-        // remove actions specified in perm agument
+
+// remove actions specified in perm agument
         oldperm.removeActions(actions);
-        
+
         if (oldperm.isEmpty()) {
             // no actions left in permission so remove it
             this.strategy.remove(oldperm);
@@ -596,37 +682,37 @@
             this.strategy.store(oldperm);
         }
     }
+
     
-    
-    public List<WeblogPermission> getWeblogPermissions(User user) throws WebloggerException { 
+    public List<WeblogPermission> getWeblogPermissions(User user) throws WebloggerException {
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName");
         q.setParameter(1, user.getUserName());
         return (List<WeblogPermission>)q.getResultList();
     }
-    
+
     
     public List<WeblogPermission> getWeblogPermissions(Weblog weblog) throws WebloggerException {
         Query q = strategy.getNamedQuery("WeblogPermission.getByWeblogId");
         q.setParameter(1, weblog.getHandle());
         return (List<WeblogPermission>)q.getResultList();
     }
-    
+
     
     public List<WeblogPermission> getWeblogPermissionsPending(User user) throws WebloggerException {
         Query q = strategy.getNamedQuery("WeblogPermission.getByUserName&Pending");
         q.setParameter(1, user.getUserName());
         return (List<WeblogPermission>)q.getResultList();
     }
-    
+
 
     public List<WeblogPermission> getWeblogPermissionsPending(Weblog weblog) throws WebloggerException {
         Query q = strategy.getNamedQuery("WeblogPermission.getByWeblogId&Pending");
         q.setParameter(1, weblog.getHandle());
         return (List<WeblogPermission>)q.getResultList();
     }
+
     
-    
-    //-------------------------------------------------------------- role CRUD
+//-------------------------------------------------------------- role CRUD
  
     
     /**
@@ -643,12 +729,12 @@
         }
         return true;
     }
-    
+
     
     /**
      * Get all of user's roles.
      */
-    public List<String> getRoles(User user) throws WebloggerException { 
+    public List<String> getRoles(User user) throws WebloggerException {
         Query q = strategy.getNamedQuery("UserRole.getByUserName");
         q.setParameter(1, user.getUserName());
         List roles = q.getResultList();
@@ -657,10 +743,10 @@
             UserRole userRole = (UserRole)it.next();
             roleNames.add(userRole.getRole());
         }
+
         return roleNames;
     }
-    
-    
+
     /**
      * Grant to user role specified by role name.
      */
@@ -670,7 +756,7 @@
             this.strategy.store(role);
         }
     }
-    
+
     
     public void revokeRole(String roleName, User user) throws WebloggerException {
         Query q = strategy.getNamedQuery("UserRole.getByUserNameAndRole");
@@ -679,7 +765,7 @@
         try {
             UserRole role = (UserRole)q.getSingleResult();
             this.strategy.remove(role);
-            
+
         } catch (NoResultException e) {
             throw new WebloggerException("ERROR: removing role", e);
         }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/config/roller.properties Sun Sep 14 19:49:10 2008
@@ -335,6 +335,13 @@
 # Enable container managed authentication
 authentication.cma.enabled=false
 
+# Enable/disable OpenID (requires Spring Security, will not work with CMA)
+# This can be set to one of three values:
+# - disabled: no OpenID support, no evidence of OpenID in the Web UI
+# - hybrid:   allow users to use either password and/or OpenID
+# - only:     users must use OpenID only, no password allowed
+authentication.openid=hybrid
+
 # Password security settings
 passwds.encryption.enabled=true
 passwds.encryption.algorithm=SHA

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.java Sun Sep 14 19:49:10 2008
@@ -25,8 +25,6 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.roller.weblogger.WebloggerException;
@@ -60,7 +58,7 @@
     
     private Set roles = new HashSet();
     private List permissions = new ArrayList();
-    
+                 
     
     public User() {
     }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.orm.xml?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.orm.xml (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/User.orm.xml Sun Sep 14 19:49:10 2008
@@ -70,7 +70,7 @@
             DISTINCT is not required for this query as no duplicate User would be retrieved
             -->
             <query>SELECT COUNT(u) FROM User u WHERE u.enabled = ?1</query>
-        </named-query>
+        </named-query>  
         <attributes>
             <id name="id">
                 <column name="id"/>

Added: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.java?rev=695329&view=auto
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.java (added)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.java Sun Sep 14 19:49:10 2008
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.pojos;
+
+import java.io.Serializable;
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.roller.util.UUIDGenerator;
+
+
+/**
+ * Name and value pair associated with a user object.
+ * @author Tatyana Tokareva
+ */
+public class UserAttribute implements Serializable {
+    
+    public static final long serialVersionUID = -6354583200913127874L;    
+    
+    private String id = UUIDGenerator.generateUUID();
+    private String userName;
+    private String attrName;
+    private String attrValue;
+    
+    
+    public static enum Attributes {
+        OPENID_URL("openid.url");
+        
+        private Attributes(String name) {
+            this.name = name;
+        }        
+        private final String name;
+        @Override
+        public String toString() {
+            return name;
+        }     
+        public String get() {
+            return name.toString();
+        }
+    }
+
+    public UserAttribute(String userName, String attrName, String attrValue) {
+        this.userName = userName;
+        this.attrName = attrName;
+        this.attrValue = attrValue;
+    }        
+    
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userId) {
+        this.userName = userId;
+    }
+    
+    public String getName() {
+        return attrName;
+    }
+
+    public void setName(String attrName) {
+        this.attrName = attrName;
+    }
+
+    public String getValue() {
+        return attrValue;
+    }
+
+    public void setValue(String attrValue) {
+        this.attrValue = attrValue;
+    }
+
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        buf.append("{");
+        buf.append(this.id);
+        buf.append(", ").append(this.userName);
+        buf.append(", ").append(this.attrName);
+        buf.append(", ").append(this.attrValue);
+        buf.append("}");
+        return buf.toString();
+    }
+    
+    public boolean equals(Object other) {
+        if (other == this) return true;
+        if (other instanceof UserRole != true) return false;
+        UserAttribute o = (UserAttribute)other;
+        return new EqualsBuilder()
+            .append(getUserName(), o.getUserName())
+            .append(getName(), o.getName())
+            .append(getValue(), o.getValue())        
+            .isEquals();
+    }
+    
+    public int hashCode() {
+        return new HashCodeBuilder().append(getUserName()).append(getName()).append(getValue()).toHashCode();
+    }
+}

Added: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.orm.xml
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.orm.xml?rev=695329&view=auto
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.orm.xml (added)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/UserAttribute.orm.xml Sun Sep 14 19:49:10 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings version="1.0" xmlns="http://java.sun.com/xml/ns/persistence/orm"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
+    <description>Persistence Metadata for Roller</description>
+    <persistence-unit-metadata>
+        <persistence-unit-defaults>
+            <access>PROPERTY</access>
+        </persistence-unit-defaults>
+    </persistence-unit-metadata>
+    <package>org.apache.roller.weblogger.pojos</package>
+    <entity metadata-complete="true" name="UserAttribute" class="org.apache.roller.weblogger.pojos.UserAttribute">
+        <table name="roller_userattribute"/>
+        
+        <named-query name="UserAttribute.getByUserName">
+            <query>SELECT r FROM UserAttribute r WHERE r.userName = ?1</query>
+        </named-query>
+        
+        <named-query name="UserAttribute.getByAttrNameAndAttrValue">
+            <query>SELECT r FROM UserAttribute r WHERE r.name = ?1 AND r.value = ?2</query>
+        </named-query>
+        
+        <named-query name="UserAttribute.getByUserNameAndAttrName">
+            <query>SELECT r FROM UserAttribute r WHERE r.userName = ?1 AND r.name = ?2</query>
+        </named-query>                
+        
+        <attributes>
+            <id name="id">
+                <column name="id"/>
+            </id>
+            <basic name="userName">
+                <column name="username" insertable="true" updatable="true" unique="false"/>
+            </basic>
+            <basic name="name">
+                <column name="attrname" insertable="true" updatable="true" unique="false"/>
+            </basic>
+            <basic name="value">
+                <column name="attrvalue" insertable="true" updatable="true" unique="true"/>
+            </basic>
+        </attributes>
+        
+    </entity>
+</entity-mappings>

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerSession.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerSession.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerSession.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/RollerSession.java Sun Sep 14 19:49:10 2008
@@ -33,6 +33,7 @@
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.UserAttribute;
 import org.apache.roller.weblogger.ui.core.security.AutoProvision;
 
 
@@ -84,6 +85,17 @@
                     UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
                     User user = umgr.getUserByUserName(principal.getName());
                     
+                    // check for OpenID username (in the form of a URL)
+                    if (user == null && principal.getName() != null && principal.getName().startsWith("http://")) {
+                        String openidurl = principal.getName();
+                        if (openidurl.endsWith("/")) {
+                            openidurl = openidurl.substring(0, openidurl.length() - 1);
+                        }
+                        user = umgr.getUserByAttribute(
+                                UserAttribute.Attributes.OPENID_URL.toString(), 
+                                openidurl);
+                    }
+                    
                     // try one time to auto-provision, only happens if user==null
                     // which means installation has SSO-enabled in security.xml
                     if (user == null && WebloggerConfig.getBooleanProperty("users.sso.autoProvision.enabled")) {

Added: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/CustomOpenIDAuthenticationProcessingFilter.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/CustomOpenIDAuthenticationProcessingFilter.java?rev=695329&view=auto
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/CustomOpenIDAuthenticationProcessingFilter.java (added)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/filters/CustomOpenIDAuthenticationProcessingFilter.java Sun Sep 14 19:49:10 2008
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.core.filters;
+
+import javax.servlet.Filter;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.security.Authentication;
+import org.springframework.security.AuthenticationException;
+import org.springframework.security.providers.openid.OpenIDAuthenticationToken;
+import org.springframework.security.ui.openid.OpenIDAuthenticationProcessingFilter;
+import org.springframework.security.userdetails.UsernameNotFoundException;
+import org.springframework.security.ui.openid.OpenIDConsumer;
+//import org.springframework.security.userdetails.openid.OpenIDUserAttribute;
+
+
+/**
+ * Handle response from OpenID provider.
+ * @author Tatyana Tokareva
+ */
+public class CustomOpenIDAuthenticationProcessingFilter 
+        extends OpenIDAuthenticationProcessingFilter implements Filter {
+
+    private OpenIDConsumer consumer;
+    private String claimedIdentityFieldName = DEFAULT_CLAIMED_IDENTITY_FIELD;
+    private static Log log = LogFactory.getLog(CustomOpenIDAuthenticationProcessingFilter.class);
+
+    @Override
+    public Authentication attemptAuthentication(HttpServletRequest req) throws AuthenticationException {
+        OpenIDAuthenticationToken auth = null;
+
+        // Processing standard OpenId user authentication    
+        auth = (OpenIDAuthenticationToken) super.attemptAuthentication(req);
+
+        if (auth.getAuthorities()[0].getAuthority().equals("openidLogin")) {
+
+            /* TODO: when Spring Security 2.1 is released, we can uncomment 
+             * this code, which will allow us to pre-populate the new user 
+             * registration form with information from the OpenID Provider.
+             * 
+            Collection<OpenIDUserAttribute> sREGAttributesList = auth.getAttributes();
+            OpenIDUserAttribute openidName = new OpenIDUserAttribute(
+                OpenIDUserAttribute.Attributes.openidname.toString(), "");
+            openidName.setValue(auth.getIdentityUrl());
+            sREGAttributesList.add(openidName);
+            
+            // TODO: find a better place to stash attributes
+            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();            
+            mgr.userAttributes.put(
+                UserAttribute.Attributes.openidUrl.toString(),
+                sREGAttributesList);
+            */
+            
+            // Username not found in Roller for this user, so throw exception
+            // which will route user to the new user registration page.
+            throw new UsernameNotFoundException("ERROR no user: new openid user");
+        }
+        return auth;
+    }
+}

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java Sun Sep 14 19:49:10 2008
@@ -11,6 +11,7 @@
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.UserAttribute;
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.DataAccessResourceFailureException;
 import org.springframework.dao.DataRetrievalFailureException;
@@ -19,36 +20,72 @@
  * Spring Security UserDetailsService implemented using Weblogger API.
  */
 public class RollerUserDetailsService implements UserDetailsService {
-
+      
     public UserDetails loadUserByUsername(String userName) 
             throws UsernameNotFoundException, DataAccessException {
         try {
-
             Weblogger roller = WebloggerFactory.getWeblogger();
             UserManager umgr = roller.getUserManager();
-            User userData = null;
-            try {
-                userData = umgr.getUserByUserName(userName, Boolean.TRUE);
-            } catch (WebloggerException ex) {
-                throw new DataRetrievalFailureException("ERROR in user lookup", ex);
-            }
-
-            if (userData == null) {
-                throw new UsernameNotFoundException("ERROR no user: " + userName);
-            }
+            User userData = null;  
+            if (userName.startsWith("http://")) {
+                if (userName.endsWith("/")) {
+                    userName = userName.substring(0, userName.length() -1 );
+                }
+                try {
+                    userData = umgr.getUserByAttribute(
+                        UserAttribute.Attributes.OPENID_URL.toString(), 
+                        userName);
+                } catch (WebloggerException ex) {
+                    throw new DataRetrievalFailureException("ERROR in user lookup", ex);
+                }
+                String name;
+                String password;
+                GrantedAuthority[] authorities;
+                
+                // We are not throwing UsernameNotFound exception in case of 
+                // openid authentication in order to recieve user SREG attributes 
+                // from the authentication filter and save them                
+                if (userData == null) {
+                     authorities = new GrantedAuthority[1];
+                     GrantedAuthority g = new GrantedAuthorityImpl("openidLogin");
+                     authorities[0] = g;
+                     name = "openid";
+                     password = "openid";
+                } else {
+                     authorities =  getAuthorities(userData, umgr);
+                     name = userData.getUserName();
+                     password = userData.getPassword();
+                }
+                UserDetails usr = new org.springframework.security.userdetails.User(name, password, true, authorities);
+                return  usr;
+                
+            } else {
+                try {
+                    userData = umgr.getUserByUserName(userName);
+                } catch (WebloggerException ex) {
+                    throw new DataRetrievalFailureException("ERROR in user lookup", ex);
+                }
+                if (userData == null) {
+                    throw new UsernameNotFoundException("ERROR no user: " + userName);
+                }
+                GrantedAuthority[] authorities =  getAuthorities(userData, umgr);        
+                return new org.springframework.security.userdetails.User(userData.getUserName(), userData.getPassword(), true, authorities);
+            }            
+        } catch (WebloggerException ex) {
+            throw new DataAccessResourceFailureException("ERROR: fetching roles", ex);
+        }
+        
 
-            List<String> roles = umgr.getRoles(userData);
+    }
+        
+     private GrantedAuthority[] getAuthorities(User userData, UserManager umgr) throws WebloggerException {
+             List<String> roles = umgr.getRoles(userData);
             GrantedAuthority[] authorities = new GrantedAuthorityImpl[roles.size()];
             int i = 0;
             for (String role : roles) {
                 authorities[i++] = new GrantedAuthorityImpl(role);
             }
-
-            return new org.springframework.security.userdetails.User(userData.getUserName(), userData.getPassword(), true, authorities);
-            
-        } catch (WebloggerException ex) {
-            throw new DataAccessResourceFailureException("ERROR: fetching roles", ex);
+            return authorities;
         }
-    }
     
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Login.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Login.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Login.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Login.java Sun Sep 14 19:49:10 2008
@@ -18,6 +18,7 @@
 
 package org.apache.roller.weblogger.ui.struts2.core;
 
+import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 
 
@@ -27,7 +28,7 @@
 public class Login extends UIAction {
     
     private String error = null;
-    
+    private boolean openidEnabled = WebloggerConfig.getBooleanProperty("authentication.openid.enabled");
     
     public Login() {
         this.pageTitle = "loginPage.title";
@@ -43,7 +44,10 @@
     public boolean isWeblogRequired() {
         return false;
     }
-    
+
+    public String getOpenIdConfiguration() {
+        return WebloggerConfig.getProperty("authentication.openid");
+    }
     
     public String execute() {
         

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java Sun Sep 14 19:49:10 2008
@@ -15,7 +15,6 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-
 package org.apache.roller.weblogger.ui.struts2.core;
 
 import org.apache.commons.lang.StringUtils;
@@ -24,36 +23,40 @@
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
+import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.UserAttribute;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
 
 /**
  * Allows user to edit his/her profile.
- *
  * TODO: check on the impact of deleting that cookieLogin stuff
  */
 public class Profile extends UIAction {
-    
     private static Log log = LogFactory.getLog(Profile.class);
     
     private ProfileBean bean = new ProfileBean();
-    
+    private String openIdConfiguration = 
+        WebloggerConfig.getProperty("authentication.openid");
+    private boolean usingSso = 
+        WebloggerConfig.getBooleanProperty("users.sso.enabled");
+            
     
     public Profile() {
         this.pageTitle = "yourProfile.title";
     }
     
+    
     // override default security, we do not require an action weblog
     public boolean isWeblogRequired() {
         return false;
     }
-    
-    
+
+
     @SkipValidation
     public String execute() {
-        
         User ud = getAuthenticatedUser();
         
         // load up the form from the users existing profile data
@@ -62,28 +65,55 @@
         getBean().setPasswordConfirm(null);
         getBean().setLocale(ud.getLocale());
         getBean().setTimeZone(ud.getTimeZone());
-
+        
+        UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
+        try {
+            UserAttribute openIdUrl = mgr.getUserAttribute(
+                ud.getUserName(), UserAttribute.Attributes.OPENID_URL.toString());
+            if (openIdUrl != null) {
+                getBean().setOpenIdUrl(openIdUrl.getValue());
+            }
+        } catch (Exception ex) {
+            log.error("Unexpected error loading user OpenID url", ex);
+            addError("error in action", ex.toString());
+        }
         return INPUT;
     }
-    
+
     
     public String save() {
-        
+
         myValidate();
-        
+
         if (!hasActionErrors()) {
+            
             // We ONLY modify the user currently logged in
             User existingUser = getAuthenticatedUser();
-            
+
             // We want to be VERY selective about what data gets updated
             existingUser.setScreenName(getBean().getScreenName());
             existingUser.setFullName(getBean().getFullName());
             existingUser.setEmailAddress(getBean().getEmailAddress());
             existingUser.setLocale(getBean().getLocale());
             existingUser.setTimeZone(getBean().getTimeZone());
+            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
             
+            if (StringUtils.isNotEmpty(getBean().getOpenIdUrl())) { 
+                try {
+                    String openidurl = getBean().getOpenIdUrl();
+                    if (openidurl != null && openidurl.endsWith("/")) {
+                        openidurl = openidurl.substring(0, openidurl.length() - 1);
+                    }
+                    mgr.setUserAttribute(existingUser.getUserName(), 
+                        UserAttribute.Attributes.OPENID_URL.toString(), openidurl);
+                } catch (Exception ex) {
+                    log.error("Unexpected error saving user OpenID URL", ex);
+                    addError("Error in action", ex.toString());
+                }
+            }
+
             // If user set both password and passwordConfirm then reset password
-            if (!StringUtils.isEmpty(getBean().getPasswordText()) && 
+            if (!StringUtils.isEmpty(getBean().getPasswordText()) &&
                     !StringUtils.isEmpty(getBean().getPasswordConfirm())) {
                 try {
                     existingUser.resetPassword(getBean().getPasswordText());
@@ -91,40 +121,42 @@
                     addMessage("yourProfile.passwordResetError");
                 }
             }
-            
+
             try {
                 // save the updated profile
-                UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
                 mgr.saveUser(existingUser);
                 WebloggerFactory.getWeblogger().flush();
-                
+
                 // TODO: i18n
                 addMessage("profile updated.");
-                
+
                 return SUCCESS;
-                
+
             } catch (WebloggerException ex) {
                 log.error("ERROR in action", ex);
                 // TODO: i18n
                 addError("unexpected error doing profile save");
             }
-            
+
         }
-        
+
         return INPUT;
     }
-    
+
     
     public void myValidate() {
-        
+
         // check that passwords match if they were specified
-        if(!StringUtils.isEmpty(getBean().getPasswordText())) {
-            if(!getBean().getPasswordText().equals(getBean().getPasswordConfirm())) {
+        if (!StringUtils.isEmpty(getBean().getPasswordText())) {
+            if (!getBean().getPasswordText().equals(getBean().getPasswordConfirm())) {
                 addError("Register.error.passowordMismatch");
             }
         }
     }
-    
+
+    public String getOpenIdConfiguration() {
+        return openIdConfiguration;
+    }
     
     public ProfileBean getBean() {
         return bean;
@@ -134,4 +166,7 @@
         this.bean = bean;
     }
     
+    public boolean getUsingSso() {
+        return this.usingSso;
+    }
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ProfileBean.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ProfileBean.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ProfileBean.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ProfileBean.java Sun Sep 14 19:49:10 2008
@@ -34,11 +34,14 @@
     private String emailAddress = null;
     private String locale = null;
     private String timeZone = null;
+    private String openidUrl = null;
     
     private String passwordText = null;
     private String passwordConfirm = null;
     
     
+    
+    
     public String getId() {
         return id;
     }
@@ -102,6 +105,14 @@
     public void setTimeZone(String timeZone) {
         this.timeZone = timeZone;
     }
+
+    public String getOpenIdUrl() {
+        return openidUrl;
+    }
+
+    public void setOpenIdUrl(String openidUrl) {
+        this.openidUrl = openidUrl;
+    }
     
     public String getPasswordText() {
         return passwordText;

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Register.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Register.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Register.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/Register.java Sun Sep 14 19:49:10 2008
@@ -18,7 +18,6 @@
 
 package org.apache.roller.weblogger.ui.struts2.core;
 
-import java.util.Locale;
 import java.util.TimeZone;
 import java.util.UUID;
 import javax.servlet.http.HttpServletRequest;
@@ -32,11 +31,14 @@
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.UserAttribute;
 import org.apache.roller.weblogger.ui.core.security.CustomUserRegistry;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.MailUtil;
 import org.apache.struts2.interceptor.ServletRequestAware;
 import org.apache.struts2.interceptor.validation.SkipValidation;
+//import org.springframework.security.userdetails.openid.OpenIDUserAttribute;
+
 
 
 /**
@@ -46,7 +48,7 @@
     
     private static Log log = LogFactory.getLog(Register.class);
     
-    public static String DEFAULT_ALLOWED_CHARS = "A-Za-z0-9";
+    public static String DEFAULT_ALLOWED_CHARS = "A-Za-z0-9";    
     
     // this is a no-no, we should not need this
     private HttpServletRequest servletRequest = null;
@@ -73,6 +75,9 @@
         return false;
     }
     
+    public String getOpenIdConfiguration() {
+        return WebloggerConfig.getProperty("authentication.openid");
+    }
     
     @SkipValidation
     public String execute() {
@@ -80,10 +85,44 @@
         if (!WebloggerRuntimeConfig.getBooleanProperty("users.registration.enabled")) {
             return "disabled";
         }
+                
+        // For new user default to locale set in browser
+        bean.setLocale(getServletRequest().getLocale().toString());
         
-        // set some defaults
-        getBean().setLocale(Locale.getDefault().toString());
-        getBean().setTimeZone(TimeZone.getDefault().getID());
+        // For new user default to timezone of server
+        bean.setTimeZone(TimeZone.getDefault().getID());
+        
+        /* TODO: when Spring Security 2.1 is release comment out this stuff, 
+         * which pre-populates the user bean with info from OpenID provider.
+         * 
+        Collection attrsCollect = (Collection)WebloggerFactory.getWeblogger()
+                .getUserManager().userAttributes.get(UserAttribute.Attributes.openidUrl.toString());
+        
+        if (attrsCollect != null) {
+            ArrayList attrs = new ArrayList(attrsCollect);
+            for (Iterator it = attrs.iterator(); it.hasNext();) {                
+                OpenIDUserAttribute attr = (OpenIDUserAttribute) it.next();    
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.country.toString())) {                                        
+                    getBean().setLocale(UIUtils.getLocale(attr.getValue()));
+                }                
+               if (attr.getName().equals(OpenIDUserAttribute.Attributes.email.toString())) {
+                    getBean().setEmailAddress(attr.getValue());
+                }
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.fullname.toString())) {
+                    getBean().setFullName(attr.getValue());
+                }
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.nickname.toString())) {
+                    getBean().setUserName(attr.getValue());
+                }
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.timezone.toString())) {
+                    getBean().setTimeZone(UIUtils.getTimeZone(attr.getValue()));
+                }
+                if (attr.getName().equals(OpenIDUserAttribute.Attributes.openidname.toString())) {
+                    getBean().setOpenidUrl(attr.getValue());
+                }
+                
+            }
+        }*/
             
         try {
 
@@ -172,6 +211,17 @@
             
             // save new user
             mgr.addUser(ud);
+            
+            String openidurl = getBean().getOpenIdUrl();
+            if (openidurl != null) {
+                if (openidurl.endsWith("/")) {
+                    openidurl = openidurl.substring(0, openidurl.length() - 1);
+                }
+                mgr.setUserAttribute(
+                    ud.getUserName(), UserAttribute.Attributes.OPENID_URL.toString(),
+                    openidurl);
+            }
+            
             WebloggerFactory.getWeblogger().flush();
             
             // now send activation email if necessary
@@ -288,7 +338,15 @@
             addError("error.add.user.badUserName");
         }
         
-        // check that passwords match
+        // check password, it is required if OpenID and SSO are disabled
+        if (getOpenIdConfiguration().equals("disabled") && !getFromSso()) {
+            if (StringUtils.isEmpty(getBean().getPasswordText())) {            
+                addError("error.add.user.passwordEmpty");
+                return;
+            }
+        }
+        
+        // check that passwords match 
         if (!getBean().getPasswordText().equals(getBean().getPasswordConfirm())) {
             addError("Register.error.passowordMismatch");
         }
@@ -296,7 +354,7 @@
         // check that username is not taken
         if (!StringUtils.isEmpty(getBean().getUserName())) try {
             UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
-            if(mgr.getUserByUserName(getBean().getUserName(), null) != null) {
+            if (mgr.getUserByUserName(getBean().getUserName(), null) != null) {
                 addError("error.add.user.userNameInUse");
                 // reset user name
                 getBean().setUserName(null);

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIAction.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIAction.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIAction.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIAction.java Sun Sep 14 19:49:10 2008
@@ -32,7 +32,6 @@
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
-import org.apache.roller.weblogger.ui.struts2.util.UIUtils;
 import org.apache.roller.weblogger.ui.core.util.menu.Menu;
 import org.apache.roller.weblogger.ui.core.util.menu.MenuHelper;
 

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIUtils.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIUtils.java (original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/util/UIUtils.java Sun Sep 14 19:49:10 2008
@@ -47,10 +47,18 @@
     }
     
     
+    public static String getLocale(String localeName) {
+        Locale locale = new Locale(localeName,localeName);        
+        return locale.toString();        
+    }
+    
     public static List getLocales() {
         return locales;
     }
     
+    public static String getTimeZone(String timeZoneName) {
+        return TimeZone.getTimeZone(timeZoneName).getID();                
+    }
     
     public static List getTimeZones() {
         return timeZones;

Modified: roller/trunk/apps/weblogger/src/sql/400-to-410-migration.vm
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/sql/400-to-410-migration.vm?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/sql/400-to-410-migration.vm (original)
+++ roller/trunk/apps/weblogger/src/sql/400-to-410-migration.vm Sun Sep 14 19:49:10 2008
@@ -57,3 +57,13 @@
 update roller_weblogentrytag as w set 
     time = time,
     creator = (select u.username from rolleruser as u where u.id = w.userid);
+
+create table  roller_userattribute(
+    id        varchar(48) not null primary key,
+    username  varchar(255) not null,
+    attrname  varchar(255) not null,
+    attrvalue varchar(255) not null
+);    
+create index ua_username_idx  on roller_userattribute( username$!db.INDEXSIZE );
+create index ua_attrname_idx  on roller_userattribute( attrname$!db.INDEXSIZE );
+create index ua_attrvalue_idx on roller_userattribute( attrvalue$!db.INDEXSIZE );

Modified: roller/trunk/apps/weblogger/src/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/sql/createdb.vm?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/sql/createdb.vm (original)
+++ roller/trunk/apps/weblogger/src/sql/createdb.vm Sun Sep 14 19:49:10 2008
@@ -31,6 +31,16 @@
 );
 create index ur_username_idx on userrole( username$!db.INDEXSIZE );
 
+create table  roller_userattribute(
+    id        varchar(48) not null primary key,
+    username  varchar(255) not null,
+    attrname  varchar(255) not null,
+    attrvalue varchar(255) not null
+);    
+create index ua_username_idx  on roller_userattribute( username$!db.INDEXSIZE );
+create index ua_attrname_idx  on roller_userattribute( attrname$!db.INDEXSIZE );
+create index ua_attrvalue_idx on roller_userattribute( attrvalue$!db.INDEXSIZE );
+
 -- actions: comma separated list of actions permitted by permission
 -- objectid: for now this will always store weblogid
 -- objectType: for now this will always be 'Weblog'

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java (original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/CoreWeblogPlatformTestSuite.java Sun Sep 14 19:49:10 2008
@@ -38,6 +38,7 @@
 	
         // test users
         suite.addTestSuite(UserTest.class);
+        suite.addTestSuite(UserAttributeTest.class);
 
         // test weblogs
         suite.addTestSuite(WeblogTest.class);

Added: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserAttributeTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserAttributeTest.java?rev=695329&view=auto
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserAttributeTest.java (added)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserAttributeTest.java Sun Sep 14 19:49:10 2008
@@ -0,0 +1,83 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+*  contributor license agreements.  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.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+
+package org.apache.roller.weblogger.business;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.pojos.User;
+
+/**
+ * Test User related business operations.
+ */
+public class UserAttributeTest extends TestCase {    
+    public static Log log = LogFactory.getLog(UserAttributeTest.class);
+    
+    
+    public UserAttributeTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(UserAttributeTest.class);
+    }
+    
+    
+    public void setUp() throws Exception {
+        // setup weblogger
+        TestUtils.setupWeblogger();
+    }
+    
+    public void tearDown() throws Exception {
+    }
+    
+    
+    /**
+     * Test basic persistence operations ... Create, Update, Delete.
+     */
+    public void testUserAttributeCRUD() throws Exception {
+        log.debug("BEGIN");
+        User user = TestUtils.setupUser("auser");
+
+        UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
+        umgr.setUserAttribute(user.getUserName(), "testattname", "testattvalue");
+        TestUtils.endSession(true);
+        
+        assertEquals(user.getId(), umgr.getUserByAttribute("testattname", "testattvalue").getId());
+        
+        user = TestUtils.getManagedUser(user);
+        user.setEnabled(Boolean.FALSE);
+        umgr.saveUser(user);
+        TestUtils.endSession(true);
+        
+        assertNull(umgr.getUserByAttribute("testattname", "testattvalue"));
+        
+        TestUtils.teardownUser("auser");
+
+        assertEquals(0, umgr.getUserAttributes("auser").size());
+        
+        log.debug("END");
+    }
+}
+
+

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java?rev=695329&r1=695328&r2=695329&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java (original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/UserTest.java Sun Sep 14 19:49:10 2008
@@ -18,8 +18,6 @@
 
 package org.apache.roller.weblogger.business;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -27,8 +25,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.TestUtils;
-import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.pojos.User;
 



Mime
View raw message