JBoss Portal SVN: r5889 - in trunk: bridge cms cms/src/main/org/jboss/portal/cms/impl/jcr/command core identity registration search wsrp
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2006-12-18 11:10:11 -0500 (Mon, 18 Dec 2006)
New Revision: 5889
Added:
trunk/registration/.classpath
trunk/registration/.project
Modified:
trunk/bridge/
trunk/bridge/.classpath
trunk/cms/.classpath
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java
trunk/core/.classpath
trunk/identity/.classpath
trunk/search/
trunk/wsrp/.classpath
Log:
Eclipse files update
Property changes on: trunk/bridge
___________________________________________________________________
Name: svn:ignore
- output
+ output
bin
Modified: trunk/bridge/.classpath
===================================================================
--- trunk/bridge/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/bridge/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -12,5 +12,5 @@
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
<classpathentry combineaccessrules="false" kind="src" path="/jems"/>
<classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="output" path="output/classes"/>
</classpath>
Modified: trunk/cms/.classpath
===================================================================
--- trunk/cms/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/cms/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -38,5 +38,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
<classpathentry combineaccessrules="false" kind="src" path="/portlet"/>
<classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/identity"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ACLEnforcer.java 2006-12-18 16:10:11 UTC (rev 5889)
@@ -27,9 +27,9 @@
import java.util.HashSet;
import java.util.StringTokenizer;
-import org.jboss.portal.cms.impl.jcr.command.*;
-import org.jboss.portal.cms.impl.jcr.composite.*;
-import org.jboss.portal.cms.impl.jcr.*;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+import org.jboss.portal.cms.impl.jcr.composite.NewFileCommand;
+import org.jboss.portal.cms.impl.jcr.composite.UpdateFileCommand;
import org.jboss.portal.cms.security.AuthorizationProvider;
import org.jboss.portal.cms.security.PortalSecurityContext;
import org.jboss.portal.cms.security.SecurityContext;
Modified: trunk/core/.classpath
===================================================================
--- trunk/core/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/core/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -45,5 +45,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/identity"/>
<classpathentry combineaccessrules="false" kind="src" path="/format"/>
<classpathentry combineaccessrules="false" kind="src" path="/federation"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/registration"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: trunk/identity/.classpath
===================================================================
--- trunk/identity/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/identity/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -19,5 +19,8 @@
<classpathentry combineaccessrules="false" kind="src" path="/test"/>
<classpathentry kind="lib" path="/thirdparty/apache-directory/lib/apacheds-protocol-shared-1.0-RC4.jar"/>
<classpathentry kind="lib" path="/thirdparty/sun-opends/lib/OpenDS.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-microcontainer.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-dependency.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: trunk/registration/.classpath
===================================================================
--- trunk/registration/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/registration/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/common"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jems"/>
+ <classpathentry kind="lib" path="/thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/registration/.project
===================================================================
--- trunk/registration/.project 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/registration/.project 2006-12-18 16:10:11 UTC (rev 5889)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>registration</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/search
___________________________________________________________________
Name: svn:ignore
- Test
+ Test
output
test
Modified: trunk/wsrp/.classpath
===================================================================
--- trunk/wsrp/.classpath 2006-12-18 15:24:44 UTC (rev 5888)
+++ trunk/wsrp/.classpath 2006-12-18 16:10:11 UTC (rev 5889)
@@ -26,5 +26,7 @@
<classpathentry combineaccessrules="false" kind="src" path="/federation"/>
<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-xml-binding.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/jems"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/registration"/>
<classpathentry kind="output" path="output/classes"/>
</classpath>
19 years, 4 months
JBoss Portal SVN: r5888 - in trunk/search: . src/main/org/jboss/portal/search src/main/org/jboss/portal/search/federation src/main/org/jboss/portal/search/federation/impl src/main/org/jboss/portal/search/lucene src/main/org/jboss/portal/search/query src/main/org/jboss/portal/search/query/impl src/main/org/jboss/portal/search/result src/main/org/jboss/portal/search/result/impl src/main/org/jboss/portal/search/test
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2006-12-18 10:24:44 -0500 (Mon, 18 Dec 2006)
New Revision: 5888
Added:
trunk/search/src/main/org/jboss/portal/search/lucene/
trunk/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java
trunk/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java
trunk/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java
trunk/search/src/main/org/jboss/portal/search/query/impl/BetweenDatesTerm.java
trunk/search/src/main/org/jboss/portal/search/query/impl/DateTerm.java
trunk/search/src/main/org/jboss/portal/search/result/ResultURL.java
trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java
trunk/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
Removed:
trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java
trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
Modified:
trunk/search/
trunk/search/build.xml
trunk/search/src/main/org/jboss/portal/search/federation/Info.java
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
trunk/search/src/main/org/jboss/portal/search/query/Query.java
trunk/search/src/main/org/jboss/portal/search/result/Result.java
trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
Log:
Lucene implementation + tests
Property changes on: trunk/search
___________________________________________________________________
Name: svn:ignore
+ Test
Modified: trunk/search/build.xml
===================================================================
--- trunk/search/build.xml 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/build.xml 2006-12-18 15:24:44 UTC (rev 5888)
@@ -171,6 +171,7 @@
<x-test>
<test todir="${test.reports}" name="org.jboss.portal.search.test.LuceneQueryTest"/>
+ <test todir="${test.reports}" name="org.jboss.portal.search.test.FederationTest"/>
</x-test>
<x-classpath>
<pathelement location="${build.classes}"/>
@@ -178,6 +179,7 @@
<path refid="dom4j.dom4j.classpath"/>
<path refid="library.classpath"/>
<path refid="dependentmodule.classpath"/>
+ <path refid="oswego.concurrent.classpath"/>
</x-classpath>
</execute-tests>
</target>
Modified: trunk/search/src/main/org/jboss/portal/search/federation/Info.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/Info.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/federation/Info.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -57,8 +57,9 @@
public static final int STARTED = 0;
public static final int INDEXING = 1;
public static final int CORRUPTED = 2;
- public static final int UNAVAILABLE = 3;
- public static final int STOPPED = 4;
+ public static final int AVAILABLE = 3;
+ public static final int UNAVAILABLE = 4;
+ public static final int STOPPED = 5;
}
}
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederated.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -33,14 +33,38 @@
public interface SearchFederated
{
+ /**
+ * Get the ID for this federated search
+ * @return String representing this particular federated search
+ */
public String getId();
+ /**
+ * Method called when this federated search is not used anymore.
+ * This could be the place to destry any index
+ * @throws IndexingException
+ */
public void destroy() throws IndexingException;
+ /**
+ * The create method should index the required components
+ * @throws IndexingException
+ */
public void create() throws IndexingException;
+ /**
+ * Info should return information on the current status
+ * if the federated search
+ * @return
+ */
public Info getInfo();
+ /**
+ * From the query object this method is responsible to return the
+ * results of the query
+ * @param query
+ * @return
+ */
public Results search(Query query);
public String getMarkup(Results results, int markupLevel);
Modified: trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -39,7 +39,7 @@
public void reindexAll();
- public List getSearchFederated();
+ public List getSearchFederatedList();
public SearchFederated getSearchFederated(String id);
Modified: trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -90,7 +90,8 @@
while (it.hasNext())
{
SearchFederated federated = (SearchFederated) it.next();
- if (federated.getInfo().getStatus() != Info.Status.INDEXING)
+ int status = federated.getInfo().getStatus();
+ if (status != Info.Status.INDEXING)
{
Thread thread = new ReindexFederatedThread(federated);
thread.run();
@@ -115,7 +116,7 @@
{
federated.destroy();
federated.create();
- federated.getInfo().setStatus(Info.Status.STARTED);
+ federated.getInfo().setStatus(Info.Status.AVAILABLE);
}
catch (IndexingException e)
{
@@ -125,7 +126,7 @@
}
}
- public List getSearchFederated()
+ public List getSearchFederatedList()
{
return Collections.unmodifiableList(new ArrayList(registry.values()));
}
@@ -142,7 +143,10 @@
while (it.hasNext())
{
SearchFederated federated = (SearchFederated)it.next();
- results.addAll(federated.search(query));
+ if (federated.getInfo().getStatus() == Info.Status.AVAILABLE)
+ {
+ results.addAll(federated.search(query));
+ }
}
return results;
}
Added: trunk/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.lucene;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class GenericDocument
+{
+ private String title;
+
+ private long date;
+
+ private Map fields;
+
+ public Map getFields()
+ {
+ return fields;
+ }
+
+ public long getDate()
+ {
+ return date;
+ }
+
+ public void setDate(long date)
+ {
+ this.date = date;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public void addField(String name, String value)
+ {
+ if (fields == null)
+ {
+ fields = new HashMap();
+ }
+ fields.put(name, value);
+ }
+}
Added: trunk/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.lucene;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.query.QueryTerm;
+import org.jboss.portal.search.query.impl.BetweenDatesTerm;
+import org.jboss.portal.search.query.impl.DateTerm;
+import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.query.impl.KeywordQueryTerm;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQueryConverter
+{
+
+ public static String convert(Query query)
+ {
+ StringBuffer result = new StringBuffer();
+ Iterator it;
+
+ List terms = query.getMandatoryTerms();
+ if (terms != null)
+ {
+ it = terms.iterator();
+ while (it.hasNext())
+ {
+ QueryTerm term = (QueryTerm) it.next();
+ convert(result, term, "+");
+ }
+ }
+
+ terms = query.getNotTerms();
+ if (terms != null)
+ {
+ it = terms.iterator();
+ while (it.hasNext())
+ {
+ QueryTerm term = (QueryTerm) it.next();
+ convert(result, term, "-");
+ }
+ }
+
+ terms = query.getOptionalTerms();
+ if (terms != null)
+ {
+ it = terms.iterator();
+ while (it.hasNext())
+ {
+ QueryTerm term = (QueryTerm) it.next();
+ convert(result, term, "");
+ }
+ }
+ return result.toString();
+ }
+
+ private static void convert(StringBuffer result, QueryTerm term, String prefix)
+ {
+ if (term instanceof FieldQueryTerm)
+ {
+ FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
+ result.append(" " + prefix + convertedTerm.getName() + ":\"" + convertedTerm.getValue()+"\"");
+ }
+ else if (term instanceof KeywordQueryTerm)
+ {
+ KeywordQueryTerm convertedTerm = (KeywordQueryTerm) term;
+ result.append(" " + prefix + convertedTerm.getKeyWord());
+ }
+ else if (term instanceof BetweenDatesTerm)
+ {
+ BetweenDatesTerm convertedTerm = (BetweenDatesTerm) term;
+ result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getFromTime() + "," + convertedTerm.getToTime() + "]");
+ }
+ else if (term instanceof DateTerm)
+ {
+ DateTerm convertedTerm = (DateTerm) term;
+ result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getTime() + "," + (convertedTerm.getTime() + 24*60*60*1000) + "}");
+ }
+ }
+
+}
Added: trunk/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,183 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.lucene;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.federation.SearchFederated;
+import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.result.Results;
+import org.jboss.portal.search.result.impl.AbstractResult;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class LuceneSearchFederated implements SearchFederated
+{
+
+ private IndexWriter index;
+
+ private String id;
+
+ private Info info;
+
+ private String indexPath;
+
+ private String defaultField;
+
+ public LuceneSearchFederated(String id, String indexPath, String defaultField)
+ {
+ this.id = id;
+ this.indexPath = indexPath;
+ this.defaultField = defaultField;
+ info = new Info();
+ }
+
+ public void create() throws IndexingException
+ {
+
+ try
+ {
+ index = new IndexWriter(indexPath, new StandardAnalyzer(), true);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ info.setStatus(Info.Status.INDEXING);
+ try
+ {
+ List documents = getLuceneDocuments();
+ Iterator it = documents.iterator();
+ while (it.hasNext())
+ {
+ Document document = (Document)it.next();
+ index.addDocument(document);
+ }
+ index.optimize();
+ index.close();
+ }
+ catch (IOException e)
+ {
+ throw new IndexingException("Cannot index document", e);
+ }
+ info.setStatus(Info.Status.STARTED);
+ }
+
+ public List getLuceneDocuments()
+ {
+ List documents = getDocuments();
+ Iterator it = documents.iterator();
+ while (it.hasNext())
+ {
+ GenericDocument genericDoc = (GenericDocument) it.next();
+ Document doc = new Document();
+ if (genericDoc.getTitle() != null)
+ doc.add(Field.Text("title", genericDoc.getTitle()));
+ if (genericDoc.getDate() != 0)
+ doc.add(Field.Text("date", genericDoc.getDate()+""));
+ if (genericDoc.getFields() != null)
+ {
+ Map map = genericDoc.getFields();
+ Iterator itKeys = map.keySet().iterator();
+ while (itKeys.hasNext())
+ {
+ String key = (String)itKeys.next();
+ doc.add(Field.Text(key, (String)map.get(key)));
+ }
+ }
+ documents.add(doc);
+ }
+ return documents;
+ }
+
+ public abstract List getDocuments();
+
+ public void destroy()
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public Results search(Query query)
+ {
+ Results result = new Results();
+ String luceneQueryString = LuceneQueryConverter.convert(query);
+ QueryParser parser = new QueryParser(defaultField, new StandardAnalyzer());
+ try
+ {
+ org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
+ Searcher searcher = new IndexSearcher(indexPath);
+ Hits hits = searcher.search(luceneQuery);
+ for (int i=0; i<hits.length(); i++)
+ {
+ result.add(new SimpleResult(id, hits.doc(i)));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ public String getMarkup(Results results, int markupLevel)
+ {
+ StringBuffer buffer = new StringBuffer();
+ Iterator it = results.iterator();
+ while (it.hasNext())
+ {
+ AbstractResult result = (AbstractResult) it.next();
+ Document document = (Document)((SimpleResult)result).getValue();
+ buffer.append("Id:" + document.getField("id").stringValue());
+ buffer.append(" ");
+ }
+ return buffer.toString();
+ }
+
+}
Modified: trunk/search/src/main/org/jboss/portal/search/query/Query.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/Query.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/query/Query.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -27,6 +27,13 @@
/**
+ * The Query object is used to express a query.
+ * Common queries use mandatory terms, optional terms and missing terms.
+ * For instance you could do a query stating that you absolutely want
+ * the keyword 'Mustang' in your query, that the keyword 'car' is optional
+ * and could be used to show the results with the two keywords higher
+ * in the list and without the keyword 'horse'. In traditional search
+ * tools it would be represented as the string: "+mustang car -horse"
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
@@ -37,9 +44,11 @@
private List optionalTerms;
private List notTerms;
+ /*
private List mandatoryQueries;
private List optionalQueries;
private List notQueries;
+ */
public void addMandatoryTerm(QueryTerm term)
{
@@ -68,6 +77,7 @@
notTerms.add(term);
}
+ /*
public void addMandatoryQuery(Query query)
{
if (mandatoryQueries == null)
@@ -99,27 +109,27 @@
{
return mandatoryQueries;
}
-
+*/
public List getMandatoryTerms()
{
return mandatoryTerms;
}
-
+/*
public List getNotQueries()
{
return notQueries;
}
-
+*/
public List getNotTerms()
{
return notTerms;
}
-
+/*
public List getOptionalQueries()
{
return optionalQueries;
}
-
+*/
public List getOptionalTerms()
{
return optionalTerms;
Added: trunk/search/src/main/org/jboss/portal/search/query/impl/BetweenDatesTerm.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/impl/BetweenDatesTerm.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/query/impl/BetweenDatesTerm.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query.impl;
+
+import org.jboss.portal.search.query.QueryTerm;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class BetweenDatesTerm implements QueryTerm
+{
+ private String field;
+ private long fromTime;
+ private long toTime;
+
+ public BetweenDatesTerm(String field, long fromTime, long toTime)
+ {
+ this.field = field;
+ this.fromTime = fromTime;
+ this.toTime = toTime;
+ }
+
+ public String getField()
+ {
+ return field;
+ }
+
+ public long getFromTime()
+ {
+ return fromTime;
+ }
+
+ public long getToTime()
+ {
+ return toTime;
+ }
+}
Added: trunk/search/src/main/org/jboss/portal/search/query/impl/DateTerm.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/query/impl/DateTerm.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/query/impl/DateTerm.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query.impl;
+
+import org.jboss.portal.search.query.QueryTerm;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DateTerm implements QueryTerm
+{
+
+ public static final int BEFORE = 0;
+ public static final int AFTER = 1;
+ public static final int ON = 2;
+
+ private String field;
+ private long time;
+ private int temporal;
+
+ public DateTerm(String field, long time, int temporal)
+ {
+ this.field = field;
+ this.time = time;
+ this.temporal = temporal;
+ }
+
+ public String getField()
+ {
+ return field;
+ }
+
+ public int getTemporal()
+ {
+ return temporal;
+ }
+
+ public long getTime()
+ {
+ return time;
+ }
+
+}
Modified: trunk/search/src/main/org/jboss/portal/search/result/Result.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/result/Result.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -31,4 +31,6 @@
public float getScore();
public String getFederatedId();
+
+ public ResultURL getURL();
}
Added: trunk/search/src/main/org/jboss/portal/search/result/ResultURL.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/ResultURL.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/result/ResultURL.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface ResultURL
+{
+
+}
Modified: trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -23,6 +23,7 @@
package org.jboss.portal.search.result.impl;
import org.jboss.portal.search.result.Result;
+import org.jboss.portal.search.result.ResultURL;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -32,8 +33,22 @@
{
private String federatedId;
+ private String title;
+
private float score;
+ private ResultURL url;
+
+ public ResultURL getURL()
+ {
+ return url;
+ }
+
+ public void setURL(ResultURL url)
+ {
+ this.url = url;
+ }
+
public AbstractResult(String federatedId)
{
this.federatedId = federatedId;
@@ -54,4 +69,14 @@
this.score = score;
}
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
}
Modified: trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -47,5 +47,4 @@
this.value = value;
}
-
}
Added: trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result.impl;
+
+import org.jboss.portal.search.result.ResultURL;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SimpleResultURL implements ResultURL
+{
+ private String url;
+
+ public SimpleResultURL(String url)
+ {
+ this.url = url;
+ }
+
+ public String getURL()
+ {
+ return url;
+ }
+}
Modified: trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -46,6 +46,7 @@
public void create() throws IndexingException
{
info.setStatus(Info.Status.STARTED);
+ info.setStatus(Info.Status.AVAILABLE);
}
public void destroy() throws IndexingException
Modified: trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -23,7 +23,10 @@
package org.jboss.portal.search.test;
import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.lucene.LuceneQueryConverter;
+import org.jboss.portal.search.lucene.LuceneSearchFederated;
import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.query.impl.BetweenDatesTerm;
import org.jboss.portal.search.query.impl.FieldQueryTerm;
import org.jboss.portal.search.result.Results;
@@ -41,17 +44,28 @@
Query query = new Query();
query.addMandatoryTerm(new FieldQueryTerm("Title", "My Title"));
query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- assertEquals(" +Title:\"My Title\" +id:\"1\"", LuceneUtil.convert(query));
+ assertEquals(" +Title:\"My Title\" +id:\"1\"", LuceneQueryConverter.convert(query));
}
-
- public void test02() throws IndexingException
+
+ public void test02()
{
Query query = new Query();
+ query.addMandatoryTerm(new FieldQueryTerm("Title", "My Title"));
query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- SearchFederatedLucene fed = new SearchFederatedLucene();
+ query.addNotTerm(new BetweenDatesTerm("date", 10000, 20000));
+ assertEquals(" +Title:\"My Title\" +id:\"1\" -date:[10000,20000]", LuceneQueryConverter.convert(query));
+ }
+
+ public void test03() throws IndexingException
+ {
+ LuceneSearchFederated fed = new TestLuceneSearchFederated("TestSearch", "test", "id");
fed.create();
+
+ Query query = new Query();
+ query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
Results results = fed.search(query);
- assertEquals("Id:1 Id:1 test ", fed.getMarkup(results, 0));
+ System.out.println(fed.getMarkup(results, 0));
+ assertEquals("Id:1 Id:1 cat ", fed.getMarkup(results, 0));
}
}
Deleted: trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/test/LuceneUtil.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.test;
-
-import java.util.Iterator;
-
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.QueryTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneUtil
-{
-
- // TODO: actually do it...
- public static String convert(Query query)
- {
- StringBuffer result = new StringBuffer();
- Iterator it = query.getMandatoryTerms().iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- if (term instanceof FieldQueryTerm)
- {
- FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
- result.append(" +" + convertedTerm.getName() + ":\"" + convertedTerm.getValue()+"\"");
- }
- }
-
- return result.toString();
- }
-
-}
Deleted: trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/test/SearchFederatedLucene.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -1,145 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.test;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Searcher;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.federation.SearchFederated;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.Results;
-import org.jboss.portal.search.result.impl.AbstractResult;
-import org.jboss.portal.search.result.impl.SimpleResult;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class SearchFederatedLucene implements SearchFederated
-{
-
- private IndexWriter index;
-
- private String id;
-
- private Info info;
-
- public SearchFederatedLucene()
- {
- this.id = "Lucene Federated";
- info = new Info();
- try
- {
- index = new IndexWriter("Test", new StandardAnalyzer(), true);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- info.setStatus(Info.Status.STARTED);
- }
-
- public void create() throws IndexingException
- {
- info.setStatus(Info.Status.INDEXING);
- try
- {
- Document doc1 = new Document();
- doc1.add(Field.Keyword("id", "1"));
- index.addDocument(doc1);
- Document doc2 = new Document();
- doc2.add(Field.Text("id", "1 test"));
- index.addDocument(doc2);
- index.close();
- }
- catch (IOException e)
- {
- throw new IndexingException("Cannot index document", e);
- }
- info.setStatus(Info.Status.STARTED);
- }
-
- public void destroy()
- {
- info.setStatus(Info.Status.STOPPED);
- }
-
- public String getId()
- {
- return id;
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public Results search(Query query)
- {
- Results result = new Results();
- String luceneQueryString = LuceneUtil.convert(query);
- QueryParser parser = new QueryParser("all", new StandardAnalyzer());
- try
- {
- org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
- Searcher searcher = new IndexSearcher("Test");
- Hits hits = searcher.search(luceneQuery);
- for (int i=0; i<hits.length(); i++)
- {
- result.add(new SimpleResult(id, hits.doc(i)));
- }
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return result;
- }
-
- public String getMarkup(Results results, int markupLevel)
- {
- StringBuffer buffer = new StringBuffer();
- Iterator it = results.iterator();
- while (it.hasNext())
- {
- AbstractResult result = (AbstractResult) it.next();
- Document document = (Document)((SimpleResult)result).getValue();
- buffer.append("Id:" + document.getField("id").stringValue());
- buffer.append(" ");
- }
- return buffer.toString();
- }
-
-}
Added: trunk/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
===================================================================
--- trunk/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2006-12-18 03:03:27 UTC (rev 5887)
+++ trunk/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2006-12-18 15:24:44 UTC (rev 5888)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.jboss.portal.search.lucene.LuceneSearchFederated;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class TestLuceneSearchFederated extends LuceneSearchFederated
+{
+
+ public TestLuceneSearchFederated(String id, String indexPath, String defaultField)
+ {
+ super(id, indexPath, defaultField);
+ }
+
+ public List getLuceneDocuments()
+ {
+ List result = new ArrayList();
+
+ Document doc1 = new Document();
+ doc1.add(Field.Text("id", "1"));
+ result.add(doc1);
+
+ Document doc2 = new Document();
+ doc2.add(Field.Text("id", "1 cat"));
+ result.add(doc2);
+
+ return result;
+ }
+
+ public List getDocuments()
+ {
+ return null;
+ }
+
+}
19 years, 4 months
JBoss Portal SVN: r5887 - in trunk/core/src: main/org/jboss/portal/core/aspects/controller main/org/jboss/portal/core/portlet/dashboard resources/portal-core-war/WEB-INF/jsp/dashboard
by portal-commits@lists.jboss.org
Author: roy.russo(a)jboss.com
Date: 2006-12-17 22:03:27 -0500 (Sun, 17 Dec 2006)
New Revision: 5887
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
Log:
JBPORTAL-1140 - users can customize dashboards with layouts/theme
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-17 15:18:04 UTC (rev 5886)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/controller/PageCustomizerInterceptor.java 2006-12-18 03:03:27 UTC (rev 5887)
@@ -231,11 +231,14 @@
sb.append(" | ");
sb.append("<a href=\"").append(showadminURL).append("\">Admin</a>");
}
-/* else
+ else
{
- sb.append(" | ");
- sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
- }*/
+ if (!dashboard)
+ {
+ sb.append(" | ");
+ sb.append("<a href=\"").append(showDefaultURL).append("\">Main</a>");
+ }
+ }
if (dashboard)
{
@@ -251,16 +254,6 @@
sb.append(" | ");
- //inject CMS Admin link TODO: what is this?!
-/*
- if (user != null && showadminURL == null)
- {
- sb.append("<a href=\"").append("/portal/portal/cms").append("\">CMS Admin Tool</a>");
- }
-
- sb.append(" | ");
-*/
-
sb.append("<a href=\"").append(logoutURL).append("\">Logout</a>");
}
return sb;
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-17 15:18:04 UTC (rev 5886)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/dashboard/Configurator.java 2006-12-18 03:03:27 UTC (rev 5887)
@@ -32,6 +32,7 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.theme.LayoutService;
import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.ThemeService;
import org.jboss.portlet.JBossActionRequest;
@@ -176,14 +177,21 @@
layoutId = page.getProperty(ThemeConstants.PORTAL_PROP_LAYOUT);
}
PortalLayout currentLayout = layoutService.getLayout(layoutId, true);
- String themeId = page.getProperty(ThemeConstants.PORTAL_PROP_THEME);
+ String themeId = page.getDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME);
+ if (themeId == null)
+ {
+ themeId = page.getProperty(ThemeConstants.PORTAL_PROP_THEME);
+ }
+ PortalTheme currentTheme = themeService.getTheme(themeId, true);
+
// dispatch
req.setAttribute("available_instances", available_instances);
req.setAttribute("pages", pages);
req.setAttribute("currentPage", page.getName());
req.setAttribute("layouts", layouts);
req.setAttribute("currentLayout", currentLayout.getLayoutInfo().getName());
+ req.setAttribute("currentTheme", currentTheme.getThemeInfo().getName());
req.setAttribute("themes", themes);
if (errorMessage != null)
{
@@ -380,13 +388,13 @@
}
else if ("assignTheme".equals(op))
{
- String selectedLayout = actionRequest.getParameter("theme");
+ String selectedTheme = actionRequest.getParameter("theme");
- PortalLayout checkLayout = layoutService.getLayout(selectedLayout, true);
+ PortalTheme checkTheme = themeService.getTheme(selectedTheme, true);
- if (checkLayout != null)
+ if (checkTheme != null)
{
- page.setDeclaredProperty(ThemeConstants.PORTAL_PROP_LAYOUT, checkLayout.getLayoutInfo().getName());
+ page.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, checkTheme.getThemeInfo().getName());
}
actionResponse.setRenderParameter("editPageSelect", editPage);
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-17 15:18:04 UTC (rev 5886)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/dashboard/editpage.jsp 2006-12-18 03:03:27 UTC (rev 5887)
@@ -3,9 +3,7 @@
<%@ page import="org.jboss.portal.core.model.portal.Window" %>
<%@ page import="org.jboss.portal.theme.PortalLayout" %>
<%@ page import="org.jboss.portal.theme.PortalTheme" %>
-<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collection" %>
-<%@ page import="java.util.Collections" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
@@ -22,6 +20,7 @@
List pages = (List)request.getAttribute("pages");
Map windowMap = (Map)request.getAttribute("windowMap");
+ List regions = (List)request.getAttribute("regions");
String currentPage = (String)request.getAttribute("currentPage");
String currentLayout = (String)request.getAttribute("currentLayout");
@@ -84,15 +83,9 @@
<th colspan="2" class="portlet-section-header" align="center">Personal Dashboard Editor</th>
<tr>
<td class="portlet-section-body" align="center">
- <table width="500">
+ <table width="100%">
<tr>
- <td align="left">
- Use this tool to manage the content and appearance of your dashboard pages. <br/>
- You can control the page titles, column layouts, page themes,
- and add,
- order, or remove portlets.
- </td>
- <td>
+ <td width="250">
<table class="bottombuttonbar">
<tr>
<td align="left" valign="top"><b>Create a New Page:</b><br/>Page name:
@@ -107,6 +100,12 @@
</tr>
</table>
</td>
+ <td align="left" valign="top">
+ Use this tool to manage the content and appearance of your dashboard pages. <br/>
+ You can control the page titles, column layouts, page themes,
+ and add,
+ order, or remove portlets.
+ </td>
</tr>
</table>
</td>
@@ -166,8 +165,7 @@
</td>
</tr>
<tr>
- <td>
-
+ <td>Choose a layout:<br/>
<select name="layout">
<%
for (Iterator iterator = layouts.iterator(); iterator.hasNext();)
@@ -186,11 +184,14 @@
}
%>
</select> <input type="submit" class="portlet-form-button" name="Select" value="Select"
- onclick="switchLayout('assignLayout');"/>
+ onclick="switchLayout('assignLayout');"/>
</td>
</tr>
<tr>
- <td>
+ <td height="20"></td>
+ </tr>
+ <tr>
+ <td>Choose a theme:<br/>
<select name="theme">
<%
for (Iterator iterator = themes.iterator(); iterator.hasNext();)
@@ -209,9 +210,12 @@
}
%>
</select> <input type="submit" class="portlet-form-button" name="Select" value="Select"
- onclick="switchTheme('assignTheme');"/>
+ onclick="switchTheme('assignTheme');"/>
</td>
</tr>
+ <tr>
+ <td height="20"></td>
+ </tr>
</table>
</td>
<td class="portlet-section-body" valign="top" align="right"><b>Available Content</b><br/>
@@ -231,8 +235,6 @@
<td>
<table>
<%
- List regions = new ArrayList(windowMap.keySet());
- Collections.sort(regions);
for (Iterator i = regions.iterator(); i.hasNext();)
{
String region = (String)i.next();
19 years, 4 months
JBoss Portal SVN: r5885 - in trunk/identity/src: main/org/jboss/portal/identity main/org/jboss/portal/identity/auth main/org/jboss/portal/identity/config main/org/jboss/portal/identity/config/info main/org/jboss/portal/identity/config/metadata main/org/jboss/portal/identity/config/metadata/profile main/org/jboss/portal/identity/db main/org/jboss/portal/identity/experimental main/org/jboss/portal/identity/experimental/db main/org/jboss/portal/identity/info main/org/jboss/portal/identity/ldap
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-17 09:52:15 -0500 (Sun, 17 Dec 2006)
New Revision: 5885
Added:
trunk/identity/src/main/org/jboss/portal/identity/AnnonymousRole.java
trunk/identity/src/main/org/jboss/portal/identity/AnnonymousUser.java
trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity/UserProfileModule.java
trunk/identity/src/main/org/jboss/portal/identity/config/
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java
trunk/identity/src/main/org/jboss/portal/identity/config/info/
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java
trunk/identity/src/main/org/jboss/portal/identity/info/
trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java
trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/helper/
trunk/identity/src/main/org/jboss/portal/identity/service/
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java
Removed:
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java
trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java
trunk/identity/src/main/org/jboss/portal/identity/config/info/
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/
trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java
trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java
trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/helper/
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java
trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java
trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java
trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java
trunk/identity/src/main/org/jboss/portal/identity2/ProfileMap.java
trunk/identity/src/main/org/jboss/portal/identity2/Role.java
trunk/identity/src/main/org/jboss/portal/identity2/RoleModule.java
trunk/identity/src/main/org/jboss/portal/identity2/User.java
trunk/identity/src/main/org/jboss/portal/identity2/UserModule.java
trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java
trunk/identity/src/main/org/jboss/portal/identity2/config/
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/db/ProfileMapImpl.java
trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/
trunk/identity/src/main/org/jboss/portal/identity2/info/
trunk/identity/src/main/org/jboss/portal/identity2/ldap/
trunk/identity/src/main/org/jboss/portal/identity2/service/
Modified:
trunk/identity/src/main/org/jboss/portal/identity/Role.java
trunk/identity/src/main/org/jboss/portal/identity/RoleModule.java
trunk/identity/src/main/org/jboss/portal/identity/User.java
trunk/identity/src/main/org/jboss/portal/identity/UserModule.java
trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
trunk/identity/src/main/org/jboss/portal/identity/config/info/ProfileInfoSupport.java
trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigOptionMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigurationParser.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourceMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourcesMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaDataFactory.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModuleMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModulesMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupOptionMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedStringMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedValueMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingDatabaseMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingLDAPMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMetaData.java
trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java
trunk/identity/src/main/org/jboss/portal/identity/ldap/helper/LDAPTools.java
trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java
trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java
trunk/identity/src/resources/hibernate/domain-identity.hbm.xml
trunk/identity/src/resources/hibernate/domain.hbm.xml
trunk/identity/src/resources/test/config/standardidentity-config.xml
Log:
- plug in new identity modules
- correct API usages
(Still some stuff not working 100% ok)
Added: trunk/identity/src/main/org/jboss/portal/identity/AnnonymousRole.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/AnnonymousRole.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/AnnonymousRole.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,50 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnonymousRole implements Role
+{
+
+ public Object getId()
+ {
+ return new Long(0);
+ }
+
+ public String getName()
+ {
+ return "StandardAnnonymousPortalRole";
+ }
+
+ public String getDisplayName()
+ {
+ return "Portal Annonymous Role";
+ }
+
+ public void setDisplayName(String name)
+ {
+ //nothing
+ }
+}
Added: trunk/identity/src/main/org/jboss/portal/identity/AnnonymousUser.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/AnnonymousUser.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/AnnonymousUser.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,52 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.identity.User;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnnonymousUser implements User
+{
+
+ public Object getId()
+ {
+ return new Long(0);
+ }
+
+ public String getUserName()
+ {
+ return "StandardAnnonymousPortalUser";
+ }
+
+ public void updatePassword(String password)
+ {
+ //nothing
+ }
+
+ public boolean validatePassword(String password)
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/DelegatingUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,230 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.ldap.LDAPUserImpl;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityException;
+
+
+import javax.naming.InitialContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class DelegatingUserProfileModuleImpl extends UserProfileModuleService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(DelegatingUserProfileModuleImpl.class);
+
+ private String ldapModuleJNDIName;
+
+ private String dbModuleJNDIName;
+
+ private UserProfileModule LDAPModule;
+
+ private UserProfileModule dbModule;
+
+ protected void startService() throws Exception
+ {
+ super.startService();
+
+ if(getProfileInfo() == null)
+ {
+ throw new IdentityException("No profile information found. Check the configuration.");
+ }
+
+ //check if we don't delegate to ourselves:
+ if (getJndiName().equals(getDbModuleJNDIName()))
+ {
+ throw new IdentityException("Cannot delegate to itself - correct dbModuleJNDIName option");
+ }
+ if (getJndiName().equals(getLdapModuleJNDIName()))
+ {
+ throw new IdentityException("Cannot delegate to itself - correct ldapModuleJNDIName option");
+ }
+ }
+
+ public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("getProperty: " + propertyName);
+ try
+ {
+ PropertyInfo property = getProfileInfo().getPropertyInfo(propertyName);
+ if (property == null)
+ {
+ throw new IdentityException("Such property name is not supported");
+ }
+ else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
+ {
+ log.debug("Delegating to LDAP module");
+ return getLDAPModule().getProperty(user, propertyName);
+ }
+ else if (property.isMappedDB())
+ {
+ log.debug("Delegating to DB module");
+ return getDBModule().getProperty(user, propertyName);
+ }
+ throw new IdentityException("Cannot process property - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+ public void setProperty(User user, String name, Object propertyValue) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("setProperty: " + name + "/" + propertyValue);
+ try
+ {
+ PropertyInfo property = getProfileInfo().getPropertyInfo(name);
+ if (property == null)
+ {
+ throw new IdentityException("Such property name is not supported");
+ }
+ else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
+ {
+ log.debug("Delegating to LDAP module");
+ getLDAPModule().setProperty(user, name, propertyValue);
+ return;
+ }
+ else if (property.isMappedDB())
+ {
+ log.debug("Delegating to DB module");
+
+
+ Object val = null;
+ //if property is dynamic convert value to String first
+ if(property.getMappingDBType().equals(PropertyInfo.MAPPING_DB_TYPE_DYNAMIC))
+ {
+ val = propertyValue.toString();
+ }
+ else
+ {
+ val = propertyValue;
+ }
+
+ getDBModule().setProperty(user, name, val);
+ return;
+ }
+ throw new IdentityException("Cannot process property - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+ public Map getProperties(User user) throws IdentityException, IllegalArgumentException
+ {
+ if (log.isDebugEnabled()) log.debug("getProperties");//: " + name + "/" + propertyValue)
+ try
+ {
+ if (user instanceof LDAPUserImpl && isLDAPSupported())
+ {
+ log.debug("Delegating to LDAP module");
+ return getLDAPModule().getProperties(user);
+ }
+ else if (user instanceof HibernateUserImpl && isDBSupported())
+ {
+ log.debug("Delegating to DB module");
+ return getDBModule().getProperties(user);
+ }
+ throw new IdentityException("Cannot process properties - incorrect profile or module configuration");
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot resolve property: ", e);
+ }
+ }
+
+
+ public ProfileInfo getProfileInfo() throws IdentityException
+ {
+ return profileInfo;
+ }
+
+ public String getLdapModuleJNDIName()
+ {
+ return ldapModuleJNDIName;
+ }
+
+ public void setLdapModuleJNDIName(String ldapModuleJNDIName)
+ {
+ this.ldapModuleJNDIName = ldapModuleJNDIName;
+ }
+
+ public String getDbModuleJNDIName()
+ {
+ return dbModuleJNDIName;
+ }
+
+ public void setDbModuleJNDIName(String dbModuleJNDIName)
+ {
+ this.dbModuleJNDIName = dbModuleJNDIName;
+ }
+
+ public boolean isLDAPSupported()
+ {
+ return getLdapModuleJNDIName()!=null;
+ }
+
+ public boolean isDBSupported()
+ {
+ return getDbModuleJNDIName()!=null;
+ }
+
+ protected UserProfileModule getDBModule() throws Exception
+ {
+
+ //TODO: to tired to clean this at the moment
+ if (dbModule == null)
+ {
+ dbModule = (UserProfileModule)new InitialContext().lookup(getDbModuleJNDIName());
+ if (dbModule == null)
+ {
+ throw new IdentityException("Couldn't obtain DB UserProfileModule");
+ }
+ }
+ return dbModule;
+ }
+
+ protected UserProfileModule getLDAPModule() throws Exception
+ {
+ if (LDAPModule == null)
+ {
+ LDAPModule = (UserProfileModule)new InitialContext().lookup(getLdapModuleJNDIName());
+ if (LDAPModule == null)
+ {
+ throw new IdentityException("Couldn't obtain LDAP UserProfileModule");
+ }
+ }
+ return LDAPModule;
+ }
+
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityConfiguration.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,105 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityConfiguration
+{
+
+ //TODO: isMembershipAttributeRequired
+ //TODO: memebershipAttributeEmptyValue
+ //TODO: options for secured connection to ldap
+ //TODO: let decide if has should be in hex or base64
+
+ public static final String GROUP_COMMON = "common";
+
+ public static final String GROUP_CONNECTION = "connection";
+
+ public static final String GROUP_USER_CREATE_ATTRIBUTES = "userCreateAttibutes";
+
+ public static final String GROUP_ROLE_CREATE_ATTRIBUTES = "roleCreateAttibutes";
+
+ public static final String GROUP_USER_PROFILE_MAPPINGS = "userProfileMappings";
+
+ public static final String CONNECTION_NAME = "connection-name";
+
+ public static final String CONNECTION_CONTEXT_FACTORY = "context-factory";
+
+ public static final String CONNECTION_HOST = "host";
+
+ public static final String CONNECTION_PORT = "port";
+
+ public static final String CONNECTION_ADMIN_DN = "admin-dn";
+
+ public static final String CONNECTION_ADMIN_PASSWORD = "admin-password";
+
+ public static final String CONNECTION_AUTHENTICATION = "authentication";
+
+ public static final String USER_CONTAINER_DN = "userContainerDN";
+
+ public static final String USER_UID_ATTRIBUTE_ID = "uidAttributeID";
+
+ public static final String USER_PASSWORD_ATTRIBUTE_ID = "passwordAttributeID";
+
+ public static final String USER_EMAIL_ATTRIBUTE_ID = "emailAttributeID";
+
+ public static final String ROLE_CONTAINER_DN = "roleContainerDN";
+
+ public static final String ROLE_RID_ATTRIBUTE_ID = "ridAttributeID";
+
+ public static final String ROLE_DISPLAY_NAME_ATTRIBUTE_ID = "roleDisplayNameAttributeID";
+
+ public static final String MEMBERSHIP_ATTRIBUTE_ID = "membershipAttributeID";
+
+ public static final String MEMBERSHIP_ATTRIBUTE_IS_DN = "membershipAttributeIsDN";
+
+ public static final String HASH_ALGORITHM = "hashAlgorithm";
+
+ public static final String HASH_ENCODING = "hashEncoding";
+
+
+ public Set getValues(String optionGroup, String option);
+
+ public String getValue(String optionGroup, String option);
+
+ public String getValue(String option);
+
+ public void setValues(String optionGroup, String option, Set values);
+
+ public void addValue(String optionGroup, String option, String value);
+
+ public Map getOptions(String optionGroup);
+
+ public void setOptions(String optionGroup, Map options);
+
+ public void remoeOption(String optionGroup, String option);
+
+ public Map getOptionGroups();
+
+
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityContext.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,52 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.identity.IdentityException;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityContext
+{
+
+ //TODO: move to safe type enum
+ public static final String TYPE_USER_MODULE = "User";
+
+ public static final String TYPE_ROLE_MODULE = "Role";
+
+ public static final String TYPE_MEMBERSHIP_MODULE = "Membership";
+
+ public static final String TYPE_USER_PROFILE_MODULE = "UserProfile";
+
+ public static final String TYPE_CONNECTION_CONTEXT = "ConnectionContext";
+
+ public static final String TYPE_IDENTITY_CONFIGURATION = "IdentityConfiguration";
+
+
+ public void register(Object object, String name) throws IdentityException;
+
+ public void unregister(String name);
+
+ public Object getObject(String name) throws IdentityException;
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,106 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.IdentityContext;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Keeps references to all identity related modules to enable them interactions
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityContextImpl extends AbstractJBossService implements IdentityContext {
+ //private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityContextImpl.class);
+
+ private Map registry;
+
+ public IdentityContextImpl()
+ {
+ registry = new HashMap();
+ }
+
+ public void register(Object object, String name) throws IdentityException
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException("Cannot register null reference");
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Cannot register object with null name");
+ }
+
+ synchronized(this)
+ {
+ if (registry.containsKey(name))
+ {
+ throw new IdentityException("Name: " + name + " already registered.");
+ }
+ if (log.isDebugEnabled()) log.debug("registering object: " + name + " ; " + object.getClass());
+ registry.put(name, object);
+ }
+ }
+
+ public void unregister(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ synchronized(this)
+ {
+ if(registry.containsKey(name))
+ {
+ if (log.isDebugEnabled()) log.debug("unregistering object: " + name);
+
+ registry.remove(name);
+ }
+ }
+ }
+
+ public Object getObject(String name) throws IdentityException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+
+ //TODO:
+ synchronized(this)
+ {
+ if (registry.containsKey(name))
+ {
+ return registry.get(name);
+ }
+ else
+ {
+ throw new IdentityException("No such mapping in IdentityContext: " + name);
+ }
+ }
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceController.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,34 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.identity.IdentityContext;
+
+/**
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface IdentityServiceController
+{
+ public IdentityContext getIdentityContext();
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,579 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.jems.as.system.JBossServiceModelMBean;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityContextImpl;
+import org.jboss.portal.identity.IdentityServiceController;
+import org.jboss.portal.identity.config.metadata.IdentityConfigurationMetaData;
+import org.jboss.portal.identity.config.metadata.ModuleMetaData;
+import org.jboss.portal.identity.config.metadata.ConfigOptionMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupOptionMetaData;
+import org.jboss.portal.identity.config.metadata.DatasourceMetaData;
+import org.jboss.portal.identity.config.metadata.ConfigurationParser;
+import org.jboss.portal.identity.service.IdentityModuleService;
+import org.jboss.portal.identity.service.IdentityConfigurationService;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+
+import javax.management.ObjectName;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityServiceControllerImpl extends AbstractJBossService implements IdentityServiceController {
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityServiceControllerImpl.class);
+
+ private String jndiName;
+
+ protected JNDI.Binding jndiBinding;
+
+ private IdentityContext identityContext;
+
+ private boolean registerMBeans = true;
+
+ private String configFile;
+
+ private String defaultConfigFile;
+
+ /**
+ * .
+ */
+ protected Kernel kernel;
+
+ /**
+ * .
+ */
+ protected List beans;
+
+ protected void startService() throws Exception
+ {
+ if (jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ //initialize microcontainer stuff
+ try
+ {
+ BasicBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ kernel = bootstrap.getKernel();
+ beans = new ArrayList();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException(e);
+ }
+
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+ //TODO: make a dtd for config files.
+
+ //parse config files
+ IdentityConfigurationMetaData meta = ConfigurationParser.parseIdentityConfiguration(configFile);
+ IdentityConfigurationMetaData defaultMeta = ConfigurationParser.parseIdentityConfiguration(defaultConfigFile);
+
+ KernelControllerContext identityKernelContext;
+ try
+ {
+ AbstractBeanMetaData contextBMD = new AbstractBeanMetaData(
+ "portal:identity=IdentityContext",
+ IdentityContextImpl.class.getName());
+ beans.add(contextBMD);
+ identityKernelContext = kernel.getController().install(contextBMD);
+ identityContext = (IdentityContext)identityKernelContext.getTarget();
+
+ }
+ catch (Throwable throwable)
+ {
+ throw new IdentityException(throwable);
+ }
+
+ //TODO:update meta options using defaultMeta options
+
+ //create detault modules set
+
+ //Map[implementation] --> Map[Type] --> ModuleMetaData
+ Map defaultImplementations = new HashMap();
+
+ //update modules data with defaults
+ try
+ {
+ List defaultModules = defaultMeta.getModules().getModules();
+ for (Iterator iterator = defaultModules.iterator(); iterator.hasNext();)
+ {
+ ModuleMetaData module = (ModuleMetaData)iterator.next();
+
+ //check if defaults contains all information
+ if (module.getType() == null ||
+ module.getImplementation() == null ||
+ //module.getJndiName() == null ||
+ module.getServiceName() == null ||
+ module.getConfig() == null)
+ {
+ throw new IdentityException("Default module configuration must be complete");
+ }
+
+ //store them as maps for different implementations
+ String implType = module.getImplementation();
+ Map implementation;
+ if (defaultImplementations.containsKey(implType))
+ {
+ implementation = (Map)defaultImplementations.get(implType);
+ }
+ else
+ {
+ implementation = new HashMap();
+ }
+
+ //store per implementation
+ implementation.put(module.getType(), module);
+ defaultImplementations.put(implType, implementation);
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Error during processing default configuration file", e);
+ }
+
+ //map default datasources by name
+ Map defaultDatasources = new HashMap();
+ for (Iterator iterator = defaultMeta.getDatasources().getDatasources().iterator(); iterator.hasNext();)
+ {
+ DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
+ defaultDatasources.put(ds.getName(), ds);
+
+ }
+
+ //process the list of modules, instantiate them, configure them, tide them
+ try
+ {
+ List datasources = meta.getDatasources().getDatasources();
+ List modules = meta.getModules().getModules();
+
+ //inject configuration service
+ IdentityConfigurationService configuration = new IdentityConfigurationService(meta.getOptions());
+ configuration.setIdentityContext(identityContext);
+
+ //TODO:set proper jndiName and serviceName
+ configuration.start();
+
+ //update options with defaults
+ updateOptionsWithDefaults(configuration, defaultMeta.getOptions());
+
+ //process datasources
+ for (Iterator iterator = datasources.iterator(); iterator.hasNext();)
+ {
+ DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
+ if (log.isDebugEnabled()) log.debug("processing datasource: " + ds.getName() + "/" + ds.getClassName());
+ log.info("Installing datasourc: " + ds.getName());
+ updateDatasourceWithDefaults(ds, defaultDatasources);
+
+ //generate initial options
+ //TODO:presence of config tag should be forced in dtd
+ Map configOptions = ds.getConfig().getOptions();
+ Map optionMap = new HashMap();
+ for (Iterator iterator1 = configOptions.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionName = (String)iterator1.next();
+ ConfigOptionMetaData option = (ConfigOptionMetaData)configOptions.get(optionName);
+ optionMap.put(optionName, option.getValue());
+ }
+
+ //instantiate the module
+ //IdentityModuleService moduleService = null;
+
+
+ if (ds.getClassName() == null)
+ {
+ throw new IdentityException("Class name not found for datasource type: " + ds.getName() + " wrong configuration");
+ }
+
+ /*try
+ {
+ moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Unable to instantiate the class: " + module.getClassName() );
+ }*/
+
+ //instantiate datasource using MC
+ String entryName = "portal:identity=Datasource,type=" + ds.getName();
+ AbstractBeanMetaData dsBMD = new AbstractBeanMetaData(entryName,
+ ds.getClassName());
+ //AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData("identityContext", identityContext);
+ //moduleBMD.addProperty(propertyBMD);
+
+ //initiate parameters from <config>
+ for (Iterator iterator1 = optionMap.keySet().iterator(); iterator1.hasNext();)
+ {
+ String propertyKey = (String)iterator1.next();
+ String propertyValue = (String)optionMap.get(propertyKey);
+ if (log.isDebugEnabled()) log.debug("adding parameter: " + propertyKey + " ; " + propertyValue);
+ AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData(propertyKey, propertyValue);
+ dsBMD.addProperty(propertyBMD);
+ }
+
+ // Installation
+ beans.add(dsBMD);
+ KernelControllerContext controllerContext = kernel.getController().install(dsBMD);
+ Object datasource = controllerContext.getTarget();
+
+ //make a part of identityContext
+ //moduleService.setIdentityContext(identityContext);
+
+ //register as an mbean
+ if (isRegisterMBeans() && (ds.getServiceName() != null))
+ {
+ getServer().registerMBean(datasource, new ObjectName(ds.getServiceName()));
+ }
+
+
+ }
+
+
+
+ //process modules for instantiation
+ for (Iterator iterator = modules.iterator(); iterator.hasNext();)
+ {
+
+ ModuleMetaData module = (ModuleMetaData)iterator.next();
+ log.info("Processing module: " + module.getType() + "/" + module.getImplementation());// + "/" + module.getClassName());
+
+ updateModuleWithDefaults(module, defaultImplementations);
+
+ //generate initial options
+ Map configOptions = module.getConfig().getOptions();
+ Map optionMap = new HashMap();
+ for (Iterator iterator1 = configOptions.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionName = (String)iterator1.next();
+ ConfigOptionMetaData option = (ConfigOptionMetaData)configOptions.get(optionName);
+ optionMap.put(optionName, option.getValue());
+ }
+
+ //instantiate the module
+ //IdentityModuleService moduleService = null;
+
+
+ if (module.getClassName() == null)
+ {
+ throw new IdentityException("Class name not found for module type: " + module.getType() + " wrong configuration");
+ }
+
+ /*try
+ {
+ moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Unable to instantiate the class: " + module.getClassName() );
+ }*/
+
+ //instantiate module using MC
+ String entryName = "portal:identity=Module,type=" + module.getType();
+ AbstractBeanMetaData moduleBMD = new AbstractBeanMetaData(entryName,
+ module.getClassName());
+ AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData("identityContext", identityContext);
+ moduleBMD.addProperty(propertyBMD);
+
+ //initiate parameters from <config>
+ for (Iterator iterator1 = optionMap.keySet().iterator(); iterator1.hasNext();)
+ {
+ String propertyKey = (String)iterator1.next();
+ String propertyValue = (String)optionMap.get(propertyKey);
+ if (log.isDebugEnabled()) log.debug("adding parameter: " + propertyKey + " ; " + propertyValue);
+ propertyBMD = new AbstractPropertyMetaData(propertyKey, propertyValue);
+ moduleBMD.addProperty(propertyBMD);
+ }
+
+ //make the type from name
+ propertyBMD = new AbstractPropertyMetaData("moduleType", module.getType());
+ moduleBMD.addProperty(propertyBMD);
+
+
+ // Installation
+ beans.add(moduleBMD);
+ KernelControllerContext controllerContext = kernel.getController().install(moduleBMD);
+ Object moduleService = (IdentityModuleService)controllerContext.getTarget();
+
+ //make a part of identityContext
+ //moduleService.setIdentityContext(identityContext);
+
+ //register as an mbean
+ if (isRegisterMBeans() && (module.getServiceName() != null))
+ {
+ //getServer().registerMBean(moduleService, new ObjectName(module.getServiceName()));
+ JBossServiceModelMBean mbean = new JBossServiceModelMBean(moduleService);
+ //serviceName = new ObjectName("portal:container=WebApp,id=" + portletAppMD.getId());
+ //mbeanServer.registerMBean(mbean, serviceName);
+ getServer().registerMBean(mbean, new ObjectName(module.getServiceName()));
+
+ }
+ }
+
+
+ }
+ catch (Throwable e)
+ {
+ throw new IdentityException("Cannot initiate identity modules: ", e);
+ }
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ }
+
+
+
+
+ /**
+ * updates module with proper defaults
+ *
+ * @param module
+ * @param defaultModules
+ */
+ private void updateModuleWithDefaults(ModuleMetaData module, Map defaultModules)
+ {
+ if (module.getImplementation() == null)
+ {
+ return;
+ }
+ if (!defaultModules.containsKey(module.getImplementation()))
+ {
+ return;
+ }
+ Map modules = (Map)defaultModules.get(module.getImplementation());
+ if (!modules.containsKey(module.getType()))
+ {
+ return;
+ }
+ ModuleMetaData def = (ModuleMetaData)modules.get(module.getType());
+
+ if (module.getClassName() == null)
+ {
+ module.setClassName(def.getClassName());
+ }
+ if (module.getServiceName() == null)
+ {
+ module.setServiceName(def.getServiceName());
+ }
+
+ //now check if config options are overwritten
+ if (module.getConfig() == null)
+ {
+ module.setConfig(def.getConfig());
+ }
+ else
+ {
+ Map moduleOptions = module.getConfig().getOptions();
+ if (moduleOptions == null)
+ {
+ return;
+ }
+ Map defOptions = def.getConfig().getOptions();
+
+ for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ if (!moduleOptions.containsKey(key))
+ {
+ ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
+ module.getConfig().addOption(o);
+ }
+ }
+ }
+ }
+
+ /**
+ * updates module with proper defaults
+ */
+ private void updateDatasourceWithDefaults(DatasourceMetaData ds, Map defaultDS)
+ {
+ if (ds.getName() == null)
+ {
+ return;
+ }
+ if (!defaultDS.containsKey(ds.getName()))
+ {
+ return;
+ }
+ DatasourceMetaData def = (DatasourceMetaData)defaultDS.get(ds.getName());
+ if (ds.getClassName() == null)
+ {
+ ds.setClassName(def.getClassName());
+ }
+ if (ds.getServiceName() == null)
+ {
+ ds.setServiceName(def.getServiceName());
+ }
+
+ //now check if config options are overwritten
+ if (ds.getConfig() == null)
+ {
+ ds.setConfig(def.getConfig());
+ }
+ else
+ {
+ Map dsOptions = ds.getConfig().getOptions();
+ if (dsOptions == null)
+ {
+ return;
+ }
+ Map defOptions = def.getConfig().getOptions();
+
+ for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ if (!dsOptions.containsKey(key))
+ {
+ ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
+ ds.getConfig().addOption(o);
+ }
+ }
+ }
+ }
+
+ /**
+ * Check current options and update them with defaults if not exists;
+ *
+ * @param config
+ * @param defaults
+ */
+ public void updateOptionsWithDefaults(IdentityConfigurationService config, OptionsMetaData defaults)
+ {
+ //Map newGroups = new HashMap();
+ Map groups = defaults.getGroups();
+ for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
+ {
+ String groupKey = (String)iterator.next();
+
+ OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
+
+ if (config.getOptions(groupKey) == null)
+ {
+ config.setOptions(groupKey, new HashMap());
+ }
+
+ //Map newOptions = new HashMap();
+ Map options = group.getOptions();
+ for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionKey = (String)iterator1.next();
+
+ OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
+
+ if (config.getValues(groupKey, optionKey) == null)
+ {
+
+ //config.setValues(groupKey, optionKey, new HashSet());
+ config.setValues(groupKey, optionKey, option.getValues());
+ }
+
+
+ }
+ }
+
+ }
+
+
+ public IdentityContext getIdentityContext()
+ {
+ return identityContext;
+ }
+
+
+ public String getConfigFile()
+ {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile)
+ {
+ this.configFile = configFile;
+ }
+
+ public String getDefaultConfigFile()
+ {
+ return defaultConfigFile;
+ }
+
+ public void setDefaultConfigFile(String defaultConfigFile)
+ {
+ this.defaultConfigFile = defaultConfigFile;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public JNDI.Binding getJndiBinding()
+ {
+ return jndiBinding;
+ }
+
+ public void setJndiBinding(JNDI.Binding jndiBinding)
+ {
+ this.jndiBinding = jndiBinding;
+ }
+
+ public boolean isRegisterMBeans()
+ {
+ return registerMBeans;
+ }
+
+ public void setRegisterMBeans(boolean registerMBeans)
+ {
+ this.registerMBeans = registerMBeans;
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/MembershipModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity;
+
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MembershipModule
+{
+
+ //TODO: add isUserInRole method - it could gain better performance
+
+ /**
+ * Return the set of role objects that a given user has.
+ *
+ * @param user the user
+ * @return the set of roles of the specified user
+ */
+ Set getRoles(User user) throws IdentityException, IllegalArgumentException;
+
+ Set getUsers(Role role) throws IdentityException, IllegalArgumentException;
+
+
+ /**
+ * Creates a relationship beetween a role and set of users. Other roles that have assotiontions with
+ * those users remain unaffected.
+ *
+ * @param role
+ * @param users
+ * @throws IdentityException
+ */
+ void assignUsers(Role role, Set users) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Creates a relationship beetween a user and set of roles. This operation will erase any other assotientions
+ * beetween the user and roles not specified in the provided set.
+ *
+ * @param user
+ * @param roles
+ * @throws IdentityException
+ */
+ void assignRoles(User user, Set roles) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Returns role members based on rolename - depreciated method ethod here only for compatibility with
+ * old RoleModule interface
+ *
+ * @param roleName
+ * @param offset
+ * @param limit
+ * @deprecated
+ */
+ Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException, IllegalArgumentException;
+}
Modified: trunk/identity/src/main/org/jboss/portal/identity/Role.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/Role.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/Role.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.identity;
-import java.util.Set;
-
/**
* A role of users.
*
@@ -34,19 +32,14 @@
public interface Role
{
/** The role identifier. */
- Object getId();
+ public Object getId();
/** The role name used in security rules. This name can not be modified */
- String getName();
+ public String getName();
/** The role display name used on screens. This name can be modified */
- String getDisplayName();
+ public String getDisplayName();
- /**
- *
- */
- void setDisplayName(String name);
-
- /** The users. */
- Set getUsers();
+ /** */
+ public void setDisplayName(String name);
}
Modified: trunk/identity/src/main/org/jboss/portal/identity/RoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/RoleModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/RoleModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,6 +22,9 @@
******************************************************************************/
package org.jboss.portal.identity;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+
import java.util.Set;
/**
@@ -95,28 +98,5 @@
*/
Set findRoles() throws IdentityException;
- /**
- * Returns role members based on rolename
- *
- * @param roleName
- * @param offset
- * @param limit
- */
- Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException;
- /**
- * Assign a set of role objects to a given user.
- *
- * @param user the user
- * @param roles the user roles
- */
- void setRoles(User user, Set roles) throws IdentityException;
-
- /**
- * Return the set of role objects that a given user has.
- *
- * @param user the user
- * @return the set of roles of the specified user
- */
- Set getRoles(User user) throws IdentityException;
}
Modified: trunk/identity/src/main/org/jboss/portal/identity/User.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/User.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/User.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.identity;
+import org.jboss.portal.identity.ProfileMap;
+
import java.util.Date;
import java.util.Locale;
@@ -35,11 +37,8 @@
*/
public interface User
{
-
- String INFO_USER_REGISTRATION_DATE = "portal.user.registration-date";
- String INFO_USER_HOMEPAGE = "portal.user.homepage";
- String INFO_USER_TIME_ZONE_OFFSET = "portal.user.time-zone-offset";
- String INFO_USER_THEME = "portal.user.theme";
+ String INFO_USER_NAME_GIVEN = "portal.user.name.given";
+ String INFO_USER_NAME_FAMILY = "portal.user.name.family";
String INFO_USER_LOCATION = "portal.user.location";
String INFO_USER_OCCUPATION = "portal.user.occupation";
String INFO_USER_EXTRA = "portal.user.extra";
@@ -51,111 +50,31 @@
String INFO_USER_IM_MSNM = "portal.user.im.msnm";
String INFO_USER_IM_YIM = "portal.user.im.yim";
String INFO_USER_IM_SKYPE = "portal.user.im.skype";
+ String INFO_USER_HOMEPAGE = "portal.user.homepage";
+ String INFO_USER_TIME_ZONE_OFFSET = "portal.user.time-zone-offset";
+ String INFO_USER_THEME = "portal.user.theme";
String INFO_USER_SECURITY_QUESTION = "portal.user.security.question";
String INFO_USER_SECURITY_ANSWER = "portal.user.security.answer";
String INFO_USER_EMAIL_FAKE = "portal.user.email.fake";
String INFO_USER_VIEW_EMAIL_VIEW_REAL = "portal.user.email.view-real";
String INFO_USER_LAST_LOGIN_DATE = "portal.user.last-login-date";
+ String INFO_USER_REGISTRATION_DATE = "portal.user.registration-date";
- /** The user identifier. To safetly cast to String use .toString() method */
- Object getId();
+ String INFO_USER_ENABLED = "portal.user.enabled";
+ String INFO_USER_EMAIL_REAL = "portal.user.email.real";
- // User management **************************************************************************************************
- /** Disable the user. */
- boolean getEnabled();
- /** Enable the user. */
- void setEnabled(boolean enable);
- /** Set the password. */
- void updatePassword(String password);
+ /** The user identifier. */
+ public Object getId();
- /** Return true if the password is valid. */
- boolean validatePassword(String password);
-
- // Detyped access to properties *************************************************************************************
-
- /** Returns the user properties. */
- ProfileMap getProfile();
-
- // Properties declared in this interface for convenient access ******************************************************
-
/** The user name. */
- String getUserName();
+ public String getUserName();
- /** The given name (firstname). */
- String getGivenName();
+ /** Set the password using proper encoding. */
+ public void updatePassword(String password);
- /**
- *
- */
- void setGivenName(String givenName);
-
- /** The family name. */
- String getFamilyName();
-
- /**
- *
- */
- void setFamilyName(String familyName);
-
- /**
- *
- */
- String getRealEmail();
-
- /**
- *
- */
- void setRealEmail(String realEmail);
-
- /**
- *
- */
- String getFakeEmail();
-
- /**
- *
- */
- void setFakeEmail(String fakeEmail);
-
- /**
- *
- */
- Date getRegistrationDate();
-
- /**
- *
- */
- boolean getViewRealEmail();
-
- /**
- *
- */
- void setViewRealEmail(boolean viewRealEmail);
-
- /** Return the user preferred locale. */
- Locale getPreferredLocale();
-
- /** Set the user preferred locale. */
- void setPreferredLocale(Locale locale);
-
- /** Returns the signature. */
- String getSignature();
-
- /** Set the signature. */
- void setSignature(String signature);
-
- /** Return the last time the user logged in or null if this date is not known. */
- Date getLastVisitDate();
-
- /** Set the last visit date on this user. */
- void setLastVisitDate(Date date);
-
- /** Return the theme set for this user as the app id of the Theme. */
- String getTheme();
-
- /** Set the theme for this user. */
- void setTheme(String themeId);
+ /** Return true if the password is valid. */
+ public boolean validatePassword(String password);
}
Modified: trunk/identity/src/main/org/jboss/portal/identity/UserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/UserModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/UserModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,6 +22,10 @@
******************************************************************************/
package org.jboss.portal.identity;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.User;
+
import java.util.Set;
/**
@@ -62,7 +66,7 @@
* @param userName
* @return the user
*/
- User createUser(String userName, String password, String realEmail) throws IdentityException, IllegalArgumentException;
+ User createUser(String userName, String password) throws IdentityException, IllegalArgumentException;
/**
* Remove a user.
Copied: trunk/identity/src/main/org/jboss/portal/identity/UserProfileModule.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/UserProfileModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.User;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface UserProfileModule
+{
+
+ public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException;
+
+ public void setProperty(User user, String name, Object property) throws IdentityException, IllegalArgumentException;
+
+ public Map getProperties(User user) throws IdentityException, IllegalArgumentException;
+
+ public ProfileInfo getProfileInfo() throws IdentityException;
+
+}
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -20,14 +20,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.legacy_identity.auth;
+package org.jboss.portal.identity.auth;
import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.legacy_identity.NoSuchUserException;
-import org.jboss.portal.legacy_identity.Role;
-import org.jboss.portal.legacy_identity.RoleModule;
-import org.jboss.portal.legacy_identity.User;
-import org.jboss.portal.legacy_identity.UserModule;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.MembershipModule;
import org.jboss.security.SimpleGroup;
import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
@@ -55,6 +56,7 @@
protected String userModuleJNDIName;
protected String roleModuleJNDIName;
+ protected String membershipModuleJNDIName;
protected String additionalRole;
protected String havingRole;
@@ -65,18 +67,21 @@
// Get data
userModuleJNDIName = (String)options.get("userModuleJNDIName");
roleModuleJNDIName = (String)options.get("roleModuleJNDIName");
+ membershipModuleJNDIName = (String)options.get("membershipModuleJNDIName");
additionalRole = (String)options.get("additionalRole");
havingRole = (String)options.get("havingRole");
// Some info
log.trace("userModuleJNDIName = " + userModuleJNDIName);
log.trace("roleModuleJNDIName = " + roleModuleJNDIName);
+ log.trace("membershipModuleJNDIName = " + membershipModuleJNDIName);
log.trace("additionalRole = " + additionalRole);
log.trace("havingRole = " + havingRole);
}
private UserModule userModule;
private RoleModule roleModule;
+ private MembershipModule membershipModule;
protected UserModule getUserModule() throws NamingException
{
@@ -97,6 +102,16 @@
return roleModule;
}
+ protected MembershipModule getMembershipModule() throws NamingException
+ {
+
+ if (membershipModule == null)
+ {
+ membershipModule = (MembershipModule)new InitialContext().lookup(membershipModuleJNDIName);
+ }
+ return membershipModule;
+ }
+
protected String getUsersPassword() throws LoginException
{
return "";
@@ -122,7 +137,7 @@
if (havingRole != null)
{
boolean hasTheRole = false;
- Set roles = getRoleModule().getRoles(user);
+ Set roles = getMembershipModule().getRoles(user);
for (Iterator i = roles.iterator(); i.hasNext();)
{
Role role = (Role)i.next();
@@ -176,7 +191,7 @@
try
{
User user = getUserModule().findUserByUserName(getUsername());
- Set roles = getRoleModule().getRoles(user);
+ Set roles = getMembershipModule().getRoles(user);
//
Group rolesGroup = new SimpleGroup("Roles");
Copied: trunk/identity/src/main/org/jboss/portal/identity/config (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/config)
Deleted: trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,318 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.config;
-
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.UnmarshallerFactory;
-
-import java.util.Map;
-import java.util.Set;
-import java.net.URL;
-import java.io.InputStream;
-
-/**
- * Immutable object storing options in simple manner
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class SimpleConfigurationImpl extends AbstractJBossService implements IdentityConfiguration
-{
-
- private Map data;
-
- private String jndiName;
-
- private String configFile;
-
- protected JNDI.Binding jndiBinding;
-
- private IdentityContext identityContext;
-
- protected void startService() throws Exception
- {
-
-
- try
- {
- log.info("Processing portal identity configuration");
- log.debug("config file: " + configFile);
- URL config = Thread.currentThread().getContextClassLoader().getResource(configFile);
- InputStream in = config.openStream();
- // create unmarshaller
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
-
- // create an instance of ObjectModelFactory
- ObjectModelFactory factory = new SimpleIdentityConfigurationFactory();
-
- // let the object model factory to create an instance of Map and populate it with data from XML
- data = (Map)unmarshaller.unmarshal(in, factory, null);
-
- // close the XML stream
- in.close();
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot parse configuration file", e);
- }
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- identityContext.register(this, IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
-
-
- }
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- identityContext.unregister(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
-
- }
-
-
-
- public Set getValues(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- return (Set)group.get(option);
- }
- }
- return null;
- }
-
- public String getValue(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- Set values = (Set)group.get(option);
- if (values.size() > 0)
- {
- return (String)values.toArray()[0];
- }
- }
- }
- return null;
- }
-
- public String getValue(String option)
- {
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(GROUP_COMMON))
- {
- Map group = (Map)data.get(GROUP_COMMON);
- if (group.containsKey(option))
- {
- Set values = (Set)group.get(option);
- if (values.size() > 0)
- {
- return (String)values.toArray()[0];
- }
- }
- }
- return null;
- }
-
- public void setValues(String optionGroup, String option, Set values)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (values == null)
- {
- throw new IllegalArgumentException("null values list");
- }
- if (data.containsKey(optionGroup))
- {
- ((Map)data.get(optionGroup)).put(option, values);
- }
- }
-
- public void addValue(String optionGroup, String option, String value)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("null value name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- ((Set)group.get(option)).add(value);
- }
- }
- }
-
- public Map getOptions(String optionGroup)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (data.containsKey(optionGroup))
- {
- return (Map)data.get(optionGroup);
- }
- return null;
- }
-
- public void setOptions(String optionGroup, Map options)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (options == null)
- {
- throw new IllegalArgumentException("null options map");
- }
- data.put(optionGroup,options);
- }
-
- public void remoeOption(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- ((Map)data.get(optionGroup)).put(option, null);
- }
- }
-
-
- public void setData(Map data)
- {
- this.data = data;
- }
-
- public Map getOptionGroups()
- {
- return data;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public String getConfigFile()
- {
- return configFile;
- }
-
- public void setConfigFile(String configFile)
- {
- this.configFile = configFile;
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleConfigurationImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/SimpleConfigurationImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,318 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.config;
+
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+import java.util.Map;
+import java.util.Set;
+import java.net.URL;
+import java.io.InputStream;
+
+/**
+ * Immutable object storing options in simple manner
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleConfigurationImpl extends AbstractJBossService implements IdentityConfiguration
+{
+
+ private Map data;
+
+ private String jndiName;
+
+ private String configFile;
+
+ protected JNDI.Binding jndiBinding;
+
+ private IdentityContext identityContext;
+
+ protected void startService() throws Exception
+ {
+
+
+ try
+ {
+ log.info("Processing portal identity configuration");
+ log.debug("config file: " + configFile);
+ URL config = Thread.currentThread().getContextClassLoader().getResource(configFile);
+ InputStream in = config.openStream();
+ // create unmarshaller
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ // create an instance of ObjectModelFactory
+ ObjectModelFactory factory = new SimpleIdentityConfigurationFactory();
+
+ // let the object model factory to create an instance of Map and populate it with data from XML
+ data = (Map)unmarshaller.unmarshal(in, factory, null);
+
+ // close the XML stream
+ in.close();
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot parse configuration file", e);
+ }
+
+ //
+ if (jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ if (identityContext == null)
+ {
+ throw new IdentityException("Cannot register module in context - missing reference");
+ }
+ else
+ {
+ identityContext.register(this, IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+
+
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ if (identityContext == null)
+ {
+ log.error("Cannot unregister module in context - missing reference");
+ }
+ else
+ {
+ identityContext.unregister(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+
+ }
+
+
+
+ public Set getValues(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ return (Set)group.get(option);
+ }
+ }
+ return null;
+ }
+
+ public String getValue(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ Set values = (Set)group.get(option);
+ if (values.size() > 0)
+ {
+ return (String)values.toArray()[0];
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getValue(String option)
+ {
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(GROUP_COMMON))
+ {
+ Map group = (Map)data.get(GROUP_COMMON);
+ if (group.containsKey(option))
+ {
+ Set values = (Set)group.get(option);
+ if (values.size() > 0)
+ {
+ return (String)values.toArray()[0];
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setValues(String optionGroup, String option, Set values)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (values == null)
+ {
+ throw new IllegalArgumentException("null values list");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ ((Map)data.get(optionGroup)).put(option, values);
+ }
+ }
+
+ public void addValue(String optionGroup, String option, String value)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("null value name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ ((Set)group.get(option)).add(value);
+ }
+ }
+ }
+
+ public Map getOptions(String optionGroup)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ return (Map)data.get(optionGroup);
+ }
+ return null;
+ }
+
+ public void setOptions(String optionGroup, Map options)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (options == null)
+ {
+ throw new IllegalArgumentException("null options map");
+ }
+ data.put(optionGroup,options);
+ }
+
+ public void remoeOption(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ ((Map)data.get(optionGroup)).put(option, null);
+ }
+ }
+
+
+ public void setData(Map data)
+ {
+ this.data = data;
+ }
+
+ public Map getOptionGroups()
+ {
+ return data;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public String getConfigFile()
+ {
+ return configFile;
+ }
+
+ public void setConfigFile(String configFile)
+ {
+ this.configFile = configFile;
+ }
+
+ public IdentityContext getIdentityContext()
+ {
+ return identityContext;
+ }
+
+ public void setIdentityContext(IdentityContext identityContext)
+ {
+ this.identityContext = identityContext;
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleIdentityConfigurationFactory.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,117 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.config;
-
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.jboss.xb.binding.GenericObjectModelFactory;
-import org.xml.sax.Attributes;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class SimpleIdentityConfigurationFactory implements GenericObjectModelFactory
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(SimpleIdentityConfigurationFactory.class);
-
- String currentGroupName;
-
- String currentOptionName;
-
- public Object newRoot(Object object, UnmarshallingContext unmarshallingContext, String string, String string1, Attributes attributes)
- {
- return new HashMap();
- }
-
- public Object completeRoot(Object root, UnmarshallingContext unmarshallingContext, String string, String string1)
- {
- return root;
- }
-
- public Object newChild(Object root, UnmarshallingContext nav, String nsURI, String localName, Attributes attrs)
- {
- //return a new map for group options
- if ("option-group".equals(localName))
- {
- return new HashMap();
- }
- //return list for option values
- if ("option".equals(localName))
- {
- return new HashSet();
- }
- if (root instanceof Set)
- {
- if ("value".equals(localName))
- {
- return root;
- }
- }
- return null;
- }
-
- public void addChild(Object parent, Object child, UnmarshallingContext nav, String nsURI, String localName)
- {
- if (child instanceof Set && parent instanceof Map)
- {
- if ("option".equals(localName))
- {
- ((Map)parent).put(this.currentOptionName, child);
- }
- }
- if (child instanceof Map && parent instanceof Map)
- {
- if ("option-group".equals(localName))
- {
- ((Map)parent).put(this.currentGroupName, child);
- }
- }
- }
-
- public void setValue(Object object, UnmarshallingContext unmarshallingContext, String nsUri, String localName, String value)
- {
- if(object instanceof Map)
- {
- if ("group-name".equals(localName))
- {
- this.currentGroupName = value;
- }
- }
- if(object instanceof Set)
- {
- if ("name".equals(localName))
- {
- this.currentOptionName = value;
- }
- if ("value".equals(localName))
- {
- Set option = (Set)object;
- option.add(value);
- }
- }
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleIdentityConfigurationFactory.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/SimpleIdentityConfigurationFactory.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/SimpleIdentityConfigurationFactory.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,117 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.config;
+
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.jboss.xb.binding.GenericObjectModelFactory;
+import org.xml.sax.Attributes;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleIdentityConfigurationFactory implements GenericObjectModelFactory
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(SimpleIdentityConfigurationFactory.class);
+
+ String currentGroupName;
+
+ String currentOptionName;
+
+ public Object newRoot(Object object, UnmarshallingContext unmarshallingContext, String string, String string1, Attributes attributes)
+ {
+ return new HashMap();
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext unmarshallingContext, String string, String string1)
+ {
+ return root;
+ }
+
+ public Object newChild(Object root, UnmarshallingContext nav, String nsURI, String localName, Attributes attrs)
+ {
+ //return a new map for group options
+ if ("option-group".equals(localName))
+ {
+ return new HashMap();
+ }
+ //return list for option values
+ if ("option".equals(localName))
+ {
+ return new HashSet();
+ }
+ if (root instanceof Set)
+ {
+ if ("value".equals(localName))
+ {
+ return root;
+ }
+ }
+ return null;
+ }
+
+ public void addChild(Object parent, Object child, UnmarshallingContext nav, String nsURI, String localName)
+ {
+ if (child instanceof Set && parent instanceof Map)
+ {
+ if ("option".equals(localName))
+ {
+ ((Map)parent).put(this.currentOptionName, child);
+ }
+ }
+ if (child instanceof Map && parent instanceof Map)
+ {
+ if ("option-group".equals(localName))
+ {
+ ((Map)parent).put(this.currentGroupName, child);
+ }
+ }
+ }
+
+ public void setValue(Object object, UnmarshallingContext unmarshallingContext, String nsUri, String localName, String value)
+ {
+ if(object instanceof Map)
+ {
+ if ("group-name".equals(localName))
+ {
+ this.currentGroupName = value;
+ }
+ }
+ if(object instanceof Set)
+ {
+ if ("name".equals(localName))
+ {
+ this.currentOptionName = value;
+ }
+ if ("value".equals(localName))
+ {
+ Set option = (Set)object;
+ option.add(value);
+ }
+ }
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/config/info (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/config/info)
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/info/ProfileInfoSupport.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/info/ProfileInfoSupport.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/info/ProfileInfoSupport.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,12 +19,12 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.info;
+package org.jboss.portal.identity.config.info;
-import org.jboss.portal.identity2.info.ProfileInfo;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity2.config.metadata.profile.ProfileMetaData;
-import org.jboss.portal.identity2.config.metadata.profile.PropertyMetaData;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.config.metadata.profile.ProfileMetaData;
+import org.jboss.portal.identity.config.metadata.profile.PropertyMetaData;
import org.jboss.portal.identity.IdentityException;
import java.util.Map;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/info/PropertyInfoSupport.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/info/PropertyInfoSupport.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,11 +19,11 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.info;
+package org.jboss.portal.identity.config.info;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity2.config.metadata.profile.PropertyMetaData;
-import org.jboss.portal.identity2.config.metadata.profile.LocalizedValueMetaData;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.config.metadata.profile.PropertyMetaData;
+import org.jboss.portal.identity.config.metadata.profile.LocalizedValueMetaData;
import org.jboss.portal.common.util.LocalizedString;
import org.jboss.portal.identity.IdentityException;
import org.jboss.logging.Logger;
Copied: trunk/identity/src/main/org/jboss/portal/identity/config/metadata (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/config/metadata)
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ConfigMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import java.util.Map;
import java.util.HashMap;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigOptionMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ConfigOptionMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigOptionMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigurationParser.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ConfigurationParser.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ConfigurationParser.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,10 +19,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
-import org.jboss.portal.identity2.config.metadata.profile.ProfileMetaData;
-import org.jboss.portal.identity2.config.metadata.profile.ProfileMetaDataFactory;
+import org.jboss.portal.identity.config.metadata.profile.ProfileMetaData;
+import org.jboss.portal.identity.config.metadata.profile.ProfileMetaDataFactory;
import org.jboss.portal.identity.IdentityException;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourceMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/DatasourceMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourceMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourcesMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/DatasourcesMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/DatasourcesMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import java.util.List;
import java.util.LinkedList;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/IdentityConfigurationMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,11 +19,8 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
-import java.util.Map;
-import java.util.HashMap;
-
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaDataFactory.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/IdentityConfigurationMetaDataFactory.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/IdentityConfigurationMetaDataFactory.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,20 +19,20 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import org.jboss.xb.binding.GenericObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
-import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaData;
-import org.jboss.portal.identity2.config.metadata.ModulesMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
-import org.jboss.portal.identity2.config.metadata.ModuleMetaData;
-import org.jboss.portal.identity2.config.metadata.ConfigMetaData;
-import org.jboss.portal.identity2.config.metadata.ConfigOptionMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
-import org.jboss.portal.identity2.config.metadata.DatasourcesMetaData;
-import org.jboss.portal.identity2.config.metadata.DatasourceMetaData;
+import org.jboss.portal.identity.config.metadata.IdentityConfigurationMetaData;
+import org.jboss.portal.identity.config.metadata.ModulesMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity.config.metadata.ModuleMetaData;
+import org.jboss.portal.identity.config.metadata.ConfigMetaData;
+import org.jboss.portal.identity.config.metadata.ConfigOptionMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupOptionMetaData;
+import org.jboss.portal.identity.config.metadata.DatasourcesMetaData;
+import org.jboss.portal.identity.config.metadata.DatasourceMetaData;
import org.xml.sax.Attributes;
/**
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModuleMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModuleMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModuleMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModulesMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/ModulesMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/ModulesMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,10 +19,8 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
-import java.util.Map;
-import java.util.HashMap;
import java.util.List;
import java.util.LinkedList;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/OptionsGroupMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import java.util.Map;
import java.util.HashMap;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupOptionMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/OptionsGroupOptionMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsGroupOptionMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import java.util.Set;
import java.util.HashSet;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/OptionsMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/OptionsMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata;
+package org.jboss.portal.identity.config.metadata;
import java.util.Map;
import java.util.HashMap;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedStringMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/LocalizedStringMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedStringMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
import java.util.List;
import java.util.ArrayList;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedValueMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/LocalizedValueMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/LocalizedValueMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
import java.util.Locale;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/ProfileMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
import java.util.Map;
import java.util.HashMap;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/ProfileMetaDataFactory.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/ProfileMetaDataFactory.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
import org.jboss.xb.binding.GenericObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingDatabaseMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/PropertyMappingDatabaseMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingDatabaseMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingLDAPMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/PropertyMappingLDAPMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingLDAPMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/PropertyMappingMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMappingMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMetaData.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/config/metadata/profile/PropertyMetaData.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/config/metadata/profile/PropertyMetaData.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.config.metadata.profile;
+package org.jboss.portal.identity.config.metadata.profile;
/**
Deleted: trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,419 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.legacy_identity.db;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.criterion.Restrictions;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.legacy_identity.IdentityException;
-import org.jboss.portal.legacy_identity.Role;
-import org.jboss.portal.legacy_identity.RoleModule;
-import org.jboss.portal.legacy_identity.User;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import javax.naming.InitialContext;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision$
- * @portal.core
- */
-public class DBRoleModuleImpl
- extends AbstractJBossService
- implements RoleModule
-{
-
- /** . */
- private final Logger log = Logger.getLogger(getClass());
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String jndiName;
-
- /** . */
- protected JNDI.Binding jndiBinding;
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public SessionFactory getSessionFactory()
- {
- return sessionFactory;
- }
-
- public String getJNDIName()
- {
- return jndiName;
- }
-
- public void setJNDIName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
- }
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- //
- sessionFactory = null;
- }
-
- public Role findRoleByName(String name) throws IdentityException
- {
- if (name != null)
- {
- try
- {
- Session session = getCurrentSession();
- Criteria criteria = session.createCriteria(RoleImpl.class);
- criteria.add(Restrictions.naturalId().set("name", name));
- criteria.setCacheable(true);
- RoleImpl role = (RoleImpl)criteria.uniqueResult();
- if (role == null)
- {
- throw new IdentityException("No such role " + name);
- }
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by name " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Set findRolesByNames(String[] names) throws IdentityException
- {
- if (names != null)
- {
- try
- {
- Session session = getCurrentSession();
- StringBuffer queryString = new StringBuffer("from RoleImpl as g where g.name=?");
- for (int i = 1; i < names.length; i++)
- {
- queryString.append(" or g.name=?");
- }
- Query query = session.createQuery(queryString.toString());
- for (int i = 0; i < names.length; i++)
- {
- query.setString(i, names[i]);
- }
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findRoleById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public Role findRoleById(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- RoleImpl role = (RoleImpl)session.get(RoleImpl.class, (Long)id);
- if (role == null)
- {
- throw new IdentityException("No role found for " + id);
- }
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Role createRole(String name, String displayName) throws IdentityException
- {
- if (name != null)
- {
- try
- {
- RoleImpl role = new RoleImpl(name, displayName);
- Session session = getCurrentSession();
- session.save(role);
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create role " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeRole(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- RoleImpl role = (RoleImpl)session.load(RoleImpl.class, (Long)id);
- Iterator users = role.getUsers().iterator();
- while (users.hasNext())
- {
- UserImpl user = (UserImpl)users.next();
- user.getRoles().remove(role);
- }
- session.delete(role);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove role " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public int getRolesCount() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(g.id) from RoleImpl as g");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findRoles() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from RoleImpl");
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- if (roleName != null)
- {
- try
- {
- Session session = getCurrentSession();
-
- UserImpl userimpl = new UserImpl();
- userimpl.setEnabled(true);
-
- Query query;
- if (userNameFilter.trim().length() != 0)
- {
- //
- userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-
- //
- query = session.createQuery("from UserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
- query.setString("filter", userNameFilter);
- }
- else
- {
- query = session.createQuery("from UserImpl as user left join user.roles role where role.name=:name");
- }
- query.setString("name", roleName);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
-
- Iterator iterator = query.iterate();
- Set result = Tools.toSet(iterator);
-
- Set newResult = new HashSet();
- Iterator cleaner = result.iterator();
- while (cleaner.hasNext())
- {
- Object[] oArr = (Object[])cleaner.next();
- newResult.add(oArr[0]);
- }
-
- return newResult;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role " + roleName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- }
-
- public void setRoles(User user, Set roles) throws IdentityException
- {
- if (!(user instanceof UserImpl))
- {
- throw new IllegalArgumentException("User is not a db user");
- }
-
- // We make a defensive copy and update with a new set
- Set copy = new HashSet();
- for (Iterator i = roles.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof RoleImpl)
- {
- copy.add(o);
- }
- else
- {
- throw new IllegalArgumentException("Only db roles can be accepted");
- }
- }
-
- // Assign new roles
- UserImpl ui = (UserImpl)user;
- ui.setRoles(copy);
- }
-
- public Set getRoles(User user) throws IdentityException
- {
- if (!(user instanceof UserImpl))
- {
- throw new IllegalArgumentException("User is not a db user");
- }
-
- // We return an immutable set to avoid modifications
- UserImpl ui = (UserImpl)user;
- return Collections.unmodifiableSet(ui.getRoles());
- }
-
- /** Can be subclasses to provide testing in a non JTA environement. */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,321 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.legacy_identity.db;
-
-import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.legacy_identity.IdentityException;
-import org.jboss.portal.legacy_identity.NoSuchUserException;
-import org.jboss.portal.legacy_identity.User;
-import org.jboss.portal.legacy_identity.UserModule;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import javax.naming.InitialContext;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @version $Revision$
- * @portal.core
- */
-public class DBUserModuleImpl
- extends AbstractJBossService
- implements UserModule
-{
-
- /** . */
- private final Logger log = Logger.getLogger(getClass());
-
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected String jndiName;
-
- /** . */
- protected JNDI.Binding jndiBinding;
-
- public DBUserModuleImpl()
- {
- }
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- //
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
- }
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- //
- sessionFactory = null;
- }
-
- public SessionFactory getSessionFactory()
- {
- return sessionFactory;
- }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public String getJNDIName()
- {
- return jndiName;
- }
-
- public void setJNDIName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public User findUserByUserName(String userName) throws IdentityException
- {
- if (userName != null)
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from UserImpl where userName=:userName");
- query.setParameter("userName", userName);
- query.setCacheable(true);
- UserImpl user = (UserImpl)query.uniqueResult();
- if (user == null)
- {
- throw new NoSuchUserException("No such user " + userName);
- }
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by name " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("user name cannot be null");
- }
- }
-
- public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findUserById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- UserImpl user = (UserImpl)session.get(UserImpl.class, (Long)id);
- if (user == null)
- {
- throw new NoSuchUserException("No user found for " + id);
- }
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public User createUser(String userName, String password, String realEmail) throws IdentityException
- {
- if (userName != null)
- {
- try
- {
- UserImpl user = new UserImpl(userName);
- user.updatePassword(password);
- user.setRealEmail(realEmail);
- Session session = getCurrentSession();
- session.save(user);
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create user " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeUser(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- UserImpl user = (UserImpl)session.load(UserImpl.class, (Serializable)id);
- if (user == null)
- {
- throw new NoSuchUserException("No such user " + id);
- }
- session.delete(user);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove user " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Set findUsers(int offset, int limit) throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from UserImpl");
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
- {
- try
- {
- // Remove all occurences of % and add ours
- filter = "%" + filter.replaceAll("%", "") + "%";
-
- //
- Session session = getCurrentSession();
- Query query = session.createQuery("from UserImpl as u where u.userName like :filter");
- query.setString("filter", filter);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public int getUserCount() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(u.key) from UserImpl as u");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count users";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,253 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.identity.db.HibernateRoleImpl;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateMembershipModuleImpl extends MembershipModuleService
+{
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateMembershipModuleImpl.class);
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ protected void startService() throws Exception
+ {
+ //
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ super.startService();
+ }
+
+ protected void stopService() throws Exception
+ {
+
+ //
+ sessionFactory = null;
+
+ super.stopService();
+ }
+
+// public SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+ public Set getRoles(User user) throws IdentityException
+ {
+ //throw new UnsupportedOperationException("Not yet implemented");
+ if (!(user instanceof HibernateUserImpl))
+ {
+ throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+ }
+
+ // We return an immutable set to avoid modifications
+ HibernateUserImpl ui = (HibernateUserImpl)user;
+ Set roles = ui.getRoles();
+ Set copy = new HashSet();
+ for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+ {
+ HibernateRoleImpl role = (HibernateRoleImpl)iterator.next();
+ copy.add(role);
+ }
+
+ return Collections.unmodifiableSet(copy);
+ }
+
+ public Set getUsers(Role role) throws IdentityException
+ {
+ if (!(role instanceof HibernateRoleImpl))
+ {
+ throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+ }
+
+ // We return an immutable set to avoid modifications
+ HibernateRoleImpl ri = (HibernateRoleImpl)role;
+ Set users = ri.getUsers();
+ Set copy = new HashSet();
+ for (Iterator iterator = users.iterator(); iterator.hasNext();)
+ {
+ HibernateUserImpl user = (HibernateUserImpl)iterator.next();
+ copy.add(user);
+ }
+
+ return Collections.unmodifiableSet(copy);
+ }
+
+ public void assignUsers(Role role, Set users) throws IdentityException
+ {
+ //throw new UnsupportedOperationException("Not yet implemented");
+ if (!(role instanceof HibernateRoleImpl))
+ {
+ throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+ }
+
+ for (Iterator i = users.iterator(); i.hasNext();)
+ {
+ Object o = i.next();
+ if (o instanceof HibernateUserImpl)
+ {
+ HibernateUserImpl user = (HibernateUserImpl)o;
+ user.getRoles().add(role);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Only HibernateUserImpl roles can be accepted");
+ }
+ }
+
+ }
+
+ public void assignRoles(User user, Set roles) throws IdentityException
+ {
+ //throw new UnsupportedOperationException("Not yet implemented");
+ if (!(user instanceof HibernateUserImpl))
+ {
+ throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+ }
+
+ // We make a defensive copy with unwrapped maps and update with a new set
+ Set copy = new HashSet();
+ for (Iterator i = roles.iterator(); i.hasNext();)
+ {
+ Object o = i.next();
+ if (o instanceof HibernateRoleImpl)
+ {
+ copy.add(o);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
+ }
+ }
+
+ // Assign new roles
+ HibernateUserImpl ui = (HibernateUserImpl)user;
+ ui.setRoles(copy);
+ }
+
+ //TODO:
+ public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+ {
+ if (roleName != null)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+
+ HibernateUserImpl userimpl = new HibernateUserImpl();
+ userimpl.setEnabled(true);
+
+ Query query;
+ if (userNameFilter.trim().length() != 0)
+ {
+ //
+ userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+
+ //
+ query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+ query.setString("filter", userNameFilter);
+ }
+ else
+ {
+ query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name");
+ }
+ query.setString("name", roleName);
+ query.setFirstResult(offset);
+ query.setMaxResults(limit);
+
+ Iterator iterator = query.iterate();
+ Set result = Tools.toSet(iterator);
+
+ Set newResult = new HashSet();
+ Iterator cleaner = result.iterator();
+ while (cleaner.hasNext())
+ {
+ Object[] oArr = (Object[])cleaner.next();
+ newResult.add(oArr[0]);
+ }
+
+ return newResult;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find role " + roleName;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ }
+
+ /**
+ * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
+ * @param maps
+ * @return
+ * @throws Exception
+ */
+
+ /** Can be subclasses to provide testing in a non JTA environement. */
+ protected Session getCurrentSession()
+ {
+ if (sessionFactory == null)
+ {
+ throw new IllegalStateException("No session factory");
+ }
+ return sessionFactory.getCurrentSession();
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,151 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.Role;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
+ * @author Roy Russo : roy at jboss dot org
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateRoleImpl
+ implements Role
+{
+
+ private Long key;
+ private String name;
+ private Set users;
+ private String displayName;
+
+ /**
+ *
+ */
+ //TODO: make this protected (clashes with bsh script in HibernateSerssionBinder
+ public HibernateRoleImpl()
+ {
+ this.key = null;
+ this.name = null;
+ this.displayName = null;
+ this.users = new HashSet();
+ }
+
+ /**
+ *
+ */
+ //TODO: make this protected (clashes with bsh script in HibernateSerssionBinder
+ public HibernateRoleImpl(String name)
+ {
+ this.key = null;
+ this.name = name;
+ this.displayName = name;
+ this.users = new HashSet();
+ }
+
+ /**
+ *
+ */
+ public HibernateRoleImpl(String name, String displayName)
+ {
+ this.key = null;
+ this.name = name;
+ this.displayName = displayName;
+ this.users = new HashSet();
+ }
+
+ /**
+ * @hibernate.id column="jbp_rid" generator-class="native"
+ * <p/>
+ * Called by hibernate.
+ */
+ protected Long getKey()
+ {
+ return key;
+ }
+
+ /** Called by hibernate. */
+ protected void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ /** Called by hibernate. */
+ protected void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /** Called by hibernate. */
+ protected void setUsers(Set users)
+ {
+ this.users = users;
+ }
+
+ // ******************************************************************************************************************
+
+ public Object getId()
+ {
+ return key;
+ }
+
+ /**
+ *
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ *
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ /**
+ *
+ */
+ public void setDisplayName(String displayName)
+ {
+ this.displayName = displayName;
+ }
+
+ /**
+ *
+ */
+ public Set getUsers()
+ {
+ return users;
+ }
+
+ public String toString()
+ {
+ return "Role[" + key + "," + name + "]";
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,391 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.db.HibernateRoleImpl;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.service.RoleModuleService;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
+ * @author Roy Russo : roy at jboss dot org
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateRoleModuleImpl extends RoleModuleService
+{
+
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateRoleModuleImpl.class);
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ protected void startService() throws Exception
+ {
+ //
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ super.startService();
+ }
+
+ protected void stopService() throws Exception
+ {
+
+ //
+ sessionFactory = null;
+
+ super.stopService();
+ }
+
+// public SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+
+ public Role findRoleByName(String name) throws IdentityException
+ {
+ if (name != null)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Criteria criteria = session.createCriteria(HibernateRoleImpl.class);
+ criteria.add(Restrictions.naturalId().set("name", name));
+ criteria.setCacheable(true);
+ HibernateRoleImpl role = (HibernateRoleImpl)criteria.uniqueResult();
+ if (role == null)
+ {
+ throw new IdentityException("No such role " + name);
+ }
+ return role;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find role by name " + name;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ }
+
+ public Set findRolesByNames(String[] names) throws IdentityException
+ {
+ if (names != null)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ StringBuffer queryString = new StringBuffer("from HibernateRoleImpl as g where g.name=?");
+ for (int i = 1; i < names.length; i++)
+ {
+ queryString.append(" or g.name=?");
+ }
+ Query query = session.createQuery(queryString.toString());
+ for (int i = 0; i < names.length; i++)
+ {
+ query.setString(i, names[i]);
+ }
+ Iterator iterator = query.iterate();
+ return Tools.toSet(iterator);
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find roles";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ }
+
+ public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("The id is null");
+ }
+ try
+ {
+ return findRoleById(new Long(id));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Cannot parse id into an long " + id);
+ }
+ }
+
+ public Role findRoleById(Object id) throws IdentityException
+ {
+ if (id instanceof Long)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ HibernateRoleImpl role = (HibernateRoleImpl)session.get(HibernateRoleImpl.class, (Long)id);
+ if (role == null)
+ {
+ throw new IdentityException("No role found for " + id);
+ }
+ return role;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find role by id " + id;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("The id is not an long : " + id);
+ }
+ }
+
+ public Role createRole(String name, String displayName) throws IdentityException
+ {
+ if (name != null)
+ {
+ try
+ {
+ HibernateRoleImpl role = new HibernateRoleImpl(name, displayName);
+ Session session = getCurrentSession();
+ session.save(role);
+ return role;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot create role " + name;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ }
+
+ public void removeRole(Object id) throws IdentityException
+ {
+ if (id instanceof Long)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ HibernateRoleImpl role = (HibernateRoleImpl)session.load(HibernateRoleImpl.class, (Long)id);
+ Iterator users = role.getUsers().iterator();
+ while (users.hasNext())
+ {
+ HibernateUserImpl user = (HibernateUserImpl)users.next();
+ user.getRoles().remove(role);
+ }
+ session.delete(role);
+ session.flush();
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot remove role " + id;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("The id is not an long : " + id);
+ }
+ }
+
+ public int getRolesCount() throws IdentityException
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("select count(g.id) from HibernateRoleImpl as g");
+ return ((Number)query.uniqueResult()).intValue();
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot count roles";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+ public Set findRoles() throws IdentityException
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from HibernateRoleImpl");
+ Iterator iterator = query.iterate();
+ return Tools.toSet(iterator);
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find roles";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+ public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+ {
+ if (roleName != null)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+
+ HibernateUserImpl HibernateUserImpl = new HibernateUserImpl();
+ HibernateUserImpl.setEnabled(true);
+
+ Query query;
+ if (userNameFilter.trim().length() != 0)
+ {
+ //
+ userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+
+ //
+ query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+ query.setString("filter", userNameFilter);
+ }
+ else
+ {
+ query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name");
+ }
+ query.setString("name", roleName);
+ query.setFirstResult(offset);
+ query.setMaxResults(limit);
+
+ Iterator iterator = query.iterate();
+ Set result = Tools.toSet(iterator);
+
+ Set newResult = new HashSet();
+ Iterator cleaner = result.iterator();
+ while (cleaner.hasNext())
+ {
+ Object[] oArr = (Object[])cleaner.next();
+ newResult.add(oArr[0]);
+ }
+
+ return newResult;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find role " + roleName;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("id cannot be null");
+ }
+ }
+
+ public void setRoles(User user, Set roles) throws IdentityException
+ {
+ if (!(user instanceof HibernateUserImpl))
+ {
+ throw new IllegalArgumentException("User is not a db user");
+ }
+
+ // We make a defensive copy and update with a new set
+ Set copy = new HashSet();
+ for (Iterator i = roles.iterator(); i.hasNext();)
+ {
+ Object o = i.next();
+ if (o instanceof HibernateRoleImpl)
+ {
+ copy.add(o);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Only db roles can be accepted");
+ }
+ }
+
+ // Assign new roles
+ HibernateUserImpl ui = (HibernateUserImpl)user;
+ ui.setRoles(copy);
+ }
+
+ public Set getRoles(User user) throws IdentityException
+ {
+ if (!(user instanceof HibernateUserImpl))
+ {
+ throw new IllegalArgumentException("User is not a db user");
+ }
+
+ // We return an immutable set to avoid modifications
+ HibernateUserImpl ui = (HibernateUserImpl)user;
+ return Collections.unmodifiableSet(ui.getRoles());
+ }
+
+ /** Can be subclasses to provide testing in a non JTA environement. */
+ protected Session getCurrentSession()
+ {
+ if (sessionFactory == null)
+ {
+ throw new IllegalStateException("No session factory");
+ }
+ return sessionFactory.getCurrentSession();
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,542 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.p3p.P3PConstants;
+import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.identity.db.ProfileMapImpl;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Collections;
+import java.lang.reflect.Field;
+import java.text.SimpleDateFormat;
+import java.text.DateFormat;
+import java.text.ParseException;
+
+/**
+ * User interface implementation.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
+ * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar Bojan </a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateUserImpl
+ implements User
+{
+
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserImpl.class);
+
+ static final Map ACCESSORS = HibernateUserImpl.buildAccessors();
+
+ private static Map buildAccessors()
+ {
+ Map map = new HashMap();
+
+ // Map attributes defined by the JSR 168 spec P3P.
+ map.put(P3PConstants.INFO_USER_NAME_NICKNAME, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_NICKNAME, "userName", false, false));
+ map.put(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, new StringPropertyAccessor(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "realEmail", true, true));
+ map.put(P3PConstants.INFO_USER_NAME_GIVEN, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_GIVEN, "givenName", true, true));
+ map.put(P3PConstants.INFO_USER_NAME_FAMILY, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_FAMILY, "familyName", true, true));
+
+ // Map attributes specific to JBoss Portal
+ map.put(org.jboss.portal.identity.User.INFO_USER_EMAIL_FAKE, new StringPropertyAccessor(org.jboss.portal.identity.User.INFO_USER_EMAIL_FAKE, "fakeEmail", true, true));
+ map.put(org.jboss.portal.identity.User.INFO_USER_REGISTRATION_DATE, new DatePropertyAccessor(org.jboss.portal.identity.User.INFO_USER_REGISTRATION_DATE, "registrationDate", false, false));
+ map.put(org.jboss.portal.identity.User.INFO_USER_VIEW_EMAIL_VIEW_REAL, new BooleanPropertyAccessor(org.jboss.portal.identity.User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "viewRealEmail", true, false));
+ map.put(org.jboss.portal.identity.User.INFO_USER_ENABLED, new BooleanPropertyAccessor(org.jboss.portal.identity.User.INFO_USER_ENABLED, "enabled", true, false));
+
+ //
+ return Collections.unmodifiableMap(map);
+ }
+
+ protected ProfileMap profileMap;
+
+ /*
+ * P3P mapped persistent fields.
+ */
+
+ protected String userName;
+ protected String givenName;
+ protected String familyName;
+ protected String realEmail;
+
+ /*
+ * Non mapped persistent fields.
+ */
+
+ protected Long key;
+ protected boolean enabled;
+ protected String password;
+
+ /*
+ * Extension mapped persistent fields.
+ */
+
+ protected String fakeEmail;
+ protected boolean viewRealEmail;
+ protected Date registrationDate;
+
+ /*
+ * Persistent associations
+ */
+
+ protected Map dynamic;
+ protected Set roles;
+
+ /**
+ *
+ */
+ //TODO: make this protected (clashes with bsh script in HibernateSerssionBinder
+ public HibernateUserImpl()
+ {
+ this.key = null;
+ this.userName = null;
+ this.dynamic = null;
+ this.roles = null;
+ this.registrationDate = null;
+ this.enabled = false;
+ this.profileMap = new org.jboss.portal.identity.db.ProfileMapImpl(this);
+ }
+
+ /**
+ *
+ */
+ public HibernateUserImpl(String userName)
+ {
+ this.key = null;
+ this.userName = userName;
+ this.dynamic = new HashMap();
+ this.roles = new HashSet();
+ this.registrationDate = new Date();
+ this.enabled = false;
+ this.profileMap = new ProfileMapImpl(this);
+ }
+
+ /** Called by hibernate. */
+ public Long getKey()
+ {
+ return key;
+ }
+
+ /** Called by hibernate. */
+ protected void setKey(Long key)
+ {
+ this.key = key;
+ }
+
+ /** Called by hibernate. */
+ protected void setUserName(String userName)
+ {
+ this.userName = userName;
+ }
+
+ /** Called by Hibernate. */
+ protected Map getDynamic()
+ {
+ return dynamic;
+ }
+
+ /** Called by Hibernate. */
+ protected void setDynamic(Map dynamic)
+ {
+ this.dynamic = dynamic;
+ }
+
+ public ProfileMap getProfileMap()
+ {
+ return profileMap;
+ }
+
+ // User implementation **********************************************************************************************
+
+ /**
+ *
+ */
+ public Object getId()
+ {
+ return key;
+ }
+
+ /**
+ *
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ *
+ */
+ public String getGivenName()
+ {
+ return givenName;
+ }
+
+ public void setGivenName(String givenName)
+ {
+ this.givenName = givenName;
+ }
+
+ /**
+ *
+ */
+ public String getFamilyName()
+ {
+ return familyName;
+ }
+
+ public void setFamilyName(String familyName)
+ {
+ this.familyName = familyName;
+ }
+
+ public void updatePassword(String password)
+ {
+ this.password = Tools.md5AsHexString(password);
+ }
+
+ /**
+ *
+ */
+ public String getRealEmail()
+ {
+ return realEmail;
+ }
+
+ /**
+ *
+ */
+ public void setRealEmail(String realEmail)
+ {
+ this.realEmail = realEmail;
+ }
+
+ /**
+ *
+ */
+ public String getFakeEmail()
+ {
+ return fakeEmail;
+ }
+
+ /**
+ *
+ */
+ public void setFakeEmail(String fakeEmail)
+ {
+ this.fakeEmail = fakeEmail;
+ }
+
+ /**
+ *
+ */
+ public Date getRegistrationDate()
+ {
+ return registrationDate;
+ }
+
+ /**
+ *
+ */
+ public void setRegistrationDate(Date registrationDate)
+ {
+ this.registrationDate = registrationDate;
+ }
+
+ /**
+ *
+ */
+ public boolean getViewRealEmail()
+ {
+ return viewRealEmail;
+ }
+
+ /**
+ *
+ */
+ public void setViewRealEmail(boolean viewRealEmail)
+ {
+ this.viewRealEmail = viewRealEmail;
+ }
+
+ /**
+ *
+ */
+ public boolean getEnabled()
+ {
+ return enabled;
+ }
+
+ /**
+ *
+ */
+ public void setEnabled(boolean enable)
+ {
+ this.enabled = enable;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /** Returns the roles related to this user. */
+ public Set getRoles()
+ {
+ return roles;
+ }
+
+ /** Update the roles. */
+ public void setRoles(Set roles)
+ {
+ this.roles = roles;
+ }
+
+ public boolean validatePassword(String password)
+ {
+ if (password != null)
+ {
+ String hashedPassword = Tools.md5AsHexString(password);
+ return hashedPassword.equals(this.password);
+ }
+ return false;
+ }
+
+ /**
+ *
+ */
+ public String toString()
+ {
+ return "User[" + key + "," + userName + "]";
+ }
+
+
+ /** An accessor that maps a user field to a property name. */
+ static abstract class PropertyAccessor
+ {
+
+ protected final String propertyName;
+ protected final Field field;
+ protected final boolean writable;
+ protected final boolean nullable;
+
+ public PropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
+ {
+ try
+ {
+ this.propertyName = propertyName;
+ this.writable = writable;
+ this.field = HibernateUserImpl.class.getDeclaredField(fieldName);
+ this.nullable = nullable;
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ public String getPropertyName()
+ {
+ return propertyName;
+ }
+
+ public boolean isNullable()
+ {
+ return nullable;
+ }
+
+ public boolean isWritable()
+ {
+ return writable;
+ }
+
+ /**
+ * @param instance the user instance
+ * @param string the value
+ * @throws IllegalArgumentException if the string cannot be converted to an object
+ */
+ public void set(Object instance, String string) throws IllegalArgumentException
+ {
+ try
+ {
+ if (string == null)
+ {
+ field.set(instance, null);
+ }
+ else
+ {
+ Object object = toObject(string);
+ field.set(instance, object);
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ /**
+ * @param instance the user instance
+ * @return the converted value
+ * @throws IllegalArgumentException if the object cannot be converted to a string
+ */
+ public String get(Object instance) throws IllegalArgumentException
+ {
+ try
+ {
+ Object object = field.get(instance);
+ if (object == null)
+ {
+ return null;
+ }
+ else
+ {
+ return toString(object);
+ }
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ /**
+ * Perform the to object conversion.
+ *
+ * @param value the value to convert
+ * @return the converted value
+ * @throws IllegalArgumentException if the string cannot be converted to an object
+ */
+ protected abstract Object toObject(String value) throws IllegalArgumentException;
+
+ /**
+ * Perform the to strong conversion.
+ *
+ * @param value the value to convert
+ * @return the converted value
+ * @throws IllegalArgumentException if the object cannot be converted to a string
+ */
+ protected abstract String toString(Object value);
+
+ public String toString()
+ {
+ return "PropertyAccessor[" + propertyName + "," + field + "]";
+ }
+ }
+
+ static class StringPropertyAccessor extends PropertyAccessor
+ {
+ public StringPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
+ {
+ super(propertyName, fieldName, writable, nullable);
+ }
+
+ protected Object toObject(String value)
+ {
+ return value;
+ }
+
+ protected String toString(Object value)
+ {
+ return (String)value;
+ }
+ }
+
+ static class BooleanPropertyAccessor extends PropertyAccessor
+ {
+ public BooleanPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
+ {
+ super(propertyName, fieldName, writable, nullable);
+ }
+
+ protected Object toObject(String value) throws IllegalArgumentException
+ {
+ if ("true".equalsIgnoreCase(value))
+ {
+ return Boolean.TRUE;
+ }
+ else if ("false".equalsIgnoreCase(value))
+ {
+ return Boolean.FALSE;
+ }
+ else
+ {
+ throw new IllegalArgumentException("The value " + value + " cannot be converted to boolean for accessor " + toString());
+ }
+ }
+
+ protected String toString(Object value)
+ {
+ return value.toString();
+ }
+ }
+
+ static class DatePropertyAccessor extends PropertyAccessor
+ {
+ private static final ThreadLocal formatLocal = new ThreadLocal()
+ {
+ protected Object initialValue()
+ {
+ return new SimpleDateFormat();
+ }
+ };
+
+ public DatePropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
+ {
+ super(propertyName, fieldName, writable, nullable);
+ }
+
+ protected Object toObject(String value) throws IllegalArgumentException
+ {
+ try
+ {
+ DateFormat format = (DateFormat)HibernateUserImpl.DatePropertyAccessor.formatLocal.get();
+ Date date = format.parse(value);
+ return date;
+ }
+ catch (ParseException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ protected String toString(Object value)
+ {
+ Date date = (Date)value;
+ DateFormat format = (DateFormat)HibernateUserImpl.DatePropertyAccessor.formatLocal.get();
+ return format.format(date);
+ }
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,288 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.service.UserModuleService;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.io.Serializable;
+import java.util.Set;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateUserModuleImpl extends UserModuleService
+{
+
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ protected void startService() throws Exception
+ {
+ //
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ super.startService();
+ }
+
+ protected void stopService() throws Exception
+ {
+
+ //
+ sessionFactory = null;
+
+ super.stopService();
+ }
+
+// public SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+
+ public User findUserByUserName(String userName) throws IdentityException
+ {
+ if (userName != null)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from HibernateUserImpl where userName=:userName");
+ query.setParameter("userName", userName);
+ query.setCacheable(true);
+ HibernateUserImpl user = (HibernateUserImpl)query.uniqueResult();
+ if (user == null)
+ {
+ throw new NoSuchUserException("No such user " + userName);
+ }
+ return user;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find user by name " + userName;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("user name cannot be null");
+ }
+ }
+
+ public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("The id is null");
+ }
+ try
+ {
+ return findUserById(new Long(id));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("Cannot parse id into an long " + id);
+ }
+ }
+
+ public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+ {
+ if (id instanceof Long)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ HibernateUserImpl user = (HibernateUserImpl)session.get(HibernateUserImpl.class, (Long)id);
+ if (user == null)
+ {
+ throw new NoSuchUserException("No user found for " + id);
+ }
+ return user;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find user by id " + id;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("The id is not an long : " + id);
+ }
+ }
+
+ public User createUser(String userName, String password) throws IdentityException
+ {
+ if (userName != null)
+ {
+ try
+ {
+ HibernateUserImpl user = new HibernateUserImpl(userName);
+ user.updatePassword(password);
+ //user.setRealEmail(realEmail);
+ Session session = getCurrentSession();
+ session.save(user);
+ return user;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot create user " + userName;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("name cannot be null");
+ }
+ }
+
+ public void removeUser(Object id) throws IdentityException
+ {
+ if (id instanceof Long)
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ HibernateUserImpl user = (HibernateUserImpl)session.load(HibernateUserImpl.class, (Serializable)id);
+ if (user == null)
+ {
+ throw new NoSuchUserException("No such user " + id);
+ }
+ session.delete(user);
+ session.flush();
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot remove user " + id;
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("The id is not an long : " + id);
+ }
+ }
+
+ public Set findUsers(int offset, int limit) throws IdentityException
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from HibernateUserImpl");
+ query.setFirstResult(offset);
+ query.setMaxResults(limit);
+ Iterator iterator = query.iterate();
+ return Tools.toSet(iterator);
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find user range [" + offset + "," + limit + "]";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+ public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
+ {
+ try
+ {
+ // Remove all occurences of % and add ours
+ filter = "%" + filter.replaceAll("%", "") + "%";
+
+ //
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from HibernateUserImpl as u where u.userName like :filter");
+ query.setString("filter", filter);
+ query.setFirstResult(offset);
+ query.setMaxResults(limit);
+ Iterator iterator = query.iterate();
+ return Tools.toSet(iterator);
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot find user range [" + offset + "," + limit + "]";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+ public int getUserCount() throws IdentityException
+ {
+ try
+ {
+ Session session = getCurrentSession();
+ Query query = session.createQuery("select count(u.key) from HibernateUserImpl as u");
+ return ((Number)query.uniqueResult()).intValue();
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot count users";
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+ /**
+ * Can be subclasses to provide testing in a non JTA environement.
+ *
+ * @throws IllegalStateException if no session factory is present
+ */
+ protected Session getCurrentSession() throws IllegalStateException
+ {
+ if (sessionFactory == null)
+ {
+ throw new IllegalStateException("No session factory");
+ }
+ return sessionFactory.getCurrentSession();
+ }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,293 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.jboss.portal.identity.IdentityException;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateUserProfileModuleImpl extends UserProfileModuleService
+{
+
+ /** . */
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserProfileModuleImpl.class);
+ /** . */
+ protected SessionFactory sessionFactory;
+
+ /** . */
+ protected String sessionFactoryJNDIName;
+
+ private boolean synchronizeNonExistingUsers = true;
+
+ private boolean acceptOtherImplementations = true;
+
+ private String defaultSynchronizePassword;
+
+ protected void startService() throws Exception
+ {
+ //
+ sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+ super.startService();
+
+ }
+
+ protected void stopService() throws Exception
+ {
+ //
+ sessionFactory = null;
+ super.stopService();
+ }
+
+// public SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+
+ public String getSessionFactoryJNDIName()
+ {
+ return sessionFactoryJNDIName;
+ }
+
+ public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+ {
+ this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+ }
+
+ public Object getProperty(User user, String propertyName) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name need to have value");
+ }
+
+ HibernateUserImpl dbUser = processUser(user);
+
+ PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
+
+ if (pi == null)
+ {
+ throw new IdentityException("Cannot find profile information about property: " + propertyName);
+ }
+
+ return dbUser.getProfileMap().get(propertyName);
+ }
+
+ public void setProperty(User user, String propertyName, Object propertyValue) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name need to have value");
+ }
+
+ HibernateUserImpl dbUser = processUser(user);
+
+
+ PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
+
+ if (pi == null)
+ {
+ throw new IdentityException("Cannot find profile information about property: " + propertyName);
+ }
+ else if (!pi.getAccessMode().equals(PropertyInfo.ACCESS_MODE_READ_WRITE))
+ {
+ throw new IdentityException("Property is not allowed for write access: " + propertyName);
+ }
+
+ //if value is null reset property
+
+ dbUser.getProfileMap().put(propertyName, propertyValue);
+ }
+
+ public Map getProperties(User user) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ HibernateUserImpl dbUser = processUser(user);
+
+
+
+ //make a copy
+ Map props = new HashMap();
+ Map profile = dbUser.getProfileMap();
+ Set keys = profile.keySet();
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ props.put(key, profile.get(key));
+ }
+ return props;
+ }
+
+
+
+ /** Can be subclasses to provide testing in a non JTA environement. */
+ protected Session getCurrentSession()
+ {
+ if (sessionFactory == null)
+ {
+ throw new IllegalStateException("No session factory");
+ }
+ return sessionFactory.getCurrentSession();
+ }
+
+ protected HibernateUserImpl processUser(User user) throws IdentityException
+ {
+ if (user instanceof HibernateUserImpl)
+ {
+ return (HibernateUserImpl)user;
+ }
+ else if (!isAcceptOtherImplementations())
+ {
+ throw new IllegalArgumentException("This UserProfileModule implementation support only HibenrateUserImpl objects - set acceptOtherImplementations option to true");
+ }
+ if (log.isDebugEnabled()) log.debug("Processing non HibernateUserImpl object: " + user.getClass());
+ //if not Hibernate user try to obtain it using userName
+ Session session = getCurrentSession();
+ Query query = session.createQuery("from HibernateUserImpl where userName=:userName");
+ query.setParameter("userName", user.getUserName());
+ query.setCacheable(true);
+ HibernateUserImpl hu = (HibernateUserImpl)query.uniqueResult();
+
+ if (hu != null )
+ {
+ return hu;
+ }
+ else if (!isSynchronizeNonExistingUsers())
+ {
+ throw new IdentityException("No user in DB - set synchronizeNonExistingUsers option to true");
+ }
+ else
+ {
+ try
+ {
+ hu = new HibernateUserImpl(user.getUserName());
+ //user.updatePassword(user.getPassword());
+ if (defaultSynchronizePassword != null)
+ {
+ user.updatePassword(getDefaultSynchronizePassword());
+ }
+ session = getCurrentSession();
+ session.save(hu);
+ return hu;
+ }
+ catch (HibernateException e)
+ {
+ String message = "Cannot create user " + user.getUserName();
+ log.error(message, e);
+ throw new IdentityException(message, e);
+ }
+ }
+
+
+ }
+
+
+ /**
+ * obtains UserProfile object - if module is used as a Delegate it tries to obtain it from the main one.
+ * @return
+ * @throws IdentityException
+ */
+ public ProfileInfo getProfileInfo() throws IdentityException
+ {
+
+
+ if (profileInfo == null)
+ {
+ //obtain main UserProfileModule
+ UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ if (module == this)
+ {
+ throw new IdentityException("ProfileInfo not accessible - check configuration");
+ }
+ else
+ {
+ setProfileInfo(module.getProfileInfo());
+ }
+ }
+ return profileInfo;
+ }
+
+
+ public boolean isSynchronizeNonExistingUsers()
+ {
+ return synchronizeNonExistingUsers;
+ }
+
+ public void setSynchronizeNonExistingUsers(boolean synchronizeNonExistingUsers)
+ {
+ this.synchronizeNonExistingUsers = synchronizeNonExistingUsers;
+ }
+
+
+ public boolean isAcceptOtherImplementations()
+ {
+ return acceptOtherImplementations;
+ }
+
+ public void setAcceptOtherImplementations(boolean acceptOtherImplementations)
+ {
+ this.acceptOtherImplementations = acceptOtherImplementations;
+ }
+
+ public String getDefaultSynchronizePassword()
+ {
+ return defaultSynchronizePassword;
+ }
+
+ public void setDefaultSynchronizePassword(String defaultSynchronizePassword)
+ {
+ this.defaultSynchronizePassword = defaultSynchronizePassword;
+ }
+}
+
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,37 +1,36 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.legacy_identity.db;
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.db;
-import org.jboss.portal.legacy_identity.ProfileMap;
+import org.jboss.portal.identity.ProfileMap;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
+import java.util.HashSet;
+import java.util.Collection;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
/**
* A mutable map that expose user properties.
@@ -43,9 +42,9 @@
{
/** . */
- private UserImpl user;
+ private HibernateUserImpl user;
- public ProfileMapImpl(UserImpl user)
+ public ProfileMapImpl(HibernateUserImpl user)
{
if (user == null)
{
@@ -64,13 +63,13 @@
{
throw new ClassCastException("Key must be a string");
}
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
return accessor != null && !accessor.isWritable();
}
public int size()
{
- return UserImpl.ACCESSORS.size() + user.getDynamic().size();
+ return HibernateUserImpl.ACCESSORS.size() + user.getDynamic().size();
}
public boolean isEmpty()
@@ -89,7 +88,7 @@
{
throw new ClassCastException("Key must be a string");
}
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
if (accessor != null)
{
return true;
@@ -108,9 +107,9 @@
{
throw new ClassCastException("Value must be a string");
}
- for (Iterator i = UserImpl.ACCESSORS.values().iterator(); i.hasNext();)
+ for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
{
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)i.next();
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
Object value2 = accessor.get(user);
if (value == value2 || value.equals(value2))
{
@@ -131,7 +130,7 @@
{
throw new ClassCastException("Key must be a string");
}
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
if (accessor != null)
{
return accessor.get(user);
@@ -158,7 +157,7 @@
{
throw new ClassCastException("Key is not a String");
}
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
if (accessor != null)
{
if (newValue == null && !accessor.isNullable())
@@ -194,7 +193,7 @@
{
throw new ClassCastException("Key is not a String");
}
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
if (accessor != null)
{
throw new IllegalArgumentException("Key " + key + " is not removable");
@@ -215,16 +214,16 @@
//
set.addAll(user.getDynamic().keySet());
- set.addAll(UserImpl.ACCESSORS.keySet());
+ set.addAll(HibernateUserImpl.ACCESSORS.keySet());
return set;
}
public Collection values()
{
ArrayList collection = new ArrayList(size());
- for (Iterator i = UserImpl.ACCESSORS.values().iterator(); i.hasNext();)
+ for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
{
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)i.next();
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
collection.add(accessor.get(user));
}
collection.addAll(user.getDynamic().values());
@@ -235,9 +234,9 @@
public Set entrySet()
{
Map copy = new HashMap(user.getDynamic());
- for (Iterator i = UserImpl.ACCESSORS.values().iterator(); i.hasNext();)
+ for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
{
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)i.next();
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
copy.put(accessor.getPropertyName(), accessor.get(user));
}
return Collections.unmodifiableMap(copy).entrySet();
@@ -248,12 +247,12 @@
// todo : check all properties ok with changes before proceeding
for (Iterator i = map.entrySet().iterator(); i.hasNext();)
{
- Map.Entry entry = (Map.Entry)i.next();
+ Entry entry = (Entry)i.next();
Object key = entry.getKey();
if (key instanceof String)
{
Object value = entry.getValue();
- UserImpl.PropertyAccessor accessor = (UserImpl.PropertyAccessor)UserImpl.ACCESSORS.get(key);
+ HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
if (accessor != null)
{
if (accessor.isWritable())
Deleted: trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,149 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.legacy_identity.db;
-
-import org.jboss.portal.legacy_identity.Role;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision$
- */
-public class RoleImpl
- implements Role
-{
-
- private Long key;
- private String name;
- private Set users;
- private String displayName;
-
- /**
- *
- */
- public RoleImpl()
- {
- this.key = null;
- this.name = null;
- this.displayName = null;
- this.users = new HashSet();
- }
-
- /**
- *
- */
- public RoleImpl(String name)
- {
- this.key = null;
- this.name = name;
- this.displayName = name;
- this.users = new HashSet();
- }
-
- /**
- *
- */
- public RoleImpl(String name, String displayName)
- {
- this.key = null;
- this.name = name;
- this.displayName = displayName;
- this.users = new HashSet();
- }
-
- /**
- * @hibernate.id column="jbp_rid" generator-class="native"
- * <p/>
- * Called by hibernate.
- */
- protected Long getKey()
- {
- return key;
- }
-
- /** Called by hibernate. */
- protected void setKey(Long key)
- {
- this.key = key;
- }
-
- /** Called by hibernate. */
- protected void setName(String name)
- {
- this.name = name;
- }
-
- /** Called by hibernate. */
- protected void setUsers(Set users)
- {
- this.users = users;
- }
-
- // ******************************************************************************************************************
-
- public Object getId()
- {
- return key;
- }
-
- /**
- *
- */
- public String getName()
- {
- return name;
- }
-
- /**
- *
- */
- public String getDisplayName()
- {
- return displayName;
- }
-
- /**
- *
- */
- public void setDisplayName(String displayName)
- {
- this.displayName = displayName;
- }
-
- /**
- *
- */
- public Set getUsers()
- {
- return users;
- }
-
- public String toString()
- {
- return "Role[" + key + "," + name + "]";
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,661 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.legacy_identity.db;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.common.util.LocaleInfo;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.legacy_identity.ProfileMap;
-import org.jboss.portal.legacy_identity.Role;
-import org.jboss.portal.legacy_identity.User;
-
-import java.lang.reflect.Field;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * User interface implementation.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar Bojan </a>
- * @version $Revision$
- */
-public class UserImpl
- implements User
-{
-
- private static final Logger log = Logger.getLogger(UserImpl.class);
-
- static final Map ACCESSORS = UserImpl.buildAccessors();
-
- private static Map buildAccessors()
- {
- Map map = new HashMap();
-
- // Map attributes defined by the JSR 168 spec P3P.
- map.put(P3PConstants.INFO_USER_NAME_NICKNAME, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_NICKNAME, "userName", false, false));
- map.put(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, new StringPropertyAccessor(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "realEmail", true, true));
- map.put(P3PConstants.INFO_USER_NAME_GIVEN, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_GIVEN, "givenName", true, true));
- map.put(P3PConstants.INFO_USER_NAME_FAMILY, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_FAMILY, "familyName", true, true));
-
- // Map attributes specific to JBoss Portal
- map.put(User.INFO_USER_EMAIL_FAKE, new StringPropertyAccessor(User.INFO_USER_EMAIL_FAKE, "fakeEmail", true, true));
- map.put(User.INFO_USER_REGISTRATION_DATE, new DatePropertyAccessor(User.INFO_USER_REGISTRATION_DATE, "registrationDate", false, false));
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, new BooleanPropertyAccessor(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "viewRealEmail", true, false));
-
- //
- return Collections.unmodifiableMap(map);
- }
-
- /*
- * Transient fields.
- */
-
- protected ProfileMap profile;
- protected Set roleNames;
-
- /*
- * P3P mapped persistent fields.
- */
-
- protected String userName;
- protected String givenName;
- protected String familyName;
- protected String realEmail;
-
- /*
- * Non mapped persistent fields.
- */
-
- protected Long key;
- protected boolean enabled;
- protected String password;
-
- /*
- * Extension mapped persistent fields.
- */
-
- protected String fakeEmail;
- protected boolean viewRealEmail;
- protected Date registrationDate;
-
- /*
- * Persistent associations
- */
-
- protected Map dynamic;
- protected Set roles;
-
- /**
- *
- */
- public UserImpl()
- {
- this.key = null;
- this.userName = null;
- this.dynamic = null;
- this.profile = new ProfileMapImpl(this);
- this.roles = null;
- this.registrationDate = null;
- this.enabled = false;
- }
-
- /**
- *
- */
- public UserImpl(String userName)
- {
- this.key = null;
- this.userName = userName;
- this.dynamic = new HashMap();
- this.profile = new ProfileMapImpl(this);
- this.roles = new HashSet();
- this.registrationDate = new Date();
- this.enabled = false;
- }
-
- /** Called by hibernate. */
- public Long getKey()
- {
- return key;
- }
-
- /** Called by hibernate. */
- protected void setKey(Long key)
- {
- this.key = key;
- }
-
- /** Called by hibernate. */
- protected void setUserName(String userName)
- {
- this.userName = userName;
- }
-
- /** Called by Hibernate. */
- protected Map getDynamic()
- {
- return dynamic;
- }
-
- /** Called by Hibernate. */
- protected void setDynamic(Map dynamic)
- {
- this.dynamic = dynamic;
- }
-
- // User implementation **********************************************************************************************
-
- /**
- *
- */
- public Object getId()
- {
- return key;
- }
-
- /**
- *
- */
- public String getUserName()
- {
- return userName;
- }
-
- /**
- *
- */
- public String getGivenName()
- {
- return givenName;
- }
-
- public void setGivenName(String givenName)
- {
- this.givenName = givenName;
- }
-
- /**
- *
- */
- public String getFamilyName()
- {
- return familyName;
- }
-
- public void setFamilyName(String familyName)
- {
- this.familyName = familyName;
- }
-
- public void updatePassword(String password)
- {
- this.password = Tools.md5AsHexString(password);
- }
-
- /**
- *
- */
- public String getRealEmail()
- {
- return realEmail;
- }
-
- /**
- *
- */
- public void setRealEmail(String realEmail)
- {
- this.realEmail = realEmail;
- }
-
- /**
- *
- */
- public String getFakeEmail()
- {
- return fakeEmail;
- }
-
- /**
- *
- */
- public void setFakeEmail(String fakeEmail)
- {
- this.fakeEmail = fakeEmail;
- }
-
- /**
- *
- */
- public Date getRegistrationDate()
- {
- return registrationDate;
- }
-
- /**
- *
- */
- public void setRegistrationDate(Date registrationDate)
- {
- this.registrationDate = registrationDate;
- }
-
- /**
- *
- */
- public boolean getViewRealEmail()
- {
- return viewRealEmail;
- }
-
- /**
- *
- */
- public void setViewRealEmail(boolean viewRealEmail)
- {
- this.viewRealEmail = viewRealEmail;
- }
-
- /**
- *
- */
- public boolean getEnabled()
- {
- return enabled;
- }
-
- /**
- *
- */
- public void setEnabled(boolean enable)
- {
- this.enabled = enable;
- }
-
- /**
- *
- */
- public ProfileMap getProfile()
- {
- return profile;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- /** Returns the roles related to this user. */
- public Set getRoles()
- {
- return roles;
- }
-
- /** Update the roles. */
- public void setRoles(Set roles)
- {
- this.roles = roles;
- this.roleNames = null;
- }
-
- // Dynamic attributes
-
- /** Implemented as a dynamic attribute (see #INFO_USER_LAST_LOGIN_DATE). */
- public Date getLastVisitDate()
- {
- Date date = null;
- String dateAsString = (String)getDynamic().get(User.INFO_USER_LAST_LOGIN_DATE);
- if (dateAsString != null)
- {
- try
- {
- long dateAsLong = Long.parseLong(dateAsString);
- date = new Date(dateAsLong);
- }
- catch (NumberFormatException e)
- {
- UserImpl.log.error("Bad date format " + dateAsString + " try to remove it", e);
- getDynamic().remove(User.INFO_USER_LAST_LOGIN_DATE);
- }
- }
- return date;
- }
-
- public void setLastVisitDate(Date date)
- {
- if (date == null)
- {
- getDynamic().remove(User.INFO_USER_LAST_LOGIN_DATE);
- }
- else
- {
- long dateAsLong = date.getTime();
- String dateAsString = Long.toString(dateAsLong);
- getDynamic().put(User.INFO_USER_LAST_LOGIN_DATE, dateAsString);
- }
- }
-
- /** Implemented as a dynamic attribute (see #INFO_USER_SIGNATURE). */
- public String getSignature()
- {
- return (String)getDynamic().get(User.INFO_USER_SIGNATURE);
- }
-
- public void setSignature(String signature)
- {
- getDynamic().put(User.INFO_USER_SIGNATURE, signature);
- }
-
- /** Implemented as a dynamic attribute (see #INFO_USER_LOCALE). */
- public Locale getPreferredLocale()
- {
- Locale locale = null;
- String localeAsString = (String)getDynamic().get(User.INFO_USER_LOCALE);
- if (localeAsString != null)
- {
- LocaleInfo info = LocaleInfo.decodeLocaleInfo(localeAsString);
- if (info != null)
- {
- locale = info.getLocale();
- }
- }
- return locale;
- }
-
- public void setPreferredLocale(Locale locale)
- {
- if (locale == null)
- {
- getDynamic().remove(User.INFO_USER_LOCALE);
- }
- else
- {
- String localeAsString = locale.toString();
- getDynamic().put(User.INFO_USER_LOCALE, localeAsString);
- }
- }
-
- public String getTheme()
- {
- return (String)getDynamic().get(User.INFO_USER_THEME);
- }
-
- public void setTheme(String themeId)
- {
- if ((themeId == null) || (themeId.equals("")))
- {
- getDynamic().remove(User.INFO_USER_THEME);
- }
- else
- {
- getDynamic().put(User.INFO_USER_THEME, themeId);
- }
- }
-
- public boolean validatePassword(String password)
- {
- if (password != null)
- {
- String hashedPassword = Tools.md5AsHexString(password);
- return hashedPassword.equals(this.password);
- }
- return false;
- }
-
- /** Return all the role names of the user. */
- public Set getRoleNames()
- {
- if (roleNames == null)
- {
- Iterator it = roles.iterator();
- roleNames = new HashSet();
- while (it.hasNext())
- {
- roleNames.add(((Role)it.next()).getName());
- }
- }
- return roleNames;
- }
-
- /**
- *
- */
- public String toString()
- {
- return "User[" + key + "," + userName + "]";
- }
-
- /** An accessor that maps a user field to a property name. */
- static abstract class PropertyAccessor
- {
-
- protected final String propertyName;
- protected final Field field;
- protected final boolean writable;
- protected final boolean nullable;
-
- public PropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- try
- {
- this.propertyName = propertyName;
- this.writable = writable;
- this.field = UserImpl.class.getDeclaredField(fieldName);
- this.nullable = nullable;
- }
- catch (NoSuchFieldException e)
- {
- throw new Error(e);
- }
- }
-
- public String getPropertyName()
- {
- return propertyName;
- }
-
- public boolean isNullable()
- {
- return nullable;
- }
-
- public boolean isWritable()
- {
- return writable;
- }
-
- /**
- * @param instance the user instance
- * @param string the value
- * @throws IllegalArgumentException if the string cannot be converted to an object
- */
- public void set(Object instance, String string) throws IllegalArgumentException
- {
- try
- {
- if (string == null)
- {
- field.set(instance, null);
- }
- else
- {
- Object object = toObject(string);
- field.set(instance, object);
- }
- }
- catch (IllegalAccessException e)
- {
- throw new Error(e);
- }
- }
-
- /**
- * @param instance the user instance
- * @return the converted value
- * @throws IllegalArgumentException if the object cannot be converted to a string
- */
- public String get(Object instance) throws IllegalArgumentException
- {
- try
- {
- Object object = field.get(instance);
- if (object == null)
- {
- return null;
- }
- else
- {
- return toString(object);
- }
- }
- catch (IllegalAccessException e)
- {
- throw new Error(e);
- }
- }
-
- /**
- * Perform the to object conversion.
- *
- * @param value the value to convert
- * @return the converted value
- * @throws IllegalArgumentException if the string cannot be converted to an object
- */
- protected abstract Object toObject(String value) throws IllegalArgumentException;
-
- /**
- * Perform the to strong conversion.
- *
- * @param value the value to convert
- * @return the converted value
- * @throws IllegalArgumentException if the object cannot be converted to a string
- */
- protected abstract String toString(Object value);
-
- public String toString()
- {
- return "PropertyAccessor[" + propertyName + "," + field + "]";
- }
- }
-
- static class StringPropertyAccessor extends PropertyAccessor
- {
- public StringPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value)
- {
- return value;
- }
-
- protected String toString(Object value)
- {
- return (String)value;
- }
- }
-
- static class BooleanPropertyAccessor extends PropertyAccessor
- {
- public BooleanPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value) throws IllegalArgumentException
- {
- if ("true".equalsIgnoreCase(value))
- {
- return Boolean.TRUE;
- }
- else if ("false".equalsIgnoreCase(value))
- {
- return Boolean.FALSE;
- }
- else
- {
- throw new IllegalArgumentException("The value " + value + " cannot be converted to boolean for accessor " + toString());
- }
- }
-
- protected String toString(Object value)
- {
- return value.toString();
- }
- }
-
- static class DatePropertyAccessor extends PropertyAccessor
- {
- private static final ThreadLocal formatLocal = new ThreadLocal()
- {
- protected Object initialValue()
- {
- return new SimpleDateFormat();
- }
- };
-
- public DatePropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value) throws IllegalArgumentException
- {
- try
- {
- DateFormat format = (DateFormat)UserImpl.DatePropertyAccessor.formatLocal.get();
- Date date = format.parse(value);
- return date;
- }
- catch (ParseException e)
- {
- throw new IllegalArgumentException();
- }
- }
-
- protected String toString(Object value)
- {
- Date date = (Date)value;
- DateFormat format = (DateFormat)UserImpl.DatePropertyAccessor.formatLocal.get();
- return format.format(date);
- }
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db)
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,143 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.info.ProfileInfo;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity.IdentityException;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.FileOutputStream;
-import java.io.LineNumberReader;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.OutputStreamWriter;
-import java.io.File;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.Map;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class HibernateHelper
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateHelper.class);
-
-
- public static synchronized String generateProfileMappings(String template, String output, String mappingPattern, ProfileInfo info, ClassLoader tcl) throws Exception
- {
- //InputStream profileIS;
- InputStream templateIS;
- OutputStream mappingOS;
- File of = null;
-
- try
- {
- templateIS = tcl.getResourceAsStream(template);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot open mapping template resource: " + template, e);
- }
-
- try
- {
- of = new File(output);
- if (!of.exists())
- {
- log.info("creating new file");
- of.createNewFile();
- }
- log.info("Generating identity hibernate mappings file to: " + of.getAbsolutePath());
- mappingOS = new FileOutputStream(of, false);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot open mapping file for write",e);
- }
-
- if (output == null)
- {
- throw new IdentityException("Mapping Pattern not specified");
- }
-
-
-
- //process template
- LineNumberReader templateReader = new LineNumberReader(new InputStreamReader(templateIS));
- PrintWriter mappingWriter = new PrintWriter(new OutputStreamWriter(mappingOS));
-
- Pattern pattern = Pattern.compile(".*@mappings@.*");
-
-
- String line;
-
- while ((line = templateReader.readLine()) != null)
- {
- Matcher matcher = pattern.matcher(line);
- if (matcher.matches())
- {
- if (log.isDebugEnabled())
- {
- log.debug("Found @mappings@ tag at line: " + templateReader.getLineNumber());
- }
-
- line = generateColumns(info, mappingPattern);
- if (log.isDebugEnabled())
- {
- log.debug("Generated mappings: " + line);
- }
- }
- mappingWriter.println(line);
- }
- templateReader.close();
- mappingWriter.close();
- return of.getAbsolutePath();
- }
-
- private static String generateColumns(ProfileInfo info, String pattern)
- {
- StringBuffer columns = new StringBuffer();
-
- Map properties = info.getPropertiesInfo();
- for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- PropertyInfo property = (PropertyInfo)properties.get(key);
-
- if (property.isMappedDB() && property.getMappingDBType().equals(PropertyInfo.MAPPING_DB_TYPE_COLUMN))
- {
- String mapping = pattern.replaceFirst("@name@", property.getName()).replaceFirst("@column@", property.getMappingDBValue());
- columns.append(mapping);
- columns.append('\n');
- }
-
- }
- return columns.toString();
-
- }
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateHelper.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,143 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.IdentityException;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
+import java.io.File;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HibernateHelper
+{
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateHelper.class);
+//
+//
+// public static synchronized String generateProfileMappings(String template, String output, String mappingPattern, ProfileInfo info, ClassLoader tcl) throws Exception
+// {
+// //InputStream profileIS;
+// InputStream templateIS;
+// OutputStream mappingOS;
+// File of = null;
+//
+// try
+// {
+// templateIS = tcl.getResourceAsStream(template);
+// }
+// catch (Exception e)
+// {
+// throw new IdentityException("Cannot open mapping template resource: " + template, e);
+// }
+//
+// try
+// {
+// of = new File(output);
+// if (!of.exists())
+// {
+// log.info("creating new file");
+// of.createNewFile();
+// }
+// log.info("Generating identity hibernate mappings file to: " + of.getAbsolutePath());
+// mappingOS = new FileOutputStream(of, false);
+// }
+// catch (Exception e)
+// {
+// throw new IdentityException("Cannot open mapping file for write",e);
+// }
+//
+// if (output == null)
+// {
+// throw new IdentityException("Mapping Pattern not specified");
+// }
+//
+//
+//
+// //process template
+// LineNumberReader templateReader = new LineNumberReader(new InputStreamReader(templateIS));
+// PrintWriter mappingWriter = new PrintWriter(new OutputStreamWriter(mappingOS));
+//
+// Pattern pattern = Pattern.compile(".*@mappings@.*");
+//
+//
+// String line;
+//
+// while ((line = templateReader.readLine()) != null)
+// {
+// Matcher matcher = pattern.matcher(line);
+// if (matcher.matches())
+// {
+// if (log.isDebugEnabled())
+// {
+// log.debug("Found @mappings@ tag at line: " + templateReader.getLineNumber());
+// }
+//
+// line = generateColumns(info, mappingPattern);
+// if (log.isDebugEnabled())
+// {
+// log.debug("Generated mappings: " + line);
+// }
+// }
+// mappingWriter.println(line);
+// }
+// templateReader.close();
+// mappingWriter.close();
+// return of.getAbsolutePath();
+// }
+//
+// private static String generateColumns(ProfileInfo info, String pattern)
+// {
+// StringBuffer columns = new StringBuffer();
+//
+// Map properties = info.getPropertiesInfo();
+// for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();)
+// {
+// String key = (String)iterator.next();
+// PropertyInfo property = (PropertyInfo)properties.get(key);
+//
+// if (property.isMappedDB() && property.getMappingDBType().equals(PropertyInfo.MAPPING_DB_TYPE_COLUMN))
+// {
+// String mapping = pattern.replaceFirst("@name@", property.getName()).replaceFirst("@column@", property.getMappingDBValue());
+// columns.append(mapping);
+// columns.append('\n');
+// }
+//
+// }
+// return columns.toString();
+//
+// }
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,267 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.Tools;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateMembershipModuleImpl extends MembershipModuleService
-{
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateMembershipModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
-
- //
- sessionFactory = null;
-
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public Set getRoles(User user) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(user instanceof HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateUserImpl user");
- }
-
- // We return an immutable set to avoid modifications
- HibernateUserImpl ui = (HibernateUserImpl)user;
- Set roles = ui.getRoleMapsSet();
- Set wrappers = new HashSet();
- for (Iterator iterator = roles.iterator(); iterator.hasNext();)
- {
- Map map = (Map)iterator.next();
- wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
- }
-
- return wrappers;
- }
-
- public Set getUsers(Role role) throws IdentityException
- {
- if (!(role instanceof HibernateRoleImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
- }
-
- // We return an immutable set to avoid modifications
- HibernateRoleImpl ri = (HibernateRoleImpl)role;
- Set users = ri.getUserMapsSet();
- Set wrappers = new HashSet();
- for (Iterator iterator = users.iterator(); iterator.hasNext();)
- {
- Map map = (Map)iterator.next();
- wrappers.add(new HibernateUserImpl(getSessionFactory(), map));
- }
-
- return wrappers;
- }
-
- public void assignUsers(Role role, Set users) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(role instanceof HibernateRoleImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
- }
-
- for (Iterator i = users.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof HibernateUserImpl)
- {
- ((HibernateUserImpl)o).addRole(((HibernateRoleImpl)role).getCurrentMap());
- }
- else
- {
- throw new IllegalArgumentException("Only HibernateUserImpl roles can be accepted");
- }
- }
-
- }
-
- public void assignRoles(User user, Set roles) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(user instanceof HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateUserImpl user");
- }
-
- // We make a defensive copy with unwrapped maps and update with a new set
- Set copy = new HashSet();
- for (Iterator i = roles.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof HibernateRoleImpl)
- {
- copy.add(((HibernateRoleImpl)o).getCurrentMap());
- }
- else
- {
- throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
- }
- }
-
- // Assign new roles
- HibernateUserImpl ui = (HibernateUserImpl)user;
- ui.setRoles(copy);
- }
-
- //TODO:
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- if (roleName != null)
- {
- try
- {
- Session session = getCurrentSession();
-
- Query query;
- if (userNameFilter.trim().length() != 0)
- {
- //
- userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-
- //
- query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
- query.setString("filter", userNameFilter);
- }
- else
- {
- query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
- }
- query.setString("name", roleName);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
-
- Iterator iterator = query.iterate();
- Set result = processRolesSet(Tools.toSet(iterator));
-
- Set newResult = new HashSet();
- Iterator cleaner = result.iterator();
- while (cleaner.hasNext())
- {
- Object[] oArr = (Object[])cleaner.next();
- newResult.add(oArr[0]);
- }
-
- return newResult;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role " + roleName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- }
-
- /**
- * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
- * @param maps
- * @return
- * @throws Exception
- */
- private Set processRolesSet(Set maps) throws IdentityException
- {
- Set roles = new HashSet();
- for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
- {
- Map roleMap = (Map)iterator1.next();
- roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
- }
- return roles;
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
-
- }
-
- protected SessionFactory getSessionFactory() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory;//.getCurrentSession();
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,267 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateMembershipModuleImpl //extends MembershipModuleService
+{
+// /** . */
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateMembershipModuleImpl.class);
+// /** . */
+// protected SessionFactory sessionFactory;
+//
+// /** . */
+// protected String sessionFactoryJNDIName;
+//
+// protected void startService() throws Exception
+// {
+// //
+// sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+//
+// super.startService();
+// }
+//
+// protected void stopService() throws Exception
+// {
+//
+// //
+// sessionFactory = null;
+//
+// super.stopService();
+// }
+//
+//// public SessionFactory getSessionFactory()
+//// {
+//// return sessionFactory;
+//// }
+//
+// public String getSessionFactoryJNDIName()
+// {
+// return sessionFactoryJNDIName;
+// }
+//
+// public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+// {
+// this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+// }
+//
+// public Set getRoles(User user) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (!(user instanceof HibernateUserImpl))
+// {
+// throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+// }
+//
+// // We return an immutable set to avoid modifications
+// HibernateUserImpl ui = (HibernateUserImpl)user;
+// Set roles = ui.getRoleMapsSet();
+// Set wrappers = new HashSet();
+// for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+// {
+// Map map = (Map)iterator.next();
+// wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
+// }
+//
+// return wrappers;
+// }
+//
+// public Set getUsers(Role role) throws IdentityException
+// {
+// if (!(role instanceof HibernateRoleImpl))
+// {
+// throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+// }
+//
+// // We return an immutable set to avoid modifications
+// HibernateRoleImpl ri = (HibernateRoleImpl)role;
+// Set users = ri.getUserMapsSet();
+// Set wrappers = new HashSet();
+// for (Iterator iterator = users.iterator(); iterator.hasNext();)
+// {
+// Map map = (Map)iterator.next();
+// wrappers.add(new HibernateUserImpl(getSessionFactory(), map));
+// }
+//
+// return wrappers;
+// }
+//
+// public void assignUsers(Role role, Set users) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (!(role instanceof HibernateRoleImpl))
+// {
+// throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+// }
+//
+// for (Iterator i = users.iterator(); i.hasNext();)
+// {
+// Object o = i.next();
+// if (o instanceof HibernateUserImpl)
+// {
+// ((HibernateUserImpl)o).addRole(((HibernateRoleImpl)role).getCurrentMap());
+// }
+// else
+// {
+// throw new IllegalArgumentException("Only HibernateUserImpl roles can be accepted");
+// }
+// }
+//
+// }
+//
+// public void assignRoles(User user, Set roles) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (!(user instanceof HibernateUserImpl))
+// {
+// throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+// }
+//
+// // We make a defensive copy with unwrapped maps and update with a new set
+// Set copy = new HashSet();
+// for (Iterator i = roles.iterator(); i.hasNext();)
+// {
+// Object o = i.next();
+// if (o instanceof HibernateRoleImpl)
+// {
+// copy.add(((HibernateRoleImpl)o).getCurrentMap());
+// }
+// else
+// {
+// throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
+// }
+// }
+//
+// // Assign new roles
+// HibernateUserImpl ui = (HibernateUserImpl)user;
+// ui.setRoles(copy);
+// }
+//
+// //TODO:
+// public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+// {
+// if (roleName != null)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+//
+// Query query;
+// if (userNameFilter.trim().length() != 0)
+// {
+// //
+// userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+//
+// //
+// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+// query.setString("filter", userNameFilter);
+// }
+// else
+// {
+// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
+// }
+// query.setString("name", roleName);
+// query.setFirstResult(offset);
+// query.setMaxResults(limit);
+//
+// Iterator iterator = query.iterate();
+// Set result = processRolesSet(Tools.toSet(iterator));
+//
+// Set newResult = new HashSet();
+// Iterator cleaner = result.iterator();
+// while (cleaner.hasNext())
+// {
+// Object[] oArr = (Object[])cleaner.next();
+// newResult.add(oArr[0]);
+// }
+//
+// return newResult;
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find role " + roleName;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("id cannot be null");
+// }
+// }
+//
+// /**
+// * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
+// * @param maps
+// * @return
+// * @throws Exception
+// */
+// private Set processRolesSet(Set maps) throws IdentityException
+// {
+// Set roles = new HashSet();
+// for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+// {
+// Map roleMap = (Map)iterator1.next();
+// roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
+// }
+// return roles;
+// }
+//
+// /**
+// * Can be subclasses to provide testing in a non JTA environement.
+// *
+// * @throws IllegalStateException if no session factory is present
+// */
+// protected Session getCurrentSession() throws IllegalStateException
+// {
+// return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+//
+// }
+//
+// protected SessionFactory getSessionFactory() throws IllegalStateException
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory;//.getCurrentSession();
+// }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,206 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.EntityMode;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 5448 $
- */
-public class HibernateRoleImpl
- implements Role
-{
-
- public static final String ENTITY_NAME = "PortalRole";
- public static final String MAPPING_ID = "key";
- public static final String MAPPING_NAME = "name";
- public static final String MAPPING_DISPLAY_NAME = "displayName";
- public static final String MAPPING_USERS = "users";
-
- private SessionFactory sessionFactory;
-
- private Map currentMap;
-
- /*
- * Transient fields.
- */
-
- private HibernateRoleImpl()
- {
-
- }
-
- /**
- * Initializes Hibernate role object. initialContent map should be already persisted in hibernate Session
- * @param sf
- * @param initialContent
- * @throws IdentityException
- */
- public HibernateRoleImpl(SessionFactory sf, Map initialContent) throws IdentityException
- {
- if (sf == null)
- {
- throw new IdentityException("SessionFactory is null");
- }
- if (initialContent == null)
- {
- throw new IdentityException("Map is null");
- }
- this.sessionFactory = sf;
- this.currentMap = initialContent;
- //persist();
- }
-
- // ***
- //
- // API
- //
- // ***
-
- public Object getId()
- {
- return getCurrentMap().get(MAPPING_ID);
- }
-
- public String getName()
- {
- return (String)getCurrentMap().get(MAPPING_NAME);
- }
-
- public String getDisplayName()
- {
- return (String)getCurrentMap().get(MAPPING_DISPLAY_NAME);
- }
-
- public void setDisplayName(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
- getCurrentMap().put(MAPPING_DISPLAY_NAME, name);
- persist();
- }
-
- //users
- public Set getUserMapsSet()
- {
- return Collections.unmodifiableSet(getUsersSet());
- }
-
- public void setUsers(Set users)
- {
- if (users == null)
- {
- throw new IllegalArgumentException("users set is null");
- }
- getCurrentMap().put(MAPPING_USERS, users);
- }
-
- // ***
- //
- // SPI
- //
-
- // ***
-
- public void setName(String name, String value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
- getCurrentMap().put(name, value);
- persist();
- }
-
- public Map getCurrentMap()
- {
- return currentMap;
- }
-
- // ********
- //
- // Internal
- //
- // ********
- protected SessionFactory getSessionFactory()
- {
- return sessionFactory;
- }
-
- protected void setSessionFactory(SessionFactory sessionFactory)
- {
- this.sessionFactory = sessionFactory;
- }
-
- protected void setCurrentMap(Map currentMap)
- {
- this.currentMap = currentMap;
- }
-
- protected Set getUsersSet()
- {
- Set users = (Set)getCurrentMap().get(MAPPING_USERS);
- if (users == null)
- {
- users = new HashSet();
- getCurrentMap().put(MAPPING_USERS, users);
- }
- return users;
- }
-
- protected void persist()
- {
- getCurrentSession().save(ENTITY_NAME, currentMap);
- }
-
-
- public String toString()
- {
- return "Role[" + getId() + "," + getName() + "]";
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
- }
-}
-
-
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,205 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.EntityMode;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateRoleImpl //implements Role
+{
+
+// public static final String ENTITY_NAME = "PortalRole";
+// public static final String MAPPING_ID = "key";
+// public static final String MAPPING_NAME = "name";
+// public static final String MAPPING_DISPLAY_NAME = "displayName";
+// public static final String MAPPING_USERS = "users";
+//
+// private SessionFactory sessionFactory;
+//
+// private Map currentMap;
+//
+// /*
+// * Transient fields.
+// */
+//
+// private HibernateRoleImpl()
+// {
+//
+// }
+//
+// /**
+// * Initializes Hibernate role object. initialContent map should be already persisted in hibernate Session
+// * @param sf
+// * @param initialContent
+// * @throws IdentityException
+// */
+// public HibernateRoleImpl(SessionFactory sf, Map initialContent) throws IdentityException
+// {
+// if (sf == null)
+// {
+// throw new IdentityException("SessionFactory is null");
+// }
+// if (initialContent == null)
+// {
+// throw new IdentityException("Map is null");
+// }
+// this.sessionFactory = sf;
+// this.currentMap = initialContent;
+// //persist();
+// }
+//
+// // ***
+// //
+// // API
+// //
+// // ***
+//
+// public Object getId()
+// {
+// return getCurrentMap().get(MAPPING_ID);
+// }
+//
+// public String getName()
+// {
+// return (String)getCurrentMap().get(MAPPING_NAME);
+// }
+//
+// public String getDisplayName()
+// {
+// return (String)getCurrentMap().get(MAPPING_DISPLAY_NAME);
+// }
+//
+// public void setDisplayName(String name)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("name is null");
+// }
+// getCurrentMap().put(MAPPING_DISPLAY_NAME, name);
+// persist();
+// }
+//
+// //users
+// public Set getUserMapsSet()
+// {
+// return Collections.unmodifiableSet(getUsersSet());
+// }
+//
+// public void setUsers(Set users)
+// {
+// if (users == null)
+// {
+// throw new IllegalArgumentException("users set is null");
+// }
+// getCurrentMap().put(MAPPING_USERS, users);
+// }
+//
+// // ***
+// //
+// // SPI
+// //
+//
+// // ***
+//
+// public void setName(String name, String value)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("name is null");
+// }
+// getCurrentMap().put(name, value);
+// persist();
+// }
+//
+// public Map getCurrentMap()
+// {
+// return currentMap;
+// }
+//
+// // ********
+// //
+// // Internal
+// //
+// // ********
+// protected SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+//
+// protected void setSessionFactory(SessionFactory sessionFactory)
+// {
+// this.sessionFactory = sessionFactory;
+// }
+//
+// protected void setCurrentMap(Map currentMap)
+// {
+// this.currentMap = currentMap;
+// }
+//
+// protected Set getUsersSet()
+// {
+// Set users = (Set)getCurrentMap().get(MAPPING_USERS);
+// if (users == null)
+// {
+// users = new HashSet();
+// getCurrentMap().put(MAPPING_USERS, users);
+// }
+// return users;
+// }
+//
+// protected void persist()
+// {
+// getCurrentSession().save(ENTITY_NAME, currentMap);
+// }
+//
+//
+// public String toString()
+// {
+// return "Role[" + getId() + "," + getName() + "]";
+// }
+//
+// /**
+// * Can be subclasses to provide testing in a non JTA environement.
+// */
+// protected Session getCurrentSession()
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
+// }
+}
+
+
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,459 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.Criteria;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-import org.hibernate.criterion.Restrictions;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.service.RoleModuleService;
-import org.jboss.portal.common.util.Tools;
-
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateRoleModuleImpl extends RoleModuleService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateRoleModuleImpl.class);
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- /** . */
- protected SessionFactory sessionFactory;
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
- sessionFactory = null;
-
- super.stopService();
-
- //
-
- }
-
- public Role findRoleByName(String name) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (name != null)
- {
- try
- {
- Session session = getCurrentSession();
- Criteria criteria = session.createCriteria(HibernateRoleImpl.ENTITY_NAME);
- criteria.add(Restrictions.naturalId().set("name", name));
- criteria.setCacheable(true);
- Map roleMap = (Map)criteria.uniqueResult();
- if (roleMap == null)
- {
- throw new IdentityException("No such role " + name);
- }
- return new HibernateRoleImpl(getSessionFactory(), roleMap);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by name " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Set findRolesByNames(String[] names) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (names != null)
- {
- try
- {
- Session session = getCurrentSession();
- StringBuffer queryString = new StringBuffer("from PortalRole as g where g.name=?");
- for (int i = 1; i < names.length; i++)
- {
- queryString.append(" or g.name=?");
- }
- Query query = session.createQuery(queryString.toString());
- for (int i = 0; i < names.length; i++)
- {
- query.setString(i, names[i]);
- }
- Iterator iterator = query.iterate();
- return processRolesSet(Tools.toSet(iterator));
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findRoleById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public Role findRoleById(Object id) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- Map roleMap = (Map)session.get(HibernateRoleImpl.ENTITY_NAME, (Long)id);
- if (roleMap == null)
- {
- throw new IdentityException("No role found for " + id);
- }
- return new HibernateRoleImpl(getSessionFactory(),roleMap);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Role createRole(String name, String displayName) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (name != null)
- {
- try
- {
- Map roleMap = new HashMap();
- roleMap.put(HibernateRoleImpl.MAPPING_NAME, name);
- getCurrentSession().save(HibernateRoleImpl.ENTITY_NAME, roleMap);
- HibernateRoleImpl role = new HibernateRoleImpl(getSessionFactory(), roleMap);
- role.setDisplayName(displayName);
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create role " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeRole(Object id) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- Map roleMap = (Map)session.load(HibernateRoleImpl.ENTITY_NAME, (Long)id);
-
- //remove users asignments
- Set usersSet = (Set)roleMap.get(HibernateRoleImpl.MAPPING_USERS);
-
- if (usersSet != null)
- {
- Iterator users = usersSet.iterator();
- while (users.hasNext())
- {
- Map userMap = (Map)users.next();
-
- //make a new set of roles without this one
- Set newRoles = new HashSet();
- Set roles = (Set)userMap.get(HibernateUserImpl.MAPPING_ROLES);
- for (Iterator iterator = roles.iterator(); iterator.hasNext();)
- {
- Map role = (Map)iterator.next();
- if (!(role.get(HibernateRoleImpl.MAPPING_ID)).equals(id))
- {
- newRoles.add(role);
- }
- }
- userMap.put(HibernateUserImpl.MAPPING_ROLES, newRoles);
- }
- }
- session.delete(HibernateRoleImpl.ENTITY_NAME, roleMap);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove role " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public int getRolesCount() throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(g.id) from PortalRole as g");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findRoles() throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from PortalRole");
- Iterator iterator = query.iterate();
- return processRolesSet(Tools.toSet(iterator));
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
-// public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
-// {
-// //throw new UnsupportedOperationException("Not yet implemented");
-// if (roleName != null)
-// {
-// try
-// {
-// Session session = getCurrentSession();
-//
-// Query query;
-// if (userNameFilter.trim().length() != 0)
-// {
-// //
-// userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-//
-// //
-// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
-// query.setString("filter", userNameFilter);
-// }
-// else
-// {
-// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
-// }
-// query.setString("name", roleName);
-// query.setFirstResult(offset);
-// query.setMaxResults(limit);
-//
-// Iterator iterator = query.iterate();
-// Set result = processRolesSet(Tools.toSet(iterator));
-//
-// Set newResult = new HashSet();
-// Iterator cleaner = result.iterator();
-// while (cleaner.hasNext())
-// {
-// Object[] oArr = (Object[])cleaner.next();
-// newResult.add(oArr[0]);
-// }
-//
-// return newResult;
-// }
-// catch (HibernateException e)
-// {
-// String message = "Cannot find role " + roleName;
-// log.error(message, e);
-// throw new IdentityException(message, e);
-// }
-// }
-// else
-// {
-// throw new IllegalArgumentException("id cannot be null");
-// }
-// }
-
- /**
- * @deprecated
- * @param user
- * @param roles
- * @throws IdentityException
- */
-// public void setRoles(User user, Set roles) throws IdentityException
-// {
-// //throw new UnsupportedOperationException("Not yet implemented");
-// if (!(user instanceof HibernateUserImpl))
-// {
-// throw new IllegalArgumentException("User is not a HibernateUserImpl user");
-// }
-//
-// // We make a defensive copy with unwrapped maps and update with a new set
-// Set copy = new HashSet();
-// for (Iterator i = roles.iterator(); i.hasNext();)
-// {
-// Object o = i.next();
-// if (o instanceof HibernateRoleImpl)
-// {
-// copy.add(((HibernateRoleImpl)o).getCurrentMap());
-// }
-// else
-// {
-// throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
-// }
-// }
-//
-// // Assign new roles
-// HibernateUserImpl ui = (HibernateUserImpl)user;
-// ui.setRoles(copy);
-// }
-//
-//
-// public Set getRoles(User user) throws IdentityException
-// {
-// //throw new UnsupportedOperationException("Not yet implemented");
-// if (!(user instanceof HibernateUserImpl))
-// {
-// throw new IllegalArgumentException("User is not a db_old user");
-// }
-//
-// // We return an immutable set to avoid modifications
-// HibernateUserImpl ui = (HibernateUserImpl)user;
-// Set roles = ui.getRoleMapsSet();
-// Set wrappers = new HashSet();
-// for (Iterator iterator = roles.iterator(); iterator.hasNext();)
-// {
-// Map map = (Map)iterator.next();
-// wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
-// }
-//
-// return wrappers;
-// }
-
- /**
- * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
- * @param maps
- * @return
- * @throws Exception
- */
- private Set processRolesSet(Set maps) throws IdentityException
- {
- Set roles = new HashSet();
- for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
- {
- Map roleMap = (Map)iterator1.next();
- roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
- }
- return roles;
- }
-
-/**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
-
- }
-
- protected SessionFactory getSessionFactory() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory;//.getCurrentSession();
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,459 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+import org.hibernate.criterion.Restrictions;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.service.RoleModuleService;
+import org.jboss.portal.common.util.Tools;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
+ * @author Roy Russo : roy at jboss dot org
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateRoleModuleImpl //extends RoleModuleService
+{
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateRoleModuleImpl.class);
+//
+// /** . */
+// protected String sessionFactoryJNDIName;
+//
+// /** . */
+// protected SessionFactory sessionFactory;
+//
+// public String getSessionFactoryJNDIName()
+// {
+// return sessionFactoryJNDIName;
+// }
+//
+// public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+// {
+// this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+// }
+//
+//// public SessionFactory getSessionFactory()
+//// {
+//// return sessionFactory;
+//// }
+//
+// protected void startService() throws Exception
+// {
+// //
+// sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+//
+// super.startService();
+// }
+//
+// protected void stopService() throws Exception
+// {
+// sessionFactory = null;
+//
+// super.stopService();
+//
+// //
+//
+// }
+//
+// public Role findRoleByName(String name) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (name != null)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// Criteria criteria = session.createCriteria(HibernateRoleImpl.ENTITY_NAME);
+// criteria.add(Restrictions.naturalId().set("name", name));
+// criteria.setCacheable(true);
+// Map roleMap = (Map)criteria.uniqueResult();
+// if (roleMap == null)
+// {
+// throw new IdentityException("No such role " + name);
+// }
+// return new HibernateRoleImpl(getSessionFactory(), roleMap);
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find role by name " + name;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("name cannot be null");
+// }
+// }
+//
+// public Set findRolesByNames(String[] names) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (names != null)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// StringBuffer queryString = new StringBuffer("from PortalRole as g where g.name=?");
+// for (int i = 1; i < names.length; i++)
+// {
+// queryString.append(" or g.name=?");
+// }
+// Query query = session.createQuery(queryString.toString());
+// for (int i = 0; i < names.length; i++)
+// {
+// query.setString(i, names[i]);
+// }
+// Iterator iterator = query.iterate();
+// return processRolesSet(Tools.toSet(iterator));
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find roles";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("name cannot be null");
+// }
+// }
+//
+// public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (id == null)
+// {
+// throw new IllegalArgumentException("The id is null");
+// }
+// try
+// {
+// return findRoleById(new Long(id));
+// }
+// catch (NumberFormatException e)
+// {
+// throw new IllegalArgumentException("Cannot parse id into an long " + id);
+// }
+// }
+//
+// public Role findRoleById(Object id) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (id instanceof Long)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// Map roleMap = (Map)session.get(HibernateRoleImpl.ENTITY_NAME, (Long)id);
+// if (roleMap == null)
+// {
+// throw new IdentityException("No role found for " + id);
+// }
+// return new HibernateRoleImpl(getSessionFactory(),roleMap);
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find role by id " + id;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("The id is not an long : " + id);
+// }
+// }
+//
+// public Role createRole(String name, String displayName) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (name != null)
+// {
+// try
+// {
+// Map roleMap = new HashMap();
+// roleMap.put(HibernateRoleImpl.MAPPING_NAME, name);
+// getCurrentSession().save(HibernateRoleImpl.ENTITY_NAME, roleMap);
+// HibernateRoleImpl role = new HibernateRoleImpl(getSessionFactory(), roleMap);
+// role.setDisplayName(displayName);
+// return role;
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot create role " + name;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("name cannot be null");
+// }
+// }
+//
+// public void removeRole(Object id) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (id instanceof Long)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// Map roleMap = (Map)session.load(HibernateRoleImpl.ENTITY_NAME, (Long)id);
+//
+// //remove users asignments
+// Set usersSet = (Set)roleMap.get(HibernateRoleImpl.MAPPING_USERS);
+//
+// if (usersSet != null)
+// {
+// Iterator users = usersSet.iterator();
+// while (users.hasNext())
+// {
+// Map userMap = (Map)users.next();
+//
+// //make a new set of roles without this one
+// Set newRoles = new HashSet();
+// Set roles = (Set)userMap.get(HibernateUserImpl.MAPPING_ROLES);
+// for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+// {
+// Map role = (Map)iterator.next();
+// if (!(role.get(HibernateRoleImpl.MAPPING_ID)).equals(id))
+// {
+// newRoles.add(role);
+// }
+// }
+// userMap.put(HibernateUserImpl.MAPPING_ROLES, newRoles);
+// }
+// }
+// session.delete(HibernateRoleImpl.ENTITY_NAME, roleMap);
+// session.flush();
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot remove role " + id;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("The id is not an long : " + id);
+// }
+// }
+//
+// public int getRolesCount() throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// try
+// {
+// Session session = getCurrentSession();
+// Query query = session.createQuery("select count(g.id) from PortalRole as g");
+// return ((Number)query.uniqueResult()).intValue();
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot count roles";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+//
+// public Set findRoles() throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// try
+// {
+// Session session = getCurrentSession();
+// Query query = session.createQuery("from PortalRole");
+// Iterator iterator = query.iterate();
+// return processRolesSet(Tools.toSet(iterator));
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find roles";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+//
+//// public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+//// {
+//// //throw new UnsupportedOperationException("Not yet implemented");
+//// if (roleName != null)
+//// {
+//// try
+//// {
+//// Session session = getCurrentSession();
+////
+//// Query query;
+//// if (userNameFilter.trim().length() != 0)
+//// {
+//// //
+//// userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+////
+//// //
+//// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+//// query.setString("filter", userNameFilter);
+//// }
+//// else
+//// {
+//// query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
+//// }
+//// query.setString("name", roleName);
+//// query.setFirstResult(offset);
+//// query.setMaxResults(limit);
+////
+//// Iterator iterator = query.iterate();
+//// Set result = processRolesSet(Tools.toSet(iterator));
+////
+//// Set newResult = new HashSet();
+//// Iterator cleaner = result.iterator();
+//// while (cleaner.hasNext())
+//// {
+//// Object[] oArr = (Object[])cleaner.next();
+//// newResult.add(oArr[0]);
+//// }
+////
+//// return newResult;
+//// }
+//// catch (HibernateException e)
+//// {
+//// String message = "Cannot find role " + roleName;
+//// log.error(message, e);
+//// throw new IdentityException(message, e);
+//// }
+//// }
+//// else
+//// {
+//// throw new IllegalArgumentException("id cannot be null");
+//// }
+//// }
+//
+// /**
+// * @deprecated
+// * @param user
+// * @param roles
+// * @throws IdentityException
+// */
+//// public void setRoles(User user, Set roles) throws IdentityException
+//// {
+//// //throw new UnsupportedOperationException("Not yet implemented");
+//// if (!(user instanceof HibernateUserImpl))
+//// {
+//// throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+//// }
+////
+//// // We make a defensive copy with unwrapped maps and update with a new set
+//// Set copy = new HashSet();
+//// for (Iterator i = roles.iterator(); i.hasNext();)
+//// {
+//// Object o = i.next();
+//// if (o instanceof HibernateRoleImpl)
+//// {
+//// copy.add(((HibernateRoleImpl)o).getCurrentMap());
+//// }
+//// else
+//// {
+//// throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
+//// }
+//// }
+////
+//// // Assign new roles
+//// HibernateUserImpl ui = (HibernateUserImpl)user;
+//// ui.setRoles(copy);
+//// }
+////
+////
+//// public Set getRoles(User user) throws IdentityException
+//// {
+//// //throw new UnsupportedOperationException("Not yet implemented");
+//// if (!(user instanceof HibernateUserImpl))
+//// {
+//// throw new IllegalArgumentException("User is not a db_old user");
+//// }
+////
+//// // We return an immutable set to avoid modifications
+//// HibernateUserImpl ui = (HibernateUserImpl)user;
+//// Set roles = ui.getRoleMapsSet();
+//// Set wrappers = new HashSet();
+//// for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+//// {
+//// Map map = (Map)iterator.next();
+//// wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
+//// }
+////
+//// return wrappers;
+//// }
+//
+// /**
+// * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
+// * @param maps
+// * @return
+// * @throws Exception
+// */
+// private Set processRolesSet(Set maps) throws IdentityException
+// {
+// Set roles = new HashSet();
+// for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+// {
+// Map roleMap = (Map)iterator1.next();
+// roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
+// }
+// return roles;
+// }
+//
+///**
+// * Can be subclasses to provide testing in a non JTA environement.
+// *
+// * @throws IllegalStateException if no session factory is present
+// */
+// protected Session getCurrentSession() throws IllegalStateException
+// {
+// return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+//
+// }
+//
+// protected SessionFactory getSessionFactory() throws IllegalStateException
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory;//.getCurrentSession();
+// }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,324 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.Tools;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.EntityMode;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-
-/**
- * User interface implementation.
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 5448 $
- */
-public class HibernateUserImpl
- implements User
-{
-
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserImpl.class);
-
- //names used in hibernate.hbm.xml file to map fields
- public static final String ENTITY_NAME = "PortalUser";
- public static final String MAPPING_DYNAMIC_PROPERTY_MAP = "dynamic";
- public static final String MAPPING_ROLES = "roles";
- public static final String MAPPING_ID = "key";
- public static final String MAPPING_USER_NAME = "userName";
- public static final String MAPPING_PASSWORD = "password";
-
- //list of fields used for mapping
- public static final Set restrictedFieldNames = buildRestrictedFields();
-
- private static Set buildRestrictedFields()
- {
- Set set = new HashSet();
- set.add(MAPPING_DYNAMIC_PROPERTY_MAP);
- set.add(MAPPING_ROLES);
- set.add(MAPPING_ID);
- set.add(MAPPING_USER_NAME);
- set.add(MAPPING_PASSWORD);
-
- return Collections.unmodifiableSet(set);
- }
-
- private SessionFactory sessionFactory;
-
- private Map currentMap;
-
- /*
- * Transient fields.
- */
-
- private HibernateUserImpl()
- {
-
- }
-
- /**
- * Initializes Hibernate user object. initialContent map should be already persisted in hibernate Session
- * @param sf
- * @param initialContent
- * @throws IdentityException
- */
- public HibernateUserImpl(SessionFactory sf, Map initialContent) throws IdentityException
- {
- if (sf == null)
- {
- throw new IdentityException("SessionFactory is null");
- }
- if (initialContent == null)
- {
- throw new IdentityException("Map is null");
- }
- this.sessionFactory = sf;
- this.currentMap = initialContent;
- //persist();
- }
-
- // ***
- //
- // API
- //
- // ***
-
- public Object getId()
- {
- return getCurrentMap().get(MAPPING_ID);
- }
-
- public String getUserName()
- {
- return (String)getCurrentMap().get(MAPPING_USER_NAME);
- }
-
- public void updatePassword(String password)
- {
- if (password == null)
- {
- throw new IllegalArgumentException("Password is null");
- }
- getCurrentMap().put(MAPPING_PASSWORD, Tools.md5AsHexString(password));
- persist();
- }
-
- public boolean validatePassword(String password)
- {
- if (password != null)
- {
- String hashedPassword = Tools.md5AsHexString(password);
- return hashedPassword.equals(getPassword());
- }
- return false;
- }
-
- public void setPassword(String pass)
- {
- getCurrentMap().put(MAPPING_PASSWORD, pass);
- persist();
- }
-
- // ***
- //
- // SPI
- //
- // ***
-
- public void setUserName(String userName)
- {
- if (userName == null)
- {
- throw new IllegalArgumentException("userName is null");
- }
- getCurrentMap().put(MAPPING_USER_NAME, userName);
- persist();
- }
-
- public Map getCurrentMap()
- {
- return currentMap;
- }
-
- //properties
- public Map getProperties()
- {
- return Collections.unmodifiableMap(getDynamic());
- }
-
- public void setDynamicProperties(Map props)
- {
- getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
- persist();
- }
-
- public void setDynamicProperty(String name, String value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("property name is null");
- }
- getDynamic().put(name, value);
- persist();
- }
-
- public String getDynamicProperty(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("property name is null");
- }
- return (String)getDynamic().get(name);
- }
-
- public boolean hasDynamicPropertyValue(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("property name is null");
- }
-
- return getDynamic().containsKey(name);
- }
-
- //fields
- public String getFieldValue(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
- return (String)getCurrentMap().get(name);
- }
-
- public void setFieldValue(String name, String value) throws IdentityException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("property name is null");
- }
- if (restrictedFieldNames.contains(name))
- {
- throw new IdentityException("Cannot set field name: " + name + " as it's restricted one");
- }
- getCurrentMap().put(name, value);
- persist();
- }
-
- //roles
-
- public Set getRoleMapsSet()
- {
- return Collections.unmodifiableSet(getRolesSet());
- }
-
-
- public void setRoles(Set roles)
- {
- if (roles == null)
- {
- throw new IllegalArgumentException("roles set is null");
- }
- getCurrentMap().put(MAPPING_ROLES, roles);
- persist();
- }
-
- public void addRole(Map map)
- {
- getRolesSet().add(map);
- persist();
- }
-
- public String getPassword()
- {
- return (String)getCurrentMap().get(MAPPING_PASSWORD);
- }
-
- // ********
- //
- // Internal
- //
- // ********
-
-
- protected SessionFactory getSessionFactory()
- {
- return sessionFactory;
- }
-
- protected void setSessionFactory(SessionFactory sessionFactory)
- {
- this.sessionFactory = sessionFactory;
- }
-
- protected Map getDynamic()
- {
- Map props = (Map)getCurrentMap().get(MAPPING_DYNAMIC_PROPERTY_MAP);
- if (props == null)
- {
- props = new HashMap();
- getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
- }
- return props;
- }
-
- protected Set getRolesSet()
- {
- Set roles = (Set)getCurrentMap().get(MAPPING_ROLES);
- if (roles == null)
- {
- roles = new HashSet();
- getCurrentMap().put(MAPPING_ROLES, roles);
- }
- return roles;
- }
-
- protected void persist()
- {
- getCurrentSession().save(ENTITY_NAME, currentMap);
- }
-
-
- public String toString()
- {
- return "User[" + getId() + "," + getUserName() + "]";
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,323 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.EntityMode;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * User interface implementation.
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateUserImpl //implements User
+{
+
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserImpl.class);
+//
+// //names used in hibernate.hbm.xml file to map fields
+// public static final String ENTITY_NAME = "PortalUser";
+// public static final String MAPPING_DYNAMIC_PROPERTY_MAP = "dynamic";
+// public static final String MAPPING_ROLES = "roles";
+// public static final String MAPPING_ID = "key";
+// public static final String MAPPING_USER_NAME = "userName";
+// public static final String MAPPING_PASSWORD = "password";
+//
+// //list of fields used for mapping
+// public static final Set restrictedFieldNames = buildRestrictedFields();
+//
+// private static Set buildRestrictedFields()
+// {
+// Set set = new HashSet();
+// set.add(MAPPING_DYNAMIC_PROPERTY_MAP);
+// set.add(MAPPING_ROLES);
+// set.add(MAPPING_ID);
+// set.add(MAPPING_USER_NAME);
+// set.add(MAPPING_PASSWORD);
+//
+// return Collections.unmodifiableSet(set);
+// }
+//
+// private SessionFactory sessionFactory;
+//
+// private Map currentMap;
+//
+// /*
+// * Transient fields.
+// */
+//
+// private HibernateUserImpl()
+// {
+//
+// }
+//
+// /**
+// * Initializes Hibernate user object. initialContent map should be already persisted in hibernate Session
+// * @param sf
+// * @param initialContent
+// * @throws IdentityException
+// */
+// public HibernateUserImpl(SessionFactory sf, Map initialContent) throws IdentityException
+// {
+// if (sf == null)
+// {
+// throw new IdentityException("SessionFactory is null");
+// }
+// if (initialContent == null)
+// {
+// throw new IdentityException("Map is null");
+// }
+// this.sessionFactory = sf;
+// this.currentMap = initialContent;
+// //persist();
+// }
+//
+// // ***
+// //
+// // API
+// //
+// // ***
+//
+// public Object getId()
+// {
+// return getCurrentMap().get(MAPPING_ID);
+// }
+//
+// public String getUserName()
+// {
+// return (String)getCurrentMap().get(MAPPING_USER_NAME);
+// }
+//
+// public void updatePassword(String password)
+// {
+// if (password == null)
+// {
+// throw new IllegalArgumentException("Password is null");
+// }
+// getCurrentMap().put(MAPPING_PASSWORD, Tools.md5AsHexString(password));
+// persist();
+// }
+//
+// public boolean validatePassword(String password)
+// {
+// if (password != null)
+// {
+// String hashedPassword = Tools.md5AsHexString(password);
+// return hashedPassword.equals(getPassword());
+// }
+// return false;
+// }
+//
+// public void setPassword(String pass)
+// {
+// getCurrentMap().put(MAPPING_PASSWORD, pass);
+// persist();
+// }
+//
+// // ***
+// //
+// // SPI
+// //
+// // ***
+//
+// public void setUserName(String userName)
+// {
+// if (userName == null)
+// {
+// throw new IllegalArgumentException("userName is null");
+// }
+// getCurrentMap().put(MAPPING_USER_NAME, userName);
+// persist();
+// }
+//
+// public Map getCurrentMap()
+// {
+// return currentMap;
+// }
+//
+// //properties
+// public Map getProperties()
+// {
+// return Collections.unmodifiableMap(getDynamic());
+// }
+//
+// public void setDynamicProperties(Map props)
+// {
+// getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
+// persist();
+// }
+//
+// public void setDynamicProperty(String name, String value)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("property name is null");
+// }
+// getDynamic().put(name, value);
+// persist();
+// }
+//
+// public String getDynamicProperty(String name)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("property name is null");
+// }
+// return (String)getDynamic().get(name);
+// }
+//
+// public boolean hasDynamicPropertyValue(String name)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("property name is null");
+// }
+//
+// return getDynamic().containsKey(name);
+// }
+//
+// //fields
+// public String getFieldValue(String name)
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("name is null");
+// }
+// return (String)getCurrentMap().get(name);
+// }
+//
+// public void setFieldValue(String name, String value) throws IdentityException
+// {
+// if (name == null)
+// {
+// throw new IllegalArgumentException("property name is null");
+// }
+// if (restrictedFieldNames.contains(name))
+// {
+// throw new IdentityException("Cannot set field name: " + name + " as it's restricted one");
+// }
+// getCurrentMap().put(name, value);
+// persist();
+// }
+//
+// //roles
+//
+// public Set getRoleMapsSet()
+// {
+// return Collections.unmodifiableSet(getRolesSet());
+// }
+//
+//
+// public void setRoles(Set roles)
+// {
+// if (roles == null)
+// {
+// throw new IllegalArgumentException("roles set is null");
+// }
+// getCurrentMap().put(MAPPING_ROLES, roles);
+// persist();
+// }
+//
+// public void addRole(Map map)
+// {
+// getRolesSet().add(map);
+// persist();
+// }
+//
+// public String getPassword()
+// {
+// return (String)getCurrentMap().get(MAPPING_PASSWORD);
+// }
+//
+// // ********
+// //
+// // Internal
+// //
+// // ********
+//
+//
+// protected SessionFactory getSessionFactory()
+// {
+// return sessionFactory;
+// }
+//
+// protected void setSessionFactory(SessionFactory sessionFactory)
+// {
+// this.sessionFactory = sessionFactory;
+// }
+//
+// protected Map getDynamic()
+// {
+// Map props = (Map)getCurrentMap().get(MAPPING_DYNAMIC_PROPERTY_MAP);
+// if (props == null)
+// {
+// props = new HashMap();
+// getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
+// }
+// return props;
+// }
+//
+// protected Set getRolesSet()
+// {
+// Set roles = (Set)getCurrentMap().get(MAPPING_ROLES);
+// if (roles == null)
+// {
+// roles = new HashSet();
+// getCurrentMap().put(MAPPING_ROLES, roles);
+// }
+// return roles;
+// }
+//
+// protected void persist()
+// {
+// getCurrentSession().save(ENTITY_NAME, currentMap);
+// }
+//
+//
+// public String toString()
+// {
+// return "User[" + getId() + "," + getUserName() + "]";
+// }
+//
+// /**
+// * Can be subclasses to provide testing in a non JTA environement.
+// */
+// protected Session getCurrentSession()
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
+// }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,329 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.common.util.Tools;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import java.io.Serializable;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateUserModuleImpl extends UserModuleService
-{
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
-
- //
- sessionFactory = null;
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public User findUserByUserName(String userName) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
-
- if (userName != null)
- {
- try
- {
- Session session = getCurrentSession();
- //TODO: use contants
- Query query = session.createQuery("from PortalUser where userName=:userName");
- query.setParameter("userName", userName);
- //query.setCacheable(true);
- Map userMap = (Map)query.uniqueResult();
- if (userMap == null)
- {
- throw new NoSuchUserException("No such user " + userName);
- }
- return new HibernateUserImpl(getSessionFactory(), userMap);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by name " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("user name cannot be null");
- }
- }
-
- public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findUserById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- Map userMap = (Map)session.get(HibernateUserImpl.ENTITY_NAME, (Long)id);
- if (userMap == null)
- {
- throw new NoSuchUserException("No user found for " + id);
- }
- return new HibernateUserImpl(getSessionFactory(),userMap);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public User createUser(String userName, String password) throws IdentityException
- {
- if (userName != null)
- {
- try
- {
- Map mapUser = new HashMap();
- mapUser.put(HibernateUserImpl.MAPPING_USER_NAME, userName);
- mapUser.put(HibernateUserImpl.MAPPING_DYNAMIC_PROPERTY_MAP, new HashMap());
- mapUser.put(HibernateUserImpl.MAPPING_ROLES, new HashSet());
- //persist
- getCurrentSession().save(HibernateUserImpl.ENTITY_NAME, mapUser);
- //create wrapper
- HibernateUserImpl user = new HibernateUserImpl(getSessionFactory(), mapUser);
- user.updatePassword(password);
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create user " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeUser(Object id) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- Map mapUser = (Map)session.load(HibernateUserImpl.ENTITY_NAME, (Serializable)id);
-
-
- if (mapUser == null)
- {
- throw new NoSuchUserException("No such user " + id);
- }
- session.delete(HibernateUserImpl.ENTITY_NAME, mapUser);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove user " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Set findUsers(int offset, int limit) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- try
- {
- Session session = getCurrentSession();
- //TODO: Use constants
- Query query = session.createQuery("from PortalUser");
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return processUsersSet(Tools.toSet(iterator));
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- try
- {
- // Remove all occurences of % and add ours
- filter = "%" + filter.replaceAll("%", "") + "%";
-
- //
- Session session = getCurrentSession();
- //TODO: use constants
- Query query = session.createQuery("from PortalUser as u where u.userName like :filter");
- query.setString("filter", filter);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return processUsersSet(Tools.toSet(iterator));
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public int getUserCount() throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(u.key) from PortalUser as u");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count users";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- /**
- * Process Set of Map objects and returns a Set of HibernateUserImpl objects
- * @param maps
- * @return Set
- * @throws IdentityException
- */
- private Set processUsersSet(Set maps) throws IdentityException
- {
- Set users = new HashSet();
- for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
- {
- Map userMap = (Map)iterator1.next();
- users.add(new HibernateUserImpl(getSessionFactory(),userMap));
- }
- return users;
- }
-
-
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- * @return Session
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
-
- }
-
- protected SessionFactory getSessionFactory() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory;//.getCurrentSession();
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,329 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.service.UserModuleService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.io.Serializable;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateUserModuleImpl //extends UserModuleService
+{
+// /** . */
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
+// /** . */
+// protected SessionFactory sessionFactory;
+//
+// /** . */
+// protected String sessionFactoryJNDIName;
+//
+// protected void startService() throws Exception
+// {
+// //
+// sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+//
+// super.startService();
+// }
+//
+// protected void stopService() throws Exception
+// {
+//
+// //
+// sessionFactory = null;
+// super.stopService();
+// }
+//
+//// public SessionFactory getSessionFactory()
+//// {
+//// return sessionFactory;
+//// }
+//
+// public String getSessionFactoryJNDIName()
+// {
+// return sessionFactoryJNDIName;
+// }
+//
+// public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+// {
+// this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+// }
+//
+// public User findUserByUserName(String userName) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+//
+// if (userName != null)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// //TODO: use contants
+// Query query = session.createQuery("from PortalUser where userName=:userName");
+// query.setParameter("userName", userName);
+// //query.setCacheable(true);
+// Map userMap = (Map)query.uniqueResult();
+// if (userMap == null)
+// {
+// throw new NoSuchUserException("No such user " + userName);
+// }
+// return new HibernateUserImpl(getSessionFactory(), userMap);
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find user by name " + userName;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("user name cannot be null");
+// }
+// }
+//
+// public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+// {
+// if (id == null)
+// {
+// throw new IllegalArgumentException("The id is null");
+// }
+// try
+// {
+// return findUserById(new Long(id));
+// }
+// catch (NumberFormatException e)
+// {
+// throw new IllegalArgumentException("Cannot parse id into an long " + id);
+// }
+// }
+//
+// public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (id instanceof Long)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// Map userMap = (Map)session.get(HibernateUserImpl.ENTITY_NAME, (Long)id);
+// if (userMap == null)
+// {
+// throw new NoSuchUserException("No user found for " + id);
+// }
+// return new HibernateUserImpl(getSessionFactory(),userMap);
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find user by id " + id;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("The id is not an long : " + id);
+// }
+// }
+//
+// public User createUser(String userName, String password) throws IdentityException
+// {
+// if (userName != null)
+// {
+// try
+// {
+// Map mapUser = new HashMap();
+// mapUser.put(HibernateUserImpl.MAPPING_USER_NAME, userName);
+// mapUser.put(HibernateUserImpl.MAPPING_DYNAMIC_PROPERTY_MAP, new HashMap());
+// mapUser.put(HibernateUserImpl.MAPPING_ROLES, new HashSet());
+// //persist
+// getCurrentSession().save(HibernateUserImpl.ENTITY_NAME, mapUser);
+// //create wrapper
+// HibernateUserImpl user = new HibernateUserImpl(getSessionFactory(), mapUser);
+// user.updatePassword(password);
+// return user;
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot create user " + userName;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("name cannot be null");
+// }
+// }
+//
+// public void removeUser(Object id) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// if (id instanceof Long)
+// {
+// try
+// {
+// Session session = getCurrentSession();
+// Map mapUser = (Map)session.load(HibernateUserImpl.ENTITY_NAME, (Serializable)id);
+//
+//
+// if (mapUser == null)
+// {
+// throw new NoSuchUserException("No such user " + id);
+// }
+// session.delete(HibernateUserImpl.ENTITY_NAME, mapUser);
+// session.flush();
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot remove user " + id;
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+// else
+// {
+// throw new IllegalArgumentException("The id is not an long : " + id);
+// }
+// }
+//
+// public Set findUsers(int offset, int limit) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// try
+// {
+// Session session = getCurrentSession();
+// //TODO: Use constants
+// Query query = session.createQuery("from PortalUser");
+// query.setFirstResult(offset);
+// query.setMaxResults(limit);
+// Iterator iterator = query.iterate();
+// return processUsersSet(Tools.toSet(iterator));
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find user range [" + offset + "," + limit + "]";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+//
+// public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// try
+// {
+// // Remove all occurences of % and add ours
+// filter = "%" + filter.replaceAll("%", "") + "%";
+//
+// //
+// Session session = getCurrentSession();
+// //TODO: use constants
+// Query query = session.createQuery("from PortalUser as u where u.userName like :filter");
+// query.setString("filter", filter);
+// query.setFirstResult(offset);
+// query.setMaxResults(limit);
+// Iterator iterator = query.iterate();
+// return processUsersSet(Tools.toSet(iterator));
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot find user range [" + offset + "," + limit + "]";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+//
+// public int getUserCount() throws IdentityException
+// {
+// //throw new UnsupportedOperationException("Not yet implemented");
+// try
+// {
+// Session session = getCurrentSession();
+// Query query = session.createQuery("select count(u.key) from PortalUser as u");
+// return ((Number)query.uniqueResult()).intValue();
+// }
+// catch (HibernateException e)
+// {
+// String message = "Cannot count users";
+// log.error(message, e);
+// throw new IdentityException(message, e);
+// }
+// }
+//
+// /**
+// * Process Set of Map objects and returns a Set of HibernateUserImpl objects
+// * @param maps
+// * @return Set
+// * @throws IdentityException
+// */
+// private Set processUsersSet(Set maps) throws IdentityException
+// {
+// Set users = new HashSet();
+// for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+// {
+// Map userMap = (Map)iterator1.next();
+// users.add(new HibernateUserImpl(getSessionFactory(),userMap));
+// }
+// return users;
+// }
+//
+//
+//
+// /**
+// * Can be subclasses to provide testing in a non JTA environement.
+// *
+// * @throws IllegalStateException if no session factory is present
+// * @return Session
+// */
+// protected Session getCurrentSession() throws IllegalStateException
+// {
+// return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+//
+// }
+//
+// protected SessionFactory getSessionFactory() throws IllegalStateException
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory;//.getCurrentSession();
+// }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,173 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.identity2.experimental.db.HibernateUserImpl;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-
-import javax.naming.InitialContext;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateUserProfileModuleImpl extends UserProfileModuleService
-{
-
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserProfileModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
-
- }
-
- protected void stopService() throws Exception
- {
- //
- sessionFactory = null;
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public Object getProperty(User user, String propertyName)
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- HibernateUserImpl dbUser = null;
-
- if (user instanceof HibernateUserImpl)
- {
- dbUser = (HibernateUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
- }
-
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void setProperty(User user, String propertyName, Object propertyValue)
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- HibernateUserImpl dbUser = null;
-
- if (user instanceof HibernateUserImpl)
- {
- dbUser = (HibernateUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
- }
-
- //if value is null reset property
-
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Map getProperties(User user)
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- HibernateUserImpl dbUser = null;
-
- if (user instanceof HibernateUserImpl)
- {
- dbUser = (HibernateUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
- }
-
-
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
-
- }
-
- protected SessionFactory getSessionFactory() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory;//.getCurrentSession();
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.identity.experimental.db.HibernateUserImpl;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+
+import javax.naming.InitialContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateUserProfileModuleImpl //extends UserProfileModuleService
+{
+
+// /** . */
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserProfileModuleImpl.class);
+// /** . */
+// protected SessionFactory sessionFactory;
+//
+// /** . */
+// protected String sessionFactoryJNDIName;
+//
+// protected void startService() throws Exception
+// {
+// //
+// sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+//
+// super.startService();
+//
+// }
+//
+// protected void stopService() throws Exception
+// {
+// //
+// sessionFactory = null;
+// super.stopService();
+// }
+//
+//// public SessionFactory getSessionFactory()
+//// {
+//// return sessionFactory;
+//// }
+//
+// public String getSessionFactoryJNDIName()
+// {
+// return sessionFactoryJNDIName;
+// }
+//
+// public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+// {
+// this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+// }
+//
+// public Object getProperty(User user, String propertyName)
+// {
+// if (user == null)
+// {
+// throw new IllegalArgumentException("User cannot be null");
+// }
+// if (propertyName == null)
+// {
+// throw new IllegalArgumentException("Property name need to have value");
+// }
+//
+// HibernateUserImpl dbUser = null;
+//
+// if (user instanceof HibernateUserImpl)
+// {
+// dbUser = (HibernateUserImpl)user;
+// }
+// else
+// {
+// throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+// }
+//
+// throw new UnsupportedOperationException("Not yet implemented");
+// }
+//
+// public void setProperty(User user, String propertyName, Object propertyValue)
+// {
+// if (user == null)
+// {
+// throw new IllegalArgumentException("User cannot be null");
+// }
+// if (propertyName == null)
+// {
+// throw new IllegalArgumentException("Property name need to have value");
+// }
+//
+// HibernateUserImpl dbUser = null;
+//
+// if (user instanceof HibernateUserImpl)
+// {
+// dbUser = (HibernateUserImpl)user;
+// }
+// else
+// {
+// throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+// }
+//
+// //if value is null reset property
+//
+// throw new UnsupportedOperationException("Not yet implemented");
+// }
+//
+// public Map getProperties(User user)
+// {
+// if (user == null)
+// {
+// throw new IllegalArgumentException("User cannot be null");
+// }
+//
+// HibernateUserImpl dbUser = null;
+//
+// if (user instanceof HibernateUserImpl)
+// {
+// dbUser = (HibernateUserImpl)user;
+// }
+// else
+// {
+// throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+// }
+//
+//
+// throw new UnsupportedOperationException("Not yet implemented");
+// }
+//
+//
+// public ProfileInfo getProfileInfo() throws IdentityException
+// {
+// return null; //To change body of implemented methods use File | Settings | File Templates.
+// }
+//
+// /**
+// * Can be subclasses to provide testing in a non JTA environement.
+// *
+// * @throws IllegalStateException if no session factory is present
+// */
+// protected Session getCurrentSession() throws IllegalStateException
+// {
+// return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+//
+// }
+//
+// protected SessionFactory getSessionFactory() throws IllegalStateException
+// {
+// if (sessionFactory == null)
+// {
+// throw new IllegalStateException("No session factory");
+// }
+// return sessionFactory;//.getCurrentSession();
+// }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,119 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.experimental.db;
-
-import org.jboss.portal.jems.hibernate.SessionFactoryBinder;
-import org.jboss.portal.identity2.info.ProfileInfo;
-import org.jboss.portal.identity2.config.metadata.profile.ProfileMetaData;
-import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
-import org.jboss.portal.identity2.config.info.ProfileInfoSupport;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentitySessionFactoryBinder extends SessionFactoryBinder
-{
-
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentitySessionFactoryBinder.class);
-
- private String profileConfigFile;
-
- private String mappingTemplateFile;
-
- private String mappingOutputFile;
-
- private String mappingPattern;
-
- private ProfileInfo profileInfo;
-
- protected void createService() throws Exception
- {
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-
-
- //parse profile config
- ProfileMetaData meta = ConfigurationParser.parseProfileConfiguration(getProfileConfigFile());
- profileInfo = new ProfileInfoSupport(meta);
-
- //process files
- HibernateHelper.generateProfileMappings(getMappingTemplateFile(), getMappingOutputFile(), getMappingPattern(), profileInfo, tcl);
-
- //create configuration
- super.createService();
-
- //set MAP entity mode
- config.setProperty("hibernate.default_entity_mode","dynamic-map");
-
- //inject generated mappings into configuration
- config.addFile(getMappingOutputFile());
-
-
- }
-
-
- protected void startService() throws Exception
- {
- //super.startService(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
-
- public String getProfileConfigFile()
- {
- return profileConfigFile;
- }
-
- public void setProfileConfigFile(String profileConfigFile)
- {
- this.profileConfigFile = profileConfigFile;
- }
-
- public String getMappingTemplateFile()
- {
- return mappingTemplateFile;
- }
-
- public void setMappingTemplateFile(String mappingTemplateFile)
- {
- this.mappingTemplateFile = mappingTemplateFile;
- }
-
- public String getMappingOutputFile()
- {
- return mappingOutputFile;
- }
-
- public void setMappingOutputFile(String mappingOutputFile)
- {
- this.mappingOutputFile = mappingOutputFile;
- }
-
- public String getMappingPattern()
- {
- return mappingPattern;
- }
-
- public void setMappingPattern(String mappingPattern)
- {
- this.mappingPattern = mappingPattern;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/experimental/db/IdentitySessionFactoryBinder.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,119 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.experimental.db;
+
+import org.jboss.portal.jems.hibernate.SessionFactoryBinder;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.config.metadata.profile.ProfileMetaData;
+import org.jboss.portal.identity.config.metadata.ConfigurationParser;
+import org.jboss.portal.identity.config.info.ProfileInfoSupport;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentitySessionFactoryBinder //extends SessionFactoryBinder
+{
+
+// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentitySessionFactoryBinder.class);
+//
+// private String profileConfigFile;
+//
+// private String mappingTemplateFile;
+//
+// private String mappingOutputFile;
+//
+// private String mappingPattern;
+//
+// private ProfileInfo profileInfo;
+//
+// protected void createService() throws Exception
+// {
+// ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+//
+//
+// //parse profile config
+// ProfileMetaData meta = ConfigurationParser.parseProfileConfiguration(getProfileConfigFile());
+// profileInfo = new ProfileInfoSupport(meta);
+//
+// //process files
+// HibernateHelper.generateProfileMappings(getMappingTemplateFile(), getMappingOutputFile(), getMappingPattern(), profileInfo, tcl);
+//
+// //create configuration
+// super.createService();
+//
+// //set MAP entity mode
+// config.setProperty("hibernate.default_entity_mode","dynamic-map");
+//
+// //inject generated mappings into configuration
+// config.addFile(getMappingOutputFile());
+//
+//
+// }
+//
+//
+// protected void startService() throws Exception
+// {
+// //super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+// }
+//
+//
+// public String getProfileConfigFile()
+// {
+// return profileConfigFile;
+// }
+//
+// public void setProfileConfigFile(String profileConfigFile)
+// {
+// this.profileConfigFile = profileConfigFile;
+// }
+//
+// public String getMappingTemplateFile()
+// {
+// return mappingTemplateFile;
+// }
+//
+// public void setMappingTemplateFile(String mappingTemplateFile)
+// {
+// this.mappingTemplateFile = mappingTemplateFile;
+// }
+//
+// public String getMappingOutputFile()
+// {
+// return mappingOutputFile;
+// }
+//
+// public void setMappingOutputFile(String mappingOutputFile)
+// {
+// this.mappingOutputFile = mappingOutputFile;
+// }
+//
+// public String getMappingPattern()
+// {
+// return mappingPattern;
+// }
+//
+// public void setMappingPattern(String mappingPattern)
+// {
+// this.mappingPattern = mappingPattern;
+// }
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/info (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/info)
Deleted: trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/ProfileInfo.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,43 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.info;
-
-import java.util.Set;
-import java.util.Map;
-
-/**
- * Class provides info about user profile
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface ProfileInfo
-{
- /**
- * Returns a Map o PropertyInfo objects describing profile properties
- * @return Map of PropertyInfo objects
- */
- public Map getPropertiesInfo();
-
- public PropertyInfo getPropertyInfo(String name);
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/info/ProfileInfo.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/ProfileInfo.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/info/ProfileInfo.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,42 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.info;
+
+import java.util.Map;
+
+/**
+ * Class provides info about user profile
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ProfileInfo
+{
+ /**
+ * Returns a Map o PropertyInfo objects describing profile properties
+ * @return Map of PropertyInfo objects
+ */
+ public Map getPropertiesInfo();
+
+ public PropertyInfo getPropertyInfo(String name);
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,65 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.info;
-
-import org.jboss.portal.common.util.LocalizedString;
-
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface PropertyInfo
-{
-
- //TODO: make it int or safe type enum
- public static final String ACCESS_MODE_READ_ONLY = "read-only";
- public static final String ACCESS_MODE_READ_WRITE = "read-write";
- public static final String USAGE_MANDATORY = "mandatory";
- public static final String USAGE_OPTIONAL = "optional";
- public static final String MAPPING_DB_TYPE_COLUMN = "column";
- public static final String MAPPING_DB_TYPE_DYNAMIC = "dynamic";
-
- public String getName();
-
- public String getType();
-
- public String getAccessMode();
-
- public String getUsage();
-
- public LocalizedString getDisplayName();
-
- public LocalizedString getDescription();
-
- public String getMappingDBType();
-
- public String getMappingLDAPValue();
-
- public String getMappingDBValue();
-
- public boolean isMappedDB();
-
- public boolean isMappedLDAP();
-
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/info/PropertyInfo.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/info/PropertyInfo.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,65 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.info;
+
+import org.jboss.portal.common.util.LocalizedString;
+
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PropertyInfo
+{
+
+ //TODO: make it int or safe type enum
+ public static final String ACCESS_MODE_READ_ONLY = "read-only";
+ public static final String ACCESS_MODE_READ_WRITE = "read-write";
+ public static final String USAGE_MANDATORY = "mandatory";
+ public static final String USAGE_OPTIONAL = "optional";
+ public static final String MAPPING_DB_TYPE_COLUMN = "column";
+ public static final String MAPPING_DB_TYPE_DYNAMIC = "dynamic";
+
+ public String getName();
+
+ public String getType();
+
+ public String getAccessMode();
+
+ public String getUsage();
+
+ public LocalizedString getDisplayName();
+
+ public LocalizedString getDescription();
+
+ public String getMappingDBType();
+
+ public String getMappingLDAPValue();
+
+ public String getMappingDBValue();
+
+ public boolean isMappedDB();
+
+ public boolean isMappedLDAP();
+
+
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/ldap)
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,259 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.service.IdentityModuleService;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.JNDI;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import java.util.Hashtable;
-
-/**
- * Keeps configuration of connection to LDAP server
- *
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPConnectionContext extends AbstractJBossService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
-
- private String jndiName;
-
- private JNDI.Binding jndiBinding;
-
-
- private String name;
-
- private String contextFactory;
-
- private String adminDN;
-
- private String adminPassword;
-
- private String protocol;
-
- private String authentication = "simple";
-
- private String host;
-
- private String port;
-
- /*public LDAPConnectionContext(String name,
- String url,
- String context,
- String admin,
- String password,
- String protocol,
- String authentication)
- {
- this.name = name;
- this.providerUrl = url;
- this.contextFactory = context;
- this.adminDN = admin;
- this.adminPassword = password;
- this.protocol = protocol;
- this.authentication = authentication;
- }*/
-
- /*public LDAPConnectionContext()
- {
- super(IdentityContext.TYPE_CONNECTION_CONTEXT);
- }*/
-
-
-
-
- public InitialLdapContext createInitialContext() throws IdentityException
- {
- try
- {
- Hashtable env = new Hashtable();
- env.put(Context.INITIAL_CONTEXT_FACTORY, this.getContextFactory());
- env.put(Context.PROVIDER_URL, "ldap://" + getHost() + ":" + getPort());
- env.put(Context.SECURITY_AUTHENTICATION, this.getAuthentication());
- env.put(Context.SECURITY_PRINCIPAL, this.getAdminDN());
- env.put(Context.SECURITY_CREDENTIALS, this.getAdminPassword());
- return new InitialLdapContext(env, null);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Unable to create ConnectionContext: " + this, e);
- //return null;
- }
-
- }
-
-
- protected void startService() throws Exception
- {
-
- //
- if (jndiName != null)
- {
- log.debug("Binding identity module to JNDI with name: " + jndiName);
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- }
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- }
-
- public String toString()
- {
- StringBuffer str = new StringBuffer();
- str.append("Name: ").append(getName())
- .append(", Host: ").append(getHost())
- .append(", Port: ").append(getPort())
- .append(", Context factory: ").append(getContextFactory())
- .append(", Admin user: ").append(getAdminDN())
- .append(", Admin password: ").append(getAdminPassword())
- .append(", Authentication: ").append(getAuthentication());
- return str.toString();
- }
-
- //************************************
- //******* Getters and Setters ********
- //************************************
- public String getAuthentication()
- {
- if (authentication == null)
- {
- return "simple";
- }
- return authentication;
- }
-
- public void setAuthentication(String authentication)
- {
- this.authentication = authentication;
- }
-
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public JNDI.Binding getJndiBinding()
- {
- return jndiBinding;
- }
-
- public void setJndiBinding(JNDI.Binding jndiBinding)
- {
- this.jndiBinding = jndiBinding;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getContextFactory()
- {
- return contextFactory;
- }
-
- public void setContextFactory(String contextFactory)
- {
- this.contextFactory = contextFactory;
- }
-
- public String getAdminDN()
- {
- return adminDN;
- }
-
- public void setAdminDN(String adminDN)
- {
- this.adminDN = adminDN;
- }
-
- public String getAdminPassword()
- {
- return adminPassword;
- }
-
- public void setAdminPassword(String adminPassword)
- {
- this.adminPassword = adminPassword;
- }
-
- public String getProtocol()
- {
- return protocol;
- }
-
- public void setProtocol(String protocol)
- {
- this.protocol = protocol;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public void setHost(String host)
- {
- this.host = host;
- }
-
-
- public String getPort()
- {
- return port;
- }
-
- public void setPort(String port)
- {
- this.port = port;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPConnectionContext.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPConnectionContext.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,257 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.service.IdentityModuleService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.JNDI;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import java.util.Hashtable;
+
+/**
+ * Keeps configuration of connection to LDAP server
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPConnectionContext extends AbstractJBossService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+
+ private String jndiName;
+
+ private JNDI.Binding jndiBinding;
+
+
+ private String name;
+
+ private String contextFactory;
+
+ private String adminDN;
+
+ private String adminPassword;
+
+ private String protocol;
+
+ private String authentication = "simple";
+
+ private String host;
+
+ private String port;
+
+ /*public LDAPConnectionContext(String name,
+ String url,
+ String context,
+ String admin,
+ String password,
+ String protocol,
+ String authentication)
+ {
+ this.name = name;
+ this.providerUrl = url;
+ this.contextFactory = context;
+ this.adminDN = admin;
+ this.adminPassword = password;
+ this.protocol = protocol;
+ this.authentication = authentication;
+ }*/
+
+ /*public LDAPConnectionContext()
+ {
+ super(IdentityContext.TYPE_CONNECTION_CONTEXT);
+ }*/
+
+
+
+
+ public InitialLdapContext createInitialContext() throws IdentityException
+ {
+ try
+ {
+ Hashtable env = new Hashtable();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, this.getContextFactory());
+ env.put(Context.PROVIDER_URL, "ldap://" + getHost() + ":" + getPort());
+ env.put(Context.SECURITY_AUTHENTICATION, this.getAuthentication());
+ env.put(Context.SECURITY_PRINCIPAL, this.getAdminDN());
+ env.put(Context.SECURITY_CREDENTIALS, this.getAdminPassword());
+ return new InitialLdapContext(env, null);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Unable to create ConnectionContext: " + this, e);
+ //return null;
+ }
+
+ }
+
+
+ protected void startService() throws Exception
+ {
+
+ //
+ if (jndiName != null)
+ {
+ log.debug("Binding identity module to JNDI with name: " + jndiName);
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ }
+
+ public String toString()
+ {
+ StringBuffer str = new StringBuffer();
+ str.append("Name: ").append(getName())
+ .append(", Host: ").append(getHost())
+ .append(", Port: ").append(getPort())
+ .append(", Context factory: ").append(getContextFactory())
+ .append(", Admin user: ").append(getAdminDN())
+ .append(", Admin password: ").append(getAdminPassword())
+ .append(", Authentication: ").append(getAuthentication());
+ return str.toString();
+ }
+
+ //************************************
+ //******* Getters and Setters ********
+ //************************************
+ public String getAuthentication()
+ {
+ if (authentication == null)
+ {
+ return "simple";
+ }
+ return authentication;
+ }
+
+ public void setAuthentication(String authentication)
+ {
+ this.authentication = authentication;
+ }
+
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public JNDI.Binding getJndiBinding()
+ {
+ return jndiBinding;
+ }
+
+ public void setJndiBinding(JNDI.Binding jndiBinding)
+ {
+ this.jndiBinding = jndiBinding;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getContextFactory()
+ {
+ return contextFactory;
+ }
+
+ public void setContextFactory(String contextFactory)
+ {
+ this.contextFactory = contextFactory;
+ }
+
+ public String getAdminDN()
+ {
+ return adminDN;
+ }
+
+ public void setAdminDN(String adminDN)
+ {
+ this.adminDN = adminDN;
+ }
+
+ public String getAdminPassword()
+ {
+ return adminPassword;
+ }
+
+ public void setAdminPassword(String adminPassword)
+ {
+ this.adminPassword = adminPassword;
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol)
+ {
+ this.protocol = protocol;
+ }
+
+ public String getHost()
+ {
+ return host;
+ }
+
+ public void setHost(String host)
+ {
+ this.host = host;
+ }
+
+
+ public String getPort()
+ {
+ return port;
+ }
+
+ public void setPort(String port)
+ {
+ this.port = port;
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtRoleModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,77 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPExtRoleModuleImpl extends LDAPRoleModuleImpl
-{
-
- public Role findRoleByName(String name) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Role findRoleById(Object id) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Role findRoleById(String id) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Role management is not supported in this implementation of RoleModule");
- }
-
- public void removeRole(Object id) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Role management is not supported in this implementation of RoleModule");
- }
-
- public int getRolesCount() throws IdentityException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Set findRoles() throws IdentityException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtRoleModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtRoleModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPExtRoleModuleImpl extends LDAPRoleModuleImpl
+{
+
+ public Role findRoleByName(String name) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Role findRoleById(Object id) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Role findRoleById(String id) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Role management is not supported in this implementation of RoleModule");
+ }
+
+ public void removeRole(Object id) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Role management is not supported in this implementation of RoleModule");
+ }
+
+ public int getRolesCount() throws IdentityException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Set findRoles() throws IdentityException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtUserModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,78 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPExtUserModuleImpl extends LDAPUserModuleImpl
-{
-
- public User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public User createUser(String userName, String password, String realEmail) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("User management is not supported in this implementation of UserModule");
- }
-
- public void removeUser(Object id) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("User management is not supported in this implementation of UserModule");
- }
-
- public Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public int getUserCount() throws IdentityException, IllegalArgumentException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtUserModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPExtUserModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPExtUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.User;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPExtUserModuleImpl extends LDAPUserModuleImpl
+{
+
+ public User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public User createUser(String userName, String password, String realEmail) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("User management is not supported in this implementation of UserModule");
+ }
+
+ public void removeUser(Object id) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("User management is not supported in this implementation of UserModule");
+ }
+
+ public Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public int getUserCount() throws IdentityException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,127 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity.IdentityException;
-
-import javax.naming.InitialContext;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LDAPMembershipModule extends MembershipModuleService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPMembershipModule.class);
-
- private LDAPConnectionContext connectionContext;
-
- private LDAPUserModule userModule;
-
- private LDAPRoleModule roleModule;
-
- protected void startService() throws Exception
- {
- if (getConnectionJNDIName() == null)
- {
- throw new IdentityException("Cannot obtain ldap connection context JNDI name");
- }
-
- connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
-
- super.startService(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
- //************************************
- //******* Getters and Setters ********
- //************************************
-
- protected LDAPConnectionContext getConnectionContext() throws IdentityException
- {
- if (connectionContext == null)
- {
- //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
- throw new IdentityException("No LDAPConnectionContext available");
- }
- return connectionContext;
- }
-
-
-
- protected LDAPUserModule getUserModule() throws IdentityException
- {
-
- if (userModule == null)
- {
- try
- {
- this.userModule = (LDAPUserModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
- }
- catch (ClassCastException e)
- {
- throw new IdentityException("Not supported object as part of the context - must be LDAPUserModule", e);
- }
- }
- return userModule;
- }
-
- protected LDAPRoleModule getRoleModule() throws IdentityException
- {
-
- if (roleModule == null)
- {
- try
- {
- this.roleModule = (LDAPRoleModule)getIdentityContext().getObject(IdentityContext.TYPE_ROLE_MODULE);
- }
- catch (ClassCastException e)
- {
- throw new IdentityException("Not supported object as part of the context", e);
- }
- }
- return roleModule;
- }
-
- protected String getMemberAttributeID() throws IdentityException
- {
- String uid = getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID);
- if (uid == null)
- {
- return "member";
- }
- return uid;
- }
-
- protected boolean isUidAttributeIsDN() throws IdentityException
- {
- if (getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_IS_DN) == null)
- {
- return true;
- }
-
- return getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_IS_DN).equals("true");
- }
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPMembershipModule.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPMembershipModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,127 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.IdentityException;
+
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class LDAPMembershipModule extends MembershipModuleService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPMembershipModule.class);
+
+ private LDAPConnectionContext connectionContext;
+
+ private LDAPUserModule userModule;
+
+ private LDAPRoleModule roleModule;
+
+ protected void startService() throws Exception
+ {
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI name");
+ }
+
+ connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
+
+ super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ //************************************
+ //******* Getters and Setters ********
+ //************************************
+
+ protected LDAPConnectionContext getConnectionContext() throws IdentityException
+ {
+ if (connectionContext == null)
+ {
+ //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
+ throw new IdentityException("No LDAPConnectionContext available");
+ }
+ return connectionContext;
+ }
+
+
+
+ protected LDAPUserModule getUserModule() throws IdentityException
+ {
+
+ if (userModule == null)
+ {
+ try
+ {
+ this.userModule = (LDAPUserModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_MODULE);
+ }
+ catch (ClassCastException e)
+ {
+ throw new IdentityException("Not supported object as part of the context - must be LDAPUserModule", e);
+ }
+ }
+ return userModule;
+ }
+
+ protected LDAPRoleModule getRoleModule() throws IdentityException
+ {
+
+ if (roleModule == null)
+ {
+ try
+ {
+ this.roleModule = (LDAPRoleModule)getIdentityContext().getObject(IdentityContext.TYPE_ROLE_MODULE);
+ }
+ catch (ClassCastException e)
+ {
+ throw new IdentityException("Not supported object as part of the context", e);
+ }
+ }
+ return roleModule;
+ }
+
+ protected String getMemberAttributeID() throws IdentityException
+ {
+ String uid = getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID);
+ if (uid == null)
+ {
+ return "member";
+ }
+ return uid;
+ }
+
+ protected boolean isUidAttributeIsDN() throws IdentityException
+ {
+ if (getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_IS_DN) == null)
+ {
+ return true;
+ }
+
+ return getIdentityConfiguration().getValue(IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_IS_DN).equals("true");
+ }
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,133 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.MembershipModule;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPRoleImpl implements Role
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleImpl.class);
-
- //TODO: make setters to update the state of the entry
-
- //TODO:only to make a fasade for implementing old Role interface
- private IdentityContext identityContext;
-
- private String dn;
-
- private String id;
-
- private String displayName;
-
- private LDAPRoleImpl()
- {
-
- }
-
- public LDAPRoleImpl(String dn, IdentityContext context, String id, String display)
- {
- if (dn == null)
- {
- throw new IllegalArgumentException("LDAPRoleImpl need to be aware of its DN");
- }
-
-
- if (context == null)
- {
- throw new IllegalArgumentException("IdentityContext can't be null");
- }
-
- if (id == null)
- {
- throw new IllegalArgumentException("Id can't be null");
- }
-
- if (display == null)
- {
- throw new IllegalArgumentException("displayName can't be null");
- }
-
- this.identityContext = context;
- this.id = id;
- this.displayName = display;
- this.dn = dn;
- }
-
- public String getName()
- {
- return this.id;
- }
-
- public String getDisplayName()
- {
- return displayName;
- }
-
- public void setDisplayName(String name)
- {
- this.displayName = name;
- }
-
- //TODO: fasade to MembershipModule.getUsers() method call - change this
-// public Set getUsers()
-// {
-// try
-// {
-// MembershipModule mm = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
-// return mm.getUsers(this);
-// }
-// catch (IdentityException e)
-// {
-// log.error("Unable to delegate method to MembershipModule: ", e);
-// }
-// return null;
-// }
-
-
- //**************************
- //*** Getter and Setters
- //**************************
- public String getDn()
- {
- return dn;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
- public Object getId()
- {
- return id;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.IdentityContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPRoleImpl implements Role
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleImpl.class);
+
+ //TODO: make setters to update the state of the entry
+
+ //TODO:only to make a fasade for implementing old Role interface
+ private IdentityContext identityContext;
+
+ private String dn;
+
+ private String id;
+
+ private String displayName;
+
+ private LDAPRoleImpl()
+ {
+
+ }
+
+ protected LDAPRoleImpl(String dn, IdentityContext context, String id, String display)
+ {
+ if (dn == null)
+ {
+ throw new IllegalArgumentException("LDAPRoleImpl need to be aware of its DN");
+ }
+
+
+ if (context == null)
+ {
+ throw new IllegalArgumentException("IdentityContext can't be null");
+ }
+
+ if (id == null)
+ {
+ throw new IllegalArgumentException("Id can't be null");
+ }
+
+ if (display == null)
+ {
+ throw new IllegalArgumentException("displayName can't be null");
+ }
+
+ this.identityContext = context;
+ this.id = id;
+ this.displayName = display;
+ this.dn = dn;
+ }
+
+ public String getName()
+ {
+ return this.id;
+ }
+
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(String name)
+ {
+ this.displayName = name;
+ }
+
+ //TODO: fasade to MembershipModule.getUsers() method call - change this
+// public Set getUsers()
+// {
+// try
+// {
+// MembershipModule mm = (MembershipModule)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+// return mm.getUsers(this);
+// }
+// catch (IdentityException e)
+// {
+// log.error("Unable to delegate method to MembershipModule: ", e);
+// }
+// return null;
+// }
+
+
+ //**************************
+ //*** Getter and Setters
+ //**************************
+ public String getDn()
+ {
+ return dn;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,189 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.service.RoleModuleService;
-
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.NamingException;
-import javax.naming.NamingEnumeration;
-import javax.naming.InitialContext;
-import java.util.NoSuchElementException;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LDAPRoleModule extends RoleModuleService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleModule.class);
-
- private LDAPConnectionContext connectionContext;
-
-
- protected void startService() throws Exception
- {
- if (getConnectionJNDIName() == null)
- {
- throw new IdentityException("Cannot obtain ldap connection context JNDI name");
- }
-
- connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
-
- super.startService(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
-
- protected LDAPRoleImpl createRoleInstance(Attributes attrs, String dn) throws IdentityException
- {
- LDAPRoleImpl ldapr = null;
- try
- {
-
- log.debug("Attributes: " + attrs);
-
- //role name
- Attribute uida = attrs.get(getRidAttributeID());
- if (uida == null)
- {
- throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getRidAttributeID());
- }
- //ldapr = new LDAPRoleImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN(), identityContext);
- Attribute display = attrs.get(getDisplayNameAttributeID());
- if (display == null)
- {
- throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getDisplayNameAttributeID());
- }
- ldapr = new LDAPRoleImpl(dn, getIdentityContext(), uida.get().toString(), display.get().toString());
-
-
-
- log.debug("role uid: " + ldapr.getId());
- log.debug("role dn: " + ldapr.getDn());
-
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Couldn't create LDAPRoleImpl object from ldap entry (SearchResult)", e);
- }
-
- return ldapr;
- }
-
- /**
- * method not belonging to UserModule interface - ldap specific.
- *
- */
- public Role findRoleByDN(String dn) throws IdentityException, IllegalArgumentException
- {
- try
- {
- log.debug("findRoleByDN(): DN = " + dn);
-
- if (dn == null)
- {
- throw new IdentityException("Role dn canot be null");
- }
-
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
-
- if (attrs == null)
- {
- throw new IdentityException("Can't find user entry with DN: " + dn);
- }
-
- return createRoleInstance(attrs, dn);
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No user found with dn: " + dn, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return null;
- }
-
- /**
- * This method should be used by over modules to perform searches. It will allow role module
- * implementation to apply proper filter and search scope from the configuration
- *
- * @param filter that will be concatenated with proper role search filter from the module
- * @return
- */
- public abstract NamingEnumeration searchRoles(String filter) throws NamingException, IdentityException;
-
- //**************************
- //*** Getter and Setters
- //**************************
-
- protected String getRidAttributeID() throws IdentityException
- {
- String rid = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_RID_ATTRIBUTE_ID);
- if (rid == null)
- {
- return "cn";
- }
- return rid;
- }
-
- protected LDAPConnectionContext getConnectionContext() throws IdentityException
- {
- if (connectionContext == null)
- {
- //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
- throw new IdentityException("No LDAPConnectionContext available");
- }
- return connectionContext;
- }
-
- protected String getContainerDN() throws IdentityException
- {
- String cont = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_CONTAINER_DN);
- if (cont == null)
- {
- throw new IdentityException("Configuration option missing: " + IdentityConfiguration.ROLE_CONTAINER_DN);
- }
- return cont;
- }
-
- protected String getDisplayNameAttributeID() throws IdentityException
- {
- String display = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_DISPLAY_NAME_ATTRIBUTE_ID);
- if (display == null)
- {
- return getRidAttributeID();
- }
- return display;
- }
-
-
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModule.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,188 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.service.RoleModuleService;
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.InitialContext;
+import java.util.NoSuchElementException;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class LDAPRoleModule extends RoleModuleService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleModule.class);
+
+ private LDAPConnectionContext connectionContext;
+
+
+ protected void startService() throws Exception
+ {
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI name");
+ }
+
+ connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
+
+ super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+
+ protected LDAPRoleImpl createRoleInstance(Attributes attrs, String dn) throws IdentityException
+ {
+ LDAPRoleImpl ldapr = null;
+ try
+ {
+
+ log.debug("Attributes: " + attrs);
+
+ //role name
+ Attribute uida = attrs.get(getRidAttributeID());
+ if (uida == null)
+ {
+ throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getRidAttributeID());
+ }
+ //ldapr = new LDAPRoleImpl(uida.getID().concat("=").concat((String)uida.get()) + "," + getContainerDN(), identityContext);
+ Attribute display = attrs.get(getDisplayNameAttributeID());
+ if (display == null)
+ {
+ throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getDisplayNameAttributeID());
+ }
+ ldapr = new LDAPRoleImpl(dn, getIdentityContext(), uida.get().toString(), display.get().toString());
+
+
+
+ log.debug("role uid: " + ldapr.getId());
+ log.debug("role dn: " + ldapr.getDn());
+
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Couldn't create LDAPRoleImpl object from ldap entry (SearchResult)", e);
+ }
+
+ return ldapr;
+ }
+
+ /**
+ * method not belonging to UserModule interface - ldap specific.
+ *
+ */
+ public Role findRoleByDN(String dn) throws IdentityException, IllegalArgumentException
+ {
+ try
+ {
+ log.debug("findRoleByDN(): DN = " + dn);
+
+ if (dn == null)
+ {
+ throw new IdentityException("Role dn canot be null");
+ }
+
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+
+ if (attrs == null)
+ {
+ throw new IdentityException("Can't find user entry with DN: " + dn);
+ }
+
+ return createRoleInstance(attrs, dn);
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No user found with dn: " + dn, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return null;
+ }
+
+ /**
+ * This method should be used by over modules to perform searches. It will allow role module
+ * implementation to apply proper filter and search scope from the configuration
+ *
+ * @param filter that will be concatenated with proper role search filter from the module
+ * @return
+ */
+ public abstract NamingEnumeration searchRoles(String filter) throws NamingException, IdentityException;
+
+ //**************************
+ //*** Getter and Setters
+ //**************************
+
+ protected String getRidAttributeID() throws IdentityException
+ {
+ String rid = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_RID_ATTRIBUTE_ID);
+ if (rid == null)
+ {
+ return "cn";
+ }
+ return rid;
+ }
+
+ protected LDAPConnectionContext getConnectionContext() throws IdentityException
+ {
+ if (connectionContext == null)
+ {
+ //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
+ throw new IdentityException("No LDAPConnectionContext available");
+ }
+ return connectionContext;
+ }
+
+ protected String getContainerDN() throws IdentityException
+ {
+ String cont = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_CONTAINER_DN);
+ if (cont == null)
+ {
+ throw new IdentityException("Configuration option missing: " + IdentityConfiguration.ROLE_CONTAINER_DN);
+ }
+ return cont;
+ }
+
+ protected String getDisplayNameAttributeID() throws IdentityException
+ {
+ String display = getIdentityConfiguration().getValue(IdentityConfiguration.ROLE_DISPLAY_NAME_ATTRIBUTE_ID);
+ if (display == null)
+ {
+ return getRidAttributeID();
+ }
+ return display;
+ }
+
+
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,371 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.IdentityConfiguration;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.directory.DirContext;
-import javax.naming.ldap.LdapContext;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPRoleModuleImpl extends LDAPRoleModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleModuleImpl.class);
-
- public Role findRoleByName(String name) throws IdentityException, IllegalArgumentException
- {
- try
- {
- log.debug("findRoleByName(): name = " + name);
-
- if (name == null)
- {
- throw new IdentityException("Role name canot be null");
- }
-
-
- String filter = "(".concat(getRidAttributeID()).concat("=").concat(name).concat(")");
- log.debug("Search filter: " + filter);
-
-
- NamingEnumeration results = searchRoles(filter);
- List sr = Tools.toList(results);
- if (sr.size() > 1)
- {
- throw new IdentityException("Found more than one role with id: " + name + "" +
- "Posible data inconsistency");
- }
- SearchResult res = (SearchResult)sr.iterator().next();
- DirContext ctx = (DirContext)res.getObject();
- return createRoleInstance(res.getAttributes(),ctx.getNameInNamespace());
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No role found with name: " + name, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Role search failed.", e);
- }
- return null;
- }
-
- public Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException
- {
- if (names == null)
- {
- throw new IllegalArgumentException("null argument");
- }
-
- Set roles = new HashSet();
- try
- {
- //construct a filter with all role names
- StringBuffer filter = new StringBuffer("(| ");
- for (int i = 0; i < names.length; i++)
- {
- String name = names[i];
- filter.append("(")
- .append(getRidAttributeID())
- .append("=")
- .append(name)
- .append(") ");
- }
- filter.append(")");
-
- NamingEnumeration results = searchRoles(filter.toString());
- List sr = Tools.toList(results);
- for (Iterator iterator = sr.iterator(); iterator.hasNext();)
- {
- SearchResult res = (SearchResult)iterator.next();
- DirContext ctx = (DirContext)res.getObject();
- roles.add(createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
- }
- }
- catch (Exception e)
- {
- throw new IdentityException("Can't retreive roles", e);
- }
-
- return roles;
-
- }
-
- public Role findRoleById(Object id) throws IdentityException, IllegalArgumentException
- {
- if (id == null)
- {
- throw new IdentityException("Cannot search role with null id");
- }
- if (!(id instanceof String))
- {
- throw new IdentityException("Only String id is suppoted");
- }
- return findRoleById((String)id);
- }
-
- public Role findRoleById(String id) throws IdentityException, IllegalArgumentException
- {
- return findRoleByName(id);
- }
-
- public Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException
- {
- if (name == null)
- {
- throw new IdentityException("Role name cannot be null");
- }
-
- try
- {
- //
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
-
- //We store new entry using set of attributes. This should give more flexibility then
- //extending user object from ContextDir - configure what objectClass place there
- Attributes attrs = new BasicAttributes(true);
-
- //add attribute using provided configuration
- Map attributesToAdd = getAttributesToAdd();
-
- //attribute
- for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
- {
- String attributeName = (String)it1.next();
- log.debug("adding attribute: " + attributeName);
- Attribute attr = new BasicAttribute(attributeName);
- Set attributeValues = (Set)attributesToAdd.get(attributeName);
-
- //values
- for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
- {
- String attrValue = (String)it2.next();
- log.debug("adding attribute value: " + attrValue);
- attr.add(attrValue);
- }
- attrs.put(attr);
- }
-
- //role name
- attrs.put(getRidAttributeID(), name);
-
- //display name
- if (!getDisplayNameAttributeID().equals(getRidAttributeID()))
- {
- attrs.put(getDisplayNameAttributeID(), displayName);
- }
-
- String dn = getRidAttributeID().concat("=").concat(name);
-
- log.debug("creating ldap entry for: " + dn + "; " + attrs);
- ctx.createSubcontext(dn, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to create role", e);
- }
-
- return findRoleByName(name);
- }
-
- //TODO: remove role assignments before?
- public void removeRole(Object id) throws IdentityException, IllegalArgumentException
- {
- LDAPRoleImpl ldapr = (LDAPRoleImpl)findRoleById(id);
-
- if (ldapr == null)
- {
- throw new IdentityException("Cannot find role for removal");
- }
-
- if (ldapr.getDn() == null)
- {
- throw new IdentityException("Cannot obtain DN of role");
- }
-
- try
- {
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext();//.lookup(getContainerDN());
- log.debug("removing entry: " + ldapr.getDn());
- ctx.unbind(ldapr.getDn());
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to remove role: ", e);
- }
- }
-
- public int getRolesCount() throws IdentityException
- {
- try
- {
- //search all entries containing "cn" attribute
- String filter = getRidAttributeID().concat("=").concat("*");
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = searchRoles(filter);
- List sr = Tools.toList(results);
-
- return sr.size();
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No roles found", e);
- }
- catch (Exception e)
- {
- throw new IdentityException("Role search failed.", e);
- }
- return 0;
- }
-
- public Set findRoles() throws IdentityException
- {
- Set rf = new HashSet();
- try
- {
- //search all entries containing "cn" attribute
- String filter = "(".concat(getRidAttributeID()).concat("=").concat("*").concat(")");
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = searchRoles(filter);
- while (results.hasMoreElements())
- {
- SearchResult res = (SearchResult)results.nextElement();
- DirContext ctx = (DirContext)res.getObject();
- rf.add(createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
- }
- }
- catch (NoSuchElementException e)
- {
- log.debug("No roles found", e);
- }
- catch (Exception e)
- {
- throw new IdentityException("Role search failed.", e);
- }
- return rf;
- }
-
- /**
- * This method should be used by over modules to perform searches. It will allow role module
- * implementation to apply proper filter and search scope from the configuration
- *
- * @param filter that will be concatenated with proper role search filter from the module
- * @return
- */
- public NamingEnumeration searchRoles(String filter) throws NamingException, IdentityException
- {
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- controls.setReturningObjFlag(true);
-
- //String filter = getUidAttributeID().concat("=").concat(userName);
- log.debug("Search filter: " + filter);
-
- return getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
- }
-
- //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- try
- {
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- return mm.findRoleMembers(roleName, offset, limit, userNameFilter);
- }
- catch (IdentityException e)
- {
- throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
- }
-
- }
-
- //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
- public void setRoles(User user, Set roles) throws IdentityException
- {
- try
- {
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- mm.assignRoles(user,roles);
- }
- catch (IdentityException e)
- {
- throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
- }
-
- }
-
- //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
- public Set getRoles(User user) throws IdentityException
- {
- try
- {
- MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- return mm.getRoles(user);
- }
- catch (IdentityException e)
- {
- throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
- }
-
- }
-
- private Map getAttributesToAdd() throws IdentityException
- {
- Map attributesToAdd = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_ROLE_CREATE_ATTRIBUTES);
- if (attributesToAdd == null)
- {
- throw new IdentityException(IdentityConfiguration.GROUP_ROLE_CREATE_ATTRIBUTES + " missing in configuration");
- }
- return attributesToAdd;
- }
-
-
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPRoleModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,371 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.IdentityConfiguration;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.DirContext;
+import javax.naming.ldap.LdapContext;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPRoleModuleImpl extends LDAPRoleModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPRoleModuleImpl.class);
+
+ public Role findRoleByName(String name) throws IdentityException, IllegalArgumentException
+ {
+ try
+ {
+ log.debug("findRoleByName(): name = " + name);
+
+ if (name == null)
+ {
+ throw new IdentityException("Role name canot be null");
+ }
+
+
+ String filter = "(".concat(getRidAttributeID()).concat("=").concat(name).concat(")");
+ log.debug("Search filter: " + filter);
+
+
+ NamingEnumeration results = searchRoles(filter);
+ List sr = Tools.toList(results);
+ if (sr.size() > 1)
+ {
+ throw new IdentityException("Found more than one role with id: " + name + "" +
+ "Posible data inconsistency");
+ }
+ SearchResult res = (SearchResult)sr.iterator().next();
+ DirContext ctx = (DirContext)res.getObject();
+ return createRoleInstance(res.getAttributes(),ctx.getNameInNamespace());
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No role found with name: " + name, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Role search failed.", e);
+ }
+ return null;
+ }
+
+ public Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException
+ {
+ if (names == null)
+ {
+ throw new IllegalArgumentException("null argument");
+ }
+
+ Set roles = new HashSet();
+ try
+ {
+ //construct a filter with all role names
+ StringBuffer filter = new StringBuffer("(| ");
+ for (int i = 0; i < names.length; i++)
+ {
+ String name = names[i];
+ filter.append("(")
+ .append(getRidAttributeID())
+ .append("=")
+ .append(name)
+ .append(") ");
+ }
+ filter.append(")");
+
+ NamingEnumeration results = searchRoles(filter.toString());
+ List sr = Tools.toList(results);
+ for (Iterator iterator = sr.iterator(); iterator.hasNext();)
+ {
+ SearchResult res = (SearchResult)iterator.next();
+ DirContext ctx = (DirContext)res.getObject();
+ roles.add(createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Can't retreive roles", e);
+ }
+
+ return roles;
+
+ }
+
+ public Role findRoleById(Object id) throws IdentityException, IllegalArgumentException
+ {
+ if (id == null)
+ {
+ throw new IdentityException("Cannot search role with null id");
+ }
+ if (!(id instanceof String))
+ {
+ throw new IdentityException("Only String id is suppoted");
+ }
+ return findRoleById((String)id);
+ }
+
+ public Role findRoleById(String id) throws IdentityException, IllegalArgumentException
+ {
+ return findRoleByName(id);
+ }
+
+ public Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IdentityException("Role name cannot be null");
+ }
+
+ try
+ {
+ //
+ LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+
+ //We store new entry using set of attributes. This should give more flexibility then
+ //extending user object from ContextDir - configure what objectClass place there
+ Attributes attrs = new BasicAttributes(true);
+
+ //add attribute using provided configuration
+ Map attributesToAdd = getAttributesToAdd();
+
+ //attribute
+ for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
+ {
+ String attributeName = (String)it1.next();
+ log.debug("adding attribute: " + attributeName);
+ Attribute attr = new BasicAttribute(attributeName);
+ Set attributeValues = (Set)attributesToAdd.get(attributeName);
+
+ //values
+ for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
+ {
+ String attrValue = (String)it2.next();
+ log.debug("adding attribute value: " + attrValue);
+ attr.add(attrValue);
+ }
+ attrs.put(attr);
+ }
+
+ //role name
+ attrs.put(getRidAttributeID(), name);
+
+ //display name
+ if (!getDisplayNameAttributeID().equals(getRidAttributeID()))
+ {
+ attrs.put(getDisplayNameAttributeID(), displayName);
+ }
+
+ String dn = getRidAttributeID().concat("=").concat(name);
+
+ log.debug("creating ldap entry for: " + dn + "; " + attrs);
+ ctx.createSubcontext(dn, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to create role", e);
+ }
+
+ return findRoleByName(name);
+ }
+
+ //TODO: remove role assignments before?
+ public void removeRole(Object id) throws IdentityException, IllegalArgumentException
+ {
+ LDAPRoleImpl ldapr = (LDAPRoleImpl)findRoleById(id);
+
+ if (ldapr == null)
+ {
+ throw new IdentityException("Cannot find role for removal");
+ }
+
+ if (ldapr.getDn() == null)
+ {
+ throw new IdentityException("Cannot obtain DN of role");
+ }
+
+ try
+ {
+ LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext();//.lookup(getContainerDN());
+ log.debug("removing entry: " + ldapr.getDn());
+ ctx.unbind(ldapr.getDn());
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to remove role: ", e);
+ }
+ }
+
+ public int getRolesCount() throws IdentityException
+ {
+ try
+ {
+ //search all entries containing "cn" attribute
+ String filter = getRidAttributeID().concat("=").concat("*");
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = searchRoles(filter);
+ List sr = Tools.toList(results);
+
+ return sr.size();
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No roles found", e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Role search failed.", e);
+ }
+ return 0;
+ }
+
+ public Set findRoles() throws IdentityException
+ {
+ Set rf = new HashSet();
+ try
+ {
+ //search all entries containing "cn" attribute
+ String filter = "(".concat(getRidAttributeID()).concat("=").concat("*").concat(")");
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = searchRoles(filter);
+ while (results.hasMoreElements())
+ {
+ SearchResult res = (SearchResult)results.nextElement();
+ DirContext ctx = (DirContext)res.getObject();
+ rf.add(createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
+ }
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No roles found", e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Role search failed.", e);
+ }
+ return rf;
+ }
+
+ /**
+ * This method should be used by over modules to perform searches. It will allow role module
+ * implementation to apply proper filter and search scope from the configuration
+ *
+ * @param filter that will be concatenated with proper role search filter from the module
+ * @return
+ */
+ public NamingEnumeration searchRoles(String filter) throws NamingException, IdentityException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ controls.setReturningObjFlag(true);
+
+ //String filter = getUidAttributeID().concat("=").concat(userName);
+ log.debug("Search filter: " + filter);
+
+ return getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
+ }
+
+ //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+ public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+ {
+ try
+ {
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ return mm.findRoleMembers(roleName, offset, limit, userNameFilter);
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+ }
+
+ }
+
+ //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+ public void setRoles(User user, Set roles) throws IdentityException
+ {
+ try
+ {
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ mm.assignRoles(user,roles);
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+ }
+
+ }
+
+ //TODO:remove this - it's only a fasade to make this implementation compatible with old RoleModule interface
+ public Set getRoles(User user) throws IdentityException
+ {
+ try
+ {
+ MembershipModule mm = (MembershipModule)getIdentityContext().getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ return mm.getRoles(user);
+ }
+ catch (IdentityException e)
+ {
+ throw new IdentityException("Unable to delegate method to MembershipModule: ", e);
+ }
+
+ }
+
+ private Map getAttributesToAdd() throws IdentityException
+ {
+ Map attributesToAdd = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_ROLE_CREATE_ATTRIBUTES);
+ if (attributesToAdd == null)
+ {
+ throw new IdentityException(IdentityConfiguration.GROUP_ROLE_CREATE_ATTRIBUTES + " missing in configuration");
+ }
+ return attributesToAdd;
+ }
+
+
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,395 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.ldap.helper.LDAPTools;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.ModificationItem;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPStaticGroupMembershipModuleImpl extends LDAPMembershipModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticGroupMembershipModuleImpl.class);
-
-
- public Set getRoles(User user) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
- }
-
- Set roles = new HashSet();
- try
- {
-
- log.debug("getRoles(): user DN = " + ldapUser.getDn());
-
- String memberName = "";
-
- if (isUidAttributeIsDN())
- {
- memberName = ldapUser.getDn();
- }
- else
- {
- memberName = ldapUser.getId().toString();
- }
-
-
- String filter = getMemberAttributeID().concat("=").concat(memberName);
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = getRoleModule().searchRoles(filter);
- List sr = Tools.toList(results);
-
-
- for (Iterator iterator = sr.iterator(); iterator.hasNext();)
- {
- SearchResult res = (SearchResult)iterator.next();
- DirContext ctx = (DirContext)res.getObject();
- roles.add(getRoleModule().createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
- }
-
-
-
- }
- catch (Exception e)
- {
- log.debug("Failed to resolve userRoles: " + ldapUser.getId().toString(), e);
- }
-
- return roles;
-
- }
-
- public Set getUsers(Role role) throws IdentityException
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
-
- LDAPRoleImpl ldapRole = null;
-
- if (role instanceof LDAPRoleImpl)
- {
- ldapRole = (LDAPRoleImpl)role;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
- }
-
- //throw new UnsupportedOperationException("Not yet implemented");
-
- Set users = new HashSet();
-
- try
- {
- log.debug("findUsers(): role = " + ldapRole.getDn());
-
- if (ldapRole.getName() == null)
- {
- throw new IdentityException("Role name canot be null");
- }
-
- //obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapRole.getDn());
-
- log.debug("Role attributes: " + attrs);
- if (attrs == null )
- {
- throw new IdentityException("Cannot find Role with DN: " + ldapRole.getDn());
- }
-
- //iterate over user names belonging to this role
- NamingEnumeration values = attrs.get(getMemberAttributeID()).getAll();
- while (values.hasMoreElements())
- {
- String value = values.nextElement().toString();
- String name = value;
-
- try
- {
- //if user is pointed as DN get only it's name
- if (!isUidAttributeIsDN())
- {
- name = LDAPTools.stripDnToName(name);
- users.add(getUserModule().findUserByUserName(name));
- }
- else
- {
- users.add(getUserModule().findUserByDN(name));
- }
- }
- catch(IdentityException ie)
- {
- log.error("Failed to find user: " + name + "/" + value, ie);
-
- }
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Resolving Role Users failed.", e);
- }
-
- return users;
-
- }
-
- public void assignUsers(Role role, Set users) throws IdentityException
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
-
- LDAPRoleImpl ldapRole = null;
-
- if (role instanceof LDAPRoleImpl)
- {
- ldapRole = (LDAPRoleImpl)role;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
- }
-
-
-
- if (users.size() == 0)
- {
- throw new IdentityException("Cannot assigne 0 users to a role using this membership strategy (because some LDAPs " +
- "require the member field to be set). ");
- }
-
- try
- {
- log.debug("findUsers(): role = " + ldapRole.getDn());
-
- if (ldapRole.getName() == null)
- {
- throw new IdentityException("Role name canot be null");
- }
-
- //construct new member attribute values
- Attributes attrs = new BasicAttributes(true);
-
- Attribute member = new BasicAttribute(getMemberAttributeID());
- for (Iterator iterator = users.iterator(); iterator.hasNext();)
- {
- try
- {
- LDAPUserImpl user = (LDAPUserImpl)iterator.next();
- if (isUidAttributeIsDN())
- {
- member.add(user.getDn());
- }
- else
- {
- member.add(user.getId().toString());
- }
- }
- catch (ClassCastException e)
- {
- throw new IdentityException("Only can add LDAPUserImpl objects", e);
- }
- }
- attrs.put(member);
-
- getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to change Role members", e);
- }
-
- }
-
- public void assignRoles(User user, Set roles) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
- }
-
- //First build a list of roles DNs to add
- List roleDNsToAdd = new LinkedList();
-
- for (Iterator iterator = roles.iterator(); iterator.hasNext();)
- {
- try
- {
- LDAPRoleImpl role = (LDAPRoleImpl)iterator.next();
- roleDNsToAdd.add(role.getDn());
- }
- catch(ClassCastException e)
- {
- throw new IdentityException("Only can add LDAPRoleImpl objects", e);
- }
- }
-
- String memberName=null;
-
- //Find all the roles that currently contain user as member (need to remove user from some of them)
- if (isUidAttributeIsDN())
- {
- memberName = ldapUser.getDn();
- }
- else
- {
- memberName = ldapUser.getId().toString();
- }
-
-
- try
- {
-
- String filter = getMemberAttributeID().concat("=").concat(memberName);
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = getRoleModule().searchRoles(filter);
- List sr = Tools.toList(results);
- //iterate over roles that contain a user
- for (Iterator iterator = sr.iterator(); iterator.hasNext();)
- {
- SearchResult res = (SearchResult)iterator.next();
- DirContext ctx = (DirContext)res.getObject();
- String roleDN = ctx.getNameInNamespace();
- //if role is one which we want to add
- if (roleDNsToAdd.contains(roleDN))
- {
- //we do nothing but mark this role as added
- roleDNsToAdd.remove(roleDN);
- continue;
- }
- //if it's not on the list we need to remove user from it
- else
- {
- Attribute attr = res.getAttributes().get(getMemberAttributeID());
-
- //can't remove the last member (if the attribute is required by schema)
- //TODO: workaround this somehow.... (adding goofy user or admin instead?)
- if (attr.size() != 1)
- {
- //remove user name from the member list
- attr.remove(memberName);
-
- //and replace attributes
- Attributes newAttrs = new BasicAttributes(true);
- //newAttrs.put(getMemberAttributeID(), attr);
- newAttrs.put(attr);
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
- }
- else
- {
- log.error("Couldn't remove user from role as it was the last member - possibly required field in ldap");
- }
-
- //and mark this role as done
- roleDNsToAdd.remove(roleDN);
- }
- }
-
- //now iterate over roles that left to process
- for (Iterator iterator = roleDNsToAdd.iterator(); iterator.hasNext();)
- {
- String roleDN = (String)iterator.next();
-
- //changes to make
- ModificationItem[] mods = new ModificationItem[1];
- mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
- new BasicAttribute(getMemberAttributeID(), memberName));
- // Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(roleDN, mods);
- }
-
- //and that should be all...
- }
- catch (NamingException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
-
- }
-
- //TODO:don't forget to add this....
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
-
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticGroupMembershipModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticGroupMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,389 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.ldap.helper.LDAPTools;
+import org.jboss.portal.common.util.Tools;
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.ModificationItem;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPStaticGroupMembershipModuleImpl extends LDAPMembershipModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticGroupMembershipModuleImpl.class);
+
+
+ public Set getRoles(User user) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+ }
+
+ Set roles = new HashSet();
+ try
+ {
+
+ log.debug("getRoles(): user DN = " + ldapUser.getDn());
+
+ String memberName = "";
+
+ if (isUidAttributeIsDN())
+ {
+ memberName = ldapUser.getDn();
+ }
+ else
+ {
+ memberName = ldapUser.getId().toString();
+ }
+
+
+ String filter = getMemberAttributeID().concat("=").concat(memberName);
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = getRoleModule().searchRoles(filter);
+ List sr = Tools.toList(results);
+
+
+ for (Iterator iterator = sr.iterator(); iterator.hasNext();)
+ {
+ SearchResult res = (SearchResult)iterator.next();
+ DirContext ctx = (DirContext)res.getObject();
+ roles.add(getRoleModule().createRoleInstance(res.getAttributes(),ctx.getNameInNamespace()));
+ }
+
+
+
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to resolve userRoles: " + ldapUser.getId().toString(), e);
+ }
+
+ return roles;
+
+ }
+
+ public Set getUsers(Role role) throws IdentityException
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+
+ LDAPRoleImpl ldapRole = null;
+
+ if (role instanceof LDAPRoleImpl)
+ {
+ ldapRole = (LDAPRoleImpl)role;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+ }
+
+ //throw new UnsupportedOperationException("Not yet implemented");
+
+ Set users = new HashSet();
+
+ try
+ {
+ log.debug("findUsers(): role = " + ldapRole.getDn());
+
+ if (ldapRole.getName() == null)
+ {
+ throw new IdentityException("Role name canot be null");
+ }
+
+ //obtain Role entry attributes from directory
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapRole.getDn());
+
+ log.debug("Role attributes: " + attrs);
+ if (attrs == null )
+ {
+ throw new IdentityException("Cannot find Role with DN: " + ldapRole.getDn());
+ }
+
+ //iterate over user names belonging to this role
+ NamingEnumeration values = attrs.get(getMemberAttributeID()).getAll();
+ while (values.hasMoreElements())
+ {
+ String value = values.nextElement().toString();
+ String name = value;
+
+ try
+ {
+ //if user is pointed as DN get only it's name
+ if (!isUidAttributeIsDN())
+ {
+ name = LDAPTools.stripDnToName(name);
+ users.add(getUserModule().findUserByUserName(name));
+ }
+ else
+ {
+ users.add(getUserModule().findUserByDN(name));
+ }
+ }
+ catch(IdentityException ie)
+ {
+ log.error("Failed to find user: " + name + "/" + value, ie);
+
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Resolving Role Users failed.", e);
+ }
+
+ return users;
+
+ }
+
+ public void assignUsers(Role role, Set users) throws IdentityException
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+
+ LDAPRoleImpl ldapRole = null;
+
+ if (role instanceof LDAPRoleImpl)
+ {
+ ldapRole = (LDAPRoleImpl)role;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+ }
+
+
+
+ if (users.size() == 0)
+ {
+ throw new IdentityException("Cannot assigne 0 users to a role using this membership strategy (because some LDAPs " +
+ "require the member field to be set). ");
+ }
+
+ try
+ {
+ log.debug("findUsers(): role = " + ldapRole.getDn());
+
+ if (ldapRole.getName() == null)
+ {
+ throw new IdentityException("Role name canot be null");
+ }
+
+ //construct new member attribute values
+ Attributes attrs = new BasicAttributes(true);
+
+ Attribute member = new BasicAttribute(getMemberAttributeID());
+ for (Iterator iterator = users.iterator(); iterator.hasNext();)
+ {
+ try
+ {
+ LDAPUserImpl user = (LDAPUserImpl)iterator.next();
+ if (isUidAttributeIsDN())
+ {
+ member.add(user.getDn());
+ }
+ else
+ {
+ member.add(user.getId().toString());
+ }
+ }
+ catch (ClassCastException e)
+ {
+ throw new IdentityException("Only can add LDAPUserImpl objects", e);
+ }
+ }
+ attrs.put(member);
+
+ getConnectionContext().createInitialContext().modifyAttributes(ldapRole.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to change Role members", e);
+ }
+
+ }
+
+ public void assignRoles(User user, Set roles) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+ }
+
+ //First build a list of roles DNs to add
+ List roleDNsToAdd = new LinkedList();
+
+ for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+ {
+ try
+ {
+ LDAPRoleImpl role = (LDAPRoleImpl)iterator.next();
+ roleDNsToAdd.add(role.getDn());
+ }
+ catch(ClassCastException e)
+ {
+ throw new IdentityException("Only can add LDAPRoleImpl objects", e);
+ }
+ }
+
+ String memberName=null;
+
+ //Find all the roles that currently contain user as member (need to remove user from some of them)
+ if (isUidAttributeIsDN())
+ {
+ memberName = ldapUser.getDn();
+ }
+ else
+ {
+ memberName = ldapUser.getId().toString();
+ }
+
+
+ try
+ {
+
+ String filter = getMemberAttributeID().concat("=").concat(memberName);
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = getRoleModule().searchRoles(filter);
+ List sr = Tools.toList(results);
+ //iterate over roles that contain a user
+ for (Iterator iterator = sr.iterator(); iterator.hasNext();)
+ {
+ SearchResult res = (SearchResult)iterator.next();
+ DirContext ctx = (DirContext)res.getObject();
+ String roleDN = ctx.getNameInNamespace();
+ //if role is one which we want to add
+ if (roleDNsToAdd.contains(roleDN))
+ {
+ //we do nothing but mark this role as added
+ roleDNsToAdd.remove(roleDN);
+ continue;
+ }
+ //if it's not on the list we need to remove user from it
+ else
+ {
+ Attribute attr = res.getAttributes().get(getMemberAttributeID());
+
+ //can't remove the last member (if the attribute is required by schema)
+ //TODO: workaround this somehow.... (adding goofy user or admin instead?)
+ if (attr.size() != 1)
+ {
+ //remove user name from the member list
+ attr.remove(memberName);
+
+ //and replace attributes
+ Attributes newAttrs = new BasicAttributes(true);
+ //newAttrs.put(getMemberAttributeID(), attr);
+ newAttrs.put(attr);
+ getConnectionContext().createInitialContext().modifyAttributes(roleDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+ }
+ else
+ {
+ log.error("Couldn't remove user from role as it was the last member - possibly required field in ldap");
+ }
+
+ //and mark this role as done
+ roleDNsToAdd.remove(roleDN);
+ }
+ }
+
+ //now iterate over roles that left to process
+ for (Iterator iterator = roleDNsToAdd.iterator(); iterator.hasNext();)
+ {
+ String roleDN = (String)iterator.next();
+
+ //changes to make
+ ModificationItem[] mods = new ModificationItem[1];
+ mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
+ new BasicAttribute(getMemberAttributeID(), memberName));
+ // Perform the requested modifications on the named object
+ getConnectionContext().createInitialContext().modifyAttributes(roleDN, mods);
+ }
+
+ //and that should be all...
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+
+ }
+
+ //TODO:don't forget to add this....
+ public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticRoleMembershipModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,381 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.ldap.helper.LDAPTools;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.ModificationItem;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPStaticRoleMembershipModuleImpl extends LDAPMembershipModule//extends AbstractJBossService implements MembershipModule
-{
-
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticRoleMembershipModuleImpl.class);
-
- public Set getRoles(User user) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
- }
-
- Set roles = new HashSet();
-
- try
- {
- log.debug("findRoles(): role = " + ldapUser.getDn());
-
- if (ldapUser.getUserName() == null)
- {
- throw new IdentityException("Role name canot be null");
- }
-
- //obtain Role entry attributes from directory
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
-
- log.debug("User attributes: " + attrs);
- if (attrs == null )
- {
- throw new IdentityException("Cannot find User with DN: " + ldapUser.getDn());
- }
-
- Attribute memberOfAttribute = attrs.get(getMemberAttributeID());
-
- //if there are no members
- if (memberOfAttribute == null)
- {
- return roles;
- }
-
- //iterate over user names belonging to this role
- NamingEnumeration values = memberOfAttribute.getAll();
- while (values.hasMoreElements())
- {
- String value = values.nextElement().toString();
- String name = value;
-
- try
- {
- //if user is pointed as DN get only it's name
- if (!isUidAttributeIsDN())
- {
- name = LDAPTools.stripDnToName(name);
- roles.add(getRoleModule().findRoleByName(name));
- }
- else
- {
- roles.add(getRoleModule().findRoleByDN(name));
- }
- }
- catch(IdentityException ie)
- {
- log.error("Failed to find role: " + name + "/" + value, ie);
-
- }
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Resolving User Roles failed.", e);
- }
-
- return roles;
-
- }
-
- public Set getUsers(Role role) throws IdentityException
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
-
- LDAPRoleImpl ldapRole = null;
-
- if (role instanceof LDAPRoleImpl)
- {
- ldapRole = (LDAPRoleImpl)role;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
- }
-
- //throw new UnsupportedOperationException("Not yet implemented");
-
- Set users = new HashSet();
- try
- {
-
- log.debug("getUsers(): user DN = " + ldapRole.getDn());
-
- String memberOfName = "";
-
- if (isUidAttributeIsDN())
- {
- memberOfName = ldapRole.getDn();
- }
- else
- {
- memberOfName = ldapRole.getId().toString();
- }
-
- String filter = getMemberAttributeID().concat("=").concat(memberOfName);
- log.debug("Search filter: " + filter);
-
-
- //NamingEnumeration results = getConnectionContext().createInitialContext().search(getUserContainerDN(), filter, controls);
- NamingEnumeration results = getUserModule().searchUsers(filter);
- List sr = Tools.toList(results);
-
-
- for (Iterator iterator = sr.iterator(); iterator.hasNext();)
- {
- SearchResult res = (SearchResult)iterator.next();
- DirContext ctx = (DirContext)res.getObject();
- users.add(getUserModule().createUserInstance(res.getAttributes(),ctx.getNameInNamespace()));
- }
-
-
-
- }
- catch (Exception e)
- {
- log.debug("Failed to resolve role users: " + ldapRole.getId().toString(), e);
- }
-
- return users;
-
- }
-
- public void assignUsers(Role role, Set users) throws IdentityException
- {
- if (role == null)
- {
- throw new IllegalArgumentException("Role cannot be null");
- }
-
- LDAPRoleImpl ldapRole = null;
-
- if (role instanceof LDAPRoleImpl)
- {
- ldapRole = (LDAPRoleImpl)role;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
- }
-
-
- //First build a list of user DNs to add
- List userDNsToAdd = new LinkedList();
-
- for (Iterator iterator = users.iterator(); iterator.hasNext();)
- {
- try
- {
- LDAPUserImpl user = (LDAPUserImpl)iterator.next();
- userDNsToAdd.add(user.getDn());
- }
- catch(ClassCastException e)
- {
- throw new IdentityException("Only can add LDAPUserImpl objects", e);
- }
- }
-
- String memberOfName=null;
-
- //Find all the users that currently contain role as member (need to remove role from some of them)
- if (isUidAttributeIsDN())
- {
- memberOfName = ldapRole.getDn();
- }
- else
- {
- memberOfName = ldapRole.getId().toString();
- }
-
-
- try
- {
- String filter = getMemberAttributeID().concat("=").concat(memberOfName);
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = getUserModule().searchUsers(filter);
- List sr = Tools.toList(results);
- //iterate over users that contain a role
- for (Iterator iterator = sr.iterator(); iterator.hasNext();)
- {
- SearchResult res = (SearchResult)iterator.next();
- DirContext ctx = (DirContext)res.getObject();
- String userDN = ctx.getNameInNamespace();
- //if user is one which we want to add
- if (userDNsToAdd.contains(userDN))
- {
- //we do nothing but mark this user as added
- userDNsToAdd.remove(userDN);
- continue;
- }
- //if it's not on the list we need to remove role from it
- else
- {
- Attribute attr = res.getAttributes().get(getMemberAttributeID());
-
- attr.remove(memberOfName);
-
- //and replace attributes
- Attributes newAttrs = new BasicAttributes(true);
- //newAttrs.put(getMemberAttributeID(), attr);
- newAttrs.put(attr);
-
- getConnectionContext().createInitialContext().modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
-
- //and mark this role as done
- userDNsToAdd.remove(userDN);
- }
- }
-
- //now iterate over roles that left to process
- for (Iterator iterator = userDNsToAdd.iterator(); iterator.hasNext();)
- {
- String userDN = (String)iterator.next();
-
- //changes to make
- ModificationItem[] mods = new ModificationItem[1];
- mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
- new BasicAttribute(getMemberAttributeID(), memberOfName));
- // Perform the requested modifications on the named object
- getConnectionContext().createInitialContext().modifyAttributes(userDN, mods);
- }
-
- //and that should be all...
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to assign users", e);
- }
- }
-
- public void assignRoles(User user, Set roles) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
- }
-
- try
- {
- log.debug("findRoles(): user = " + ldapUser.getDn());
-
- if (ldapUser.getUserName() == null)
- {
- throw new IdentityException("User name canot be null");
- }
-
- //construct new member attribute values
- Attributes attrs = new BasicAttributes(true);
-
- Attribute member = new BasicAttribute(getMemberAttributeID());
- for (Iterator iterator = roles.iterator(); iterator.hasNext();)
- {
- try
- {
- LDAPRoleImpl role = (LDAPRoleImpl)iterator.next();
- if (isUidAttributeIsDN())
- {
- member.add(role.getDn());
- }
- else
- {
- member.add(role.getId().toString());
- }
- }
- catch (ClassCastException e)
- {
- throw new IdentityException("Only can add LDAPRoleImpl objects", e);
- }
- }
- attrs.put(member);
-
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to change Role members", e);
- }
-
- }
-
- //TODO:don't forget to add this....
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticRoleMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPStaticRoleMembershipModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPStaticRoleMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,375 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.ldap.helper.LDAPTools;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.ModificationItem;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPStaticRoleMembershipModuleImpl extends LDAPMembershipModule//extends AbstractJBossService implements MembershipModule
+{
+
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPStaticRoleMembershipModuleImpl.class);
+
+ public Set getRoles(User user) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+ }
+
+ Set roles = new HashSet();
+
+ try
+ {
+ log.debug("findRoles(): role = " + ldapUser.getDn());
+
+ if (ldapUser.getUserName() == null)
+ {
+ throw new IdentityException("Role name canot be null");
+ }
+
+ //obtain Role entry attributes from directory
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+
+ log.debug("User attributes: " + attrs);
+ if (attrs == null )
+ {
+ throw new IdentityException("Cannot find User with DN: " + ldapUser.getDn());
+ }
+
+ Attribute memberOfAttribute = attrs.get(getMemberAttributeID());
+
+ //if there are no members
+ if (memberOfAttribute == null)
+ {
+ return roles;
+ }
+
+ //iterate over user names belonging to this role
+ NamingEnumeration values = memberOfAttribute.getAll();
+ while (values.hasMoreElements())
+ {
+ String value = values.nextElement().toString();
+ String name = value;
+
+ try
+ {
+ //if user is pointed as DN get only it's name
+ if (!isUidAttributeIsDN())
+ {
+ name = LDAPTools.stripDnToName(name);
+ roles.add(getRoleModule().findRoleByName(name));
+ }
+ else
+ {
+ roles.add(getRoleModule().findRoleByDN(name));
+ }
+ }
+ catch(IdentityException ie)
+ {
+ log.error("Failed to find role: " + name + "/" + value, ie);
+
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Resolving User Roles failed.", e);
+ }
+
+ return roles;
+
+ }
+
+ public Set getUsers(Role role) throws IdentityException
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+
+ LDAPRoleImpl ldapRole = null;
+
+ if (role instanceof LDAPRoleImpl)
+ {
+ ldapRole = (LDAPRoleImpl)role;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+ }
+
+ //throw new UnsupportedOperationException("Not yet implemented");
+
+ Set users = new HashSet();
+ try
+ {
+
+ log.debug("getUsers(): user DN = " + ldapRole.getDn());
+
+ String memberOfName = "";
+
+ if (isUidAttributeIsDN())
+ {
+ memberOfName = ldapRole.getDn();
+ }
+ else
+ {
+ memberOfName = ldapRole.getId().toString();
+ }
+
+ String filter = getMemberAttributeID().concat("=").concat(memberOfName);
+ log.debug("Search filter: " + filter);
+
+
+ //NamingEnumeration results = getConnectionContext().createInitialContext().search(getUserContainerDN(), filter, controls);
+ NamingEnumeration results = getUserModule().searchUsers(filter);
+ List sr = Tools.toList(results);
+
+
+ for (Iterator iterator = sr.iterator(); iterator.hasNext();)
+ {
+ SearchResult res = (SearchResult)iterator.next();
+ DirContext ctx = (DirContext)res.getObject();
+ users.add(getUserModule().createUserInstance(res.getAttributes(),ctx.getNameInNamespace()));
+ }
+
+
+
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to resolve role users: " + ldapRole.getId().toString(), e);
+ }
+
+ return users;
+
+ }
+
+ public void assignUsers(Role role, Set users) throws IdentityException
+ {
+ if (role == null)
+ {
+ throw new IllegalArgumentException("Role cannot be null");
+ }
+
+ LDAPRoleImpl ldapRole = null;
+
+ if (role instanceof LDAPRoleImpl)
+ {
+ ldapRole = (LDAPRoleImpl)role;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPRoleImpl objects");
+ }
+
+
+ //First build a list of user DNs to add
+ List userDNsToAdd = new LinkedList();
+
+ for (Iterator iterator = users.iterator(); iterator.hasNext();)
+ {
+ try
+ {
+ LDAPUserImpl user = (LDAPUserImpl)iterator.next();
+ userDNsToAdd.add(user.getDn());
+ }
+ catch(ClassCastException e)
+ {
+ throw new IdentityException("Only can add LDAPUserImpl objects", e);
+ }
+ }
+
+ String memberOfName=null;
+
+ //Find all the users that currently contain role as member (need to remove role from some of them)
+ if (isUidAttributeIsDN())
+ {
+ memberOfName = ldapRole.getDn();
+ }
+ else
+ {
+ memberOfName = ldapRole.getId().toString();
+ }
+
+
+ try
+ {
+ String filter = getMemberAttributeID().concat("=").concat(memberOfName);
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = getUserModule().searchUsers(filter);
+ List sr = Tools.toList(results);
+ //iterate over users that contain a role
+ for (Iterator iterator = sr.iterator(); iterator.hasNext();)
+ {
+ SearchResult res = (SearchResult)iterator.next();
+ DirContext ctx = (DirContext)res.getObject();
+ String userDN = ctx.getNameInNamespace();
+ //if user is one which we want to add
+ if (userDNsToAdd.contains(userDN))
+ {
+ //we do nothing but mark this user as added
+ userDNsToAdd.remove(userDN);
+ continue;
+ }
+ //if it's not on the list we need to remove role from it
+ else
+ {
+ Attribute attr = res.getAttributes().get(getMemberAttributeID());
+
+ attr.remove(memberOfName);
+
+ //and replace attributes
+ Attributes newAttrs = new BasicAttributes(true);
+ //newAttrs.put(getMemberAttributeID(), attr);
+ newAttrs.put(attr);
+
+ getConnectionContext().createInitialContext().modifyAttributes(userDN, DirContext.REPLACE_ATTRIBUTE, newAttrs);
+
+ //and mark this role as done
+ userDNsToAdd.remove(userDN);
+ }
+ }
+
+ //now iterate over roles that left to process
+ for (Iterator iterator = userDNsToAdd.iterator(); iterator.hasNext();)
+ {
+ String userDN = (String)iterator.next();
+
+ //changes to make
+ ModificationItem[] mods = new ModificationItem[1];
+ mods[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
+ new BasicAttribute(getMemberAttributeID(), memberOfName));
+ // Perform the requested modifications on the named object
+ getConnectionContext().createInitialContext().modifyAttributes(userDN, mods);
+ }
+
+ //and that should be all...
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to assign users", e);
+ }
+ }
+
+ public void assignRoles(User user, Set roles) throws IdentityException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("UserMembershipModuleImpl supports only LDAPUserImpl objects");
+ }
+
+ try
+ {
+ log.debug("findRoles(): user = " + ldapUser.getDn());
+
+ if (ldapUser.getUserName() == null)
+ {
+ throw new IdentityException("User name canot be null");
+ }
+
+ //construct new member attribute values
+ Attributes attrs = new BasicAttributes(true);
+
+ Attribute member = new BasicAttribute(getMemberAttributeID());
+ for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+ {
+ try
+ {
+ LDAPRoleImpl role = (LDAPRoleImpl)iterator.next();
+ if (isUidAttributeIsDN())
+ {
+ member.add(role.getDn());
+ }
+ else
+ {
+ member.add(role.getId().toString());
+ }
+ }
+ catch (ClassCastException e)
+ {
+ throw new IdentityException("Only can add LDAPRoleImpl objects", e);
+ }
+ }
+ attrs.put(member);
+
+ getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE, attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to change Role members", e);
+ }
+
+ }
+
+ //TODO:don't forget to add this....
+ public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,229 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.ProfileMap;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.common.util.Tools;
-
-import java.security.NoSuchAlgorithmException;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPUserImpl implements User
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserImpl.class);
-
- //TODO: make setters to update the state of the entry
-
- //TODO:this is to enable user act like a fasade to identity modules calls
- IdentityContext identityContext;
-
- private UserProfileModule userProfileModule;
-
- private String dn;
-
- //In ldap implementation it acts as a userName
- private String id;
-
- private String password;
-
- //private String realEmail;
-
- private LDAPUserImpl()
- {
-
- }
-
- /**
- * Creates a ldap user implementation instance
- *
- * @param dn
- * @param context
- * @param password - should contain already encrypted password from ldap
- * @throws IdentityException
- */
- public LDAPUserImpl(String dn, IdentityContext context, String id, String password) throws IdentityException
- {
- if (dn == null)
- {
- throw new IdentityException("Cannot create LDAPUserImpl without DN");
- }
- this.dn = dn;
-
- if (context == null)
- {
- throw new IllegalArgumentException("IdentityContext can't be null");
- }
-
- if (password == null)
- {
- throw new IllegalArgumentException("Password can't be null");
- }
-
- if (id == null)
- {
- throw new IllegalArgumentException("Id can't be null");
- }
-
- this.identityContext = context;
- this.password = password;
- //this.realEmail = email;
- this.id = id;
-
- }
-
- public void updatePassword(String password)
- {
- //TODO: somehow update the password to ldap?
- String algorithm = getHashAlgorightm();
- if (algorithm == null)
- {
- this.password = password;
- }
- else
- {
- try
- {
- this.password = Tools.hashAndEncodeString(password,algorithm, getHashEncoding());
- }
- catch(Exception e)
- {
- log.error("Cannot update the password",e);
- }
- }
- }
-
- public boolean validatePassword(String password)
- {
-
- String algorithm = getHashAlgorightm();
- if (algorithm == null)
- {
- return this.password.equals(password);
- }
- else
- {
- try
- {
- return this.password.equals(Tools.hashAndEncodeString(password,algorithm, getHashEncoding()));
- }
- catch(NoSuchAlgorithmException e)
- {
- log.error("Cannot validate the password",e);
- }
- return false;
- }
- }
-
- public String getPassword()
- {
- return this.password;
- }
-
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- //**************************
- //*** Getter and Setters
- //**************************
-
- public String getDn()
- {
- return dn;
- }
-
- public void setId(String id)
- {
- this.id = id;
- }
-
-
- public Object getId()
- {
- return id;
- }
-
- public UserProfileModule getUserProfileModule()
- {
- return userProfileModule;
- }
-
- public void setUserProfileModule(UserProfileModule userProfileModule)
- {
- this.userProfileModule = userProfileModule;
- }
-
-
- public String getUserName()
- {
- return this.id;
- }
-
- public void setUserName(String userName)
- {
- this.id = userName;
- }
-
- private IdentityConfiguration getIdentityConfiguration() throws IdentityException
- {
- return (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
-
- private String getHashAlgorightm()
- {
- try
- {
- return getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ALGORITHM);
- }
- catch(Exception e)
- {
- return null;
- }
- }
-
- private String getHashEncoding()
- {
- try
- {
- String enc = getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ENCODING);
- if (enc != null)
- {
- return enc;
- }
- }
- catch(Exception e)
- {
- //nothing
- }
- return "hex";
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,228 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.common.util.Tools;
+
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPUserImpl implements User
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserImpl.class);
+
+ //TODO: make setters to update the state of the entry
+
+ //TODO:this is to enable user act like a fasade to identity modules calls
+ IdentityContext identityContext;
+
+ private UserProfileModule userProfileModule;
+
+ private String dn;
+
+ //In ldap implementation it acts as a userName
+ private String id;
+
+ private String password;
+
+ //private String realEmail;
+
+ private LDAPUserImpl()
+ {
+
+ }
+
+ /**
+ * Creates a ldap user implementation instance
+ *
+ * @param dn
+ * @param context
+ * @param password - should contain already encrypted password from ldap
+ * @throws IdentityException
+ */
+ protected LDAPUserImpl(String dn, IdentityContext context, String id, String password) throws IdentityException
+ {
+ if (dn == null)
+ {
+ throw new IdentityException("Cannot create LDAPUserImpl without DN");
+ }
+ this.dn = dn;
+
+ if (context == null)
+ {
+ throw new IllegalArgumentException("IdentityContext can't be null");
+ }
+
+ if (password == null)
+ {
+ throw new IllegalArgumentException("Password can't be null");
+ }
+
+ if (id == null)
+ {
+ throw new IllegalArgumentException("Id can't be null");
+ }
+
+ this.identityContext = context;
+ this.password = password;
+ //this.realEmail = email;
+ this.id = id;
+
+ }
+
+ public void updatePassword(String password)
+ {
+ //TODO: somehow update the password to ldap?
+ String algorithm = getHashAlgorightm();
+ if (algorithm == null)
+ {
+ this.password = password;
+ }
+ else
+ {
+ try
+ {
+ this.password = Tools.hashAndEncodeString(password,algorithm, getHashEncoding());
+ }
+ catch(Exception e)
+ {
+ log.error("Cannot update the password",e);
+ }
+ }
+ }
+
+ public boolean validatePassword(String password)
+ {
+
+ String algorithm = getHashAlgorightm();
+ if (algorithm == null)
+ {
+ return this.password.equals(password);
+ }
+ else
+ {
+ try
+ {
+ return this.password.equals(Tools.hashAndEncodeString(password,algorithm, getHashEncoding()));
+ }
+ catch(NoSuchAlgorithmException e)
+ {
+ log.error("Cannot validate the password",e);
+ }
+ return false;
+ }
+ }
+
+ public String getPassword()
+ {
+ return this.password;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ //**************************
+ //*** Getter and Setters
+ //**************************
+
+ public String getDn()
+ {
+ return dn;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ public UserProfileModule getUserProfileModule()
+ {
+ return userProfileModule;
+ }
+
+ public void setUserProfileModule(UserProfileModule userProfileModule)
+ {
+ this.userProfileModule = userProfileModule;
+ }
+
+
+ public String getUserName()
+ {
+ return this.id;
+ }
+
+ public void setUserName(String userName)
+ {
+ this.id = userName;
+ }
+
+ private IdentityConfiguration getIdentityConfiguration() throws IdentityException
+ {
+ return (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+
+ private String getHashAlgorightm()
+ {
+ try
+ {
+ return getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ALGORITHM);
+ }
+ catch(Exception e)
+ {
+ return null;
+ }
+ }
+
+ private String getHashEncoding()
+ {
+ try
+ {
+ String enc = getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ENCODING);
+ if (enc != null)
+ {
+ return enc;
+ }
+ }
+ catch(Exception e)
+ {
+ //nothing
+ }
+ return "hex";
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,252 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.jboss.portal.identity.NoSuchUserException;
-
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.NamingException;
-import javax.naming.NamingEnumeration;
-import javax.naming.InitialContext;
-import java.util.NoSuchElementException;
-import java.util.Map;
-
-/**
- * Abstract LDAPUserModule that should be extended to provide compabitibility across identity modules
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LDAPUserModule extends UserModuleService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModule.class);
-
- private LDAPConnectionContext connectionContext;
-
- private UserProfileModule userProfileModule;
-
-
- protected void startService() throws Exception
- {
- if (getConnectionJNDIName() == null)
- {
- throw new IdentityException("Cannot obtain ldap connection context JNDI name");
- }
-
- connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
-
- super.startService(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
- //TODO: add enabled
- public LDAPUserImpl createUserInstance(Attributes attrs, String dn) throws IdentityException
- {
- LDAPUserImpl ldapu = null;
- try
- {
- log.debug("Search result attributes: " + attrs);
-
-
- Attribute uida = attrs.get(getUidAttributeID());
- if (uida == null)
- {
- throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getUidAttributeID());
- }
-
- Attribute passwd = attrs.get(getPasswordAttributeId());
- if (passwd == null)
- {
- throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getPasswordAttributeId());
- }
-
- ldapu = new LDAPUserImpl(dn,getIdentityContext(), uida.get().toString(), passwd.get().toString());
-
-
- log.debug("user uid: " + ldapu.getId());
- log.debug("user dn: " + ldapu.getDn());
-
-
- }
- catch (NamingException e)
- {
- throw new IdentityException("Couldn't create LDAPUserImpl object from ldap entry (SearchResult)", e);
- }
-
- return ldapu;
- }
-
- /**
- * method not belonging to UserModule interface - ldap specific.
- *
- */
- public User findUserByDN(String dn) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- try
- {
- log.debug("findUserByDN(): DN = " + dn);
-
- if (dn == null)
- {
- throw new IdentityException("User dn canot be null");
- }
-
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
-
- if (attrs == null)
- {
- throw new IdentityException("Can't find user entry with DN: " + dn);
- }
-
- return createUserInstance(attrs, dn);
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No user found with dn: " + dn, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return null;
-
- }
-
- /**
- * This method should be used by over modules to perform searches. It will allow user module
- * implementation to apply proper filter and search scope from the configuration
- *
- * @param filter that will be concatenated with proper user search filter from the module
- * @return
- */
- public abstract NamingEnumeration searchUsers(String filter) throws NamingException, IdentityException;
-
-
- //**************************
- //*** Getter and Setters
- //**************************
-
- protected UserProfileModule getUserProfileModule() throws IdentityException
- {
- if (userProfileModule == null)
- {
- this.userProfileModule = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
- }
- return userProfileModule;
- }
-
- protected String getUidAttributeID() throws IdentityException
- {
- String uid = getIdentityConfiguration().getValue(IdentityConfiguration.USER_UID_ATTRIBUTE_ID);
- if (uid == null)
- {
- return "uid";
- }
- return uid;
- }
-
- protected String getHashAlgorightm()
- {
- try
- {
- return getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ALGORITHM);
- }
- catch(Exception e)
- {
- return null;
- }
- }
-
- protected String getHashEncoding() throws IdentityException
- {
- String enc = getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ENCODING);
- if (enc == null)
- {
- return "hex";
- }
- return enc;
- }
-
- protected LDAPConnectionContext getConnectionContext() throws IdentityException
- {
- if (connectionContext == null)
- {
- //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
- throw new IdentityException("No LDAPConnectionContext available");
- }
- return connectionContext;
- }
-
- protected String getContainerDN() throws IdentityException
- {
- String cont = getIdentityConfiguration().getValue(IdentityConfiguration.USER_CONTAINER_DN);
- if (cont == null)
- {
- throw new IdentityException("Configuration option missing: " + IdentityConfiguration.USER_CONTAINER_DN);
- }
- return cont;
- }
-
- protected String getPasswordAttributeId() throws IdentityException
- {
- String passwd = getIdentityConfiguration().getValue(IdentityConfiguration.USER_PASSWORD_ATTRIBUTE_ID);
- if (passwd == null)
- {
- return "userPassword";
- }
- else
- {
- return passwd;
- }
- }
-
- /*protected String getEmailAttributeId() throws IdentityException
- {
- String email = getIdentityConfiguration().getValue(IdentityConfiguration.USER_EMAIL_ATTRIBUTE_ID);
- if (email == null)
- {
- return "mail";
- }
- else
- {
- return email;
- }
- }*/
-
- protected Map getAttributesToAdd() throws IdentityException
- {
- Map attributesToAdd = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_CREATE_ATTRIBUTES);
- if (attributesToAdd == null)
- {
- throw new IdentityException(IdentityConfiguration.GROUP_USER_CREATE_ATTRIBUTES + " missing in configuration");
- }
- return attributesToAdd;
- }
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModule.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,252 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.service.UserModuleService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityConfiguration;
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.NamingException;
+import javax.naming.NamingEnumeration;
+import javax.naming.InitialContext;
+import java.util.NoSuchElementException;
+import java.util.Map;
+
+/**
+ * Abstract LDAPUserModule that should be extended to provide compabitibility across identity modules
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class LDAPUserModule extends UserModuleService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModule.class);
+
+ private LDAPConnectionContext connectionContext;
+
+ private UserProfileModule userProfileModule;
+
+
+ protected void startService() throws Exception
+ {
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI name");
+ }
+
+ connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
+
+ super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ //TODO: add enabled
+ public LDAPUserImpl createUserInstance(Attributes attrs, String dn) throws IdentityException
+ {
+ LDAPUserImpl ldapu = null;
+ try
+ {
+ log.debug("Search result attributes: " + attrs);
+
+
+ Attribute uida = attrs.get(getUidAttributeID());
+ if (uida == null)
+ {
+ throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getUidAttributeID());
+ }
+
+ Attribute passwd = attrs.get(getPasswordAttributeId());
+ if (passwd == null)
+ {
+ throw new IdentityException("LDAP entry doesn't contain proper attribute:" + getPasswordAttributeId());
+ }
+
+ ldapu = new LDAPUserImpl(dn,getIdentityContext(), uida.get().toString(), passwd.get().toString());
+
+
+ log.debug("user uid: " + ldapu.getId());
+ log.debug("user dn: " + ldapu.getDn());
+
+
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Couldn't create LDAPUserImpl object from ldap entry (SearchResult)", e);
+ }
+
+ return ldapu;
+ }
+
+ /**
+ * method not belonging to UserModule interface - ldap specific.
+ *
+ */
+ public User findUserByDN(String dn) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ try
+ {
+ log.debug("findUserByDN(): DN = " + dn);
+
+ if (dn == null)
+ {
+ throw new IdentityException("User dn canot be null");
+ }
+
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(dn);
+
+ if (attrs == null)
+ {
+ throw new IdentityException("Can't find user entry with DN: " + dn);
+ }
+
+ return createUserInstance(attrs, dn);
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No user found with dn: " + dn, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return null;
+
+ }
+
+ /**
+ * This method should be used by over modules to perform searches. It will allow user module
+ * implementation to apply proper filter and search scope from the configuration
+ *
+ * @param filter that will be concatenated with proper user search filter from the module
+ * @return
+ */
+ public abstract NamingEnumeration searchUsers(String filter) throws NamingException, IdentityException;
+
+
+ //**************************
+ //*** Getter and Setters
+ //**************************
+
+ protected UserProfileModule getUserProfileModule() throws IdentityException
+ {
+ if (userProfileModule == null)
+ {
+ this.userProfileModule = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ }
+ return userProfileModule;
+ }
+
+ protected String getUidAttributeID() throws IdentityException
+ {
+ String uid = getIdentityConfiguration().getValue(IdentityConfiguration.USER_UID_ATTRIBUTE_ID);
+ if (uid == null)
+ {
+ return "uid";
+ }
+ return uid;
+ }
+
+ protected String getHashAlgorightm()
+ {
+ try
+ {
+ return getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ALGORITHM);
+ }
+ catch(Exception e)
+ {
+ return null;
+ }
+ }
+
+ protected String getHashEncoding() throws IdentityException
+ {
+ String enc = getIdentityConfiguration().getValue(IdentityConfiguration.HASH_ENCODING);
+ if (enc == null)
+ {
+ return "hex";
+ }
+ return enc;
+ }
+
+ protected LDAPConnectionContext getConnectionContext() throws IdentityException
+ {
+ if (connectionContext == null)
+ {
+ //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
+ throw new IdentityException("No LDAPConnectionContext available");
+ }
+ return connectionContext;
+ }
+
+ protected String getContainerDN() throws IdentityException
+ {
+ String cont = getIdentityConfiguration().getValue(IdentityConfiguration.USER_CONTAINER_DN);
+ if (cont == null)
+ {
+ throw new IdentityException("Configuration option missing: " + IdentityConfiguration.USER_CONTAINER_DN);
+ }
+ return cont;
+ }
+
+ protected String getPasswordAttributeId() throws IdentityException
+ {
+ String passwd = getIdentityConfiguration().getValue(IdentityConfiguration.USER_PASSWORD_ATTRIBUTE_ID);
+ if (passwd == null)
+ {
+ return "userPassword";
+ }
+ else
+ {
+ return passwd;
+ }
+ }
+
+ /*protected String getEmailAttributeId() throws IdentityException
+ {
+ String email = getIdentityConfiguration().getValue(IdentityConfiguration.USER_EMAIL_ATTRIBUTE_ID);
+ if (email == null)
+ {
+ return "mail";
+ }
+ else
+ {
+ return email;
+ }
+ }*/
+
+ protected Map getAttributesToAdd() throws IdentityException
+ {
+ Map attributesToAdd = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_CREATE_ATTRIBUTES);
+ if (attributesToAdd == null)
+ {
+ throw new IdentityException(IdentityConfiguration.GROUP_USER_CREATE_ATTRIBUTES + " missing in configuration");
+ }
+ return attributesToAdd;
+ }
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,327 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.IdentityConfiguration;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.Context;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapContext;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Iterator;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * Simple implementation of UserModule for LDAP support. Search of users is limited to one place * containerField - DN
- * of entry containing users (like ou=People,dc=example,dc=com). It's where users will be added using createUser()
- * method. Under this DN users will be searched using ONELEVEL_SCOPE * uidAttributeID - attribute that stores user id.
- * Default value is "uid"
- *
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPUserModuleImpl extends LDAPUserModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModuleImpl.class);
-
- public User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- try
- {
- log.debug("findUserByUserName(): username = " + userName);
-
- if (userName == null)
- {
- throw new IdentityException("User name canot be null");
- }
-
-
- String filter = "(".concat(getUidAttributeID()).concat("=").concat(userName).concat(")");
- log.debug("Search filter: " + filter);
-
- NamingEnumeration results = searchUsers(filter);
- List sr = Tools.toList(results);
- if (sr.size() > 1)
- {
- throw new IdentityException("Found more than one user with id: " + userName + "" +
- "Posible data inconsistency");
- }
- SearchResult res = (SearchResult)sr.iterator().next();
- Context ctx = (Context)res.getObject();
- String dn = ctx.getNameInNamespace();
- return createUserInstance(res.getAttributes(), dn);
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No user found with name: " + userName, e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return null;
-
- }
-
- public User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- if (id == null)
- {
- throw new IdentityException("Cannot search user with null id");
- }
- if (!(id instanceof String))
- {
- throw new IdentityException("Only String id is suppoted");
- }
- return findUserById((String)id);
-
- }
-
- public User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException
- {
- return findUserByUserName(id);
- }
-
-
-
-
- public User createUser(String userName, String password) throws IdentityException, IllegalArgumentException
- {
-
- if (userName == null)
- {
- throw new IdentityException("User name cannot be null");
- }
- /*if (realEmail == null)
- {
- throw new IdentityException("User email cannot be null");
- }*/
- if (password == null)
- {
- throw new IdentityException("User password cannot be null");
- }
-
- log.debug("Creating user: " + userName);
-
-
- try
- {
- //
- LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
-
- //We store new entry using set of attributes. This should give more flexibility then
- //extending user object from ContextDir - configure what objectClass place there
- Attributes attrs = new BasicAttributes(true);
-
- //create attribute using provided configuration
- Map attributesToAdd = getAttributesToAdd();
-
- //attributes
- for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
- {
- String attributeName = (String)it1.next();
- log.debug("adding attribute: " + attributeName);
- Attribute attr = new BasicAttribute(attributeName);
- Set attributeValues = (Set)attributesToAdd.get(attributeName);
-
- //values
- for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
- {
- String attrValue = (String)it2.next();
- log.debug("adding attribute value: " + attrValue);
- attr.add(attrValue);
- }
- attrs.put(attr);
- }
-
- //TODO:testcase password behaviour
- String algorithm = getHashAlgorightm();
- if (algorithm == null)
- {
- attrs.put(getPasswordAttributeId(), password);
- }
- else
- {
- attrs.put(getPasswordAttributeId(), Tools.hashAndEncodeString(password,algorithm, getHashEncoding()));
- }
-
- //
- //email
- //attrs.put(getEmailAttributeId(), realEmail);
-
- String dn = getUidAttributeID().concat("=").concat(userName);
-
- log.debug("creating ldap entry for: " + dn + "; " + attrs);
- ctx.createSubcontext(dn, attrs);
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new IdentityException("Failed to create user", e);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Failed to create user", e);
- }
-
- return findUserByUserName(userName);
- }
-
- //TODO: remove user assignments before?
- public void removeUser(Object id) throws IdentityException, IllegalArgumentException
- {
-
- LDAPUserImpl ldapu = (LDAPUserImpl)findUserById(id);
-
- if (ldapu == null)
- {
- throw new IdentityException("Cannot find user for removal");
- }
-
- if (ldapu.getDn() == null)
- {
- throw new IdentityException("Cannot obtain DN of user");
- }
-
- try
- {
- LdapContext ctx = getConnectionContext().createInitialContext();//.lookup(getContainerDN());
- log.debug("removing entry: " + ldapu.getDn());
- ctx.unbind(ldapu.getDn());
- }
- catch (Exception e)
- {
- throw new IdentityException("Failed to remove user: ", e);
- }
-
-
- }
-
-
- public Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException
- {
-
- return findUsersFilteredByUserName("*",0,0);
-
- }
-
- //TODO:implement something to use offset and limit - sort asc and
- //TODO: and testcase this...
- public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException
- {
- log.info("Current implementation of findUsersFilteredByUserName returns all users and is not \"offset\" and \"limit\" sensitive ");
-
- Set uf = new HashSet();
-
- try
- {
- //search all entries containing "uid" attribute
- String ldap_filter = "(".concat(getUidAttributeID()).concat("=").concat(filter).concat(")");
- log.debug("Search filter: " + filter);
-
-
- NamingEnumeration results = searchUsers(ldap_filter);
- while (results.hasMoreElements())
- {
- SearchResult res = (SearchResult)results.nextElement();
- Context ctx = (Context)res.getObject();
- String dn = ctx.getNameInNamespace();
- uf.add(createUserInstance(res.getAttributes(), dn));
- }
- }
- catch (NoSuchElementException e)
- {
- log.debug("No users found", e);
- }
- catch (Exception e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return uf;
-
- }
-
- public int getUserCount() throws IdentityException, IllegalArgumentException
- {
- try
- {
- //search all entries containing "uid" attribute
- String filter = "(".concat(getUidAttributeID()).concat("=").concat("*").concat(")");
- log.debug("Search filter: " + filter);
-
-
- NamingEnumeration results = searchUsers(filter);
- List sr = Tools.toList(results);
-
- return sr.size();
-
- }
- catch (NoSuchElementException e)
- {
- log.debug("No users found", e);
- }
- catch (Exception e)
- {
- throw new IdentityException("User search failed.", e);
- }
- return 0;
- }
-
-
- /**
- * This method should be used by over modules to perform searches. It will allow user module
- * implementation to apply proper filter and search scope from the configuration
- *
- * @param filter that will be concatenated with proper user search filter from the module
- * @return
- */
- public NamingEnumeration searchUsers(String filter) throws NamingException, IdentityException
- {
- SearchControls controls = new SearchControls();
- controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
- controls.setReturningObjFlag(true);
-
- //String filter = getUidAttributeID().concat("=").concat(userName);
- log.debug("Search filter: " + filter);
-
-
- return getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
- }
-}
-
-
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,326 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.User;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Context;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Iterator;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Simple implementation of UserModule for LDAP support. Search of users is limited to one place * containerField - DN
+ * of entry containing users (like ou=People,dc=example,dc=com). It's where users will be added using createUser()
+ * method. Under this DN users will be searched using ONELEVEL_SCOPE * uidAttributeID - attribute that stores user id.
+ * Default value is "uid"
+ *
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPUserModuleImpl extends LDAPUserModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserModuleImpl.class);
+
+ public User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ try
+ {
+ log.debug("findUserByUserName(): username = " + userName);
+
+ if (userName == null)
+ {
+ throw new IdentityException("User name canot be null");
+ }
+
+
+ String filter = "(".concat(getUidAttributeID()).concat("=").concat(userName).concat(")");
+ log.debug("Search filter: " + filter);
+
+ NamingEnumeration results = searchUsers(filter);
+ List sr = Tools.toList(results);
+ if (sr.size() > 1)
+ {
+ throw new IdentityException("Found more than one user with id: " + userName + "" +
+ "Posible data inconsistency");
+ }
+ SearchResult res = (SearchResult)sr.iterator().next();
+ Context ctx = (Context)res.getObject();
+ String dn = ctx.getNameInNamespace();
+ return createUserInstance(res.getAttributes(), dn);
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No user found with name: " + userName, e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return null;
+
+ }
+
+ public User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ if (id == null)
+ {
+ throw new IdentityException("Cannot search user with null id");
+ }
+ if (!(id instanceof String))
+ {
+ throw new IdentityException("Only String id is suppoted");
+ }
+ return findUserById((String)id);
+
+ }
+
+ public User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException
+ {
+ return findUserByUserName(id);
+ }
+
+
+
+
+ public User createUser(String userName, String password) throws IdentityException, IllegalArgumentException
+ {
+
+ if (userName == null)
+ {
+ throw new IdentityException("User name cannot be null");
+ }
+ /*if (realEmail == null)
+ {
+ throw new IdentityException("User email cannot be null");
+ }*/
+ if (password == null)
+ {
+ throw new IdentityException("User password cannot be null");
+ }
+
+ log.debug("Creating user: " + userName);
+
+
+ try
+ {
+ //
+ LdapContext ctx = (LdapContext)getConnectionContext().createInitialContext().lookup(getContainerDN());
+
+ //We store new entry using set of attributes. This should give more flexibility then
+ //extending user object from ContextDir - configure what objectClass place there
+ Attributes attrs = new BasicAttributes(true);
+
+ //create attribute using provided configuration
+ Map attributesToAdd = getAttributesToAdd();
+
+ //attributes
+ for (Iterator it1 = attributesToAdd.keySet().iterator(); it1.hasNext();)
+ {
+ String attributeName = (String)it1.next();
+ log.debug("adding attribute: " + attributeName);
+ Attribute attr = new BasicAttribute(attributeName);
+ Set attributeValues = (Set)attributesToAdd.get(attributeName);
+
+ //values
+ for (Iterator it2 = attributeValues.iterator(); it2.hasNext();)
+ {
+ String attrValue = (String)it2.next();
+ log.debug("adding attribute value: " + attrValue);
+ attr.add(attrValue);
+ }
+ attrs.put(attr);
+ }
+
+ //TODO:testcase password behaviour
+ String algorithm = getHashAlgorightm();
+ if (algorithm == null)
+ {
+ attrs.put(getPasswordAttributeId(), password);
+ }
+ else
+ {
+ attrs.put(getPasswordAttributeId(), Tools.hashAndEncodeString(password,algorithm, getHashEncoding()));
+ }
+
+ //
+ //email
+ //attrs.put(getEmailAttributeId(), realEmail);
+
+ String dn = getUidAttributeID().concat("=").concat(userName);
+
+ log.debug("creating ldap entry for: " + dn + "; " + attrs);
+ ctx.createSubcontext(dn, attrs);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new IdentityException("Failed to create user", e);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Failed to create user", e);
+ }
+
+ return findUserByUserName(userName);
+ }
+
+ //TODO: remove user assignments before?
+ public void removeUser(Object id) throws IdentityException, IllegalArgumentException
+ {
+
+ LDAPUserImpl ldapu = (LDAPUserImpl)findUserById(id);
+
+ if (ldapu == null)
+ {
+ throw new IdentityException("Cannot find user for removal");
+ }
+
+ if (ldapu.getDn() == null)
+ {
+ throw new IdentityException("Cannot obtain DN of user");
+ }
+
+ try
+ {
+ LdapContext ctx = getConnectionContext().createInitialContext();//.lookup(getContainerDN());
+ log.debug("removing entry: " + ldapu.getDn());
+ ctx.unbind(ldapu.getDn());
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Failed to remove user: ", e);
+ }
+
+
+ }
+
+
+ public Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException
+ {
+
+ return findUsersFilteredByUserName("*",0,0);
+
+ }
+
+ //TODO:implement something to use offset and limit - sort asc and
+ //TODO: and testcase this...
+ public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException
+ {
+ log.info("Current implementation of findUsersFilteredByUserName returns all users and is not \"offset\" and \"limit\" sensitive ");
+
+ Set uf = new HashSet();
+
+ try
+ {
+ //search all entries containing "uid" attribute
+ String ldap_filter = "(".concat(getUidAttributeID()).concat("=").concat(filter).concat(")");
+ log.debug("Search filter: " + filter);
+
+
+ NamingEnumeration results = searchUsers(ldap_filter);
+ while (results.hasMoreElements())
+ {
+ SearchResult res = (SearchResult)results.nextElement();
+ Context ctx = (Context)res.getObject();
+ String dn = ctx.getNameInNamespace();
+ uf.add(createUserInstance(res.getAttributes(), dn));
+ }
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No users found", e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return uf;
+
+ }
+
+ public int getUserCount() throws IdentityException, IllegalArgumentException
+ {
+ try
+ {
+ //search all entries containing "uid" attribute
+ String filter = "(".concat(getUidAttributeID()).concat("=").concat("*").concat(")");
+ log.debug("Search filter: " + filter);
+
+
+ NamingEnumeration results = searchUsers(filter);
+ List sr = Tools.toList(results);
+
+ return sr.size();
+
+ }
+ catch (NoSuchElementException e)
+ {
+ log.debug("No users found", e);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("User search failed.", e);
+ }
+ return 0;
+ }
+
+
+ /**
+ * This method should be used by over modules to perform searches. It will allow user module
+ * implementation to apply proper filter and search scope from the configuration
+ *
+ * @param filter that will be concatenated with proper user search filter from the module
+ * @return
+ */
+ public NamingEnumeration searchUsers(String filter) throws NamingException, IdentityException
+ {
+ SearchControls controls = new SearchControls();
+ controls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
+ controls.setReturningObjFlag(true);
+
+ //String filter = getUidAttributeID().concat("=").concat(userName);
+ log.debug("Search filter: " + filter);
+
+
+ return getConnectionContext().createInitialContext().search(getContainerDN(), filter, controls);
+ }
+}
+
+
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,64 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.jboss.portal.identity.IdentityException;
-
-import javax.naming.InitialContext;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LDAPUserProfileModule extends UserProfileModuleService
-{
- private LDAPConnectionContext connectionContext;
-
- protected void startService() throws Exception
- {
- if (getConnectionJNDIName() == null)
- {
- throw new IdentityException("Cannot obtain ldap connection context JNDI name");
- }
- connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
-
- super.startService(); //To change body of overridden methods use File | Settings | File Templates.
- }
-
- protected LDAPConnectionContext getConnectionContext() throws IdentityException
- {
- if (connectionContext == null)
- {
- //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
- throw new IdentityException("No LDAPConnectionContext available");
- }
- return connectionContext;
- }
-
- public void setConnectionContext(LDAPConnectionContext connectionContext)
- {
- this.connectionContext = connectionContext;
- }
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModule.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.jboss.portal.identity.IdentityException;
+
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class LDAPUserProfileModule extends UserProfileModuleService
+{
+ private LDAPConnectionContext connectionContext;
+
+ protected void startService() throws Exception
+ {
+ if (getConnectionJNDIName() == null)
+ {
+ throw new IdentityException("Cannot obtain ldap connection context JNDI name");
+ }
+ connectionContext = (LDAPConnectionContext)new InitialContext().lookup(getConnectionJNDIName());
+
+ super.startService(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ protected LDAPConnectionContext getConnectionContext() throws IdentityException
+ {
+ if (connectionContext == null)
+ {
+ //this.connectionContext = (LDAPConnectionContext)getIdentityContext().getObject(IdentityContext.TYPE_CONNECTION_CONTEXT);
+ throw new IdentityException("No LDAPConnectionContext available");
+ }
+ return connectionContext;
+ }
+
+ public void setConnectionContext(LDAPConnectionContext connectionContext)
+ {
+ this.connectionContext = connectionContext;
+ }
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,278 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.ldap;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.info.ProfileInfo;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity.IdentityException;
-
-import javax.naming.directory.Attributes;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.DirContext;
-import javax.naming.NamingException;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class LDAPUserProfileModuleImpl extends LDAPUserProfileModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserProfileModuleImpl.class);
-
- public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation supports only LDAPUserImpl objects");
- }
-
- String attributeName = resolveAttributeName(propertyName);
- String propertyValue = null;
-
- if (attributeName == null)
- {
- log.error("Proper LDAP attribute mapping not found for such property name: " + propertyName);
- return null;
- }
-
- try
- {
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
-
- Attribute attr = attrs.get(attributeName);
-
- if (attr != null)
- {
- propertyValue = (String)attr.get();
- }
- else
- {
- log.error("No such attribute ('" + attributeName + "') in entry: " + ldapUser.getDn());
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot get user property value.", e);
- }
-
- return propertyValue;
-
- }
-
- public void setProperty(User user, String propertyName, Object property) throws IdentityException, IllegalArgumentException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only LDAPUserImpl objects");
- }
-
- String attributeName = resolveAttributeName(propertyName);
-
- String propertyValue = property.toString();
-
- if (attributeName == null)
- {
- log.error("Proper LDAP attribute mapping not found for such property name: " + propertyName);
- return;
- }
-
- try
- {
- //TODO: maybe perform a schema check if this attribute is allowed for such entry
-
- Attributes attrs = new BasicAttributes(true);
- Attribute attr = new BasicAttribute(attributeName);
- attr.add(propertyValue);
- attrs.put(attr);
-
- getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot set user property value.", e);
- }
-
- }
-
- public Map getProperties(User user) throws IdentityException, IllegalArgumentException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- LDAPUserImpl ldapUser = null;
-
- if (user instanceof LDAPUserImpl)
- {
- ldapUser = (LDAPUserImpl)user;
- }
- else
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only LDAPUserImpl objects");
- }
-
- Map propertyMap = new HashMap();
-
- try
- {
- Map mappings = resolveAttributesMappingMap();
- Set props = mappings.keySet();
-
- Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
-
- for (Iterator iterator = props.iterator(); iterator.hasNext();)
- {
- String name = (String)iterator.next();
- String attrName = (String)mappings.get(name);
- Attribute attr = attrs.get(attrName);
-
- if (attr != null)
- {
- propertyMap.put(name,(String)attr.get());
- }
- else
- {
- log.error("No such attribute ('" + attrName + "') in entry: " + ldapUser.getDn());
- }
- }
- }
- catch (NamingException e)
- {
- throw new IdentityException("Cannot get user property value.", e);
- }
-
- return propertyMap;
- }
-
- private String resolveAttributeName(String propertyName) throws IdentityException
- {
- //return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS, propertyName);
-
- PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
-
- if (pi == null)
- {
- throw new IdentityException("Cannot find profile information about property: " + propertyName);
- }
-
- String mapping = pi.getMappingLDAPValue();
- if (mapping == null)
- {
- throw new IdentityException("This property is not mapped as LDAP attribute: " + propertyName);
- }
- return mapping;
- }
-
- /**
- * Returns a map of mappings - property name/attribute name.
- * @return
- * @throws IdentityException
- */
- private Map resolveAttributesMappingMap() throws IdentityException
- {
- //Map group = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS);
-
-
- Map infos = getProfileInfo().getPropertiesInfo();
- Set keys = infos.keySet();
-
- Map mappings = new HashMap();
- for (Iterator iterator = keys.iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- PropertyInfo prop = (PropertyInfo)infos.get(key);
- if (prop.isMappedLDAP())
- {
- mappings.put(prop.getName(), prop.getMappingLDAPValue());
- }
- }
- return mappings;
- }
-
-
- /**
- * obtains UserProfile object - if module is used as a Delegate it tries to obtain it from the main one.
- * @return
- * @throws IdentityException
- */
- public ProfileInfo getProfileInfo() throws IdentityException
- {
-
-
- if (super.getProfileInfo() == null)
- {
- //obtain main UserProfileModule
- UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
- if (module == this)
- {
- throw new IdentityException("ProfileInfo not accessible - check configuration");
- }
- else
- {
- setProfileInfo(module.getProfileInfo());
- }
- }
- return super.getProfileInfo();
- }
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/LDAPUserProfileModuleImpl.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/LDAPUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,277 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.ldap;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.info.PropertyInfo;
+import org.jboss.portal.identity.IdentityException;
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.DirContext;
+import javax.naming.NamingException;
+import java.util.Set;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class LDAPUserProfileModuleImpl extends LDAPUserProfileModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(LDAPUserProfileModuleImpl.class);
+
+ public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name need to have value");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("This UserProfileModule implementation supports only LDAPUserImpl objects");
+ }
+
+ String attributeName = resolveAttributeName(propertyName);
+ String propertyValue = null;
+
+ if (attributeName == null)
+ {
+ log.error("Proper LDAP attribute mapping not found for such property name: " + propertyName);
+ return null;
+ }
+
+ try
+ {
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+
+ Attribute attr = attrs.get(attributeName);
+
+ if (attr != null)
+ {
+ propertyValue = (String)attr.get();
+ }
+ else
+ {
+ log.error("No such attribute ('" + attributeName + "') in entry: " + ldapUser.getDn());
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot get user property value.", e);
+ }
+
+ return propertyValue;
+
+ }
+
+ public void setProperty(User user, String propertyName, Object property) throws IdentityException, IllegalArgumentException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name need to have value");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("This UserProfileModule implementation support only LDAPUserImpl objects");
+ }
+
+ String attributeName = resolveAttributeName(propertyName);
+
+ String propertyValue = property.toString();
+
+ if (attributeName == null)
+ {
+ log.error("Proper LDAP attribute mapping not found for such property name: " + propertyName);
+ return;
+ }
+
+ try
+ {
+ //TODO: maybe perform a schema check if this attribute is allowed for such entry
+
+ Attributes attrs = new BasicAttributes(true);
+ Attribute attr = new BasicAttribute(attributeName);
+ attr.add(propertyValue);
+ attrs.put(attr);
+
+ getConnectionContext().createInitialContext().modifyAttributes(ldapUser.getDn(), DirContext.REPLACE_ATTRIBUTE,attrs);
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot set user property value.", e);
+ }
+
+ }
+
+ public Map getProperties(User user) throws IdentityException, IllegalArgumentException
+ {
+ if (user == null)
+ {
+ throw new IllegalArgumentException("User cannot be null");
+ }
+
+ LDAPUserImpl ldapUser = null;
+
+ if (user instanceof LDAPUserImpl)
+ {
+ ldapUser = (LDAPUserImpl)user;
+ }
+ else
+ {
+ throw new IllegalArgumentException("This UserProfileModule implementation support only LDAPUserImpl objects");
+ }
+
+ Map propertyMap = new HashMap();
+
+ try
+ {
+ Map mappings = resolveAttributesMappingMap();
+ Set props = mappings.keySet();
+
+ Attributes attrs = getConnectionContext().createInitialContext().getAttributes(ldapUser.getDn());
+
+ for (Iterator iterator = props.iterator(); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+ String attrName = (String)mappings.get(name);
+ Attribute attr = attrs.get(attrName);
+
+ if (attr != null)
+ {
+ propertyMap.put(name,(String)attr.get());
+ }
+ else
+ {
+ log.error("No such attribute ('" + attrName + "') in entry: " + ldapUser.getDn());
+ }
+ }
+ }
+ catch (NamingException e)
+ {
+ throw new IdentityException("Cannot get user property value.", e);
+ }
+
+ return propertyMap;
+ }
+
+ private String resolveAttributeName(String propertyName) throws IdentityException
+ {
+ //return getIdentityConfiguration().getValue(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS, propertyName);
+
+ PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
+
+ if (pi == null)
+ {
+ throw new IdentityException("Cannot find profile information about property: " + propertyName);
+ }
+
+ String mapping = pi.getMappingLDAPValue();
+ if (mapping == null)
+ {
+ throw new IdentityException("This property is not mapped as LDAP attribute: " + propertyName);
+ }
+ return mapping;
+ }
+
+ /**
+ * Returns a map of mappings - property name/attribute name.
+ * @return
+ * @throws IdentityException
+ */
+ private Map resolveAttributesMappingMap() throws IdentityException
+ {
+ //Map group = getIdentityConfiguration().getOptions(IdentityConfiguration.GROUP_USER_PROFILE_MAPPINGS);
+
+
+ Map infos = getProfileInfo().getPropertiesInfo();
+ Set keys = infos.keySet();
+
+ Map mappings = new HashMap();
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();)
+ {
+ String key = (String)iterator.next();
+ PropertyInfo prop = (PropertyInfo)infos.get(key);
+ if (prop.isMappedLDAP())
+ {
+ mappings.put(prop.getName(), prop.getMappingLDAPValue());
+ }
+ }
+ return mappings;
+ }
+
+
+ /**
+ * obtains UserProfile object - if module is used as a Delegate it tries to obtain it from the main one.
+ * @return
+ * @throws IdentityException
+ */
+ public ProfileInfo getProfileInfo() throws IdentityException
+ {
+
+
+ if (profileInfo == null)
+ {
+ //obtain main UserProfileModule
+ UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ if (module == this)
+ {
+ throw new IdentityException("ProfileInfo not accessible - check configuration");
+ }
+ else
+ {
+ setProfileInfo(module.getProfileInfo());
+ }
+ }
+ return profileInfo;
+ }
+
+}
Copied: trunk/identity/src/main/org/jboss/portal/identity/ldap/helper (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper)
Modified: trunk/identity/src/main/org/jboss/portal/identity/ldap/helper/LDAPTools.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ldap/helper/LDAPTools.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/ldap/helper/LDAPTools.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.portal.identity2.ldap.helper;
+package org.jboss.portal.identity.ldap.helper;
/**
* Helper class for ldap operation
Copied: trunk/identity/src/main/org/jboss/portal/identity/service (from rev 5871, trunk/identity/src/main/org/jboss/portal/identity2/service)
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,274 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityConfigurationService extends IdentityModuleService implements IdentityConfiguration
-{
-
- //TODO: improve access to data to not blow up by NullPointerEx
-
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityConfigurationService.class);
-
- private Map data;
-
- public IdentityConfigurationService()
- {
- super(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
-
- public IdentityConfigurationService(Map optionGroups)
- {
- this();
- this.data = optionGroups;
- }
-
- public IdentityConfigurationService(OptionsMetaData meta) throws IdentityException
- {
- this();
- if (meta == null || meta.getGroups() == null)
- {
- data = new HashMap();
- return;
- }
- try
- {
- Map newGroups = new HashMap();
- Map groups = meta.getGroups();
- for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
- {
- String groupKey = (String)iterator.next();
- OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
-
- Map newOptions = new HashMap();
- Map options = group.getOptions();
- for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
- {
- String optionKey = (String)iterator1.next();
- OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
-
- newOptions.put(option.getName(),option.getValues());
- }
-
- newGroups.put(group.getName(), newOptions);
- }
- setData(newGroups);
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot create identity configuration options data:", e);
- }
- }
-
- public Set getValues(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- return (Set)group.get(option);
- }
- }
- return null;
- }
-
- public String getValue(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- Set values = (Set)group.get(option);
- if (values.size() > 0)
- {
- return (String)values.toArray()[0];
- }
- }
- }
- return null;
- }
-
- public String getValue(String option)
- {
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(GROUP_COMMON))
- {
- Map group = (Map)data.get(GROUP_COMMON);
- if (group.containsKey(option))
- {
- Set values = (Set)group.get(option);
- if (values.size() > 0)
- {
- return (String)values.toArray()[0];
- }
- }
- }
- return null;
- }
-
- public void setValues(String optionGroup, String option, Set values)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (values == null)
- {
- throw new IllegalArgumentException("null values list");
- }
- if (data.containsKey(optionGroup))
- {
- ((Map)data.get(optionGroup)).put(option, values);
- }
- }
-
- public void addValue(String optionGroup, String option, String value)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("null value name");
- }
- if (data.containsKey(optionGroup))
- {
- Map group = (Map)data.get(optionGroup);
- if (group.containsKey(option))
- {
- ((Set)group.get(option)).add(value);
- }
- }
- }
-
- public Map getOptions(String optionGroup)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (data.containsKey(optionGroup))
- {
- return (Map)data.get(optionGroup);
- }
- return null;
- }
-
- public void setOptions(String optionGroup, Map options)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (options == null)
- {
- throw new IllegalArgumentException("null options map");
- }
- data.put(optionGroup,options);
- }
-
- public void remoeOption(String optionGroup, String option)
- {
- if (optionGroup == null)
- {
- throw new IllegalArgumentException("null option group");
- }
- if (option == null)
- {
- throw new IllegalArgumentException("null option name");
- }
- if (data.containsKey(optionGroup))
- {
- ((Map)data.get(optionGroup)).put(option, null);
- }
- }
-
-
- public void setData(Map data)
- {
- this.data = data;
- }
-
- public Map getOptionGroups()
- {
- return data;
- }
-
-// public String getConfigFile()
-// {
-// return configFile;
-// }
-//
-// public void setConfigFile(String configFile)
-// {
-// this.configFile = configFile;
-// }
-
-
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityConfigurationService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/IdentityConfigurationService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,272 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.config.metadata.OptionsMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupMetaData;
+import org.jboss.portal.identity.config.metadata.OptionsGroupOptionMetaData;
+import org.jboss.portal.identity.IdentityException;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityConfigurationService extends IdentityModuleService implements IdentityConfiguration
+{
+
+ //TODO: improve access to data to not blow up by NullPointerEx
+
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityConfigurationService.class);
+
+ private Map data;
+
+ public IdentityConfigurationService()
+ {
+ super(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+
+ public IdentityConfigurationService(Map optionGroups)
+ {
+ this();
+ this.data = optionGroups;
+ }
+
+ public IdentityConfigurationService(OptionsMetaData meta) throws IdentityException
+ {
+ this();
+ if (meta == null || meta.getGroups() == null)
+ {
+ data = new HashMap();
+ return;
+ }
+ try
+ {
+ Map newGroups = new HashMap();
+ Map groups = meta.getGroups();
+ for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
+ {
+ String groupKey = (String)iterator.next();
+ OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
+
+ Map newOptions = new HashMap();
+ Map options = group.getOptions();
+ for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
+ {
+ String optionKey = (String)iterator1.next();
+ OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
+
+ newOptions.put(option.getName(),option.getValues());
+ }
+
+ newGroups.put(group.getName(), newOptions);
+ }
+ setData(newGroups);
+ }
+ catch (Exception e)
+ {
+ throw new IdentityException("Cannot create identity configuration options data:", e);
+ }
+ }
+
+ public Set getValues(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ return (Set)group.get(option);
+ }
+ }
+ return null;
+ }
+
+ public String getValue(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ Set values = (Set)group.get(option);
+ if (values.size() > 0)
+ {
+ return (String)values.toArray()[0];
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getValue(String option)
+ {
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(GROUP_COMMON))
+ {
+ Map group = (Map)data.get(GROUP_COMMON);
+ if (group.containsKey(option))
+ {
+ Set values = (Set)group.get(option);
+ if (values.size() > 0)
+ {
+ return (String)values.toArray()[0];
+ }
+ }
+ }
+ return null;
+ }
+
+ public void setValues(String optionGroup, String option, Set values)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (values == null)
+ {
+ throw new IllegalArgumentException("null values list");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ ((Map)data.get(optionGroup)).put(option, values);
+ }
+ }
+
+ public void addValue(String optionGroup, String option, String value)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("null value name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ Map group = (Map)data.get(optionGroup);
+ if (group.containsKey(option))
+ {
+ ((Set)group.get(option)).add(value);
+ }
+ }
+ }
+
+ public Map getOptions(String optionGroup)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ return (Map)data.get(optionGroup);
+ }
+ return null;
+ }
+
+ public void setOptions(String optionGroup, Map options)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (options == null)
+ {
+ throw new IllegalArgumentException("null options map");
+ }
+ data.put(optionGroup,options);
+ }
+
+ public void remoeOption(String optionGroup, String option)
+ {
+ if (optionGroup == null)
+ {
+ throw new IllegalArgumentException("null option group");
+ }
+ if (option == null)
+ {
+ throw new IllegalArgumentException("null option name");
+ }
+ if (data.containsKey(optionGroup))
+ {
+ ((Map)data.get(optionGroup)).put(option, null);
+ }
+ }
+
+
+ public void setData(Map data)
+ {
+ this.data = data;
+ }
+
+ public Map getOptionGroups()
+ {
+ return data;
+ }
+
+// public String getConfigFile()
+// {
+// return configFile;
+// }
+//
+// public void setConfigFile(String configFile)
+// {
+// this.configFile = configFile;
+// }
+
+
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,181 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityModuleService extends AbstractJBossService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
-
- private String jndiName;
-
- private String connectionJNDIName;
-
- private IdentityContext identityContext;
-
- private IdentityConfiguration identityConfiguration;
-
- private JNDI.Binding jndiBinding;
-
- private Map initOptions;
-
- protected String moduleType;
-
- //restrict instance creation
- private IdentityModuleService()
- {
-
- }
-
- protected IdentityModuleService(String type)
- {
- moduleType = type;
- }
-
- protected void startService() throws Exception
- {
-
- //
- if (jndiName != null)
- {
- log.debug("Binding identity module to JNDI with name: " + jndiName);
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- if (identityContext == null)
- {
- throw new IdentityException("Cannot register module in context - missing reference");
- }
- else
- {
- //identityContext.register(this, IdentityContext.TYPE_ROLE_MODULE);
- identityContext.register(this, this.moduleType);
- }
- }
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- if (identityContext == null)
- {
- log.error("Cannot unregister module in context - missing reference");
- }
- else
- {
- //identityContext.unregister(IdentityContext.TYPE_ROLE_MODULE);
- identityContext.unregister(this.moduleType);
- }
-
- }
-
- protected IdentityConfiguration getIdentityConfiguration() //throws IdentityException
- {
- /*if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;*/
- try
- {
- if (identityConfiguration == null)
- {
- this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
- }
- return identityConfiguration;
- }
- catch (IdentityException e)
- {
- throw new RuntimeException("Can't obtain IdentityConfiguration", e);
- }
- }
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
- public void setIdentityContext(IdentityContext identityContext)
- {
- this.identityContext = identityContext;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public Map getInitOptions()
- {
- return initOptions;
- }
-
-
- public void setInitOptions(Map initOptions)
- {
- this.initOptions = initOptions;
- }
-
-
- public String getModuleType()
- {
- return moduleType;
- }
-
-
- public void setModuleType(String moduleType)
- {
- this.moduleType = moduleType;
- }
-
- public String getConnectionJNDIName()
- {
- return connectionJNDIName;
- }
-
- public void setConnectionJNDIName(String connectionJNDIName)
- {
- this.connectionJNDIName = connectionJNDIName;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/IdentityModuleService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/IdentityModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,181 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.common.util.JNDI;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityModuleService extends AbstractJBossService
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityModuleService.class);
+
+ private String jndiName;
+
+ private String connectionJNDIName;
+
+ private IdentityContext identityContext;
+
+ private IdentityConfiguration identityConfiguration;
+
+ private JNDI.Binding jndiBinding;
+
+ private Map initOptions;
+
+ protected String moduleType;
+
+ //restrict instance creation
+ private IdentityModuleService()
+ {
+
+ }
+
+ protected IdentityModuleService(String type)
+ {
+ moduleType = type;
+ }
+
+ protected void startService() throws Exception
+ {
+
+ //
+ if (jndiName != null)
+ {
+ log.debug("Binding identity module to JNDI with name: " + jndiName);
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ if (identityContext == null)
+ {
+ throw new IdentityException("Cannot register module in context - missing reference");
+ }
+ else
+ {
+ //identityContext.register(this, IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.register(this, this.moduleType);
+ }
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+
+ if (identityContext == null)
+ {
+ log.error("Cannot unregister module in context - missing reference");
+ }
+ else
+ {
+ //identityContext.unregister(IdentityContext.TYPE_ROLE_MODULE);
+ identityContext.unregister(this.moduleType);
+ }
+
+ }
+
+ protected IdentityConfiguration getIdentityConfiguration() //throws IdentityException
+ {
+ /*if (identityConfiguration == null)
+ {
+ this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;*/
+ try
+ {
+ if (identityConfiguration == null)
+ {
+ this.identityConfiguration = (IdentityConfiguration)identityContext.getObject(IdentityContext.TYPE_IDENTITY_CONFIGURATION);
+ }
+ return identityConfiguration;
+ }
+ catch (IdentityException e)
+ {
+ throw new RuntimeException("Can't obtain IdentityConfiguration", e);
+ }
+ }
+
+ public IdentityContext getIdentityContext()
+ {
+ return identityContext;
+ }
+
+ public void setIdentityContext(IdentityContext identityContext)
+ {
+ this.identityContext = identityContext;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+ public Map getInitOptions()
+ {
+ return initOptions;
+ }
+
+
+ public void setInitOptions(Map initOptions)
+ {
+ this.initOptions = initOptions;
+ }
+
+
+ public String getModuleType()
+ {
+ return moduleType;
+ }
+
+
+ public void setModuleType(String moduleType)
+ {
+ this.moduleType = moduleType;
+ }
+
+ public String getConnectionJNDIName()
+ {
+ return connectionJNDIName;
+ }
+
+ public void setConnectionJNDIName(String connectionJNDIName)
+ {
+ this.connectionJNDIName = connectionJNDIName;
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,58 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.info.ProfileInfo;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class MembershipModuleService extends IdentityModuleService implements MembershipModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(MembershipModuleService.class);
-
- private ProfileInfo profileInfo;
-
- protected MembershipModuleService()
- {
- super(IdentityContext.TYPE_MEMBERSHIP_MODULE);
- }
-
- public ProfileInfo getProfileInfo()
- {
- return profileInfo;
- }
-
- public void setProfileInfo(ProfileInfo profileInfo)
- {
- this.profileInfo = profileInfo;
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/MembershipModuleService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/MembershipModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,51 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.info.ProfileInfo;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class MembershipModuleService extends IdentityModuleService implements MembershipModule {
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(MembershipModuleService.class);
+
+ private ProfileInfo profileInfo;
+
+ protected MembershipModuleService()
+ {
+ super(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+ }
+
+ public ProfileInfo getProfileInfo()
+ {
+ return profileInfo;
+ }
+
+ public void setProfileInfo(ProfileInfo profileInfo)
+ {
+ this.profileInfo = profileInfo;
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,45 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.IdentityConfiguration;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class RoleModuleService extends IdentityModuleService implements RoleModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(RoleModuleService.class);
-
- protected RoleModuleService()
- {
- super(IdentityContext.TYPE_ROLE_MODULE);
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/RoleModuleService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/RoleModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,39 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.IdentityContext;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class RoleModuleService extends IdentityModuleService implements RoleModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(RoleModuleService.class);
+
+ protected RoleModuleService()
+ {
+ super(IdentityContext.TYPE_ROLE_MODULE);
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,45 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityContext;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class UserModuleService extends IdentityModuleService implements UserModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserModuleService.class);
-
- protected UserModuleService()
- {
- super(IdentityContext.TYPE_USER_MODULE);
- }
-}
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserModuleService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/UserModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,39 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.IdentityContext;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class UserModuleService extends IdentityModuleService implements UserModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserModuleService.class);
+
+ protected UserModuleService()
+ {
+ super(IdentityContext.TYPE_USER_MODULE);
+ }
+}
Deleted: trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-12-15 15:15:26 UTC (rev 5871)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,89 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.service;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.info.ProfileInfoSupport;
-import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
-import org.jboss.portal.identity2.info.ProfileInfo;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public abstract class UserProfileModuleService extends IdentityModuleService implements UserProfileModule
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserProfileModuleService.class);
-
- private ProfileInfo profileInfo;
-
- private String profileConfigFile;
-
- protected UserProfileModuleService()
- {
- super(IdentityContext.TYPE_USER_PROFILE_MODULE);
- }
-
-
- protected void startService() throws Exception
- {
- if (getProfileConfigFile() != null)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Processing profile configuration for the module....");
- }
- profileInfo = new ProfileInfoSupport(ConfigurationParser.parseProfileConfiguration(getProfileConfigFile()));
- }
-
- super.startService();
-
- }
-
- public ProfileInfo getProfileInfo() throws IdentityException
- {
- return profileInfo;
- }
-
- public void setProfileInfo(ProfileInfo profileInfo)
- {
- this.profileInfo = profileInfo;
- }
-
- public String getProfileConfigFile()
- {
- return profileConfigFile;
- }
-
- public void setProfileConfigFile(String profileConfigFile)
- {
- this.profileConfigFile = profileConfigFile;
- }
-}
-
Copied: trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java (from rev 5883, trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/service/UserProfileModuleService.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/service/UserProfileModuleService.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -0,0 +1,84 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.identity.service;
+
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.config.info.ProfileInfoSupport;
+import org.jboss.portal.identity.config.metadata.ConfigurationParser;
+import org.jboss.portal.identity.info.ProfileInfo;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class UserProfileModuleService extends IdentityModuleService implements UserProfileModule
+{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(UserProfileModuleService.class);
+
+ protected ProfileInfo profileInfo;
+
+ private String profileConfigFile;
+
+ protected UserProfileModuleService()
+ {
+ super(IdentityContext.TYPE_USER_PROFILE_MODULE);
+ }
+
+
+ protected void startService() throws Exception
+ {
+ if (getProfileConfigFile() != null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Processing profile configuration for the module....");
+ }
+ profileInfo = new ProfileInfoSupport(ConfigurationParser.parseProfileConfiguration(getProfileConfigFile()));
+ }
+
+ super.startService();
+
+ }
+
+// public ProfileInfo getProfileInfo() throws IdentityException
+// {
+// return profileInfo;
+// }
+
+ public void setProfileInfo(ProfileInfo profileInfo)
+ {
+ this.profileInfo = profileInfo;
+ }
+
+ public String getProfileConfigFile()
+ {
+ return profileConfigFile;
+ }
+
+ public void setProfileConfigFile(String profileConfigFile)
+ {
+ this.profileConfigFile = profileConfigFile;
+ }
+}
+
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/DelegatingUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,202 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity2.ldap.LDAPUserImpl;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.jboss.portal.identity.IdentityException;
-
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class DelegatingUserProfileModuleImpl extends UserProfileModuleService
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(DelegatingUserProfileModuleImpl.class);
-
- private String ldapModuleJNDIName;
-
- private String dbModuleJNDIName;
-
- private UserProfileModule LDAPModule;
-
- private UserProfileModule dbModule;
-
- protected void startService() throws Exception
- {
- super.startService();
-
- if(getProfileInfo() == null)
- {
- throw new IdentityException("No profile information found. Check the configuration.");
- }
-
- }
-
- public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException
- {
- if (log.isDebugEnabled()) log.debug("getProperty: " + propertyName);
- try
- {
- PropertyInfo property = getProfileInfo().getPropertyInfo(propertyName);
- if (property == null)
- {
- throw new IdentityException("Such property name is not supported");
- }
- else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
- {
- log.debug("Delegating to LDAP module");
- return getLDAPModule().getProperty(user, propertyName);
- }
- else if (property.isMappedDB())
- {
- log.debug("Delegating to DB module");
- return getDBModule().getProperty(user, propertyName);
- }
- throw new IdentityException("Cannot process property - incorrect profile or module configuration");
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot resolve property: ", e);
- }
- }
-
- public void setProperty(User user, String name, Object propertyValue) throws IdentityException, IllegalArgumentException
- {
- if (log.isDebugEnabled()) log.debug("setProperty: " + name + "/" + propertyValue);
- try
- {
- PropertyInfo property = getProfileInfo().getPropertyInfo(name);
- if (property == null)
- {
- throw new IdentityException("Such property name is not supported");
- }
- else if (property.isMappedLDAP() && isLDAPSupported() && user instanceof LDAPUserImpl)
- {
- log.debug("Delegating to LDAP module");
- getLDAPModule().setProperty(user, name, propertyValue);
- return;
- }
- else if (property.isMappedDB())
- {
- log.debug("Delegating to DB module");
- getDBModule().setProperty(user, name, propertyValue);
- return;
- }
- throw new IdentityException("Cannot process property - incorrect profile or module configuration");
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot resolve property: ", e);
- }
- }
-
- public Map getProperties(User user) throws IdentityException, IllegalArgumentException
- {
- if (log.isDebugEnabled()) log.debug("getProperties");//: " + name + "/" + propertyValue)
- try
- {
- if (user instanceof LDAPUserImpl && isLDAPSupported())
- {
- log.debug("Delegating to LDAP module");
- return getLDAPModule().getProperties(user);
- }
- else if (user instanceof HibernateUserImpl && isDBSupported())
- {
- log.debug("Delegating to DB module");
- return getDBModule().getProperties(user);
- }
- throw new IdentityException("Cannot process properties - incorrect profile or module configuration");
- }
- catch (Exception e)
- {
- throw new IdentityException("Cannot resolve property: ", e);
- }
- }
-
-
- public String getLdapModuleJNDIName()
- {
- return ldapModuleJNDIName;
- }
-
- public void setLdapModuleJNDIName(String ldapModuleJNDIName)
- {
- this.ldapModuleJNDIName = ldapModuleJNDIName;
- }
-
- public String getDbModuleJNDIName()
- {
- return dbModuleJNDIName;
- }
-
- public void setDbModuleJNDIName(String dbModuleJNDIName)
- {
- this.dbModuleJNDIName = dbModuleJNDIName;
- }
-
- public boolean isLDAPSupported()
- {
- return getLdapModuleJNDIName()!=null;
- }
-
- public boolean isDBSupported()
- {
- return getDbModuleJNDIName()!=null;
- }
-
- protected UserProfileModule getDBModule() throws Exception
- {
-
- //TODO: to tired to clean this at the moment
- if (dbModule == null)
- {
- dbModule = (UserProfileModule)new InitialContext().lookup(getDbModuleJNDIName());
- if (dbModule == null)
- {
- throw new IdentityException("Couldn't obtain DB UserProfileModule");
- }
- }
- return dbModule;
- }
-
- protected UserProfileModule getLDAPModule() throws Exception
- {
- if (LDAPModule == null)
- {
- LDAPModule = (UserProfileModule)new InitialContext().lookup(getLdapModuleJNDIName());
- if (LDAPModule == null)
- {
- throw new IdentityException("Couldn't obtain LDAP UserProfileModule");
- }
- }
- return LDAPModule;
- }
-
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityConfiguration.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,105 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface IdentityConfiguration
-{
-
- //TODO: isMembershipAttributeRequired
- //TODO: memebershipAttributeEmptyValue
- //TODO: options for secured connection to ldap
- //TODO: let decide if has should be in hex or base64
-
- public static final String GROUP_COMMON = "common";
-
- public static final String GROUP_CONNECTION = "connection";
-
- public static final String GROUP_USER_CREATE_ATTRIBUTES = "userCreateAttibutes";
-
- public static final String GROUP_ROLE_CREATE_ATTRIBUTES = "roleCreateAttibutes";
-
- public static final String GROUP_USER_PROFILE_MAPPINGS = "userProfileMappings";
-
- public static final String CONNECTION_NAME = "connection-name";
-
- public static final String CONNECTION_CONTEXT_FACTORY = "context-factory";
-
- public static final String CONNECTION_HOST = "host";
-
- public static final String CONNECTION_PORT = "port";
-
- public static final String CONNECTION_ADMIN_DN = "admin-dn";
-
- public static final String CONNECTION_ADMIN_PASSWORD = "admin-password";
-
- public static final String CONNECTION_AUTHENTICATION = "authentication";
-
- public static final String USER_CONTAINER_DN = "userContainerDN";
-
- public static final String USER_UID_ATTRIBUTE_ID = "uidAttributeID";
-
- public static final String USER_PASSWORD_ATTRIBUTE_ID = "passwordAttributeID";
-
- public static final String USER_EMAIL_ATTRIBUTE_ID = "emailAttributeID";
-
- public static final String ROLE_CONTAINER_DN = "roleContainerDN";
-
- public static final String ROLE_RID_ATTRIBUTE_ID = "ridAttributeID";
-
- public static final String ROLE_DISPLAY_NAME_ATTRIBUTE_ID = "roleDisplayNameAttributeID";
-
- public static final String MEMBERSHIP_ATTRIBUTE_ID = "membershipAttributeID";
-
- public static final String MEMBERSHIP_ATTRIBUTE_IS_DN = "membershipAttributeIsDN";
-
- public static final String HASH_ALGORITHM = "hashAlgorithm";
-
- public static final String HASH_ENCODING = "hashEncoding";
-
-
- public Set getValues(String optionGroup, String option);
-
- public String getValue(String optionGroup, String option);
-
- public String getValue(String option);
-
- public void setValues(String optionGroup, String option, Set values);
-
- public void addValue(String optionGroup, String option, String value);
-
- public Map getOptions(String optionGroup);
-
- public void setOptions(String optionGroup, Map options);
-
- public void remoeOption(String optionGroup, String option);
-
- public Map getOptionGroups();
-
-
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContext.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,52 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity.IdentityException;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface IdentityContext
-{
-
- //TODO: move to safe type enum
- public static final String TYPE_USER_MODULE = "User";
-
- public static final String TYPE_ROLE_MODULE = "Role";
-
- public static final String TYPE_MEMBERSHIP_MODULE = "Membership";
-
- public static final String TYPE_USER_PROFILE_MODULE = "UserProfile";
-
- public static final String TYPE_CONNECTION_CONTEXT = "ConnectionContext";
-
- public static final String TYPE_IDENTITY_CONFIGURATION = "IdentityConfiguration";
-
-
- public void register(Object object, String name) throws IdentityException;
-
- public void unregister(String name);
-
- public Object getObject(String name) throws IdentityException;
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityContextImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,106 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity.IdentityException;
-
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * Keeps references to all identity related modules to enable them interactions
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityContextImpl extends AbstractJBossService implements IdentityContext
-{
- //private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityContextImpl.class);
-
- private Map registry;
-
- public IdentityContextImpl()
- {
- registry = new HashMap();
- }
-
- public void register(Object object, String name) throws IdentityException
- {
- if (object == null)
- {
- throw new IllegalArgumentException("Cannot register null reference");
- }
- if (name == null)
- {
- throw new IllegalArgumentException("Cannot register object with null name");
- }
-
- synchronized(this)
- {
- if (registry.containsKey(name))
- {
- throw new IdentityException("Name: " + name + " already registered.");
- }
- if (log.isDebugEnabled()) log.debug("registering object: " + name + " ; " + object.getClass());
- registry.put(name, object);
- }
- }
-
- public void unregister(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- synchronized(this)
- {
- if(registry.containsKey(name))
- {
- if (log.isDebugEnabled()) log.debug("unregistering object: " + name);
-
- registry.remove(name);
- }
- }
- }
-
- public Object getObject(String name) throws IdentityException
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
-
- //TODO:
- synchronized(this)
- {
- if (registry.containsKey(name))
- {
- return registry.get(name);
- }
- else
- {
- throw new IdentityException("No such mapping in IdentityContext: " + name);
- }
- }
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceController.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,32 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-/**
- *
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface IdentityServiceController
-{
- public IdentityContext getIdentityContext();
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/IdentityServiceControllerImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,578 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaDataFactory;
-import org.jboss.portal.identity2.config.metadata.IdentityConfigurationMetaData;
-import org.jboss.portal.identity2.config.metadata.ModuleMetaData;
-import org.jboss.portal.identity2.config.metadata.ConfigOptionMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupMetaData;
-import org.jboss.portal.identity2.config.metadata.OptionsGroupOptionMetaData;
-import org.jboss.portal.identity2.config.metadata.DatasourceMetaData;
-import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
-import org.jboss.portal.identity2.service.IdentityModuleService;
-import org.jboss.portal.identity2.service.IdentityConfigurationService;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-
-import javax.management.ObjectName;
-import java.net.URL;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityServiceControllerImpl extends AbstractJBossService implements IdentityServiceController
-{
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentityServiceControllerImpl.class);
-
- private String jndiName;
-
- protected JNDI.Binding jndiBinding;
-
- private IdentityContext identityContext;
-
- private boolean registerMBeans = true;
-
- private String configFile;
-
- private String defaultConfigFile;
-
- /**
- * .
- */
- protected Kernel kernel;
-
- /**
- * .
- */
- protected List beans;
-
- protected void startService() throws Exception
- {
- if (jndiName != null)
- {
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
- }
-
- //initialize microcontainer stuff
- try
- {
- BasicBootstrap bootstrap = new BasicBootstrap();
- bootstrap.run();
- kernel = bootstrap.getKernel();
- beans = new ArrayList();
- }
- catch (Exception e)
- {
- throw new IdentityException(e);
- }
-
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-
- //TODO: make a dtd for config files.
-
- //parse config files
- IdentityConfigurationMetaData meta = ConfigurationParser.parseIdentityConfiguration(configFile);
- IdentityConfigurationMetaData defaultMeta = ConfigurationParser.parseIdentityConfiguration(defaultConfigFile);
-
- KernelControllerContext identityKernelContext;
- try
- {
- AbstractBeanMetaData contextBMD = new AbstractBeanMetaData(
- "portal:identity=IdentityContext",
- IdentityContextImpl.class.getName());
- beans.add(contextBMD);
- identityKernelContext = kernel.getController().install(contextBMD);
- identityContext = (IdentityContext)identityKernelContext.getTarget();
-
- }
- catch (Throwable throwable)
- {
- throw new IdentityException(throwable);
- }
-
- //TODO:update meta options using defaultMeta options
-
- //create detault modules set
-
- //Map[implementation] --> Map[Type] --> ModuleMetaData
- Map defaultImplementations = new HashMap();
-
- //update modules data with defaults
- try
- {
- List defaultModules = defaultMeta.getModules().getModules();
- for (Iterator iterator = defaultModules.iterator(); iterator.hasNext();)
- {
- ModuleMetaData module = (ModuleMetaData)iterator.next();
-
- //check if defaults contains all information
- if (module.getType() == null ||
- module.getImplementation() == null ||
- //module.getJndiName() == null ||
- module.getServiceName() == null ||
- module.getConfig() == null)
- {
- throw new IdentityException("Default module configuration must be complete");
- }
-
- //store them as maps for different implementations
- String implType = module.getImplementation();
- Map implementation;
- if (defaultImplementations.containsKey(implType))
- {
- implementation = (Map)defaultImplementations.get(implType);
- }
- else
- {
- implementation = new HashMap();
- }
-
- //store per implementation
- implementation.put(module.getType(), module);
- defaultImplementations.put(implType, implementation);
- }
- }
- catch (Exception e)
- {
- throw new IdentityException("Error during processing default configuration file", e);
- }
-
- //map default datasources by name
- Map defaultDatasources = new HashMap();
- for (Iterator iterator = defaultMeta.getDatasources().getDatasources().iterator(); iterator.hasNext();)
- {
- DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
- defaultDatasources.put(ds.getName(), ds);
-
- }
-
- //process the list of modules, instantiate them, configure them, tide them
- try
- {
- List datasources = meta.getDatasources().getDatasources();
- List modules = meta.getModules().getModules();
-
- //inject configuration service
- IdentityConfigurationService configuration = new IdentityConfigurationService(meta.getOptions());
- configuration.setIdentityContext(identityContext);
-
- //TODO:set proper jndiName and serviceName
- configuration.start();
-
- //update options with defaults
- updateOptionsWithDefaults(configuration, defaultMeta.getOptions());
-
- //process datasources
- for (Iterator iterator = datasources.iterator(); iterator.hasNext();)
- {
- DatasourceMetaData ds = (DatasourceMetaData)iterator.next();
- if (log.isDebugEnabled()) log.debug("processing datasource: " + ds.getName() + "/" + ds.getClassName());
- updateDatasourceWithDefaults(ds, defaultDatasources);
-
- //generate initial options
- //TODO:presence of config tag should be forced in dtd
- Map configOptions = ds.getConfig().getOptions();
- Map optionMap = new HashMap();
- for (Iterator iterator1 = configOptions.keySet().iterator(); iterator1.hasNext();)
- {
- String optionName = (String)iterator1.next();
- ConfigOptionMetaData option = (ConfigOptionMetaData)configOptions.get(optionName);
- optionMap.put(optionName, option.getValue());
- }
-
- //instantiate the module
- //IdentityModuleService moduleService = null;
-
-
- if (ds.getClassName() == null)
- {
- throw new IdentityException("Class name not found for datasource type: " + ds.getName() + " wrong configuration");
- }
-
- /*try
- {
- moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
- }
- catch (Exception e)
- {
- throw new IdentityException("Unable to instantiate the class: " + module.getClassName() );
- }*/
-
- //instantiate datasource using MC
- String entryName = "portal:identity=Datasource,type=" + ds.getName();
- AbstractBeanMetaData dsBMD = new AbstractBeanMetaData(entryName,
- ds.getClassName());
- //AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData("identityContext", identityContext);
- //moduleBMD.addProperty(propertyBMD);
-
- //initiate parameters from <config>
- for (Iterator iterator1 = optionMap.keySet().iterator(); iterator1.hasNext();)
- {
- String propertyKey = (String)iterator1.next();
- String propertyValue = (String)optionMap.get(propertyKey);
- if (log.isDebugEnabled()) log.debug("adding parameter: " + propertyKey + " ; " + propertyValue);
- AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData(propertyKey, propertyValue);
- dsBMD.addProperty(propertyBMD);
- }
-
- // Installation
- beans.add(dsBMD);
- KernelControllerContext controllerContext = kernel.getController().install(dsBMD);
- Object datasource = controllerContext.getTarget();
-
- //make a part of identityContext
- //moduleService.setIdentityContext(identityContext);
-
- //register as an mbean
- if (isRegisterMBeans() && (ds.getServiceName() != null))
- {
- getServer().registerMBean(datasource, new ObjectName(ds.getServiceName()));
- }
-
-
- }
-
-
-
- //process modules for instantiation
- for (Iterator iterator = modules.iterator(); iterator.hasNext();)
- {
-
- ModuleMetaData module = (ModuleMetaData)iterator.next();
- if (log.isDebugEnabled())
- {
- log.debug("Processing module: " + module.getType() + "/" + module.getImplementation());
- }
- updateModuleWithDefaults(module, defaultImplementations);
-
- //generate initial options
- Map configOptions = module.getConfig().getOptions();
- Map optionMap = new HashMap();
- for (Iterator iterator1 = configOptions.keySet().iterator(); iterator1.hasNext();)
- {
- String optionName = (String)iterator1.next();
- ConfigOptionMetaData option = (ConfigOptionMetaData)configOptions.get(optionName);
- optionMap.put(optionName, option.getValue());
- }
-
- //instantiate the module
- //IdentityModuleService moduleService = null;
-
-
- if (module.getClassName() == null)
- {
- throw new IdentityException("Class name not found for module type: " + module.getType() + " wrong configuration");
- }
-
- /*try
- {
- moduleService = (IdentityModuleService)tcl.loadClass(module.getClassName()).newInstance();
- }
- catch (Exception e)
- {
- throw new IdentityException("Unable to instantiate the class: " + module.getClassName() );
- }*/
-
- //instantiate module using MC
- String entryName = "portal:identity=Module,type=" + module.getType();
- AbstractBeanMetaData moduleBMD = new AbstractBeanMetaData(entryName,
- module.getClassName());
- AbstractPropertyMetaData propertyBMD = new AbstractPropertyMetaData("identityContext", identityContext);
- moduleBMD.addProperty(propertyBMD);
-
- //initiate parameters from <config>
- for (Iterator iterator1 = optionMap.keySet().iterator(); iterator1.hasNext();)
- {
- String propertyKey = (String)iterator1.next();
- String propertyValue = (String)optionMap.get(propertyKey);
- if (log.isDebugEnabled()) log.debug("adding parameter: " + propertyKey + " ; " + propertyValue);
- propertyBMD = new AbstractPropertyMetaData(propertyKey, propertyValue);
- moduleBMD.addProperty(propertyBMD);
- }
-
- //make the type from name
- propertyBMD = new AbstractPropertyMetaData("moduleType", module.getType());
- moduleBMD.addProperty(propertyBMD);
-
-
- // Installation
- beans.add(moduleBMD);
- KernelControllerContext controllerContext = kernel.getController().install(moduleBMD);
- Object moduleService = (IdentityModuleService)controllerContext.getTarget();
-
- //make a part of identityContext
- //moduleService.setIdentityContext(identityContext);
-
- //register as an mbean
- if (isRegisterMBeans() && (module.getServiceName() != null))
- {
- getServer().registerMBean(moduleService, new ObjectName(module.getServiceName()));
- }
- }
-
-
- }
- catch (Throwable e)
- {
- throw new IdentityException("Cannot initiate identity modules: ", e);
- }
- }
-
-
- protected void stopService() throws Exception
- {
- if (jndiBinding != null)
- {
- jndiBinding.unbind();
- jndiBinding = null;
- }
-
- }
-
-
-
-
- /**
- * updates module with proper defaults
- *
- * @param module
- * @param defaultModules
- */
- private void updateModuleWithDefaults(ModuleMetaData module, Map defaultModules)
- {
- if (module.getImplementation() == null)
- {
- return;
- }
- if (!defaultModules.containsKey(module.getImplementation()))
- {
- return;
- }
- Map modules = (Map)defaultModules.get(module.getImplementation());
- if (!modules.containsKey(module.getType()))
- {
- return;
- }
- ModuleMetaData def = (ModuleMetaData)modules.get(module.getType());
-
- if (module.getClassName() == null)
- {
- module.setClassName(def.getClassName());
- }
- if (module.getServiceName() == null)
- {
- module.setServiceName(def.getServiceName());
- }
-
- //now check if config options are overwritten
- if (module.getConfig() == null)
- {
- module.setConfig(def.getConfig());
- }
- else
- {
- Map moduleOptions = module.getConfig().getOptions();
- if (moduleOptions == null)
- {
- return;
- }
- Map defOptions = def.getConfig().getOptions();
-
- for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- if (!moduleOptions.containsKey(key))
- {
- ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
- module.getConfig().addOption(o);
- }
- }
- }
- }
-
- /**
- * updates module with proper defaults
- */
- private void updateDatasourceWithDefaults(DatasourceMetaData ds, Map defaultDS)
- {
- if (ds.getName() == null)
- {
- return;
- }
- if (!defaultDS.containsKey(ds.getName()))
- {
- return;
- }
- DatasourceMetaData def = (DatasourceMetaData)defaultDS.get(ds.getName());
- if (ds.getClassName() == null)
- {
- ds.setClassName(def.getClassName());
- }
- if (ds.getServiceName() == null)
- {
- ds.setServiceName(def.getServiceName());
- }
-
- //now check if config options are overwritten
- if (ds.getConfig() == null)
- {
- ds.setConfig(def.getConfig());
- }
- else
- {
- Map dsOptions = ds.getConfig().getOptions();
- if (dsOptions == null)
- {
- return;
- }
- Map defOptions = def.getConfig().getOptions();
-
- for (Iterator iterator = defOptions.keySet().iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- if (!dsOptions.containsKey(key))
- {
- ConfigOptionMetaData o = (ConfigOptionMetaData)defOptions.get(key);
- ds.getConfig().addOption(o);
- }
- }
- }
- }
-
- /**
- * Check current options and update them with defaults if not exists;
- *
- * @param config
- * @param defaults
- */
- public void updateOptionsWithDefaults(IdentityConfigurationService config, OptionsMetaData defaults)
- {
- //Map newGroups = new HashMap();
- Map groups = defaults.getGroups();
- for (Iterator iterator = groups.keySet().iterator(); iterator.hasNext();)
- {
- String groupKey = (String)iterator.next();
-
- OptionsGroupMetaData group = (OptionsGroupMetaData)groups.get(groupKey);
-
- if (config.getOptions(groupKey) == null)
- {
- config.setOptions(groupKey, new HashMap());
- }
-
- //Map newOptions = new HashMap();
- Map options = group.getOptions();
- for (Iterator iterator1 = options.keySet().iterator(); iterator1.hasNext();)
- {
- String optionKey = (String)iterator1.next();
-
- OptionsGroupOptionMetaData option = (OptionsGroupOptionMetaData)options.get(optionKey);
-
- if (config.getValues(groupKey, optionKey) == null)
- {
-
- //config.setValues(groupKey, optionKey, new HashSet());
- config.setValues(groupKey, optionKey, option.getValues());
- }
-
-
- }
- }
-
- }
-
-
- public IdentityContext getIdentityContext()
- {
- return identityContext;
- }
-
-
- public String getConfigFile()
- {
- return configFile;
- }
-
- public void setConfigFile(String configFile)
- {
- this.configFile = configFile;
- }
-
- public String getDefaultConfigFile()
- {
- return defaultConfigFile;
- }
-
- public void setDefaultConfigFile(String defaultConfigFile)
- {
- this.defaultConfigFile = defaultConfigFile;
- }
-
- public String getJndiName()
- {
- return jndiName;
- }
-
- public void setJndiName(String jndiName)
- {
- this.jndiName = jndiName;
- }
-
- public JNDI.Binding getJndiBinding()
- {
- return jndiBinding;
- }
-
- public void setJndiBinding(JNDI.Binding jndiBinding)
- {
- this.jndiBinding = jndiBinding;
- }
-
- public boolean isRegisterMBeans()
- {
- return registerMBeans;
- }
-
- public void setRegisterMBeans(boolean registerMBeans)
- {
- this.registerMBeans = registerMBeans;
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/MembershipModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,82 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface MembershipModule
-{
-
- //TODO: add isUserInRole method - it could gain better performance
-
- /**
- * Return the set of role objects that a given user has.
- *
- * @param user the user
- * @return the set of roles of the specified user
- */
- Set getRoles(User user) throws IdentityException, IllegalArgumentException;
-
- Set getUsers(Role role) throws IdentityException, IllegalArgumentException;
-
-
- /**
- * Creates a relationship beetween a role and set of users. Other roles that have assotiontions with
- * those users remain unaffected.
- *
- * @param role
- * @param users
- * @throws IdentityException
- */
- void assignUsers(Role role, Set users) throws IdentityException, IllegalArgumentException;
-
- /**
- * Creates a relationship beetween a user and set of roles. This operation will erase any other assotientions
- * beetween the user and roles not specified in the provided set.
- *
- * @param user
- * @param roles
- * @throws IdentityException
- */
- void assignRoles(User user, Set roles) throws IdentityException, IllegalArgumentException;
-
- /**
- * Returns role members based on rolename - depreciated method ethod here only for compatibility with
- * old RoleModule interface
- *
- * @param roleName
- * @param offset
- * @param limit
- * @deprecated
- */
- Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException, IllegalArgumentException;
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/ProfileMap.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/ProfileMap.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/ProfileMap.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,43 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-import java.util.Map;
-
-/**
- * Extends <code>java.util.Map</code>le to provide meta information about user profile.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5218 $
- */
-public interface ProfileMap extends Map
-{
- /**
- * Return true if the profile value is read only.
- *
- * @param key
- * @return true if the profile value is read only
- * @throws ClassCastException if the key is not an instance of string
- */
- boolean isReadOnly(Object key);
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/Role.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/Role.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/Role.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,45 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-/**
- * A role of users.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision: 2001 $
- */
-public interface Role
-{
- /** The role identifier. */
- public Object getId();
-
- /** The role name used in security rules. This name can not be modified */
- public String getName();
-
- /** The role display name used on screens. This name can be modified */
- public String getDisplayName();
-
- /** */
- public void setDisplayName(String name);
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/RoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/RoleModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/RoleModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,102 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.Role;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision: 2001 $
- */
-public interface RoleModule
-{
- /**
- * Retrieves a role by its name
- *
- * @param name the role name
- * @return the role
- */
- Role findRoleByName(String name) throws IdentityException, IllegalArgumentException;
-
- /**
- * Retrieve a collection of role from the role names.
- *
- * @param names the role names
- * @return a collection of roles
- * @throws IllegalArgumentException
- */
- Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException;
-
- /**
- * Retrieves a role by its id.
- *
- * @param id the role id
- * @return the role
- */
- Role findRoleById(Object id) throws IdentityException, IllegalArgumentException;
-
- /**
- * Retrieves a role by its id.
- *
- * @param id the role id
- * @return the role
- */
- Role findRoleById(String id) throws IdentityException, IllegalArgumentException;
-
- /**
- * Create a new role with the specified name.
- *
- * @param name the role name
- * @param displayName the role display name
- * @return the role
- */
- Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException;
-
- /**
- * Remove a role.
- *
- * @param id the role id
- */
- void removeRole(Object id) throws IdentityException, IllegalArgumentException;
-
- /**
- * Returns the number of roles.
- *
- * @return the number of roles
- */
- int getRolesCount() throws IdentityException;
-
- /**
- * Get all the roles
- *
- * @return the roles
- */
- Set findRoles() throws IdentityException;
-
-
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/User.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/User.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/User.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,80 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity.ProfileMap;
-
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * A user.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar Bojan </a>
- * @version $Revision: 5218 $
- */
-public interface User
-{
- String INFO_USER_NAME_GIVEN = "portal.user.name.given";
- String INFO_USER_NAME_FAMILY = "portal.user.name.family";
- String INFO_USER_LOCATION = "portal.user.location";
- String INFO_USER_OCCUPATION = "portal.user.occupation";
- String INFO_USER_EXTRA = "portal.user.extra";
- String INFO_USER_SIGNATURE = "portal.user.signature";
- String INFO_USER_INTERESTS = "portal.user.interests";
- String INFO_USER_LOCALE = "portal.user.locale";
- String INFO_USER_IM_ICQ = "portal.user.im.icq";
- String INFO_USER_IM_AIM = "portal.user.im.aim";
- String INFO_USER_IM_MSNM = "portal.user.im.msnm";
- String INFO_USER_IM_YIM = "portal.user.im.yim";
- String INFO_USER_IM_SKYPE = "portal.user.im.skype";
- String INFO_USER_HOMEPAGE = "portal.user.homepage";
- String INFO_USER_TIME_ZONE_OFFSET = "portal.user.time-zone-offset";
- String INFO_USER_THEME = "portal.user.theme";
- String INFO_USER_SECURITY_QUESTION = "portal.user.security.question";
- String INFO_USER_SECURITY_ANSWER = "portal.user.security.answer";
- String INFO_USER_EMAIL_FAKE = "portal.user.email.fake";
- String INFO_USER_VIEW_EMAIL_VIEW_REAL = "portal.user.email.view-real";
- String INFO_USER_LAST_LOGIN_DATE = "portal.user.last-login-date";
- String INFO_USER_REGISTRATION_DATE = "portal.user.registration-date";
-
- String INFO_USER_ENABLED = "portal.user.enabled";
- String INFO_USER_EMAIL_REAL = "portal.user.email.real";
-
-
-
-
- /** The user identifier. */
- public Object getId();
-
- /** The user name. */
- public String getUserName();
-
- /** Set the password using proper encoding. */
- public void updatePassword(String password);
-
- /** Return true if the password is valid. */
- public boolean validatePassword(String password);
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/UserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/UserModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/UserModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,103 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity2.User;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @version $Revision: 2001 $
- */
-public interface UserModule
-{
- /**
- * Retrieve a user by its name.
- *
- * @param userName the user name
- * @return the user
- */
- User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException;
-
- /**
- * Retrieve a user by its id.
- *
- * @param id the user id
- * @return the user
- * @throws IllegalArgumentException if the id is null
- */
- User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException;
-
- /**
- * Retrieve a user by its id.
- *
- * @param id the user id
- * @return the user
- * @throws IllegalArgumentException if the id is null or not in the good format
- */
- User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException;
-
- /**
- * Creates a new user with the specified name.
- *
- * @param userName
- * @return the user
- */
- User createUser(String userName, String password) throws IdentityException, IllegalArgumentException;
-
- /**
- * Remove a user.
- *
- * @param id the user id
- */
- void removeUser(Object id) throws IdentityException, IllegalArgumentException;
-
- /**
- * Get a range of users.
- *
- * @param offset the offset of the first result to retrieve
- * @param limit the maximum number of users to retrieve
- * @return the user set
- */
- Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException;
-
- /**
- * Get a range of users.
- *
- * @param filter a string filter applied to the user name.
- * @param offset the offset of the frist result to retrieve
- * @param limit the maximum number of users to retrieve
- * @return the user set
- */
- Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException;
-
- /**
- * Returns the number of users.
- *
- * @return the number of users
- */
- int getUserCount() throws IdentityException, IllegalArgumentException;
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/UserProfileModule.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,45 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.identity2;
-
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.info.ProfileInfo;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public interface UserProfileModule
-{
-
- public Object getProperty(User user, String propertyName) throws IdentityException, IllegalArgumentException;
-
- public void setProperty(User user, String name, Object property) throws IdentityException, IllegalArgumentException;
-
- public Map getProperties(User user) throws IdentityException, IllegalArgumentException;
-
- public ProfileInfo getProfileInfo() throws IdentityException;
-
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,254 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.jboss.portal.identity2.db.HibernateRoleImpl;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.Tools;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateMembershipModuleImpl extends MembershipModuleService
-{
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateMembershipModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
-
- //
- sessionFactory = null;
-
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public Set getRoles(User user) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(user instanceof org.jboss.portal.identity2.db.HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateUserImpl user");
- }
-
- // We return an immutable set to avoid modifications
- HibernateUserImpl ui = (HibernateUserImpl)user;
- Set roles = ui.getRoles();
- Set copy = new HashSet();
- for (Iterator iterator = roles.iterator(); iterator.hasNext();)
- {
- HibernateRoleImpl role = (HibernateRoleImpl)iterator.next();
- copy.add(role);
- }
-
- return Collections.unmodifiableSet(copy);
- }
-
- public Set getUsers(Role role) throws IdentityException
- {
- if (!(role instanceof HibernateRoleImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
- }
-
- // We return an immutable set to avoid modifications
- HibernateRoleImpl ri = (HibernateRoleImpl)role;
- Set users = ri.getUsers();
- Set copy = new HashSet();
- for (Iterator iterator = users.iterator(); iterator.hasNext();)
- {
- HibernateUserImpl user = (HibernateUserImpl)iterator.next();
- copy.add(user);
- }
-
- return Collections.unmodifiableSet(copy);
- }
-
- public void assignUsers(Role role, Set users) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(role instanceof HibernateRoleImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
- }
-
- for (Iterator i = users.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof HibernateUserImpl)
- {
- HibernateUserImpl user = (HibernateUserImpl)o;
- user.getRoles().add(role);
- }
- else
- {
- throw new IllegalArgumentException("Only HibernateUserImpl roles can be accepted");
- }
- }
-
- }
-
- public void assignRoles(User user, Set roles) throws IdentityException
- {
- //throw new UnsupportedOperationException("Not yet implemented");
- if (!(user instanceof HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a HibernateUserImpl user");
- }
-
- // We make a defensive copy with unwrapped maps and update with a new set
- Set copy = new HashSet();
- for (Iterator i = roles.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof HibernateRoleImpl)
- {
- copy.add(o);
- }
- else
- {
- throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
- }
- }
-
- // Assign new roles
- HibernateUserImpl ui = (HibernateUserImpl)user;
- ui.setRoles(copy);
- }
-
- //TODO:
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- if (roleName != null)
- {
- try
- {
- Session session = getCurrentSession();
-
- HibernateUserImpl userimpl = new HibernateUserImpl();
- userimpl.setEnabled(true);
-
- Query query;
- if (userNameFilter.trim().length() != 0)
- {
- //
- userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-
- //
- query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
- query.setString("filter", userNameFilter);
- }
- else
- {
- query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name");
- }
- query.setString("name", roleName);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
-
- Iterator iterator = query.iterate();
- Set result = Tools.toSet(iterator);
-
- Set newResult = new HashSet();
- Iterator cleaner = result.iterator();
- while (cleaner.hasNext())
- {
- Object[] oArr = (Object[])cleaner.next();
- newResult.add(oArr[0]);
- }
-
- return newResult;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role " + roleName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- }
-
- /**
- * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
- * @param maps
- * @return
- * @throws Exception
- */
-
- /** Can be subclasses to provide testing in a non JTA environement. */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,149 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.Role;
-
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 5448 $
- */
-public class HibernateRoleImpl
- implements Role
-{
-
- private Long key;
- private String name;
- private Set users;
- private String displayName;
-
- /**
- *
- */
- public HibernateRoleImpl()
- {
- this.key = null;
- this.name = null;
- this.displayName = null;
- this.users = new HashSet();
- }
-
- /**
- *
- */
- public HibernateRoleImpl(String name)
- {
- this.key = null;
- this.name = name;
- this.displayName = name;
- this.users = new HashSet();
- }
-
- /**
- *
- */
- public HibernateRoleImpl(String name, String displayName)
- {
- this.key = null;
- this.name = name;
- this.displayName = displayName;
- this.users = new HashSet();
- }
-
- /**
- * @hibernate.id column="jbp_rid" generator-class="native"
- * <p/>
- * Called by hibernate.
- */
- protected Long getKey()
- {
- return key;
- }
-
- /** Called by hibernate. */
- protected void setKey(Long key)
- {
- this.key = key;
- }
-
- /** Called by hibernate. */
- protected void setName(String name)
- {
- this.name = name;
- }
-
- /** Called by hibernate. */
- protected void setUsers(Set users)
- {
- this.users = users;
- }
-
- // ******************************************************************************************************************
-
- public Object getId()
- {
- return key;
- }
-
- /**
- *
- */
- public String getName()
- {
- return name;
- }
-
- /**
- *
- */
- public String getDisplayName()
- {
- return displayName;
- }
-
- /**
- *
- */
- public void setDisplayName(String displayName)
- {
- this.displayName = displayName;
- }
-
- /**
- *
- */
- public Set getUsers()
- {
- return users;
- }
-
- public String toString()
- {
- return "Role[" + key + "," + name + "]";
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,393 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.db.HibernateRoleImpl;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity2.service.RoleModuleService;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.criterion.Restrictions;
-
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateRoleModuleImpl extends RoleModuleService
-{
-
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateRoleModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
-
- //
- sessionFactory = null;
-
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
-
- public Role findRoleByName(String name) throws IdentityException
- {
- if (name != null)
- {
- try
- {
- Session session = getCurrentSession();
- Criteria criteria = session.createCriteria(HibernateRoleImpl.class);
- criteria.add(Restrictions.naturalId().set("name", name));
- criteria.setCacheable(true);
- HibernateRoleImpl role = (HibernateRoleImpl)criteria.uniqueResult();
- if (role == null)
- {
- throw new IdentityException("No such role " + name);
- }
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by name " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Set findRolesByNames(String[] names) throws IdentityException
- {
- if (names != null)
- {
- try
- {
- Session session = getCurrentSession();
- StringBuffer queryString = new StringBuffer("from HibernateRoleImpl as g where g.name=?");
- for (int i = 1; i < names.length; i++)
- {
- queryString.append(" or g.name=?");
- }
- Query query = session.createQuery(queryString.toString());
- for (int i = 0; i < names.length; i++)
- {
- query.setString(i, names[i]);
- }
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findRoleById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public Role findRoleById(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- HibernateRoleImpl role = (HibernateRoleImpl)session.get(HibernateRoleImpl.class, (Long)id);
- if (role == null)
- {
- throw new IdentityException("No role found for " + id);
- }
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Role createRole(String name, String displayName) throws IdentityException
- {
- if (name != null)
- {
- try
- {
- HibernateRoleImpl role = new HibernateRoleImpl(name, displayName);
- Session session = getCurrentSession();
- session.save(role);
- return role;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create role " + name;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeRole(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- HibernateRoleImpl role = (HibernateRoleImpl)session.load(HibernateRoleImpl.class, (Long)id);
- Iterator users = role.getUsers().iterator();
- while (users.hasNext())
- {
- HibernateUserImpl user = (HibernateUserImpl)users.next();
- user.getRoles().remove(role);
- }
- session.delete(role);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove role " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public int getRolesCount() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(g.id) from HibernateRoleImpl as g");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findRoles() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from HibernateRoleImpl");
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find roles";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
- {
- if (roleName != null)
- {
- try
- {
- Session session = getCurrentSession();
-
- HibernateUserImpl HibernateUserImpl = new HibernateUserImpl();
- HibernateUserImpl.setEnabled(true);
-
- Query query;
- if (userNameFilter.trim().length() != 0)
- {
- //
- userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-
- //
- query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
- query.setString("filter", userNameFilter);
- }
- else
- {
- query = session.createQuery("from HibernateUserImpl as user left join user.roles role where role.name=:name");
- }
- query.setString("name", roleName);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
-
- Iterator iterator = query.iterate();
- Set result = Tools.toSet(iterator);
-
- Set newResult = new HashSet();
- Iterator cleaner = result.iterator();
- while (cleaner.hasNext())
- {
- Object[] oArr = (Object[])cleaner.next();
- newResult.add(oArr[0]);
- }
-
- return newResult;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find role " + roleName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("id cannot be null");
- }
- }
-
- public void setRoles(User user, Set roles) throws IdentityException
- {
- if (!(user instanceof HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a db user");
- }
-
- // We make a defensive copy and update with a new set
- Set copy = new HashSet();
- for (Iterator i = roles.iterator(); i.hasNext();)
- {
- Object o = i.next();
- if (o instanceof HibernateRoleImpl)
- {
- copy.add(o);
- }
- else
- {
- throw new IllegalArgumentException("Only db roles can be accepted");
- }
- }
-
- // Assign new roles
- HibernateUserImpl ui = (HibernateUserImpl)user;
- ui.setRoles(copy);
- }
-
- public Set getRoles(User user) throws IdentityException
- {
- if (!(user instanceof HibernateUserImpl))
- {
- throw new IllegalArgumentException("User is not a db user");
- }
-
- // We return an immutable set to avoid modifications
- HibernateUserImpl ui = (HibernateUserImpl)user;
- return Collections.unmodifiableSet(ui.getRoles());
- }
-
- /** Can be subclasses to provide testing in a non JTA environement. */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,538 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.identity2.ProfileMap;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Collections;
-import java.lang.reflect.Field;
-import java.text.SimpleDateFormat;
-import java.text.DateFormat;
-import java.text.ParseException;
-
-/**
- * User interface implementation.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
- * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar Bojan </a>
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 5448 $
- */
-public class HibernateUserImpl
- implements User
-{
-
- static final Map ACCESSORS = HibernateUserImpl.buildAccessors();
-
- private static Map buildAccessors()
- {
- Map map = new HashMap();
-
- // Map attributes defined by the JSR 168 spec P3P.
- map.put(P3PConstants.INFO_USER_NAME_NICKNAME, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_NICKNAME, "userName", false, false));
- map.put(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, new StringPropertyAccessor(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "realEmail", true, true));
- map.put(P3PConstants.INFO_USER_NAME_GIVEN, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_GIVEN, "givenName", true, true));
- map.put(P3PConstants.INFO_USER_NAME_FAMILY, new StringPropertyAccessor(P3PConstants.INFO_USER_NAME_FAMILY, "familyName", true, true));
-
- // Map attributes specific to JBoss Portal
- map.put(org.jboss.portal.identity2.User.INFO_USER_EMAIL_FAKE, new StringPropertyAccessor(org.jboss.portal.identity2.User.INFO_USER_EMAIL_FAKE, "fakeEmail", true, true));
- map.put(org.jboss.portal.identity2.User.INFO_USER_REGISTRATION_DATE, new DatePropertyAccessor(org.jboss.portal.identity2.User.INFO_USER_REGISTRATION_DATE, "registrationDate", false, false));
- map.put(org.jboss.portal.identity2.User.INFO_USER_VIEW_EMAIL_VIEW_REAL, new BooleanPropertyAccessor(org.jboss.portal.identity2.User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "viewRealEmail", true, false));
- map.put(org.jboss.portal.identity2.User.INFO_USER_ENABLED, new BooleanPropertyAccessor(org.jboss.portal.identity2.User.INFO_USER_ENABLED, "enabled", true, false));
-
- //
- return Collections.unmodifiableMap(map);
- }
-
- protected ProfileMap profileMap;
-
- /*
- * P3P mapped persistent fields.
- */
-
- protected String userName;
- protected String givenName;
- protected String familyName;
- protected String realEmail;
-
- /*
- * Non mapped persistent fields.
- */
-
- protected Long key;
- protected boolean enabled;
- protected String password;
-
- /*
- * Extension mapped persistent fields.
- */
-
- protected String fakeEmail;
- protected boolean viewRealEmail;
- protected Date registrationDate;
-
- /*
- * Persistent associations
- */
-
- protected Map dynamic;
- protected Set roles;
-
- /**
- *
- */
- public HibernateUserImpl()
- {
- this.key = null;
- this.userName = null;
- this.dynamic = null;
- this.roles = null;
- this.registrationDate = null;
- this.enabled = false;
- this.profileMap = new ProfileMapImpl(this);
- }
-
- /**
- *
- */
- public HibernateUserImpl(String userName)
- {
- this.key = null;
- this.userName = userName;
- this.dynamic = new HashMap();
- this.roles = new HashSet();
- this.registrationDate = new Date();
- this.enabled = false;
- this.profileMap = new ProfileMapImpl(this);
- }
-
- /** Called by hibernate. */
- public Long getKey()
- {
- return key;
- }
-
- /** Called by hibernate. */
- protected void setKey(Long key)
- {
- this.key = key;
- }
-
- /** Called by hibernate. */
- protected void setUserName(String userName)
- {
- this.userName = userName;
- }
-
- /** Called by Hibernate. */
- protected Map getDynamic()
- {
- return dynamic;
- }
-
- /** Called by Hibernate. */
- protected void setDynamic(Map dynamic)
- {
- this.dynamic = dynamic;
- }
-
- public ProfileMap getProfileMap()
- {
- return profileMap;
- }
-
- // User implementation **********************************************************************************************
-
- /**
- *
- */
- public Object getId()
- {
- return key;
- }
-
- /**
- *
- */
- public String getUserName()
- {
- return userName;
- }
-
- /**
- *
- */
- public String getGivenName()
- {
- return givenName;
- }
-
- public void setGivenName(String givenName)
- {
- this.givenName = givenName;
- }
-
- /**
- *
- */
- public String getFamilyName()
- {
- return familyName;
- }
-
- public void setFamilyName(String familyName)
- {
- this.familyName = familyName;
- }
-
- public void updatePassword(String password)
- {
- this.password = Tools.md5AsHexString(password);
- }
-
- /**
- *
- */
- public String getRealEmail()
- {
- return realEmail;
- }
-
- /**
- *
- */
- public void setRealEmail(String realEmail)
- {
- this.realEmail = realEmail;
- }
-
- /**
- *
- */
- public String getFakeEmail()
- {
- return fakeEmail;
- }
-
- /**
- *
- */
- public void setFakeEmail(String fakeEmail)
- {
- this.fakeEmail = fakeEmail;
- }
-
- /**
- *
- */
- public Date getRegistrationDate()
- {
- return registrationDate;
- }
-
- /**
- *
- */
- public void setRegistrationDate(Date registrationDate)
- {
- this.registrationDate = registrationDate;
- }
-
- /**
- *
- */
- public boolean getViewRealEmail()
- {
- return viewRealEmail;
- }
-
- /**
- *
- */
- public void setViewRealEmail(boolean viewRealEmail)
- {
- this.viewRealEmail = viewRealEmail;
- }
-
- /**
- *
- */
- public boolean getEnabled()
- {
- return enabled;
- }
-
- /**
- *
- */
- public void setEnabled(boolean enable)
- {
- this.enabled = enable;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- /** Returns the roles related to this user. */
- public Set getRoles()
- {
- return roles;
- }
-
- /** Update the roles. */
- public void setRoles(Set roles)
- {
- this.roles = roles;
- }
-
- public boolean validatePassword(String password)
- {
- if (password != null)
- {
- String hashedPassword = Tools.md5AsHexString(password);
- return hashedPassword.equals(this.password);
- }
- return false;
- }
-
- /**
- *
- */
- public String toString()
- {
- return "User[" + key + "," + userName + "]";
- }
-
-
- /** An accessor that maps a user field to a property name. */
- static abstract class PropertyAccessor
- {
-
- protected final String propertyName;
- protected final Field field;
- protected final boolean writable;
- protected final boolean nullable;
-
- public PropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- try
- {
- this.propertyName = propertyName;
- this.writable = writable;
- this.field = HibernateUserImpl.class.getDeclaredField(fieldName);
- this.nullable = nullable;
- }
- catch (NoSuchFieldException e)
- {
- throw new Error(e);
- }
- }
-
- public String getPropertyName()
- {
- return propertyName;
- }
-
- public boolean isNullable()
- {
- return nullable;
- }
-
- public boolean isWritable()
- {
- return writable;
- }
-
- /**
- * @param instance the user instance
- * @param string the value
- * @throws IllegalArgumentException if the string cannot be converted to an object
- */
- public void set(Object instance, String string) throws IllegalArgumentException
- {
- try
- {
- if (string == null)
- {
- field.set(instance, null);
- }
- else
- {
- Object object = toObject(string);
- field.set(instance, object);
- }
- }
- catch (IllegalAccessException e)
- {
- throw new Error(e);
- }
- }
-
- /**
- * @param instance the user instance
- * @return the converted value
- * @throws IllegalArgumentException if the object cannot be converted to a string
- */
- public String get(Object instance) throws IllegalArgumentException
- {
- try
- {
- Object object = field.get(instance);
- if (object == null)
- {
- return null;
- }
- else
- {
- return toString(object);
- }
- }
- catch (IllegalAccessException e)
- {
- throw new Error(e);
- }
- }
-
- /**
- * Perform the to object conversion.
- *
- * @param value the value to convert
- * @return the converted value
- * @throws IllegalArgumentException if the string cannot be converted to an object
- */
- protected abstract Object toObject(String value) throws IllegalArgumentException;
-
- /**
- * Perform the to strong conversion.
- *
- * @param value the value to convert
- * @return the converted value
- * @throws IllegalArgumentException if the object cannot be converted to a string
- */
- protected abstract String toString(Object value);
-
- public String toString()
- {
- return "PropertyAccessor[" + propertyName + "," + field + "]";
- }
- }
-
- static class StringPropertyAccessor extends PropertyAccessor
- {
- public StringPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value)
- {
- return value;
- }
-
- protected String toString(Object value)
- {
- return (String)value;
- }
- }
-
- static class BooleanPropertyAccessor extends PropertyAccessor
- {
- public BooleanPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value) throws IllegalArgumentException
- {
- if ("true".equalsIgnoreCase(value))
- {
- return Boolean.TRUE;
- }
- else if ("false".equalsIgnoreCase(value))
- {
- return Boolean.FALSE;
- }
- else
- {
- throw new IllegalArgumentException("The value " + value + " cannot be converted to boolean for accessor " + toString());
- }
- }
-
- protected String toString(Object value)
- {
- return value.toString();
- }
- }
-
- static class DatePropertyAccessor extends PropertyAccessor
- {
- private static final ThreadLocal formatLocal = new ThreadLocal()
- {
- protected Object initialValue()
- {
- return new SimpleDateFormat();
- }
- };
-
- public DatePropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
- {
- super(propertyName, fieldName, writable, nullable);
- }
-
- protected Object toObject(String value) throws IllegalArgumentException
- {
- try
- {
- DateFormat format = (DateFormat)HibernateUserImpl.DatePropertyAccessor.formatLocal.get();
- Date date = format.parse(value);
- return date;
- }
- catch (ParseException e)
- {
- throw new IllegalArgumentException();
- }
- }
-
- protected String toString(Object value)
- {
- Date date = (Date)value;
- DateFormat format = (DateFormat)HibernateUserImpl.DatePropertyAccessor.formatLocal.get();
- return format.format(date);
- }
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,291 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import java.io.Serializable;
-import java.util.Set;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateUserModuleImpl extends UserModuleService
-{
-
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
- }
-
- protected void stopService() throws Exception
- {
-
- //
- sessionFactory = null;
-
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
-
- public User findUserByUserName(String userName) throws IdentityException
- {
- if (userName != null)
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from HibernateUserImpl where userName=:userName");
- query.setParameter("userName", userName);
- query.setCacheable(true);
- HibernateUserImpl user = (HibernateUserImpl)query.uniqueResult();
- if (user == null)
- {
- throw new NoSuchUserException("No such user " + userName);
- }
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by name " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("user name cannot be null");
- }
- }
-
- public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- if (id == null)
- {
- throw new IllegalArgumentException("The id is null");
- }
- try
- {
- return findUserById(new Long(id));
- }
- catch (NumberFormatException e)
- {
- throw new IllegalArgumentException("Cannot parse id into an long " + id);
- }
- }
-
- public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- HibernateUserImpl user = (HibernateUserImpl)session.get(HibernateUserImpl.class, (Long)id);
- if (user == null)
- {
- throw new NoSuchUserException("No user found for " + id);
- }
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user by id " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public User createUser(String userName, String password) throws IdentityException
- {
- if (userName != null)
- {
- try
- {
- HibernateUserImpl user = new HibernateUserImpl(userName);
- user.updatePassword(password);
- //user.setRealEmail(realEmail);
- Session session = getCurrentSession();
- session.save(user);
- return user;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create user " + userName;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("name cannot be null");
- }
- }
-
- public void removeUser(Object id) throws IdentityException
- {
- if (id instanceof Long)
- {
- try
- {
- Session session = getCurrentSession();
- HibernateUserImpl user = (HibernateUserImpl)session.load(HibernateUserImpl.class, (Serializable)id);
- if (user == null)
- {
- throw new NoSuchUserException("No such user " + id);
- }
- session.delete(user);
- session.flush();
- }
- catch (HibernateException e)
- {
- String message = "Cannot remove user " + id;
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
- else
- {
- throw new IllegalArgumentException("The id is not an long : " + id);
- }
- }
-
- public Set findUsers(int offset, int limit) throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("from HibernateUserImpl");
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
- {
- try
- {
- // Remove all occurences of % and add ours
- filter = "%" + filter.replaceAll("%", "") + "%";
-
- //
- Session session = getCurrentSession();
- Query query = session.createQuery("from HibernateUserImpl as u where u.userName like :filter");
- query.setString("filter", filter);
- query.setFirstResult(offset);
- query.setMaxResults(limit);
- Iterator iterator = query.iterate();
- return Tools.toSet(iterator);
- }
- catch (HibernateException e)
- {
- String message = "Cannot find user range [" + offset + "," + limit + "]";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- public int getUserCount() throws IdentityException
- {
- try
- {
- Session session = getCurrentSession();
- Query query = session.createQuery("select count(u.key) from HibernateUserImpl as u");
- return ((Number)query.uniqueResult()).intValue();
- }
- catch (HibernateException e)
- {
- String message = "Cannot count users";
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
- /**
- * Can be subclasses to provide testing in a non JTA environement.
- *
- * @throws IllegalStateException if no session factory is present
- */
- protected Session getCurrentSession() throws IllegalStateException
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-}
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,294 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.info.ProfileInfo;
-import org.jboss.portal.identity2.info.PropertyInfo;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashMap;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateUserProfileModuleImpl extends UserProfileModuleService
-{
-
- /** . */
- private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserProfileModuleImpl.class);
- /** . */
- protected SessionFactory sessionFactory;
-
- /** . */
- protected String sessionFactoryJNDIName;
-
- private boolean synchronizeNonExistingUsers = true;
-
- private boolean acceptOtherImplementations = true;
-
- private String defaultSynchronizePassword;
-
- protected void startService() throws Exception
- {
- //
- sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
- super.startService();
-
- }
-
- protected void stopService() throws Exception
- {
- //
- sessionFactory = null;
- super.stopService();
- }
-
-// public SessionFactory getSessionFactory()
-// {
-// return sessionFactory;
-// }
-
- public String getSessionFactoryJNDIName()
- {
- return sessionFactoryJNDIName;
- }
-
- public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
- {
- this.sessionFactoryJNDIName = sessionFactoryJNDIName;
- }
-
- public Object getProperty(User user, String propertyName) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- HibernateUserImpl dbUser = processUser(user);
-
- PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
-
- if (pi == null)
- {
- throw new IdentityException("Cannot find profile information about property: " + propertyName);
- }
-
- return dbUser.getProfileMap().get(propertyName);
- }
-
- public void setProperty(User user, String propertyName, Object propertyValue) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
- if (propertyName == null)
- {
- throw new IllegalArgumentException("Property name need to have value");
- }
-
- HibernateUserImpl dbUser = processUser(user);
-
-
- PropertyInfo pi = getProfileInfo().getPropertyInfo(propertyName);
-
- if (pi == null)
- {
- throw new IdentityException("Cannot find profile information about property: " + propertyName);
- }
- else if (!pi.getAccessMode().equals(PropertyInfo.ACCESS_MODE_READ_WRITE))
- {
- throw new IdentityException("Property is not allowed for write access: " + propertyName);
- }
-
- //if value is null reset property
-
- dbUser.getProfileMap().put(propertyName, propertyValue);
- }
-
- public Map getProperties(User user) throws IdentityException
- {
- if (user == null)
- {
- throw new IllegalArgumentException("User cannot be null");
- }
-
- HibernateUserImpl dbUser = processUser(user);
-
-
-
- //make a copy
- Map props = new HashMap();
- Map profile = dbUser.getProfileMap();
- Set keys = profile.keySet();
- for (Iterator iterator = keys.iterator(); iterator.hasNext();)
- {
- String key = (String)iterator.next();
- props.put(key, profile.get(key));
- }
- return props;
- }
-
-
-
- /** Can be subclasses to provide testing in a non JTA environement. */
- protected Session getCurrentSession()
- {
- if (sessionFactory == null)
- {
- throw new IllegalStateException("No session factory");
- }
- return sessionFactory.getCurrentSession();
- }
-
- protected HibernateUserImpl processUser(User user) throws IdentityException
- {
- if (user instanceof HibernateUserImpl)
- {
- return (HibernateUserImpl)user;
- }
- else if (!isAcceptOtherImplementations())
- {
- throw new IllegalArgumentException("This UserProfileModule implementation support only HibenrateUserImpl objects - set acceptOtherImplementations option to true");
- }
- if (log.isDebugEnabled()) log.debug("Processing non HibernateUserImpl object: " + user.getClass());
- //if not Hibernate user try to obtain it using userName
- Session session = getCurrentSession();
- Query query = session.createQuery("from HibernateUserImpl where userName=:userName");
- query.setParameter("userName", user.getUserName());
- query.setCacheable(true);
- HibernateUserImpl hu = (HibernateUserImpl)query.uniqueResult();
-
- if (hu != null )
- {
- return hu;
- }
- else if (!isSynchronizeNonExistingUsers())
- {
- throw new IdentityException("No user in DB - set synchronizeNonExistingUsers option to true");
- }
- else
- {
- try
- {
- hu = new HibernateUserImpl(user.getUserName());
- //user.updatePassword(user.getPassword());
- if (defaultSynchronizePassword != null)
- {
- user.updatePassword(getDefaultSynchronizePassword());
- }
- session = getCurrentSession();
- session.save(hu);
- return hu;
- }
- catch (HibernateException e)
- {
- String message = "Cannot create user " + user.getUserName();
- log.error(message, e);
- throw new IdentityException(message, e);
- }
- }
-
-
- }
-
-
- /**
- * obtains UserProfile object - if module is used as a Delegate it tries to obtain it from the main one.
- * @return
- * @throws IdentityException
- */
- public ProfileInfo getProfileInfo() throws IdentityException
- {
-
-
- if (super.getProfileInfo() == null)
- {
- //obtain main UserProfileModule
- UserProfileModule module = (UserProfileModule)getIdentityContext().getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
- if (module == this)
- {
- throw new IdentityException("ProfileInfo not accessible - check configuration");
- }
- else
- {
- setProfileInfo(module.getProfileInfo());
- }
- }
- return super.getProfileInfo();
- }
-
-
- public boolean isSynchronizeNonExistingUsers()
- {
- return synchronizeNonExistingUsers;
- }
-
- public void setSynchronizeNonExistingUsers(boolean synchronizeNonExistingUsers)
- {
- this.synchronizeNonExistingUsers = synchronizeNonExistingUsers;
- }
-
-
- public boolean isAcceptOtherImplementations()
- {
- return acceptOtherImplementations;
- }
-
- public void setAcceptOtherImplementations(boolean acceptOtherImplementations)
- {
- this.acceptOtherImplementations = acceptOtherImplementations;
- }
-
- public String getDefaultSynchronizePassword()
- {
- return defaultSynchronizePassword;
- }
-
- public void setDefaultSynchronizePassword(String defaultSynchronizePassword)
- {
- this.defaultSynchronizePassword = defaultSynchronizePassword;
- }
-}
-
Deleted: trunk/identity/src/main/org/jboss/portal/identity2/db/ProfileMapImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/ProfileMapImpl.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/identity2/db/ProfileMapImpl.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -1,275 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.ProfileMap;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * A mutable map that expose user properties.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public class ProfileMapImpl implements ProfileMap
-{
-
- /** . */
- private HibernateUserImpl user;
-
- public ProfileMapImpl(HibernateUserImpl user)
- {
- if (user == null)
- {
- throw new IllegalArgumentException();
- }
- this.user = user;
- }
-
- public boolean isReadOnly(Object key)
- {
- if (key == null)
- {
- return false;
- }
- if (key instanceof String == false)
- {
- throw new ClassCastException("Key must be a string");
- }
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- return accessor != null && !accessor.isWritable();
- }
-
- public int size()
- {
- return HibernateUserImpl.ACCESSORS.size() + user.getDynamic().size();
- }
-
- public boolean isEmpty()
- {
- return false;
- }
-
- /** @throws ClassCastException if the key is not an instance of string */
- public boolean containsKey(Object key) throws ClassCastException
- {
- if (key == null)
- {
- return false;
- }
- if (key instanceof String == false)
- {
- throw new ClassCastException("Key must be a string");
- }
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- if (accessor != null)
- {
- return true;
- }
- return user.getDynamic().containsKey(key);
- }
-
- /** @throws ClassCastException if the value is not an instance of string */
- public boolean containsValue(Object value) throws ClassCastException
- {
- if (value == null)
- {
- throw new NullPointerException("Key cannot be null");
- }
- if (value instanceof String == false)
- {
- throw new ClassCastException("Value must be a string");
- }
- for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
- {
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
- Object value2 = accessor.get(user);
- if (value == value2 || value.equals(value2))
- {
- return true;
- }
- }
- return user.getDynamic().containsValue(value);
- }
-
- /** @throws ClassCastException if the key is not an instance of string */
- public Object get(Object key)
- {
- if (key == null)
- {
- return null;
- }
- if (key instanceof String == false)
- {
- throw new ClassCastException("Key must be a string");
- }
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- if (accessor != null)
- {
- return accessor.get(user);
- }
- return user.getDynamic().get(key);
- }
-
- /**
- * Put a value in the dynamic map.
- * <p/>
- * If the key is not an instance of string then an IllegalArgumentException is thrown. If the value is mapped to an
- * accessor of a non writable field then an IllegalArgumentException is thrown. If the value is mapped to an accessor
- * of a non nullable field and the field is null then an IllegalArgumentException is thrown.
- *
- * @throws IllegalArgumentException
- */
- public Object put(Object key, Object newValue) throws IllegalArgumentException
- {
- if (key == null)
- {
- return null;
- }
- if (key instanceof String == false)
- {
- throw new ClassCastException("Key is not a String");
- }
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- if (accessor != null)
- {
- if (newValue == null && !accessor.isNullable())
- {
- throw new NullPointerException("Key " + key + " is not nullable");
- }
- if (!accessor.isWritable())
- {
- throw new IllegalArgumentException("Key " + key + " is not modifiable");
- }
- else
- {
- Object oldValue = accessor.get(user);
- accessor.set(user, (String)newValue);
- return oldValue;
- }
- }
- if (newValue instanceof String == false)
- {
- throw new ClassCastException("Dynamic value must be a string");
- }
- return user.getDynamic().put(key, newValue);
- }
-
- /**
- * Only affect dynamic properties, otherwise it throws an IllegalArgumentException.
- *
- * @throws IllegalArgumentException if the key is a not a dynamic property
- */
- public Object remove(Object key) throws IllegalArgumentException
- {
- if (key instanceof String == false)
- {
- throw new ClassCastException("Key is not a String");
- }
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- if (accessor != null)
- {
- throw new IllegalArgumentException("Key " + key + " is not removable");
- }
- return user.getDynamic().remove(key);
- }
-
- /** Clear only dynamic properties. */
- public void clear()
- {
- user.getDynamic().clear();
- }
-
- public Set keySet()
- {
- // Get
- Set set = new HashSet(size());
-
- //
- set.addAll(user.getDynamic().keySet());
- set.addAll(HibernateUserImpl.ACCESSORS.keySet());
- return set;
- }
-
- public Collection values()
- {
- ArrayList collection = new ArrayList(size());
- for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
- {
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
- collection.add(accessor.get(user));
- }
- collection.addAll(user.getDynamic().values());
- return collection;
- }
-
- /** Returns an immutable collection of entries. */
- public Set entrySet()
- {
- Map copy = new HashMap(user.getDynamic());
- for (Iterator i = HibernateUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
- {
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)i.next();
- copy.put(accessor.getPropertyName(), accessor.get(user));
- }
- return Collections.unmodifiableMap(copy).entrySet();
- }
-
- public void putAll(Map map)
- {
- // todo : check all properties ok with changes before proceeding
- for (Iterator i = map.entrySet().iterator(); i.hasNext();)
- {
- Entry entry = (Entry)i.next();
- Object key = entry.getKey();
- if (key instanceof String)
- {
- Object value = entry.getValue();
- HibernateUserImpl.PropertyAccessor accessor = (HibernateUserImpl.PropertyAccessor)HibernateUserImpl.ACCESSORS.get(key);
- if (accessor != null)
- {
- if (accessor.isWritable())
- {
- accessor.set(user, (String)value);
- }
- else
- {
- // julien : Do something better ?
- }
- }
- else
- {
- user.getDynamic().put(key, value);
- }
- }
- }
- }
-}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ConfigurationTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -26,18 +26,13 @@
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.service.IdentityModuleService;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
+import org.jboss.portal.identity.IdentityContextImpl;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.service.IdentityModuleService;
import org.jboss.portal.test.framework.TestRuntimeContext;
-import java.util.Set;
-import java.util.Iterator;
-
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/MembershipStrategyTest.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -23,9 +23,9 @@
package org.jboss.portal.test.identity;
import junit.framework.Assert;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.UserModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.UserModule;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss dot com">Boleslaw Dawidowicz</a>
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/UserProtoTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -26,22 +26,12 @@
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.service.IdentityModuleService;
+import org.jboss.portal.identity.IdentityContextImpl;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.HibernateSupport;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.db.RoleImpl;
-import org.jboss.portal.identity.db.UserImpl;
-import org.hibernate.SessionFactory;
import org.hibernate.Session;
-import org.hibernate.EntityMode;
import org.hibernate.Query;
-import org.hibernate.Transaction;
-import javax.naming.InitialContext;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/UserTest.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,12 +22,12 @@
package org.jboss.portal.test.identity;
import junit.framework.Assert;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.UserProfileModule;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.common.util.CollectionBuilder;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -21,22 +21,15 @@
*/
package org.jboss.portal.test.identity.db;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.ProfileMap;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.service.RoleModuleService;
-import org.jboss.portal.identity2.db.HibernateUserImpl;
-import org.jboss.portal.identity2.db.HibernateUserModuleImpl;
-import org.jboss.portal.identity2.db.HibernateRoleModuleImpl;
-import org.jboss.portal.identity2.db.HibernateMembershipModuleImpl;
-import org.jboss.portal.identity2.db.HibernateUserProfileModuleImpl;
-import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
-import org.jboss.portal.identity2.config.info.ProfileInfoSupport;
-import org.jboss.portal.identity2.info.ProfileInfo;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.service.UserModuleService;
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.service.RoleModuleService;
import org.jboss.portal.test.identity.UserTest;
import org.jboss.portal.common.p3p.P3PConstants;
import junit.framework.TestSuite;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db/DBTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -27,16 +27,11 @@
import org.jboss.portal.test.identity.UserTest;
import org.jboss.portal.common.test.junit.POJOJUnitTest;
import org.jboss.portal.common.test.junit.JUnitAdapter;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.DelegatingUserProfileModuleImpl;
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.service.RoleModuleService;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.jboss.portal.identity2.db.HibernateUserModuleImpl;
-import org.jboss.portal.identity2.db.HibernateRoleModuleImpl;
-import org.jboss.portal.identity2.db.HibernateMembershipModuleImpl;
-import org.jboss.portal.identity2.db.HibernateUserProfileModuleImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.service.UserProfileModuleService;
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.service.RoleModuleService;
+import org.jboss.portal.identity.service.UserModuleService;
import org.apache.log4j.Appender;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.SimpleLayout;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db_old/DBUserTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -33,8 +33,8 @@
import org.jboss.portal.common.p3p.P3PConstants;
import org.jboss.portal.identity.ProfileMap;
import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.db.DBRoleModuleImpl;
-import org.jboss.portal.identity.db.DBUserModuleImpl;
+//import org.jboss.portal.identity.db.DBRoleModuleImpl;
+//import org.jboss.portal.identity.db.DBUserModuleImpl;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.DataSourceSupport;
import org.jboss.portal.test.framework.embedded.HibernateSupport;
@@ -50,278 +50,278 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class DBUserTestCase extends junit.framework.TestCase implements UserTest.Context
+public class DBUserTestCase //extends junit.framework.TestCase implements UserTest.Context
{
- static
- {
- Appender appender = new ConsoleAppender(new SimpleLayout());
- Logger.getRoot().addAppender(appender);
- Logger.getRoot().setLevel(Level.DEBUG);
- Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
- }
-
- public static TestSuite suite() throws Exception
- {
- URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
- Map parameterMap = new HashMap();
- parameterMap.put("DataSourceConfig", DataSourceSupport.Config.fromXML2(configsURL));
- POJOJUnitTest abc = new POJOJUnitTest(DBUserTestCase.class);
- JUnitAdapter adapter = new JUnitAdapter(abc, parameterMap);
- TestSuite suite = new TestSuite();
- suite.addTest(adapter);
- return suite;
- }
-
- /** . */
- private DataSourceSupport.Config dataSourceConfigParameter;
-
- /** . */
- private TestRuntimeContext runtimeContext;
-
- /** . */
- private HibernateSupport hibernate;
-
- /** . */
- private UserTest utc;
-
- /** . */
- private DBUserModuleImpl userModule;
-
- /** . */
- private DBRoleModuleImpl roleModule;
-
- public DataSourceSupport.Config getDataSourceConfigParameter()
- {
- return dataSourceConfigParameter;
- }
-
- public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfig)
- {
- this.dataSourceConfigParameter = dataSourceConfig;
- }
-
- public HibernateSupport getHibernate()
- {
- return hibernate;
- }
-
- public void setHibernate(HibernateSupport hibernate)
- {
- this.hibernate = hibernate;
- }
-
- public String getName()
- {
- return super.getName() + "," + dataSourceConfigParameter.getName();
- }
-
- public void setUp() throws Exception
- {
- runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/db_old-beans.xml");
- runtimeContext.addBean("DBTestBean", this);
- runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
- runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
- runtimeContext.start();
-
- //HibernateSupport.getConfig(dataSourceConfigParameter.getName()).
- //
- utc = new UserTest();
- userModule = new DBUserModuleImpl();
- userModule.setSessionFactoryJNDIName("java:/SessionFactory");
- userModule.start();
-
- //
- roleModule = new DBRoleModuleImpl();
- roleModule.setSessionFactoryJNDIName("java:/SessionFactory");
- roleModule.start();
-
- //
- utc.setUserModule(userModule);
- utc.setRoleModule(roleModule);
- utc.setContext(this);
- utc.populate();
- }
-
- public void tearDown() throws Exception
- {
- utc.setUserModule(null);
- utc.setRoleModule(null);
- utc.setContext(null);
- utc = null;
-
- //
- roleModule.destroy();
- userModule.destroy();
- roleModule = null;
- userModule = null;
-
- //
- runtimeContext.stop();
- }
-
-
- public void begin()
- {
- hibernate.openSession();
- }
-
- public void commit()
- {
- assertTrue(hibernate.commitTransaction());
- }
-
- //
-
- public void testFindUsersUsingFilter() throws Exception
- {
- utc.testFindUsersUsingFilter();
- }
-
- public void testFindUser1() throws Exception
- {
- utc.testFindUser1();
- }
-
- public void testFindUser2() throws Exception
- {
- utc.testFindUser2();
- }
-
- public void testFindUsers() throws Exception
- {
- utc.testFindUsers();
- }
-
- public void testCreateUser() throws Exception
- {
- utc.testCreateUser();
- }
-
- public void testCreateRole() throws Exception
- {
- utc.testCreateRole();
- }
-
- public void testCountUser() throws Exception
- {
- utc.testCountUser();
- }
-
- public void testRemoveNonExistingRole() throws Exception
- {
- utc.testRemoveNonExistingRole();
- }
-
- public void testRemoveRole() throws Exception
- {
- utc.testRemoveRole();
- }
-
- public void testRemoveUser() throws Exception
- {
- utc.testRemoveUser();
- }
-
- public void testFindRoles() throws Exception
- {
- utc.testFindRoles();
- }
-
- public void testFindRoleMembers() throws Exception
- {
- utc.testFindRoleMembers();
- }
-
- public void testDynamicProperty() throws Exception
- {
- begin();
- User user = userModule.createUser("testname", "testpassword", "testemail");
- ProfileMap map = user.getProfile();
- assertNull(map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- map.put("foo", "value");
- assertEquals("value", map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- commit();
-
- begin();
- user = userModule.findUserByUserName("testname");
- map = user.getProfile();
- assertEquals("value", map.get("foo"));
- assertFalse(map.isReadOnly("foo"));
- commit();
- }
-
- public void testStaticProperty() throws Exception
- {
- begin();
-
- //
- User user = userModule.createUser("testname", "testpassword", "testemail");
- ProfileMap map = user.getProfile();
- assertEquals("testname", map.get(P3PConstants.INFO_USER_NAME_NICKNAME));
-
- // Test cannot remove a static property
- try
- {
- map.remove(P3PConstants.INFO_USER_NAME_GIVEN);
- fail("Should not be capable to remove static property");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- // Test read only property
- assertTrue(map.isReadOnly(P3PConstants.INFO_USER_NAME_NICKNAME));
- try
- {
- map.put(P3PConstants.INFO_USER_NAME_NICKNAME, "anothername");
- fail("Should not be capable to modify a read only static property");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- // Test non nullable and writable property
- try
- {
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, null);
- fail("Should not be capable to nullify a non nullable static property");
- }
- catch (NullPointerException expected)
- {
- }
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
- assertEquals(true, user.getViewRealEmail());
-
- // Test boolean property
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
- assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
- assertEquals(false, user.getViewRealEmail());
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
- assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
- assertEquals(true, user.getViewRealEmail());
- user.setViewRealEmail(false);
- assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
- assertEquals(false, user.getViewRealEmail());
- user.setViewRealEmail(true);
- assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
- assertEquals(true, user.getViewRealEmail());
- try
- {
- map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "truee");
- fail("Should not be capable to set a bad value to boolean property");
- }
- catch (IllegalArgumentException expected)
- {
- }
-
- // Test date
- Date date = user.getRegistrationDate();
- SimpleDateFormat sdf = new SimpleDateFormat();
- assertEquals(sdf.format(date), map.get(User.INFO_USER_REGISTRATION_DATE));
-
- commit();
- }
+// static
+// {
+// Appender appender = new ConsoleAppender(new SimpleLayout());
+// Logger.getRoot().addAppender(appender);
+// Logger.getRoot().setLevel(Level.DEBUG);
+// Logger.getLogger("org.hibernate").setLevel(Level.ERROR);
+// }
+//
+// public static TestSuite suite() throws Exception
+// {
+// URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+// Map parameterMap = new HashMap();
+// parameterMap.put("DataSourceConfig", DataSourceSupport.Config.fromXML2(configsURL));
+// POJOJUnitTest abc = new POJOJUnitTest(DBUserTestCase.class);
+// JUnitAdapter adapter = new JUnitAdapter(abc, parameterMap);
+// TestSuite suite = new TestSuite();
+// suite.addTest(adapter);
+// return suite;
+// }
+//
+// /** . */
+// private DataSourceSupport.Config dataSourceConfigParameter;
+//
+// /** . */
+// private TestRuntimeContext runtimeContext;
+//
+// /** . */
+// private HibernateSupport hibernate;
+//
+// /** . */
+// private UserTest utc;
+//
+// /** . */
+// private DBUserModuleImpl userModule;
+//
+// /** . */
+// private DBRoleModuleImpl roleModule;
+//
+// public DataSourceSupport.Config getDataSourceConfigParameter()
+// {
+// return dataSourceConfigParameter;
+// }
+//
+// public void setDataSourceConfigParameter(DataSourceSupport.Config dataSourceConfig)
+// {
+// this.dataSourceConfigParameter = dataSourceConfig;
+// }
+//
+// public HibernateSupport getHibernate()
+// {
+// return hibernate;
+// }
+//
+// public void setHibernate(HibernateSupport hibernate)
+// {
+// this.hibernate = hibernate;
+// }
+//
+// public String getName()
+// {
+// return super.getName() + "," + dataSourceConfigParameter.getName();
+// }
+//
+// public void setUp() throws Exception
+// {
+// runtimeContext = new TestRuntimeContext("org/jboss/portal/test/identity/db_old-beans.xml");
+// runtimeContext.addBean("DBTestBean", this);
+// runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter);
+// runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter.getName()));
+// runtimeContext.start();
+//
+// //HibernateSupport.getConfig(dataSourceConfigParameter.getName()).
+// //
+// utc = new UserTest();
+// userModule = new DBUserModuleImpl();
+// userModule.setSessionFactoryJNDIName("java:/SessionFactory");
+// userModule.start();
+//
+// //
+// roleModule = new DBRoleModuleImpl();
+// roleModule.setSessionFactoryJNDIName("java:/SessionFactory");
+// roleModule.start();
+//
+// //
+// utc.setUserModule(userModule);
+// utc.setRoleModule(roleModule);
+// utc.setContext(this);
+// utc.populate();
+// }
+//
+// public void tearDown() throws Exception
+// {
+// utc.setUserModule(null);
+// utc.setRoleModule(null);
+// utc.setContext(null);
+// utc = null;
+//
+// //
+// roleModule.destroy();
+// userModule.destroy();
+// roleModule = null;
+// userModule = null;
+//
+// //
+// runtimeContext.stop();
+// }
+//
+//
+// public void begin()
+// {
+// hibernate.openSession();
+// }
+//
+// public void commit()
+// {
+// assertTrue(hibernate.commitTransaction());
+// }
+//
+// //
+//
+// public void testFindUsersUsingFilter() throws Exception
+// {
+// utc.testFindUsersUsingFilter();
+// }
+//
+// public void testFindUser1() throws Exception
+// {
+// utc.testFindUser1();
+// }
+//
+// public void testFindUser2() throws Exception
+// {
+// utc.testFindUser2();
+// }
+//
+// public void testFindUsers() throws Exception
+// {
+// utc.testFindUsers();
+// }
+//
+// public void testCreateUser() throws Exception
+// {
+// utc.testCreateUser();
+// }
+//
+// public void testCreateRole() throws Exception
+// {
+// utc.testCreateRole();
+// }
+//
+// public void testCountUser() throws Exception
+// {
+// utc.testCountUser();
+// }
+//
+// public void testRemoveNonExistingRole() throws Exception
+// {
+// utc.testRemoveNonExistingRole();
+// }
+//
+// public void testRemoveRole() throws Exception
+// {
+// utc.testRemoveRole();
+// }
+//
+// public void testRemoveUser() throws Exception
+// {
+// utc.testRemoveUser();
+// }
+//
+// public void testFindRoles() throws Exception
+// {
+// utc.testFindRoles();
+// }
+//
+// public void testFindRoleMembers() throws Exception
+// {
+// utc.testFindRoleMembers();
+// }
+//
+// public void testDynamicProperty() throws Exception
+// {
+// begin();
+// User user = userModule.createUser("testname", "testpassword", "testemail");
+// ProfileMap map = user.getProfile();
+// assertNull(map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// map.put("foo", "value");
+// assertEquals("value", map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// commit();
+//
+// begin();
+// user = userModule.findUserByUserName("testname");
+// map = user.getProfile();
+// assertEquals("value", map.get("foo"));
+// assertFalse(map.isReadOnly("foo"));
+// commit();
+// }
+//
+// public void testStaticProperty() throws Exception
+// {
+// begin();
+//
+// //
+// User user = userModule.createUser("testname", "testpassword", "testemail");
+// ProfileMap map = user.getProfile();
+// assertEquals("testname", map.get(P3PConstants.INFO_USER_NAME_NICKNAME));
+//
+// // Test cannot remove a static property
+// try
+// {
+// map.remove(P3PConstants.INFO_USER_NAME_GIVEN);
+// fail("Should not be capable to remove static property");
+// }
+// catch (IllegalArgumentException expected)
+// {
+// }
+//
+// // Test read only property
+// assertTrue(map.isReadOnly(P3PConstants.INFO_USER_NAME_NICKNAME));
+// try
+// {
+// map.put(P3PConstants.INFO_USER_NAME_NICKNAME, "anothername");
+// fail("Should not be capable to modify a read only static property");
+// }
+// catch (IllegalArgumentException expected)
+// {
+// }
+//
+// // Test non nullable and writable property
+// try
+// {
+// map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, null);
+// fail("Should not be capable to nullify a non nullable static property");
+// }
+// catch (NullPointerException expected)
+// {
+// }
+// map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+// assertEquals(true, user.getViewRealEmail());
+//
+// // Test boolean property
+// map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
+// assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+// assertEquals(false, user.getViewRealEmail());
+// map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+// assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+// assertEquals(true, user.getViewRealEmail());
+// user.setViewRealEmail(false);
+// assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+// assertEquals(false, user.getViewRealEmail());
+// user.setViewRealEmail(true);
+// assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+// assertEquals(true, user.getViewRealEmail());
+// try
+// {
+// map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "truee");
+// fail("Should not be capable to set a bad value to boolean property");
+// }
+// catch (IllegalArgumentException expected)
+// {
+// }
+//
+// // Test date
+// Date date = user.getRegistrationDate();
+// SimpleDateFormat sdf = new SimpleDateFormat();
+// assertEquals(sdf.format(date), map.get(User.INFO_USER_REGISTRATION_DATE));
+//
+// commit();
+// }
}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db_old/UserTest.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -42,352 +42,352 @@
*/
public class UserTest extends Assert
{
-
- /** . */
- private UserModule userModule;
-
- /** . */
- private RoleModule roleModule;
-
- /** . */
- private Context ctx;
-
- public void setUserModule(UserModule userModule)
- {
- this.userModule = userModule;
- }
-
- public void setRoleModule(RoleModule roleModule)
- {
- this.roleModule = roleModule;
- }
-
- public void setContext(Context ctx)
- {
- this.ctx = ctx;
- }
-
- public void testFindUsersUsingFilter() throws Exception
- {
- ctx.begin();
- Set set1 = userModule.findUsersFilteredByUserName("user", 0, 10);
- Set nameSet1 = new HashSet();
- for (Iterator i = set1.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet1.add(user.getUserName());
- }
- Set expectedNameSet1 = new HashSet();
- expectedNameSet1.add("user1");
- expectedNameSet1.add("user2");
- assertEquals(expectedNameSet1, nameSet1);
-
- //
- Set set2 = userModule.findUsersFilteredByUserName("blah", 0, 10);
- assertEquals(0, set2.size());
-
- //
- Set set3 = userModule.findUsersFilteredByUserName("", 0, 10);
- Set nameSet3 = new HashSet();
- for (Iterator i = set3.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet3.add(user.getUserName());
- }
- Set expectedNameSet3 = new HashSet();
- expectedNameSet3.add("user1");
- expectedNameSet3.add("user2");
- assertEquals(expectedNameSet3, nameSet3);
-
- //
- Set set4 = userModule.findUsersFilteredByUserName("user1", 0, 10);
- Set nameSet4 = new HashSet();
- for (Iterator i = set4.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet4.add(user.getUserName());
- }
- Set expectedNameSet4 = new HashSet();
- expectedNameSet4.add("user1");
- assertEquals(expectedNameSet4, nameSet4);
- ctx.commit();
- }
-
- public void testFindUser1() throws Exception
- {
- ctx.begin();
- User u1 = userModule.findUserByUserName("user1");
- assertNotNull(u1);
- Assert.assertEquals("user1", u1.getUserName());
- assertNotNull(roleModule.getRoles(u1));
- Assert.assertEquals(1, roleModule.getRoles(u1).size());
- Assert.assertEquals("role1", ((Role)roleModule.getRoles(u1).iterator().next()).getName());
- Assert.assertEquals(u1.getId(), userModule.findUserById(u1.getId()).getId());
- ctx.commit();
- }
-
- public void testFindUser2() throws Exception
- {
- ctx.begin();
- Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
- User u2 = userModule.findUserByUserName("user2");
- assertNotNull(u2);
- Assert.assertEquals("user2", u2.getUserName());
- assertNotNull(roleModule.getRoles(u2));
- Assert.assertEquals(2, roleModule.getRoles(u2).size());
- Iterator iterator = roleModule.getRoles(u2).iterator();
- assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
- assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
- Assert.assertEquals(u2.getId(), userModule.findUserById(u2.getId()).getId());
- ctx.commit();
- }
-
- public void testFindUsers() throws Exception
- {
- ctx.begin();
- Set c1 = userModule.findUsers(0, 1);
- assertNotNull(c1);
- assertEquals(1, c1.size());
-
- Set c2 = userModule.findUsers(1, 1);
- assertNotNull(c2);
- assertEquals(1, c2.size());
-
- Set c3 = userModule.findUsers(0, 2);
- assertNotNull(c3);
- assertEquals(2, c3.size());
-
- Set s1 = new HashSet();
- s1.add(((User)c1.iterator().next()).getUserName());
- s1.add(((User)c2.iterator().next()).getUserName());
- Set s2 = new HashSet();
- Iterator iterator = c3.iterator();
- s2.add(((User)iterator.next()).getUserName());
- s2.add(((User)iterator.next()).getUserName());
- assertEquals(s1, s2);
- ctx.commit();
- }
-
- public void testCreateUser() throws Exception
- {
- ctx.begin();
- User u3 = userModule.createUser("user3", "password", "realemail");
- Role g1 = roleModule.findRoleByName("role1");
- roleModule.setRoles(u3, Collections.singleton(g1));
- Assert.assertEquals("user3", u3.getUserName());
- assertNotNull(roleModule.getRoles(u3));
- Assert.assertEquals(1, roleModule.getRoles(u3).size());
- Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
- ctx.commit();
-
- ctx.begin();
- u3 = userModule.findUserByUserName("user3");
- assertNotNull(u3);
- Assert.assertEquals("user3", u3.getUserName());
- assertNotNull(roleModule.getRoles(u3));
- Assert.assertEquals(1, roleModule.getRoles(u3).size());
- Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
- ctx.commit();
- }
-
- // public void testCreateDuplicateUser() throws Exception
- // {
- // try
- // {
- // userModule.createUser("user1");
- // fail("Expected exception on duplicate user");
- // }
- // catch (ModuleException expected)
- // {
- // }
- // }
-
- public void testCreateRole() throws Exception
- {
- ctx.begin();
- Role g3 = roleModule.createRole("role3", "roleName");
- Assert.assertEquals("role3", g3.getName());
- ctx.commit();
-
- ctx.begin();
- g3 = roleModule.findRoleByName("role3");
- assertNotNull(g3);
- Assert.assertEquals("role3", g3.getName());
- ctx.commit();
- }
-
- // public void testCreateDuplicateRole() throws Exception
- // {
- // try
- // {
- // roleModule.createRole("user1");
- // fail("Expected exception on duplicate role");
- // }
- // catch (ModuleException expected)
- // {
- // }
- // }
-
- public void testCountUser() throws Exception
- {
- ctx.begin();
- Assert.assertEquals(2, userModule.getUserCount());
- ctx.commit();
- }
-
- public void testRemoveNonExistingRole() throws Exception
- {
- ctx.begin();
- try
- {
- roleModule.removeRole(new Long(Long.MAX_VALUE));
- fail("Expected exception");
- }
- catch (IdentityException expected)
- {
- }
- ctx.commit();
- }
-
- public void testRemoveRole() throws Exception
- {
- ctx.begin();
- Role g1 = roleModule.findRoleByName("role1");
- Object id = g1.getId();
- roleModule.removeRole(id);
- try
- {
- roleModule.findRoleById(id);
- fail("Expected exception");
- }
- catch (IdentityException expected)
- {
- }
- ctx.commit();
-
- ctx.begin();
- try
- {
- roleModule.findRoleById(id);
- fail("Expected exception");
- }
- catch (IdentityException expected)
- {
- }
- User u1 = userModule.findUserByUserName("user1");
- assertNotNull(u1);
- Assert.assertEquals("user1", u1.getUserName());
- ctx.commit();
- }
-
- public void testRemoveUser() throws Exception
- {
- ctx.begin();
- User u1 = userModule.findUserByUserName("user1");
- Object id = u1.getId();
- userModule.removeUser(id);
- try
- {
- userModule.findUserById(id);
- fail("Expected exception");
- }
- catch (IdentityException expected)
- {
- }
- ctx.commit();
-
- ctx.begin();
- try
- {
- userModule.findUserById(id);
- fail("Expected exception");
- }
- catch (IdentityException expected)
- {
- }
- Role g1 = roleModule.findRoleByName("role1");
- assertNotNull(g1);
- Assert.assertEquals("role1", g1.getName());
- Role g2 = roleModule.findRoleByName("role2");
- assertNotNull(g2);
- Assert.assertEquals("role2", g2.getName());
- ctx.commit();
- }
-
- public void testFindRoles() throws Exception
- {
- ctx.begin();
- Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
- Set roles = roleModule.findRoles();
- assertEquals(2, roles.size());
- Iterator iterator = roles.iterator();
- assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
- assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
- ctx.commit();
- }
-
- public void testFindRoleMembers() throws Exception
- {
- ctx.begin();
- Set set1 = roleModule.findRoleMembers("role1", 0, 10, "user");
- Set nameSet1 = new HashSet();
- for (Iterator i = set1.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet1.add(user.getUserName());
- }
- Set expectedNameSet1 = new HashSet();
- expectedNameSet1.add("user1");
- expectedNameSet1.add("user2");
- assertEquals(expectedNameSet1, nameSet1);
-
- //
- Set set2 = roleModule.findRoleMembers("role1", 0, 10, "blah");
- assertEquals(0, set2.size());
-
- //
- Set set3 = roleModule.findRoleMembers("role1", 0, 10, "");
- Set nameSet3 = new HashSet();
- for (Iterator i = set3.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet3.add(user.getUserName());
- }
- Set expectedNameSet3 = new HashSet();
- expectedNameSet3.add("user1");
- expectedNameSet3.add("user2");
- assertEquals(expectedNameSet3, nameSet3);
-
- //
- Set set4 = roleModule.findRoleMembers("role1", 0, 10, "user1");
- Set nameSet4 = new HashSet();
- for (Iterator i = set4.iterator(); i.hasNext();)
- {
- User user = (User)i.next();
- nameSet4.add(user.getUserName());
- }
- Set expectedNameSet4 = new HashSet();
- expectedNameSet4.add("user1");
- assertEquals(expectedNameSet4, nameSet4);
- ctx.commit();
- }
-
- public void populate() throws Exception
- {
- ctx.begin();
- User u1 = userModule.createUser("user1", "", "");
- User u2 = userModule.createUser("user2", "", "");
- Role g1 = roleModule.createRole("role1", "role1");
- Role g2 = roleModule.createRole("role2", "role2");
- roleModule.setRoles(u1, Collections.singleton(g1));
- roleModule.setRoles(u2, new CollectionBuilder().add(g1).add(g2).toHashSet());
- ctx.commit();
- }
-
- public interface Context
- {
- void begin();
-
- void commit();
- }
+//
+// /** . */
+// private UserModule userModule;
+//
+// /** . */
+// private RoleModule roleModule;
+//
+// /** . */
+// private Context ctx;
+//
+// public void setUserModule(UserModule userModule)
+// {
+// this.userModule = userModule;
+// }
+//
+// public void setRoleModule(RoleModule roleModule)
+// {
+// this.roleModule = roleModule;
+// }
+//
+// public void setContext(Context ctx)
+// {
+// this.ctx = ctx;
+// }
+//
+// public void testFindUsersUsingFilter() throws Exception
+// {
+// ctx.begin();
+// Set set1 = userModule.findUsersFilteredByUserName("user", 0, 10);
+// Set nameSet1 = new HashSet();
+// for (Iterator i = set1.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet1.add(user.getUserName());
+// }
+// Set expectedNameSet1 = new HashSet();
+// expectedNameSet1.add("user1");
+// expectedNameSet1.add("user2");
+// assertEquals(expectedNameSet1, nameSet1);
+//
+// //
+// Set set2 = userModule.findUsersFilteredByUserName("blah", 0, 10);
+// assertEquals(0, set2.size());
+//
+// //
+// Set set3 = userModule.findUsersFilteredByUserName("", 0, 10);
+// Set nameSet3 = new HashSet();
+// for (Iterator i = set3.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet3.add(user.getUserName());
+// }
+// Set expectedNameSet3 = new HashSet();
+// expectedNameSet3.add("user1");
+// expectedNameSet3.add("user2");
+// assertEquals(expectedNameSet3, nameSet3);
+//
+// //
+// Set set4 = userModule.findUsersFilteredByUserName("user1", 0, 10);
+// Set nameSet4 = new HashSet();
+// for (Iterator i = set4.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet4.add(user.getUserName());
+// }
+// Set expectedNameSet4 = new HashSet();
+// expectedNameSet4.add("user1");
+// assertEquals(expectedNameSet4, nameSet4);
+// ctx.commit();
+// }
+//
+// public void testFindUser1() throws Exception
+// {
+// ctx.begin();
+// User u1 = userModule.findUserByUserName("user1");
+// assertNotNull(u1);
+// Assert.assertEquals("user1", u1.getUserName());
+// assertNotNull(roleModule.getRoles(u1));
+// Assert.assertEquals(1, roleModule.getRoles(u1).size());
+// Assert.assertEquals("role1", ((Role)roleModule.getRoles(u1).iterator().next()).getName());
+// Assert.assertEquals(u1.getId(), userModule.findUserById(u1.getId()).getId());
+// ctx.commit();
+// }
+//
+// public void testFindUser2() throws Exception
+// {
+// ctx.begin();
+// Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+// User u2 = userModule.findUserByUserName("user2");
+// assertNotNull(u2);
+// Assert.assertEquals("user2", u2.getUserName());
+// assertNotNull(roleModule.getRoles(u2));
+// Assert.assertEquals(2, roleModule.getRoles(u2).size());
+// Iterator iterator = roleModule.getRoles(u2).iterator();
+// assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+// assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+// Assert.assertEquals(u2.getId(), userModule.findUserById(u2.getId()).getId());
+// ctx.commit();
+// }
+//
+// public void testFindUsers() throws Exception
+// {
+// ctx.begin();
+// Set c1 = userModule.findUsers(0, 1);
+// assertNotNull(c1);
+// assertEquals(1, c1.size());
+//
+// Set c2 = userModule.findUsers(1, 1);
+// assertNotNull(c2);
+// assertEquals(1, c2.size());
+//
+// Set c3 = userModule.findUsers(0, 2);
+// assertNotNull(c3);
+// assertEquals(2, c3.size());
+//
+// Set s1 = new HashSet();
+// s1.add(((User)c1.iterator().next()).getUserName());
+// s1.add(((User)c2.iterator().next()).getUserName());
+// Set s2 = new HashSet();
+// Iterator iterator = c3.iterator();
+// s2.add(((User)iterator.next()).getUserName());
+// s2.add(((User)iterator.next()).getUserName());
+// assertEquals(s1, s2);
+// ctx.commit();
+// }
+//
+// public void testCreateUser() throws Exception
+// {
+// ctx.begin();
+// User u3 = userModule.createUser("user3", "password", "realemail");
+// Role g1 = roleModule.findRoleByName("role1");
+// roleModule.setRoles(u3, Collections.singleton(g1));
+// Assert.assertEquals("user3", u3.getUserName());
+// assertNotNull(roleModule.getRoles(u3));
+// Assert.assertEquals(1, roleModule.getRoles(u3).size());
+// Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
+// ctx.commit();
+//
+// ctx.begin();
+// u3 = userModule.findUserByUserName("user3");
+// assertNotNull(u3);
+// Assert.assertEquals("user3", u3.getUserName());
+// assertNotNull(roleModule.getRoles(u3));
+// Assert.assertEquals(1, roleModule.getRoles(u3).size());
+// Assert.assertEquals("role1", ((Role)roleModule.getRoles(u3).iterator().next()).getName());
+// ctx.commit();
+// }
+//
+// // public void testCreateDuplicateUser() throws Exception
+// // {
+// // try
+// // {
+// // userModule.createUser("user1");
+// // fail("Expected exception on duplicate user");
+// // }
+// // catch (ModuleException expected)
+// // {
+// // }
+// // }
+//
+// public void testCreateRole() throws Exception
+// {
+// ctx.begin();
+// Role g3 = roleModule.createRole("role3", "roleName");
+// Assert.assertEquals("role3", g3.getName());
+// ctx.commit();
+//
+// ctx.begin();
+// g3 = roleModule.findRoleByName("role3");
+// assertNotNull(g3);
+// Assert.assertEquals("role3", g3.getName());
+// ctx.commit();
+// }
+//
+// // public void testCreateDuplicateRole() throws Exception
+// // {
+// // try
+// // {
+// // roleModule.createRole("user1");
+// // fail("Expected exception on duplicate role");
+// // }
+// // catch (ModuleException expected)
+// // {
+// // }
+// // }
+//
+// public void testCountUser() throws Exception
+// {
+// ctx.begin();
+// Assert.assertEquals(2, userModule.getUserCount());
+// ctx.commit();
+// }
+//
+// public void testRemoveNonExistingRole() throws Exception
+// {
+// ctx.begin();
+// try
+// {
+// roleModule.removeRole(new Long(Long.MAX_VALUE));
+// fail("Expected exception");
+// }
+// catch (IdentityException expected)
+// {
+// }
+// ctx.commit();
+// }
+//
+// public void testRemoveRole() throws Exception
+// {
+// ctx.begin();
+// Role g1 = roleModule.findRoleByName("role1");
+// Object id = g1.getId();
+// roleModule.removeRole(id);
+// try
+// {
+// roleModule.findRoleById(id);
+// fail("Expected exception");
+// }
+// catch (IdentityException expected)
+// {
+// }
+// ctx.commit();
+//
+// ctx.begin();
+// try
+// {
+// roleModule.findRoleById(id);
+// fail("Expected exception");
+// }
+// catch (IdentityException expected)
+// {
+// }
+// User u1 = userModule.findUserByUserName("user1");
+// assertNotNull(u1);
+// Assert.assertEquals("user1", u1.getUserName());
+// ctx.commit();
+// }
+//
+// public void testRemoveUser() throws Exception
+// {
+// ctx.begin();
+// User u1 = userModule.findUserByUserName("user1");
+// Object id = u1.getId();
+// userModule.removeUser(id);
+// try
+// {
+// userModule.findUserById(id);
+// fail("Expected exception");
+// }
+// catch (IdentityException expected)
+// {
+// }
+// ctx.commit();
+//
+// ctx.begin();
+// try
+// {
+// userModule.findUserById(id);
+// fail("Expected exception");
+// }
+// catch (IdentityException expected)
+// {
+// }
+// Role g1 = roleModule.findRoleByName("role1");
+// assertNotNull(g1);
+// Assert.assertEquals("role1", g1.getName());
+// Role g2 = roleModule.findRoleByName("role2");
+// assertNotNull(g2);
+// Assert.assertEquals("role2", g2.getName());
+// ctx.commit();
+// }
+//
+// public void testFindRoles() throws Exception
+// {
+// ctx.begin();
+// Set roleNames = new HashSet(Arrays.asList(new Object[]{"role1", "role2"}));
+// Set roles = roleModule.findRoles();
+// assertEquals(2, roles.size());
+// Iterator iterator = roles.iterator();
+// assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+// assertTrue(roleNames.contains(((Role)iterator.next()).getName()));
+// ctx.commit();
+// }
+//
+// public void testFindRoleMembers() throws Exception
+// {
+// ctx.begin();
+// Set set1 = roleModule.findRoleMembers("role1", 0, 10, "user");
+// Set nameSet1 = new HashSet();
+// for (Iterator i = set1.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet1.add(user.getUserName());
+// }
+// Set expectedNameSet1 = new HashSet();
+// expectedNameSet1.add("user1");
+// expectedNameSet1.add("user2");
+// assertEquals(expectedNameSet1, nameSet1);
+//
+// //
+// Set set2 = roleModule.findRoleMembers("role1", 0, 10, "blah");
+// assertEquals(0, set2.size());
+//
+// //
+// Set set3 = roleModule.findRoleMembers("role1", 0, 10, "");
+// Set nameSet3 = new HashSet();
+// for (Iterator i = set3.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet3.add(user.getUserName());
+// }
+// Set expectedNameSet3 = new HashSet();
+// expectedNameSet3.add("user1");
+// expectedNameSet3.add("user2");
+// assertEquals(expectedNameSet3, nameSet3);
+//
+// //
+// Set set4 = roleModule.findRoleMembers("role1", 0, 10, "user1");
+// Set nameSet4 = new HashSet();
+// for (Iterator i = set4.iterator(); i.hasNext();)
+// {
+// User user = (User)i.next();
+// nameSet4.add(user.getUserName());
+// }
+// Set expectedNameSet4 = new HashSet();
+// expectedNameSet4.add("user1");
+// assertEquals(expectedNameSet4, nameSet4);
+// ctx.commit();
+// }
+//
+// public void populate() throws Exception
+// {
+// ctx.begin();
+// User u1 = userModule.createUser("user1", "", "");
+// User u2 = userModule.createUser("user2", "", "");
+// Role g1 = roleModule.createRole("role1", "role1");
+// Role g2 = roleModule.createRole("role2", "role2");
+// roleModule.setRoles(u1, Collections.singleton(g1));
+// roleModule.setRoles(u2, new CollectionBuilder().add(g1).add(g2).toHashSet());
+// ctx.commit();
+// }
+//
+// public interface Context
+// {
+// void begin();
+//
+// void commit();
+// }
}
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleRoleModuleTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -23,16 +23,10 @@
package org.jboss.portal.test.identity.ldap;
import junit.framework.TestSuite;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
-import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.ldap.LDAPRoleImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
import org.jboss.portal.test.identity.ldap.LDAPTestCase;
import java.util.Set;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPSimpleUserModuleTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -23,15 +23,10 @@
package org.jboss.portal.test.identity.ldap;
import junit.framework.TestSuite;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.ldap.LDAPUserImpl;
-import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.ldap.LDAPUserImpl;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
+import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.test.identity.ldap.LDAPTestCase;
/**
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticGroupMembershipModuleTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -23,24 +23,14 @@
package org.jboss.portal.test.identity.ldap;
import junit.framework.TestSuite;
-import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.identity.ldap.LDAPMembershipModuleTestCase;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
-import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
-import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
-import org.jboss.portal.identity2.ldap.LDAPUserImpl;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.ldap.LDAPRoleImpl;
+import org.jboss.portal.identity.ldap.LDAPUserImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
import java.util.Set;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPStaticRoleMembershipModuleTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,22 +22,16 @@
package org.jboss.portal.test.identity.ldap;
import junit.framework.TestSuite;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.IdentityContextImpl;
-import org.jboss.portal.identity2.IdentityConfiguration;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.ldap.LDAPConnectionContext;
-import org.jboss.portal.identity2.ldap.LDAPUserModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl;
-import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
-import org.jboss.portal.identity2.ldap.LDAPUserImpl;
-import org.jboss.portal.identity2.ldap.LDAPStaticRoleMembershipModuleImpl;
-import org.jboss.portal.identity2.config.SimpleConfigurationImpl;
-import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.IdentityConfiguration;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
+import org.jboss.portal.identity.service.MembershipModuleService;
+import org.jboss.portal.identity.ldap.LDAPRoleImpl;
+import org.jboss.portal.identity.ldap.LDAPUserImpl;
+import org.jboss.portal.identity.ldap.LDAPStaticRoleMembershipModuleImpl;
import java.util.Set;
@@ -97,7 +91,7 @@
configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.ROLE_CONTAINER_DN, values);
values = new HashSet();
values.add("ou=People,o=example2,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com");
- configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.USER_CONTAINER_DN, values);
+ configuration.setValues(IdentityConfiguration.GROUP_COMMON, IdentityConfiguration.USER_CONTAINER_DN, values);
values = new HashSet();
values.add("memberOf");
configuration.setValues(IdentityConfiguration.GROUP_COMMON,IdentityConfiguration.MEMBERSHIP_ATTRIBUTE_ID, values);
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -28,7 +28,7 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
-import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.test.framework.TestRuntimeContext;
import org.jboss.portal.test.framework.embedded.DSConfig;
import org.jboss.portal.test.framework.embedded.DataSourceSupport;
Modified: trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/ldap/LDAPUserProfileModuleTestCase.java 2006-12-17 14:52:15 UTC (rev 5885)
@@ -22,22 +22,15 @@
package org.jboss.portal.test.identity.ldap;
import junit.framework.TestSuite;
-import org.jboss.portal.identity2.UserModule;
-import org.jboss.portal.identity2.RoleModule;
-import org.jboss.portal.identity2.MembershipModule;
-import org.jboss.portal.identity2.IdentityServiceControllerImpl;
-import org.jboss.portal.identity2.IdentityContext;
-import org.jboss.portal.identity2.UserProfileModule;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.ldap.LDAPRoleImpl;
-import org.jboss.portal.identity2.ldap.LDAPUserImpl;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.IdentityServiceControllerImpl;
+import org.jboss.portal.identity.IdentityContext;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.ldap.LDAPUserImpl;
-import java.util.Set;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Iterator;
-import java.util.HashSet;
-
/**
* @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
* @version $Revision: 1.1 $
Modified: trunk/identity/src/resources/hibernate/domain-identity.hbm.xml
===================================================================
--- trunk/identity/src/resources/hibernate/domain-identity.hbm.xml 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/resources/hibernate/domain-identity.hbm.xml 2006-12-17 14:52:15 UTC (rev 5885)
@@ -27,7 +27,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
- name="org.jboss.portal.identity2.db.HibernateUserImpl"
+ name="org.jboss.portal.identity.db.HibernateUserImpl"
table="jbp_users">
<!--<cache usage="@portal.hibernate.cache.usage@"/>-->
<id
@@ -128,13 +128,13 @@
<!--<cache usage="@portal.hibernate.cache.usage@"/>-->
<key column="jbp_uid"/>
<many-to-many
- class="org.jboss.portal.identity2.db.HibernateRoleImpl"
+ class="org.jboss.portal.identity.db.HibernateRoleImpl"
column="jbp_rid"
outer-join="true"/>
</set>
</class>
<class
- name="org.jboss.portal.identity2.db.HibernateRoleImpl"
+ name="org.jboss.portal.identity.db.HibernateRoleImpl"
table="jbp_roles">
<!--<cache usage="@portal.hibernate.cache.usage@"/>-->
<id
@@ -169,7 +169,7 @@
<!--<cache usage="@portal.hibernate.cache.usage@"/>-->
<key column="jbp_rid"/>
<many-to-many
- class="org.jboss.portal.identity2.db.HibernateUserImpl"
+ class="org.jboss.portal.identity.db.HibernateUserImpl"
column="jbp_uid"
outer-join="false"/>
</set>
Modified: trunk/identity/src/resources/hibernate/domain.hbm.xml
===================================================================
--- trunk/identity/src/resources/hibernate/domain.hbm.xml 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/resources/hibernate/domain.hbm.xml 2006-12-17 14:52:15 UTC (rev 5885)
@@ -27,7 +27,7 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
- name="org.jboss.portal.identity.db.UserImpl"
+ name="org.jboss.portal.identity.db.HibernateUserImpl"
table="jbp_users">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -128,13 +128,13 @@
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="jbp_uid"/>
<many-to-many
- class="org.jboss.portal.identity.db.RoleImpl"
+ class="org.jboss.portal.identity.db.HibernateRoleImpl"
column="jbp_rid"
outer-join="true"/>
</set>
</class>
<class
- name="org.jboss.portal.identity.db.RoleImpl"
+ name="org.jboss.portal.identity.db.HibernateRoleImpl"
table="jbp_roles">
<cache usage="@portal.hibernate.cache.usage@"/>
<id
@@ -169,7 +169,7 @@
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="jbp_rid"/>
<many-to-many
- class="org.jboss.portal.identity.db.UserImpl"
+ class="org.jboss.portal.identity.db.HibernateUserImpl"
column="jbp_uid"
outer-join="false"/>
</set>
Modified: trunk/identity/src/resources/test/config/standardidentity-config.xml
===================================================================
--- trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-12-17 14:45:10 UTC (rev 5884)
+++ trunk/identity/src/resources/test/config/standardidentity-config.xml 2006-12-17 14:52:15 UTC (rev 5885)
@@ -33,7 +33,7 @@
<name>LDAP</name>
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=LDAPConnectionContext</service-name>
- <class>org.jboss.portal.identity2.ldap.LDAPConnectionContext</class>
+ <class>org.jboss.portal.identity.ldap.LDAPConnectionContext</class>
<config>
<option>
<name>host</name>
@@ -110,7 +110,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=UserProfile</service-name>
- <class>org.jboss.portal.identity2.DelegatingUserProfileModuleImpl</class>
+ <class>org.jboss.portal.identity.DelegatingUserProfileModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
<option>
@@ -133,7 +133,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=User</service-name>
- <class>org.jboss.portal.identity2.db.HibernateUserModuleImpl</class>
+ <class>org.jboss.portal.identity.db.HibernateUserModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -155,7 +155,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Role</service-name>
- <class>org.jboss.portal.identity2.db.HibernateRoleModuleImpl</class>
+ <class>org.jboss.portal.identity.db.HibernateRoleModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -177,7 +177,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Membership</service-name>
- <class>org.jboss.portal.identity2.db.HibernateMembershipModuleImpl</class>
+ <class>org.jboss.portal.identity.db.HibernateMembershipModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -199,7 +199,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=DBUserProfile</service-name>
- <class>org.jboss.portal.identity2.db.HibernateUserProfileModuleImpl</class>
+ <class>org.jboss.portal.identity.db.HibernateUserProfileModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -222,7 +222,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=User</service-name>
- <class>org.jboss.portal.identity2.ldap.LDAPUserModuleImpl</class>
+ <class>org.jboss.portal.identity.ldap.LDAPUserModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -244,7 +244,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Role</service-name>
- <class>org.jboss.portal.identity2.ldap.LDAPRoleModuleImpl</class>
+ <class>org.jboss.portal.identity.ldap.LDAPRoleModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -266,7 +266,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=Membership</service-name>
- <class>org.jboss.portal.identity2.ldap.LDAPStaticGroupMembershipModuleImpl</class>
+ <class>org.jboss.portal.identity.ldap.LDAPStaticGroupMembershipModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
@@ -288,7 +288,7 @@
<!--name of service and class for creating mbean-->
<service-name>portal:service=Module,type=LDAPUserProfile</service-name>
- <class>org.jboss.portal.identity2.ldap.LDAPUserProfileModuleImpl</class>
+ <class>org.jboss.portal.identity.ldap.LDAPUserProfileModuleImpl</class>
<!--set of options that are passed to a class constructor-->
<config>
19 years, 4 months
JBoss Portal SVN: r5884 - in trunk/identity/src/main/org/jboss/portal: . identity/auth identity/management
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-17 09:45:10 -0500 (Sun, 17 Dec 2006)
New Revision: 5884
Removed:
trunk/identity/src/main/org/jboss/portal/legacy_identity/
Modified:
trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java
trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java
Log:
- plug in new identity modules
- correct API usages
(Still some stuff not working 100% ok)
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2006-12-17 14:45:10 UTC (rev 5884)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.legacy_identity.auth;
+package org.jboss.portal.identity.auth;
import java.security.Principal;
Modified: trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java 2006-12-17 14:45:10 UTC (rev 5884)
@@ -20,13 +20,13 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.legacy_identity.management;
+package org.jboss.portal.identity.management;
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
-import org.jboss.portal.legacy_identity.RoleModule;
-import org.jboss.portal.legacy_identity.UserModule;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java 2006-12-17 14:26:07 UTC (rev 5883)
+++ trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java 2006-12-17 14:45:10 UTC (rev 5884)
@@ -20,10 +20,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.legacy_identity.management;
+package org.jboss.portal.identity.management;
-import org.jboss.portal.legacy_identity.RoleModule;
-import org.jboss.portal.legacy_identity.UserModule;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.UserModule;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
19 years, 4 months
JBoss Portal SVN: r5883 - in trunk: cms/src/main/org/jboss/portal/cms/impl/interceptors cms/src/main/org/jboss/portal/cms/impl/jcr core/src/main/org/jboss/portal/core/aspects/server core/src/main/org/jboss/portal/core/controller/portlet core/src/main/org/jboss/portal/core/model/portal/command core/src/main/org/jboss/portal/core/portlet/cms/admin core/src/main/org/jboss/portal/core/portlet/role core/src/main/org/jboss/portal/core/portlet/test core/src/main/org/jboss/portal/core/portlet/user
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-17 09:26:07 -0500 (Sun, 17 Dec 2006)
New Revision: 5883
Added:
trunk/core/src/resources/portal-core-sar/conf/identity-config.xml
trunk/core/src/resources/portal-core-sar/conf/identity/
trunk/core/src/resources/portal-core-sar/conf/identity/ldap_identity-config.xml
trunk/core/src/resources/portal-core-sar/conf/identity/standardidentity-config.xml
trunk/core/src/resources/portal-core-sar/conf/profile-config.xml
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
trunk/core/src/main/org/jboss/portal/core/portlet/role/RolePortlet.java
trunk/core/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java
trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-sar/conf/hibernate/user/setup.txt
trunk/core/src/resources/portal-core-sar/conf/login-config.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
trunk/core/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
Log:
- plug in new identity modules
- correct API usages
(Still some stuff not working 100% ok)
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -33,6 +33,7 @@
import java.util.List;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.CMSInterceptor;
@@ -52,8 +53,9 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.db.RoleImpl;
+import org.jboss.portal.identity.db.HibernateRoleImpl;
import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.AnnonymousRole;
/**
* ACLInterceptor is plugged into the CMS system to enforce fine grained security access control
@@ -277,10 +279,19 @@
super.startService();
Tools.init(this.jndiName);
+
+ try
+ {
+ roleModule = (RoleModule)new InitialContext().lookup("java:portal/RoleModule");
+ }
+ catch (NamingException e)
+ {
+ log.error("Cannot obtain RoleModule from JNDI: ", e);
+ throw e;
+ }
-
- //check and see if cms permissions exist...if not, boot it with the default policy
- //specified in the configuration
+ //check and see if cms permissions exist...if not, boot it with the default policy
+ //specified in the configuration
if(!this.isBootRequired())
{
return;
@@ -392,7 +403,7 @@
//since this is at app start up and not on user thread...need to create a transaction context.
InitialContext context = new InitialContext();
- SessionFactory sessionFactory = (SessionFactory)context.lookup("java:/portal/UserSessionFactory");
+ SessionFactory sessionFactory = (SessionFactory)context.lookup("java:/portal/IdentitySessionFactory");
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
try
@@ -401,7 +412,7 @@
}
catch(Exception e)
{
- role = new RoleImpl();
+ role = new AnnonymousRole();
}
finally
{
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -58,6 +58,8 @@
import javax.jcr.Session;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -205,6 +207,16 @@
/** CMS Start */
public void startService() throws Exception
{
+ try
+ {
+ this.userModule = (UserModule)new InitialContext().lookup("java:portal/UserModule");
+ }
+ catch (NamingException e)
+ {
+ log.error("Cannot obtain UserModule from JNDI: ", e);
+ throw e;
+ }
+
//check the version of jbosscache being run
String cacheVersion = Version.getVersionString(Version.getVersionShort());
log.info("JBossCache Version=" + cacheVersion);
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/LocaleInterceptor.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -24,10 +24,14 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.UserModule;
import org.jboss.portal.server.ServerInterceptor;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerRequest;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -50,9 +54,40 @@
// Try to get the locale from the user
User user = (User)invocation.getRequest().getUser();
- if (user != null)
+
+ UserProfileModule userProfileModule = null;
+
+ //TODO: identity code change
+ try
{
- Locale locale = user.getPreferredLocale();
+ userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
+ }
+ catch (NameNotFoundException ignore)
+ {
+ // Name is not bound anymore, it could happen during a shutdown, we don't do anything
+ }
+
+ if (user != null && userProfileModule != null)
+ {
+ //Locale locale = user.getPreferredLocale();
+ Object lc = userProfileModule.getProperty(user,User.INFO_USER_LOCALE);
+ Locale locale = null;
+ if (lc instanceof Locale)
+ {
+ locale = (Locale)lc;
+ }
+ else
+ {
+ try
+ {
+ locale = new Locale(lc.toString());
+ }
+ catch (Exception e)
+ {
+ //just to hide failure
+ }
+ }
+
if (locale != null)
{
locales.add(locale);
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -29,11 +29,14 @@
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.server.ServerInterceptor;
import org.jboss.portal.server.ServerInvocation;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
@@ -63,6 +66,17 @@
public UserModule getUserModule()
{
+ if (userModule == null)
+ {
+ try
+ {
+ userModule = (UserModule)new InitialContext().lookup("java:portal/UserModule");
+ }
+ catch (NamingException e)
+ {
+ log.error("could not obtain User Module: ", e);
+ }
+ }
return userModule;
}
@@ -97,7 +111,7 @@
}
// Lookup
- user = userModule.findUserByUserName(userName);
+ user = getUserModule().findUserByUserName(userName);
//
if (trace)
@@ -233,10 +247,14 @@
//
// Here we use JNDI to locate the module as this finalizer could have been
// migrated in the session of another node of the cluster
- UserModule module = null;
+ UserModule userModule = null;
+ UserProfileModule userProfileModule = null;
+
+ //TODO: identity - code change
try
{
- module = (UserModule)new InitialContext().lookup("java:portal/UserModule");
+ userModule = (UserModule)new InitialContext().lookup("java:portal/UserModule");
+ userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
}
catch (NameNotFoundException ignore)
{
@@ -244,12 +262,14 @@
}
// Get user and set last visit date to now if we can
- if (module != null)
+ if (userModule != null && userProfileModule != null)
{
try
{
- User user = module.findUserById(userId);
- user.setLastVisitDate(new Date());
+ User user = userModule.findUserById(userId);
+ //user.setLastVisitDate(new Date());
+ userProfileModule.setProperty(user, User.INFO_USER_LAST_LOGIN_DATE, new Date().toString());
+
}
catch (NoSuchUserException e)
{
Modified: trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/controller/portlet/ControllerUserContext.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -24,9 +24,15 @@
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.portlet.spi.UserContext;
import org.jboss.portal.server.ServerInvocation;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -38,6 +44,8 @@
public class ControllerUserContext implements UserContext
{
+ private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(ControllerUserContext.class);
+
/** . */
private final ServerInvocation invocation;
@@ -55,10 +63,32 @@
public Map getInformations()
{
User user = getUser();
- if (user != null)
+
+ UserProfileModule userProfileModule = null;
+
+ //MARK: identity code change
+ try
{
- return user.getProfile();
+ userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
}
+ catch (NamingException ignore)
+ {
+ // Name is not bound anymore, it could happen during a shutdown, we don't do anything
+ }
+
+ if (user != null && userProfileModule != null)
+ {
+ //return user.getProfile();
+ try
+ {
+ return userProfileModule.getProperties(user);
+ }
+ catch (IdentityException e)
+ {
+ log.error("Cannot obtain user profile information: ", e);
+ return null;
+ }
+ }
else
{
return null;
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderPageCommand.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -41,6 +41,7 @@
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.portlet.Properties;
import org.jboss.portal.portlet.info.ModeInfo;
import org.jboss.portal.portlet.info.WindowStateInfo;
@@ -71,6 +72,8 @@
import org.jboss.portal.theme.page.WindowContext;
import javax.servlet.http.HttpServletRequest;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -228,7 +231,23 @@
User user = (User)controllerCtx.getServerInvocation().getRequest().getUser();
if (user != null)
{
- String themeId = user.getTheme();
+ UserProfileModule userProfileModule = null;
+
+ //MARK: identity code change
+ try
+ {
+ userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
+ }
+ catch (NamingException ignore)
+ {
+ // Name is not bound anymore, it could happen during a shutdown, we don't do anything
+ }
+
+
+ //String themeId = user.getTheme();
+
+ String themeId = (String)userProfileModule.getProperty(user, User.INFO_USER_THEME);
+
if (themeId != null)
{
theme = getTheme(themeId);
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -58,8 +58,10 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.db.RoleImpl;
+import org.jboss.portal.identity.AnnonymousRole;
+import org.jboss.portal.identity.MembershipModule;
+
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSession;
@@ -80,19 +82,21 @@
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
+ * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
*/
public class CMSAdminPortlet extends JBossPortlet
{
private CMS CMSService;
private UserModule userModule;
private RoleModule roleModule;
+ private MembershipModule membershipModule;
public void init() throws PortletException
{
CMSService = (CMS)getPortletContext().getAttribute("CMS");
userModule = (UserModule)getPortletContext().getAttribute("UserModule");
roleModule = (RoleModule)getPortletContext().getAttribute("RoleModule");
+ membershipModule = (MembershipModule)getPortletContext().getAttribute("MembershipModule");
if (CMSService == null)
{
@@ -106,6 +110,10 @@
{
throw new PortletException("No role module");
}
+ if (membershipModule == null)
+ {
+ throw new PortletException("No membership module");
+ }
}
protected void doView(final JBossRenderRequest rReq, final JBossRenderResponse rRes)
@@ -1137,7 +1145,7 @@
}
else
{
- role = new RoleImpl();
+ role = new AnnonymousRole();
}
rolesSet.add(role);
}
@@ -1259,7 +1267,7 @@
if(portletRequest.getUserPrincipal()!=null)
{
User user = this.userModule.findUserByUserName(portletRequest.getUserPrincipal().getName());
- Set roles = this.roleModule.getRoles(user);
+ Set roles = this.membershipModule.getRoles(user);
if(roles!=null)
{
for(Iterator itr=roles.iterator();itr.hasNext();)
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/role/RolePortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/role/RolePortlet.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/role/RolePortlet.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -32,6 +32,8 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.JBossPortlet;
@@ -87,6 +89,11 @@
private RoleModule roleModule;
private UserModule userModule;
+
+ private MembershipModule membershipModule;
+
+ private UserProfileModule userProfileModule;
+
private static final String ADMIN_ROLE = "Admin";
public void init() throws PortletException
@@ -95,6 +102,8 @@
userModule = (UserModule)getPortletContext().getAttribute("UserModule");
roleModule = (RoleModule)getPortletContext().getAttribute("RoleModule");
portletHelper = new PortletHelper(this);
+ membershipModule = (MembershipModule)getPortletContext().getAttribute("MembershipModule");
+ userProfileModule = (UserProfileModule)getPortletContext().getAttribute("UserProfileModule");
//
if (userModule == null)
@@ -105,6 +114,16 @@
{
throw new PortletException("No role module");
}
+ if (membershipModule == null)
+ {
+ throw new PortletException("No membership module");
+ }
+ if (userProfileModule == null)
+ {
+ throw new PortletException("No user profile module");
+ }
+
+
}
public void destroy()
@@ -277,7 +296,7 @@
ctx.put("usernameFilter", usernameFilter);
Set users = null;
- users = roleModule.findRoleMembers(role.getName(), offset, usersPerPage + 1, usernameFilter.trim());
+ users = membershipModule.findRoleMembers(role.getName(), offset, usersPerPage + 1, usernameFilter.trim());
User[] usersArray = new User[users.size()];
usersArray = (User[])users.toArray(usersArray);
@@ -291,7 +310,7 @@
rowCtx.put("username", user.getUserName());
//
- Iterator itRoles = roleModule.getRoles(user).iterator();
+ Iterator itRoles = membershipModule.getRoles(user).iterator();
while (itRoles.hasNext())
{
DelegateContext rolesCtx = rowCtx.next("roles");
@@ -378,7 +397,7 @@
ctx.put("userid", user.getId().toString());
ctx.put("username", user.getUserName());
ctx.put("userfullname", getFullName(bundle, user));
- Set userRoles = roleModule.getRoles(user);
+ Set userRoles = membershipModule.getRoles(user);
Set roles = roleModule.findRoles();
Role[] rolesArray = new Role[roles.size()];
@@ -622,7 +641,7 @@
{
User user = userModule.findUserById(userId);
Set roles = roleModule.findRolesByNames(selectedRoles);
- roleModule.setRoles(user, roles);
+ membershipModule.assignRoles(user, roles);
}
catch (IllegalArgumentException e)
{
@@ -759,22 +778,35 @@
private String getFullName(ResourceBundle bundle,
User user)
{
- if ((user.getGivenName() != null) && (user.getGivenName().trim().length() != 0))
+ String givenName = null;
+ String familyName = null;
+
+ try
{
- if ((user.getFamilyName() != null) && (user.getFamilyName().trim().length() != 0))
+ givenName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_GIVEN);
+ familyName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_FAMILY);
+ }
+ catch (IdentityException e)
+ {
+ log.error("cannot obtain user profile information: ", e);
+ }
+
+ if ((givenName != null) && (givenName.trim().length() != 0))
+ {
+ if ((familyName != null) && (familyName.trim().length() != 0))
{
- return user.getGivenName() + " " + user.getFamilyName();
+ return givenName + " " + familyName;
}
else
{
- return user.getGivenName().trim();
+ return givenName.trim();
}
}
else
{
- if ((user.getFamilyName() != null) && (user.getFamilyName().trim().length() != 0))
+ if ((familyName != null) && (familyName.trim().length() != 0))
{
- return user.getFamilyName().trim();
+ return familyName.trim();
}
else
{
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/test/TestPortlet.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -85,7 +85,9 @@
writer.write("<p>");
writer.write("<div class=\"portlet-section-header\">User infos</div>");
writer.write("<div class=\"portlet-section-body\">");
- writer.write("<div>Last visit date : " + user.getLastVisitDate() + "</div>");
+
+ //TODO: update this with new Identity API
+ //writer.write("<div>Last visit date : " + user.getLastVisitDate() + "</div>");
writer.write("</div>");
writer.write("</p>");
}
Modified: trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/main/org/jboss/portal/core/portlet/user/UserPortlet.java 2006-12-17 14:26:07 UTC (rev 5883)
@@ -38,6 +38,8 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.theme.PortalTheme;
import org.jboss.portal.theme.ThemeInfo;
import org.jboss.portal.theme.ThemeService;
@@ -108,6 +110,8 @@
private UserModule userModule;
private RoleModule roleModule;
+ private MembershipModule membershipModule;
+ private UserProfileModule userProfileModule;
private MailModule mailModule;
private PortletHelper portletHelper;
public static final short UNDEFINED_TIMEZONE = (short)0;
@@ -125,6 +129,8 @@
//
userModule = (UserModule)getPortletContext().getAttribute("UserModule");
roleModule = (RoleModule)getPortletContext().getAttribute("RoleModule");
+ membershipModule = (MembershipModule)getPortletContext().getAttribute("MembershipModule");
+ userProfileModule = (UserProfileModule)getPortletContext().getAttribute("UserProfileModule");
mailModule = (MailModule)getPortletContext().getAttribute("MailModule");
portletHelper = new PortletHelper(this);
@@ -141,6 +147,14 @@
{
throw new PortletException("No mail module");
}
+ if (membershipModule == null)
+ {
+ throw new PortletException("No membership module");
+ }
+ if (userProfileModule == null)
+ {
+ throw new PortletException("No user profile module");
+ }
}
public void destroy()
@@ -177,7 +191,7 @@
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
- if ((req.getUser() != null) && (!req.getUser().getEnabled()))
+ if ((req.getUser() != null) && (!((getProperty(req.getUser(), User.INFO_USER_ENABLED)).equals("true"))))
{
req.getPortletSession().invalidate();
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/login.jsp");
@@ -248,7 +262,8 @@
fillContextWithUserProfile(user, ctx);
//
- String selectedTimeZone = (String)user.getProfile().get(User.INFO_USER_TIME_ZONE_OFFSET);
+ //String selectedTimeZone = (String)user.getProfile().get(User.INFO_USER_TIME_ZONE_OFFSET);
+ String selectedTimeZone = (String)getProperty(user, User.INFO_USER_TIME_ZONE_OFFSET);
for (int i = 0; i < UserPortletConstants.TIME_ZONE_OFFSETS.length; i++)
{
if (UserPortletConstants.TIME_ZONE_OFFSETS[i] != null)
@@ -264,7 +279,8 @@
}
//
- String selectedLocale = (String)user.getProfile().get(User.INFO_USER_LOCALE);
+ //String selectedLocale = (String)user.getProfile().get(User.INFO_USER_LOCALE);
+ String selectedLocale = (String)getProperty(user, User.INFO_USER_LOCALE);
for (Iterator i = LocaleInfo.getAll().iterator(); i.hasNext();)
{
LocaleInfo info = (LocaleInfo)i.next();
@@ -279,7 +295,8 @@
}
//
- String selectedTheme = (String)user.getProfile().get(User.INFO_USER_THEME);
+ //String selectedTheme = (String)user.getProfile().get(User.INFO_USER_THEME);
+ String selectedTheme = (String)getProperty(user,User.INFO_USER_THEME);
ThemeService themeService = (ThemeService)getPortletContext().getAttribute("ThemeService");
for (Iterator i = themeService.getThemes().iterator(); i.hasNext();)
{
@@ -354,7 +371,7 @@
rowCtx.put("username" + oddeven, user.getUserName());
//
- Iterator itRoles = roleModule.getRoles(user).iterator();
+ Iterator itRoles = membershipModule.getRoles(user).iterator();
while (itRoles.hasNext())
{
DelegateContext rolesCtx = rowCtx.next("roles" + oddeven);
@@ -431,7 +448,7 @@
ctx.put("userid", user.getId().toString());
ctx.put("username", user.getUserName());
ctx.put("userfullname", getFullName(bundle, user));
- Set userRoles = roleModule.getRoles(user);
+ Set userRoles = membershipModule.getRoles(user);
Set roles = roleModule.findRoles();
Role[] rolesArray = new Role[roles.size()];
@@ -541,10 +558,10 @@
try
{
user = userModule.findUserById(userId);
- String hexCompare = Tools.md5AsHexString(user.getUserName() + user.getRegistrationDate() + UserPortletConstants.SALT);
+ String hexCompare = Tools.md5AsHexString(user.getUserName() + getProperty(user,User.INFO_USER_REGISTRATION_DATE) + UserPortletConstants.SALT);
if (hash.equals(hexCompare))
{
- user.setEnabled(true);
+ setProperty(user, User.INFO_USER_ENABLED, Boolean.TRUE);
rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/register_ty.jsp");
PortalNode currentNode = Navigation.getCurrentNode();
PortalNodeURL url = resp.createRenderURL(currentNode);
@@ -678,8 +695,10 @@
{
try
{
- user = userModule.createUser(uname, pass1, realEmail);
- user.setFakeEmail(fakeEmail);
+ user = userModule.createUser(uname, pass1);
+ setProperty(user,User.INFO_USER_EMAIL_REAL, realEmail);
+ //user.setFakeEmail(fakeEmail);
+ setProperty(user,User.INFO_USER_EMAIL_FAKE, fakeEmail);
//user.setRegistrationDate(new Date());
String subscriptionMode = getPortletConfig().getInitParameter(UserPortletConstants.SUBSCRIPTIONMODE);
@@ -690,17 +709,17 @@
if (UserPortletConstants.SUBSCRIPTIONMODE_AUTOMATIC.equals(subscriptionMode))
{
- user.setEnabled(true);
+ setProperty(user, User.INFO_USER_ENABLED, Boolean.TRUE);
}
else if (UserPortletConstants.SUBSCRIPTIONMODE_EMAILVERIFICATION.equals(subscriptionMode))
{
- user.setEnabled(false);
+ setProperty(user, User.INFO_USER_ENABLED, Boolean.FALSE);
String emailText = generateValidationEmail(req, resp, user, pass1);
String from = getPortletConfig().getInitParameter(UserPortletConstants.EMAILFROM);
Locale locale = req.getLocale();
ResourceBundle bundle = getResourceBundle(locale);
String subject = bundle.getString("REGISTER_CONFIRMATIONEMAIL");
- mailModule.send(from, user.getRealEmail(), subject, emailText);
+ mailModule.send(from, (String)getProperty(user,User.INFO_USER_EMAIL_REAL), subject, emailText);
}
/*
@@ -719,7 +738,7 @@
if (role != null)
{
roleSet.add(role);
- roleModule.setRoles(user, roleSet);
+ membershipModule.assignRoles(user, roleSet);
}
else
{
@@ -754,25 +773,25 @@
private void fillContextWithUserProfile(User user, DelegateContext ctx)
{
- ctx.put("GIVENNAME", user.getGivenName());
- ctx.put("FAMILYNAME", user.getFamilyName());
- ctx.put("REALEMAIL", user.getRealEmail());
- ctx.put("FAKEEMAIL", user.getFakeEmail());
- ctx.put("THEME", user.getTheme());
- ctx.put("VIEWREALEMAIL", user.getViewRealEmail() ? "checked=\"checked\"" : "");
- ctx.put("HOMEPAGE", (String)(user.getProfile().get(User.INFO_USER_HOMEPAGE)));
- ctx.put("ICQ", (String)(user.getProfile().get(User.INFO_USER_IM_ICQ)));
- ctx.put("AIM", (String)(user.getProfile().get(User.INFO_USER_IM_AIM)));
- ctx.put("YIM", (String)(user.getProfile().get(User.INFO_USER_IM_YIM)));
- ctx.put("MSNM", (String)(user.getProfile().get(User.INFO_USER_IM_MSNM)));
- ctx.put("SKYPE", (String)(user.getProfile().get(User.INFO_USER_IM_SKYPE)));
- ctx.put("SIGNATURE", (String)(user.getProfile().get(User.INFO_USER_SIGNATURE)));
- ctx.put("LOCATION", (String)(user.getProfile().get(User.INFO_USER_LOCATION)));
- ctx.put("OCCUPATION", (String)(user.getProfile().get(User.INFO_USER_OCCUPATION)));
- ctx.put("INTERESTS", (String)(user.getProfile().get(User.INFO_USER_INTERESTS)));
- ctx.put("EXTRA", (String)(user.getProfile().get(User.INFO_USER_EXTRA)));
- ctx.put("QUESTION", (String)(user.getProfile().get(User.INFO_USER_SECURITY_QUESTION)));
- ctx.put("ANSWER", (String)(user.getProfile().get(User.INFO_USER_SECURITY_ANSWER)));
+ ctx.put("GIVENNAME", (String)getProperty(user, User.INFO_USER_NAME_GIVEN));
+ ctx.put("FAMILYNAME", (String)getProperty(user, User.INFO_USER_NAME_FAMILY));
+ ctx.put("REALEMAIL", (String)getProperty(user, User.INFO_USER_EMAIL_REAL));
+ ctx.put("FAKEEMAIL", (String)getProperty(user, User.INFO_USER_EMAIL_FAKE));
+ ctx.put("THEME", (String)getProperty(user, User.INFO_USER_THEME));
+ ctx.put("VIEWREALEMAIL", ((String)getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL)).equals("true") ? "checked=\"checked\"" : "");
+ ctx.put("HOMEPAGE", (String)getProperty(user,User.INFO_USER_HOMEPAGE));
+ ctx.put("ICQ", (String)getProperty(user,User.INFO_USER_IM_ICQ));
+ ctx.put("AIM", (String)getProperty(user,User.INFO_USER_IM_AIM));
+ ctx.put("YIM", (String)getProperty(user,User.INFO_USER_IM_YIM));
+ ctx.put("MSNM", (String)getProperty(user,User.INFO_USER_IM_MSNM));
+ ctx.put("SKYPE", (String)getProperty(user,User.INFO_USER_IM_SKYPE));
+ ctx.put("SIGNATURE", (String)getProperty(user,User.INFO_USER_SIGNATURE));
+ ctx.put("LOCATION", (String)getProperty(user,User.INFO_USER_LOCATION));
+ ctx.put("OCCUPATION", (String)getProperty(user,User.INFO_USER_OCCUPATION));
+ ctx.put("INTERESTS", (String)getProperty(user,User.INFO_USER_INTERESTS));
+ ctx.put("EXTRA", (String)getProperty(user,User.INFO_USER_EXTRA));
+ ctx.put("QUESTION", (String)getProperty(user,User.INFO_USER_SECURITY_QUESTION));
+ ctx.put("ANSWER", (String)getProperty(user,User.INFO_USER_SECURITY_ANSWER));
}
/**
@@ -867,25 +886,26 @@
//
if (givenName.trim().length() != 0)
{
- user.setGivenName(givenName);
+ setProperty(user, User.INFO_USER_NAME_GIVEN, givenName);
}
if (familyName.trim().length() != 0)
{
- user.setFamilyName(familyName);
+ setProperty(user, User.INFO_USER_NAME_FAMILY, familyName);
}
if (realEmail.trim().length() != 0)
{
- user.setRealEmail(realEmail);
+ setProperty(user, User.INFO_USER_EMAIL_REAL, realEmail);
}
if (fakeEmail.trim().length() != 0)
{
- user.setFakeEmail(fakeEmail);
+ setProperty(user, User.INFO_USER_EMAIL_FAKE, fakeEmail);
}
- user.setViewRealEmail(viewRealEmail);
+ setProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL, Boolean.valueOf(viewRealEmail));
+
if (changePassword)
{
user.updatePassword(pass1);
@@ -893,13 +913,13 @@
if (timezoneoffset.shortValue() != UNDEFINED_TIMEZONE)
{
- user.getProfile().put(User.INFO_USER_TIME_ZONE_OFFSET, timezoneoffset.toString());
+ setProperty(user, User.INFO_USER_TIME_ZONE_OFFSET, timezoneoffset.toString());
}
LocaleInfo localeInfo = LocaleInfo.decodeLocaleInfo(locale);
if (localeInfo != null)
{
- user.setPreferredLocale(localeInfo.getLocale());
+ setProperty(user, User.INFO_USER_LOCALE, localeInfo.getLocale());
}
putNonEmptyProperty(user, User.INFO_USER_THEME, theme);
@@ -927,7 +947,7 @@
portletHelper.setRenderParameter(resp, "FAMILYNAME", familyName);
portletHelper.setRenderParameter(resp, "REALEMAIL", realEmail);
portletHelper.setRenderParameter(resp, "FAKEEMAIL", fakeEmail);
- if (user.getViewRealEmail())
+ if (getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL).toString().equals("true"))
{
portletHelper.setRenderParameter(resp, "VIEWREALEMAIL", "checked=\"checked\"");
}
@@ -970,7 +990,7 @@
{
User user = userModule.findUserById(userId);
Set roles = roleModule.findRolesByNames(selectedRoles);
- roleModule.setRoles(user, roles);
+ membershipModule.assignRoles(user, roles);
}
catch (IllegalArgumentException e)
{
@@ -1002,7 +1022,7 @@
String clearPassword)
{
// gen link using username, encrypted pw, and a salt.
- String hash = Tools.md5AsHexString(user.getUserName() + user.getRegistrationDate() + UserPortletConstants.SALT);
+ String hash = Tools.md5AsHexString(user.getUserName() + getProperty(user, User.INFO_USER_REGISTRATION_DATE).toString() + UserPortletConstants.SALT);
String rootURL = getPortletConfig().getInitParameter("emailDomain");
@@ -1060,10 +1080,11 @@
try
{
user = userModule.findUserById(userId);
- String hexCompare = Tools.md5AsHexString(user.getUserName() + user.getRegistrationDate() + UserPortletConstants.SALT);
+ String hexCompare = Tools.md5AsHexString(user.getUserName() + getProperty(user, User.INFO_USER_REGISTRATION_DATE).toString() + UserPortletConstants.SALT);
if (hash.equals(hexCompare))
{
- user.setEnabled(true);
+ //user.setEnabled(true);
+ setProperty(user, User.INFO_USER_ENABLED, Boolean.valueOf(true));
portletHelper.setI18nRenderParameter(req, resp, UserPortletConstants.INFOMESSAGE, "INFOMESSAGE_CONGRATULATIONACTIVATED");
}
else
@@ -1079,10 +1100,21 @@
private String getFirstName(ResourceBundle bundle, User user)
{
- if ((user.getGivenName() != null) && (user.getGivenName().trim().length() != 0))
+ String givenName = null;
+
+ try
{
- return user.getGivenName().trim();
+ givenName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_GIVEN);
}
+ catch (IdentityException e)
+ {
+ log.error("cannot obtain user profile information: ", e);
+ }
+
+ if ((givenName != null) && (givenName.trim().length() != 0))
+ {
+ return givenName.trim();
+ }
else
{
return bundle.getString("NAMENOTAVAILABLE");
@@ -1091,10 +1123,22 @@
private String getLastName(ResourceBundle bundle, User user)
{
- if ((user.getFamilyName() != null) && (user.getFamilyName().trim().length() != 0))
+ String familyName = null;
+
+ try
{
- return user.getFamilyName().trim();
+ familyName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_FAMILY);
}
+ catch (IdentityException e)
+ {
+ log.error("cannot obtain user profile information: ", e);
+ }
+
+
+ if ((familyName != null) && (familyName.trim().length() != 0))
+ {
+ return familyName.trim();
+ }
else
{
return bundle.getString("NAMENOTAVAILABLE");
@@ -1104,22 +1148,35 @@
private String getFullName(ResourceBundle bundle,
User user)
{
- if ((user.getGivenName() != null) && (user.getGivenName().trim().length() != 0))
+ String givenName = null;
+ String familyName = null;
+
+ try
{
- if ((user.getFamilyName() != null) && (user.getFamilyName().trim().length() != 0))
+ givenName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_GIVEN);
+ familyName = (String)userProfileModule.getProperty(user, User.INFO_USER_NAME_FAMILY);
+ }
+ catch (IdentityException e)
+ {
+ log.error("cannot obtain user profile information: ", e);
+ }
+
+ if ((givenName != null) && (givenName.trim().length() != 0))
+ {
+ if ((familyName != null) && (familyName.trim().length() != 0))
{
- return user.getGivenName() + " " + user.getFamilyName();
+ return givenName + " " + familyName;
}
else
{
- return user.getGivenName().trim();
+ return givenName.trim();
}
}
else
{
- if ((user.getFamilyName() != null) && (user.getFamilyName().trim().length() != 0))
+ if ((familyName != null) && (familyName.trim().length() != 0))
{
- return user.getFamilyName().trim();
+ return familyName.trim();
}
else
{
@@ -1132,7 +1189,16 @@
{
if ((value != null) && (value.trim().length() != 0))
{
- user.getProfile().put(key, value);
+ //user.getProfile().put(key, value);
+ try
+ {
+ userProfileModule.setProperty(user, key, value);
+ }
+ catch (IdentityException e)
+ {
+ //TODO: change to error
+ log.info("Cannot set profile property: ", e);
+ }
}
}
@@ -1153,6 +1219,43 @@
portletHelper.setRenderParameter(response, getOperationName(), OP_SHOWLISTUSERS);
}
+ private void setProperty(User user, String key, Object value)
+ {
+ try
+ {
+ userProfileModule.setProperty(user, key, value);
+ }
+ catch (IdentityException e)
+ {
+ //TODO: change to error
+ log.info("Cannot set profile property: ", e);
+ }
+ }
+
+ //Some temp solution to make this portlet not break with new stuff
+ private Object getProperty(User user, String key)
+ {
+ try
+ {
+ Object o = userProfileModule.getProperty(user, key);
+ if (o == null)
+ {
+ return new String();
+ }
+ else
+ {
+ return o.toString();
+ }
+ }
+ catch (IdentityException e)
+ {
+ log.error("Cannot get profile property: ", e);
+ }
+ return null;
+ }
+
+
+
/*
* private String getTimezoneOffsetString(short timezoneOffset) {
* StringBuffer timeZone = new StringBuffer(); for (int i = 0; i <
Modified: trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -57,8 +57,9 @@
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<depends>portal:service=JAASLoginModule</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
<depends optional-attribute-name="StackFactory" proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
- <depends optional-attribute-name="UserModule" proxy-type="attribute">portal:service=Module,type=User</depends>
+ <!--<depends optional-attribute-name="UserModule" proxy-type="attribute">portal:service=Module,type=User</depends>-->
<attribute name="DoChecking">true</attribute>
<attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
<attribute name="DefaultLocale">en</attribute>
@@ -478,9 +479,10 @@
</policy>
]]>
</attribute>
- <depends optional-attribute-name="RoleModule" proxy-type="attribute">
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
+ <!--<depends optional-attribute-name="RoleModule" proxy-type="attribute">
portal:service=Module,type=Role
- </depends>
+ </depends>-->
</mbean>
<!-- logging interceptor -->
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -50,12 +50,7 @@
code="org.jboss.portal.identity.management.Identity"
name="portal.management:service=Management,type=Identity,name=Default"
>
- <depends
- optional-attribute-name="UserModule"
- proxy-type="attribute">portal:service=Module,type=User</depends>
- <depends
- optional-attribute-name="RoleModule"
- proxy-type="attribute">portal:service=Module,type=Role</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
<xmbean/>
</mbean>
@@ -137,9 +132,7 @@
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends
- optional-attribute-name="UserModule"
- proxy-type="attribute">portal:service=Module,type=User</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
</mbean>
<mbean
code="org.jboss.portal.core.aspects.server.LocaleInterceptor"
@@ -444,7 +437,7 @@
<attribute name="DoChecking">true</attribute>
<attribute name="ConfigLocation">conf/hibernate/user/hibernate.cfg.xml</attribute>
<attribute name="SetupLocation">conf/hibernate/user/setup.txt</attribute>
- <attribute name="JNDIName">java:/portal/UserSessionFactory</attribute>
+ <attribute name="JNDIName">java:/portal/IdentitySessionFactory</attribute>
</mbean>
<mbean
code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
@@ -490,8 +483,24 @@
<attribute name="JNDIName">java:/portal/PortletSessionFactory</attribute>
</mbean>
+ <!--Identity-->
+ <mbean
+ code="org.jboss.portal.identity.IdentityServiceControllerImpl"
+ name="portal:service=Module,type=IdentityServiceController"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>portal:service=Hibernate</depends>
+ <!--<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>-->
+ <attribute name="JndiName">java:/portal/IdentityServiceController</attribute>
+ <attribute name="RegisterMBeans">true</attribute>
+ <attribute name="ConfigFile">conf/identity-config.xml</attribute>
+ <attribute name="DefaultConfigFile">conf/identity/standardidentity-config.xml</attribute>
+ </mbean>
+
+
<!-- Modules -->
- <mbean
+ <!--<mbean
code="org.jboss.portal.identity.db.DBUserModuleImpl"
name="portal:service=Module,type=User"
xmbean-dd=""
@@ -511,7 +520,7 @@
<attribute name="JNDIName">java:/portal/RoleModule</attribute>
<attribute name="SessionFactoryJNDIName">java:/portal/UserSessionFactory</attribute>
</mbean>
-
+-->
<mbean
code="org.jboss.portal.core.impl.mail.MailModuleImpl"
name="portal:service=Module,type=Mail"
@@ -519,7 +528,7 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends>jboss:service=Mail</depends>
- <depends>portal:service=Module,type=User</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
<attribute name="QueueCapacity">-1</attribute>
<attribute name="Gateway">localhost</attribute>
<attribute name="SmtpUser"></attribute>
@@ -623,12 +632,7 @@
<depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
- <depends
- optional-attribute-name="UserModule"
- proxy-type="attribute">portal:service=Module,type=User</depends>
- <depends
- optional-attribute-name="RoleModule"
- proxy-type="attribute">portal:service=Module,type=Role</depends>
+ <depends>portal:service=Module,type=IdentityServiceController</depends>
</mbean>
<!-- Command factories -->
Modified: trunk/core/src/resources/portal-core-sar/conf/hibernate/user/setup.txt
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/hibernate/user/setup.txt 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/hibernate/user/setup.txt 2006-12-17 14:26:07 UTC (rev 5883)
@@ -1,8 +1,8 @@
// This bsh script setup the default content of the portal.
// It is called when the SessionFactoryBinder service has created a schema and needs to populate it
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.db.UserImpl;
-import org.jboss.portal.identity.db.RoleImpl;
+import org.jboss.portal.identity.db.HibernateUserImpl;
+import org.jboss.portal.identity.db.HibernateRoleImpl;
try
{
@@ -10,11 +10,11 @@
tx = session.beginTransaction();
//
- RoleImpl adminRole = new RoleImpl("Admin", "Administrators");
- RoleImpl userRole = new RoleImpl("User", "Users");
+ HibernateRoleImpl adminRole = new HibernateRoleImpl("Admin", "Administrators");
+ HibernateRoleImpl userRole = new HibernateRoleImpl("User", "Users");
//
- UserImpl admin = new UserImpl("admin");
+ HibernateUserImpl admin = new HibernateUserImpl("admin");
admin.setPassword(Tools.md5AsHexString("admin"));
admin.setRealEmail("admin(a)portal.com");
admin.setViewRealEmail(true);
@@ -25,7 +25,7 @@
adminRole.getUsers().add(admin);
//
- UserImpl user = new UserImpl("user");
+ HibernateUserImpl user = new HibernateUserImpl("user");
user.setPassword(Tools.md5AsHexString("user"));
user.setRealEmail("user(a)portal.com");
user.setViewRealEmail(true);
Added: trunk/core/src/resources/portal-core-sar/conf/identity/ldap_identity-config.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/identity/ldap_identity-config.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/identity/ldap_identity-config.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+ <!--<!DOCTYPE identity-configuration PUBLIC
+ "-//JBoss Portal//DTD JBoss Identity Configuration 1.0//EN"
+ "http://www.jboss.org/portal/dtd/identity-config_1_0.dtd">-->
+
+<identity-configuration>
+ <datasources>
+ <datasource>
+ <name>LDAP</name>
+ <config>
+ <option>
+ <name>host</name>
+ <value>localhost</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>10389</value>
+ </option>
+ <option>
+ <name>adminDN</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>adminPassword</name>
+ <value>password</value>
+ </option>
+ </config>
+ </datasource>
+ </datasources>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>User</type>
+ <implementation>LDAP</implementation>
+ <config/>
+ </module>
+ <module>
+ <type>Role</type>
+ <implementation>LDAP</implementation>
+ <config/>
+ </module>
+ <module>
+ <type>Membership</type>
+ <implementation>LDAP</implementation>
+ <config/>
+ </module>
+
+ <module>
+ <type>UserProfile</type>
+ <implementation>DELEGATING</implementation>
+ <config>
+ <option>
+ <name>profileConfigFile</name>
+ <value>conf/profile-config.xml</value>
+ </option>
+ <option>
+ <name>ldapModuleJNDIName</name>
+ <value>java:/portal/LDAPUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+ <module>
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <type>LDAPDelegateUserProfile</type>
+ <implementation>LDAP</implementation>
+ <config/>
+ </module>
+ </modules>
+
+ <options>
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=testsuite,dc=portal,dc=qa,dc=atl,dc=jboss,dc=com</value>
+ </option>
+ </option-group>
+ </options>
+</identity-configuration>
\ No newline at end of file
Added: trunk/core/src/resources/portal-core-sar/conf/identity/standardidentity-config.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/identity/standardidentity-config.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/identity/standardidentity-config.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -0,0 +1,503 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+
+<!--
+<!DOCTYPE identity-configuration PUBLIC
+ "-//JBoss Portal//DTD JBoss Identity Configuration 1.0//EN"
+ "http://www.jboss.org/portal/dtd/identity-config_1_0.dtd">
+-->
+
+<identity-configuration>
+ <datasources>
+ <datasource>
+ <name>LDAP</name>
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=LDAPConnectionContext</service-name>
+ <class>org.jboss.portal.identity.ldap.LDAPConnectionContext</class>
+ <config>
+ <option>
+ <name>host</name>
+ <value>jboss.com</value>
+ </option>
+ <option>
+ <name>port</name>
+ <value>389</value>
+ </option>
+ <option>
+ <name>contextFactory</name>
+ <value>com.sun.jndi.ldap.LdapCtxFactory</value>
+ </option>
+ <option>
+ <name>adminDN</name>
+ <value>cn=Directory Manager</value>
+ </option>
+ <option>
+ <name>adminPassword</name>
+ <value>password</value>
+ </option>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/LDAPConnectionContext</value>
+ </option>
+ </config>
+ </datasource>
+ <!--<datasource>
+ <name>DB</name>
+ <service-name>portal:service=Hibernate</service-name>
+ <class>org.jboss.portal.identity2.experimental.db.IdentitySessionFactoryBinder</class>
+ <config>
+ <option>
+ <name>doChecking</name>
+ <value>true</value>
+ </option>
+ <option>
+ <name>configLocation</name>
+ <value>hibernate-single.cfg.xml</value>
+ </option>
+ --><!--<option>
+ <name>setupLocation</name>
+ <value>conf/hibernate/user/setup.txt</value>
+ </option>--><!--
+ <option>
+ <name>jNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>
+ <option>
+ <name>profileConfigFile</name>
+ <value>profile-config.xml</value>
+ </option>
+ <option>
+ <name>mappingTemplateFile</name>
+ <value>domain-template.hbm.xml</value>
+ </option>
+ <option>
+ <name>mappingOutputFile</name>
+ <value>domain-identity.hbm.xml</value>
+ </option>
+ <option>
+ <name>mappingPattern</name>
+ <value><![CDATA[<property name="@name@" column="@column@" type="java.lang.String" update="true" insert="true" unique="false"/>]]></value>
+ </option>
+ </config>
+ </datasource>-->
+ </datasources>
+ <modules>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfile</type>
+ <implementation>DELEGATING</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=UserProfile</service-name>
+ <class>org.jboss.portal.identity.DelegatingUserProfileModuleImpl</class>
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/UserProfileModule</value>
+ </option>
+ <option>
+ <name>dbModuleJNDIName</name>
+ <value>java:/portal/DBUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+
+
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>User</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity.db.HibernateUserModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>sessionFactoryJNDIName</name>
+ <value>java:/portal/IdentitySessionFactory</value>
+ </option>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/UserModule</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Role</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity.db.HibernateRoleModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>sessionFactoryJNDIName</name>
+ <value>java:/portal/IdentitySessionFactory</value>
+ </option>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/RoleModule</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Membership</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity.db.HibernateMembershipModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>sessionFactoryJNDIName</name>
+ <value>java:/portal/IdentitySessionFactory</value>
+ </option>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/MembershipModule</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=DBUserProfile</service-name>
+ <class>org.jboss.portal.identity.db.HibernateUserProfileModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>sessionFactoryJNDIName</name>
+ <value>java:/portal/IdentitySessionFactory</value>
+ </option>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/DBUserProfileModule</value>
+ </option>
+ </config>
+ </module>
+
+ <!--for ldap modules...-->
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>User</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=User</service-name>
+ <class>org.jboss.portal.identity.ldap.LDAPUserModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/UserModule</value>
+ </option>
+ <option>
+ <name>connectionJNDIName</name>
+ <value>java:/portal/LDAPConnectionContext</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Role</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Role</service-name>
+ <class>org.jboss.portal.identity.ldap.LDAPRoleModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/RoleModule</value>
+ </option>
+ <option>
+ <name>connectionJNDIName</name>
+ <value>java:/portal/LDAPConnectionContext</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Membership</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=Membership</service-name>
+ <class>org.jboss.portal.identity.ldap.LDAPStaticGroupMembershipModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/MembershipModule</value>
+ </option>
+ <option>
+ <name>connectionJNDIName</name>
+ <value>java:/portal/LDAPConnectionContext</value>
+ </option>
+ </config>
+ </module>
+
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>LDAPDelegateUserProfile</type>
+ <implementation>LDAP</implementation>
+
+ <!--name of service and class for creating mbean-->
+ <service-name>portal:service=Module,type=LDAPUserProfile</service-name>
+ <class>org.jboss.portal.identity.ldap.LDAPUserProfileModuleImpl</class>
+
+ <!--set of options that are passed to a class constructor-->
+ <config>
+ <!--<option>
+ <name>LDAPConnectionJNDIName</name>
+ <value>java:/portal/UserSessionFactory</value>
+ </option>-->
+ <!--Hibernate mappings for db level store (dynamic properties not mapped as ldap attributes)-->
+ <!--<option>
+ <name>SessionFactoryJNDIName</name>
+ <value>java:/portal/PropertyStoreSessionFactory</value>
+ </option>
+ <option>
+ <name>profileMappings</name>
+ <value>ldap-profile.xml</value>
+ </option>-->
+ <option>
+ <name>jndiName</name>
+ <value>java:/portal/LDAPUserProfileModule</value>
+ </option>
+ <option>
+ <name>connectionJNDIName</name>
+ <value>java:/portal/LDAPConnectionContext</value>
+ </option>
+ </config>
+ </module>
+
+ </modules>
+
+ <options>
+ <!--Common options section-->
+ <option-group>
+ <group-name>common</group-name>
+ <option>
+ <name>userContainerDN</name>
+ <value>ou=People,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>uidAttributeId</name>
+ <value>uid</value>
+ </option>
+ <option>
+ <name>passwordAttributeID</name>
+ <value>userPassword</value>
+ </option>
+ <option>
+ <name>hashAlgorithm</name>
+ <value>MD5</value>
+ </option>
+ <option>
+ <name>hashEncoding</name>
+ <value>hex</value>
+ </option>
+ <option>
+ <name>roleContainerDN</name>
+ <value>ou=Roles,dc=example,dc=com</value>
+ </option>
+ <option>
+ <name>ridAttributeId</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>roleDisplayNameAttributeID</name>
+ <value>cn</value>
+ </option>
+ <option>
+ <name>membershipAttributeID</name>
+ <value>member</value>
+ </option>
+ <option>
+ <name>membershipAttributeIsDN</name>
+ <value>true</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>userCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>uidObject</value>
+ <value>person</value>
+ <value>inetUser</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <option>
+ <name>sn</name>
+ <value>none</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>roleCreateAttibutes</group-name>
+ <option>
+ <name>objectClass</name>
+ <value>top</value>
+ <value>groupOfNames</value>
+ </option>
+ <!--Schema requires those to have initial value-->
+ <option>
+ <name>cn</name>
+ <value>none</value>
+ </option>
+ <!--Some directory servers require this attribute to be valid DN-->
+ <!--For safety reasons point to the admin user here-->
+ <option>
+ <name>member</name>
+ <value>uid=dummynonexistinguser,ou=People,dc=jboss,dc=org</value>
+ </option>
+ </option-group>
+ <option-group>
+ <group-name>userProfileMappings</group-name>
+ <option>
+ <name>portal.user.name.given</name>
+ <!--inetOrgPerson-->
+ <value>givenName</value>
+ </option>
+ <!--<option>
+ <name>portal.user.name.family</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.location</name>
+ <value></value>
+ </option>-->
+ <option>
+ <name>portal.user.occupation</name>
+ <!--inetOrgPerson-->
+ <value>title</value>
+ </option>
+ <!--<option>
+ <name>portal.user.extra</name>
+ <value></value>
+ </option>-->
+ <option>
+ <name>portal.user.signature</name>
+ <!--newPilotPerson-->
+ <value>personalSignature</value>
+ </option>
+ <!--<option>
+ <name>portal.user.interests</name>
+ <value></value>
+ </option>-->
+ <option>
+ <name>portal.user.locale</name>
+ <!--inetOrgPerson-->
+ <value>localityName</value><!--or prefferedLanguage-->
+ </option>
+ <!--<option>
+ <name>portal.user.im.icq</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.im.aim</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.im.msnm</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.im.yim</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.im.skype</name>
+ <value></value>
+ </option>-->
+ <option>
+ <name>portal.user.homepage</name>
+ <!--inetOrgPerson-->
+ <value>seeAlso</value>
+ </option>
+ <!--<option>
+ <name>portal.user.time-zone-offset</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.theme</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.security.question</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.security.answer</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.email.fake</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.email.view-real</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.last-login-date</name>
+ <value></value>
+ </option>
+ <option>
+ <name>portal.user.registration-date</name>
+ <value></value>
+ </option>-->
+ </option-group>
+ </options>
+</identity-configuration>
\ No newline at end of file
Added: trunk/core/src/resources/portal-core-sar/conf/identity-config.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/identity-config.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/identity-config.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+ <!--<!DOCTYPE identity-configuration PUBLIC
+ "-//JBoss Portal//DTD JBoss Identity Configuration 1.0//EN"
+ "http://www.jboss.org/portal/dtd/identity-config_1_0.dtd">-->
+
+<identity-configuration>
+ <datasources/>
+ <modules>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>User</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Role</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>Membership</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ <module>
+ <!--type used to correctly map in IdentityContext registry-->
+ <type>UserProfile</type>
+ <implementation>DELEGATING</implementation>
+ <config>
+ <option>
+ <name>profileConfigFile</name>
+ <value>conf/profile-config.xml</value>
+ </option>
+ </config>
+ </module>
+ <module>
+ <type>DBDelegateUserProfile</type>
+ <implementation>DB</implementation>
+ <config/>
+ </module>
+ </modules>
+ <options/>
+</identity-configuration>
\ No newline at end of file
Modified: trunk/core/src/resources/portal-core-sar/conf/login-config.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/login-config.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/login-config.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -39,6 +39,7 @@
<module-option name="unauthenticatedIdentity">guest</module-option>
<module-option name="userModuleJNDIName">java:/portal/UserModule</module-option>
<module-option name="roleModuleJNDIName">java:/portal/RoleModule</module-option>
+ <module-option name="membershipModuleJNDIName">java:/portal/MembershipModule</module-option>
<module-option name="additionalRole">Authenticated</module-option>
<module-option name="password-stacking">useFirstPass</module-option>
</login-module>
Added: trunk/core/src/resources/portal-core-sar/conf/profile-config.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/conf/profile-config.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-sar/conf/profile-config.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -0,0 +1,384 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+ <!--<!DOCTYPE profile PUBLIC
+ "-//JBoss Portal//DTD JBoss User Profile Configuration 1.0//EN"
+ "http://www.jboss.org/portal/dtd/profile-config_1_0.dtd">-->
+
+<profile>
+ <!--Database mapping - jbp_user table column mapping-->
+ <property>
+ <name>portal.user.name.given</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Name</display-name>
+ <description xml:lang="en">The user name</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_username</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.name.family</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Family name</display-name>
+ <description xml:lang="en">The user family name</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_familyname</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.email.real</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Email</display-name>
+ <description xml:lang="en">The user real email</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_realemail</value>
+ </database>
+ <ldap>
+ <value>mail</value>
+ </ldap>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.email.fake</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Fake email</display-name>
+ <description xml:lang="en">The user fake email</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_fakeemail</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.registration-date</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Registration date</display-name>
+ <description xml:lang="en">Registration date of user</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_regdate</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.email.view-real</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">View real email</display-name>
+ <description xml:lang="en">Is user real email displayed in public</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_viewrealemail</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.enabled</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>mandatory</usage>
+ <display-name xml:lang="en">Enabled</display-name>
+ <description xml:lang="en">User enabled state</description>
+ <mapping>
+ <database>
+ <type>column</type>
+ <value>jbp_enabled</value>
+ </database>
+ </mapping>
+ </property>
+
+ <!--Dynamic database store-->
+ <property>
+ <name>portal.user.location</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Location</display-name>
+ <description xml:lang="en">The user location</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.location</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.occupation</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Occupation</display-name>
+ <description xml:lang="en">The user occupation</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.occupation</value>
+ </database>
+ <ldap>
+ <value>title</value>
+ </ldap>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.extra</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Extra info</display-name>
+ <description xml:lang="en">Extra informtion about user</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.extra</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.signature</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Signature</display-name>
+ <description xml:lang="en">The user signature</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.signature</value>
+ </database>
+ <ldap>
+ <value>personalSignature</value>
+ </ldap>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.interests</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Interests</display-name>
+ <description xml:lang="en">The user interests</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.interests</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.locale</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Locale</display-name>
+ <description xml:lang="en">The user locale</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.locale</value>
+ </database>
+ <ldap>
+ <value>localityName</value>
+ </ldap>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.im.icq</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">ICQ</display-name>
+ <description xml:lang="en">The user ICQ id</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.im.icq</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.im.aim</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">AIM</display-name>
+ <description xml:lang="en">The user AIM id</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.im.aim</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.im.msnm</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">MSN</display-name>
+ <description xml:lang="en">The user MSN id</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.im.msnm</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.im.yim</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">YIM</display-name>
+ <description xml:lang="en">The user YIM id</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.im.yim</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.im.skype</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Skype</display-name>
+ <description xml:lang="en">The user skype id</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.im.skype</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.homepage</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Homepage</display-name>
+ <description xml:lang="en">The user homepage</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.homepage</value>
+ </database>
+ <ldap>
+ <value>seeAlso</value>
+ </ldap>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.time-zone-offset</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Timezone</display-name>
+ <description xml:lang="en">Timezone in users location</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.time-zone-offset</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.theme</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Theme</display-name>
+ <description xml:lang="en">Portlat theme that user is using</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.theme</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.security.question</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Password Question</display-name>
+ <description xml:lang="en">Portal password recovery question</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.security.question</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.security.answer</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Password Answer</display-name>
+ <description xml:lang="en">Portal password recovery answer</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.security.answer</value>
+ </database>
+ </mapping>
+ </property>
+ <property>
+ <name>portal.user.last-login-date</name>
+ <type>java.lang.String</type>
+ <access-mode>read-write</access-mode>
+ <usage>optional</usage>
+ <display-name xml:lang="en">Last login</display-name>
+ <description xml:lang="en">The date of users last login</description>
+ <mapping>
+ <database>
+ <type>dynamic</type>
+ <value>portal.user.last-login-date</value>
+ </database>
+ </mapping>
+ </property>
+</profile>
\ No newline at end of file
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -135,6 +135,16 @@
<service-ref>:service=Module,type=Role</service-ref>
</service>
<service>
+ <service-name>UserProfileModule</service-name>
+ <service-class>org.jboss.portal.identity.UserProfileModule</service-class>
+ <service-ref>:service=Module,type=UserProfile</service-ref>
+ </service>
+ <service>
+ <service-name>MembershipModule</service-name>
+ <service-class>org.jboss.portal.identity.MembershipModule</service-class>
+ <service-ref>:service=Module,type=Membership</service-ref>
+ </service>
+ <service>
<service-name>MailModule</service-name>
<service-class>org.jboss.portal.core.modules.MailModule</service-class>
<service-ref>:service=Module,type=Mail</service-ref>
Modified: trunk/core/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2006-12-17 14:17:34 UTC (rev 5882)
+++ trunk/core/src/resources/portal-samples-war/WEB-INF/jboss-portlet.xml 2006-12-17 14:26:07 UTC (rev 5883)
@@ -134,6 +134,16 @@
<service-ref>:service=Module,type=Role</service-ref>
</service>
<service>
+ <service-name>UserProfileModule</service-name>
+ <service-class>org.jboss.portal.identity.UserProfileModule</service-class>
+ <service-ref>:service=Module,type=UserProfile</service-ref>
+ </service>
+ <service>
+ <service-name>MembershipModule</service-name>
+ <service-class>org.jboss.portal.identity.MembershipModule</service-class>
+ <service-ref>:service=Module,type=Membership</service-ref>
+ </service>
+ <service>
<service-name>MailModule</service-name>
<service-class>org.jboss.portal.core.modules.MailModule</service-class>
<service-ref>:service=Module,type=Mail</service-ref>
19 years, 4 months
JBoss Portal SVN: r5882 - in trunk/identity/src/main/org/jboss/portal: . identity/auth identity/db identity/management legacy_identity
by portal-commits@lists.jboss.org
Author: bdaw
Date: 2006-12-17 09:17:34 -0500 (Sun, 17 Dec 2006)
New Revision: 5882
Added:
trunk/identity/src/main/org/jboss/portal/legacy_identity/
trunk/identity/src/main/org/jboss/portal/legacy_identity/IdentityException.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/NoSuchUserException.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/ProfileMap.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/Role.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/RoleModule.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/User.java
trunk/identity/src/main/org/jboss/portal/legacy_identity/UserModule.java
Modified:
trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java
trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java
trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java
trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java
Log:
- legacy identity code (backup temporarily)
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/auth/IdentityLoginModule.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,14 +20,14 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.auth;
+package org.jboss.portal.legacy_identity.auth;
import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.legacy_identity.NoSuchUserException;
+import org.jboss.portal.legacy_identity.Role;
+import org.jboss.portal.legacy_identity.RoleModule;
+import org.jboss.portal.legacy_identity.User;
+import org.jboss.portal.legacy_identity.UserModule;
import org.jboss.security.SimpleGroup;
import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.auth;
+package org.jboss.portal.legacy_identity.auth;
import java.security.Principal;
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/DBRoleModuleImpl.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.db;
+package org.jboss.portal.legacy_identity.db;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
@@ -31,10 +31,10 @@
import org.hibernate.criterion.Restrictions;
import org.jboss.portal.common.util.JNDI;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.User;
+import org.jboss.portal.legacy_identity.IdentityException;
+import org.jboss.portal.legacy_identity.Role;
+import org.jboss.portal.legacy_identity.RoleModule;
+import org.jboss.portal.legacy_identity.User;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.naming.InitialContext;
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/DBUserModuleImpl.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.db;
+package org.jboss.portal.legacy_identity.db;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
@@ -29,10 +29,10 @@
import org.hibernate.SessionFactory;
import org.jboss.portal.common.util.JNDI;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.identity.User;
-import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.legacy_identity.IdentityException;
+import org.jboss.portal.legacy_identity.NoSuchUserException;
+import org.jboss.portal.legacy_identity.User;
+import org.jboss.portal.legacy_identity.UserModule;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import javax.naming.InitialContext;
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/ProfileMapImpl.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,9 +20,9 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.db;
+package org.jboss.portal.legacy_identity.db;
-import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.legacy_identity.ProfileMap;
import java.util.ArrayList;
import java.util.Collection;
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/RoleImpl.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,9 +20,9 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.db;
+package org.jboss.portal.legacy_identity.db;
-import org.jboss.portal.identity.Role;
+import org.jboss.portal.legacy_identity.Role;
import java.util.HashSet;
import java.util.Set;
Modified: trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/db/UserImpl.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,15 +20,15 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.db;
+package org.jboss.portal.legacy_identity.db;
import org.apache.log4j.Logger;
import org.jboss.portal.common.p3p.P3PConstants;
import org.jboss.portal.common.util.LocaleInfo;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity.ProfileMap;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.User;
+import org.jboss.portal.legacy_identity.ProfileMap;
+import org.jboss.portal.legacy_identity.Role;
+import org.jboss.portal.legacy_identity.User;
import java.lang.reflect.Field;
import java.text.DateFormat;
Modified: trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/management/Identity.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,13 +20,13 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.management;
+package org.jboss.portal.legacy_identity.management;
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.legacy_identity.RoleModule;
+import org.jboss.portal.legacy_identity.UserModule;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
Modified: trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/identity/management/IdentityMBean.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -20,10 +20,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.identity.management;
+package org.jboss.portal.legacy_identity.management;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.legacy_identity.RoleModule;
+import org.jboss.portal.legacy_identity.UserModule;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/IdentityException.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/IdentityException.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/IdentityException.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class IdentityException extends Exception
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2976579334381568521L;
+
+ public IdentityException()
+ {
+ }
+
+ public IdentityException(String message)
+ {
+ super(message);
+ }
+
+ public IdentityException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public IdentityException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/IdentityException.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/NoSuchUserException.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/NoSuchUserException.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/NoSuchUserException.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class NoSuchUserException extends IdentityException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7328419579811469592L;
+ private String userName;
+
+ public NoSuchUserException(String userName)
+ {
+ super("No such user " + userName);
+ this.userName = userName;
+ }
+
+ public String getUserName()
+ {
+ return userName;
+ }
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/NoSuchUserException.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/ProfileMap.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/ProfileMap.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/ProfileMap.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+import java.util.Map;
+
+/**
+ * Extends <code>java.util.Map</code> to provide meta information about user profile.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface ProfileMap extends Map
+{
+ /**
+ * Return true if the profile value is read only.
+ *
+ * @param key
+ * @return true if the profile value is read only
+ * @throws ClassCastException if the key is not an instance of string
+ */
+ boolean isReadOnly(Object key);
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/ProfileMap.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/Role.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/Role.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/Role.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+import java.util.Set;
+
+/**
+ * A role of users.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 5448 $
+ */
+public interface Role
+{
+ /** The role identifier. */
+ Object getId();
+
+ /** The role name used in security rules. This name can not be modified */
+ String getName();
+
+ /** The role display name used on screens. This name can be modified */
+ String getDisplayName();
+
+ /**
+ *
+ */
+ void setDisplayName(String name);
+
+ /** The users. */
+ Set getUsers();
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/Role.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/RoleModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/RoleModule.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/RoleModule.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute </a>
+ * @author Roy Russo : roy at jboss dot org
+ * @version $Revision: 5448 $
+ */
+public interface RoleModule
+{
+ /**
+ * Retrieves a role by its name
+ *
+ * @param name the role name
+ * @return the role
+ */
+ Role findRoleByName(String name) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Retrieve a collection of role from the role names.
+ *
+ * @param names the role names
+ * @return a collection of roles
+ * @throws IllegalArgumentException
+ */
+ Set findRolesByNames(String[] names) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Retrieves a role by its id.
+ *
+ * @param id the role id
+ * @return the role
+ */
+ Role findRoleById(Object id) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Retrieves a role by its id.
+ *
+ * @param id the role id
+ * @return the role
+ */
+ Role findRoleById(String id) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Create a new role with the specified name.
+ *
+ * @param name the role name
+ * @param displayName the role display name
+ * @return the role
+ */
+ Role createRole(String name, String displayName) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Remove a role.
+ *
+ * @param id the role id
+ */
+ void removeRole(Object id) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Returns the number of roles.
+ *
+ * @return the number of roles
+ */
+ int getRolesCount() throws IdentityException;
+
+ /**
+ * Get all the roles
+ *
+ * @return the roles
+ */
+ Set findRoles() throws IdentityException;
+
+ /**
+ * Returns role members based on rolename
+ *
+ * @param roleName
+ * @param offset
+ * @param limit
+ */
+ Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException;
+
+ /**
+ * Assign a set of role objects to a given user.
+ *
+ * @param user the user
+ * @param roles the user roles
+ */
+ void setRoles(User user, Set roles) throws IdentityException;
+
+ /**
+ * Return the set of role objects that a given user has.
+ *
+ * @param user the user
+ * @return the set of roles of the specified user
+ */
+ Set getRoles(User user) throws IdentityException;
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/RoleModule.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/User.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/User.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/User.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,161 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * A user.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:mageshbk@jboss.com">Magesh Kumar Bojan </a>
+ * @version $Revision: 5623 $
+ */
+public interface User
+{
+
+ String INFO_USER_REGISTRATION_DATE = "portal.user.registration-date";
+ String INFO_USER_HOMEPAGE = "portal.user.homepage";
+ String INFO_USER_TIME_ZONE_OFFSET = "portal.user.time-zone-offset";
+ String INFO_USER_THEME = "portal.user.theme";
+ String INFO_USER_LOCATION = "portal.user.location";
+ String INFO_USER_OCCUPATION = "portal.user.occupation";
+ String INFO_USER_EXTRA = "portal.user.extra";
+ String INFO_USER_SIGNATURE = "portal.user.signature";
+ String INFO_USER_INTERESTS = "portal.user.interests";
+ String INFO_USER_LOCALE = "portal.user.locale";
+ String INFO_USER_IM_ICQ = "portal.user.im.icq";
+ String INFO_USER_IM_AIM = "portal.user.im.aim";
+ String INFO_USER_IM_MSNM = "portal.user.im.msnm";
+ String INFO_USER_IM_YIM = "portal.user.im.yim";
+ String INFO_USER_IM_SKYPE = "portal.user.im.skype";
+ String INFO_USER_SECURITY_QUESTION = "portal.user.security.question";
+ String INFO_USER_SECURITY_ANSWER = "portal.user.security.answer";
+ String INFO_USER_EMAIL_FAKE = "portal.user.email.fake";
+ String INFO_USER_VIEW_EMAIL_VIEW_REAL = "portal.user.email.view-real";
+ String INFO_USER_LAST_LOGIN_DATE = "portal.user.last-login-date";
+
+ /** The user identifier. To safetly cast to String use .toString() method */
+ Object getId();
+
+ // User management **************************************************************************************************
+
+ /** Disable the user. */
+ boolean getEnabled();
+
+ /** Enable the user. */
+ void setEnabled(boolean enable);
+
+ /** Set the password. */
+ void updatePassword(String password);
+
+ /** Return true if the password is valid. */
+ boolean validatePassword(String password);
+
+ // Detyped access to properties *************************************************************************************
+
+ /** Returns the user properties. */
+ ProfileMap getProfile();
+
+ // Properties declared in this interface for convenient access ******************************************************
+
+ /** The user name. */
+ String getUserName();
+
+ /** The given name (firstname). */
+ String getGivenName();
+
+ /**
+ *
+ */
+ void setGivenName(String givenName);
+
+ /** The family name. */
+ String getFamilyName();
+
+ /**
+ *
+ */
+ void setFamilyName(String familyName);
+
+ /**
+ *
+ */
+ String getRealEmail();
+
+ /**
+ *
+ */
+ void setRealEmail(String realEmail);
+
+ /**
+ *
+ */
+ String getFakeEmail();
+
+ /**
+ *
+ */
+ void setFakeEmail(String fakeEmail);
+
+ /**
+ *
+ */
+ Date getRegistrationDate();
+
+ /**
+ *
+ */
+ boolean getViewRealEmail();
+
+ /**
+ *
+ */
+ void setViewRealEmail(boolean viewRealEmail);
+
+ /** Return the user preferred locale. */
+ Locale getPreferredLocale();
+
+ /** Set the user preferred locale. */
+ void setPreferredLocale(Locale locale);
+
+ /** Returns the signature. */
+ String getSignature();
+
+ /** Set the signature. */
+ void setSignature(String signature);
+
+ /** Return the last time the user logged in or null if this date is not known. */
+ Date getLastVisitDate();
+
+ /** Set the last visit date on this user. */
+ void setLastVisitDate(Date date);
+
+ /** Return the theme set for this user as the app id of the Theme. */
+ String getTheme();
+
+ /** Set the theme for this user. */
+ void setTheme(String themeId);
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/User.java
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/identity/src/main/org/jboss/portal/legacy_identity/UserModule.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/legacy_identity/UserModule.java 2006-12-16 12:28:47 UTC (rev 5881)
+++ trunk/identity/src/main/org/jboss/portal/legacy_identity/UserModule.java 2006-12-17 14:17:34 UTC (rev 5882)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.legacy_identity;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
+ * @version $Revision: 5448 $
+ */
+public interface UserModule
+{
+ /**
+ * Retrieve a user by its name.
+ *
+ * @param userName the user name
+ * @return the user
+ */
+ User findUserByUserName(String userName) throws IdentityException, IllegalArgumentException, NoSuchUserException;
+
+ /**
+ * Retrieve a user by its id.
+ *
+ * @param id the user id
+ * @return the user
+ * @throws IllegalArgumentException if the id is null
+ */
+ User findUserById(Object id) throws IdentityException, IllegalArgumentException, NoSuchUserException;
+
+ /**
+ * Retrieve a user by its id.
+ *
+ * @param id the user id
+ * @return the user
+ * @throws IllegalArgumentException if the id is null or not in the good format
+ */
+ User findUserById(String id) throws IdentityException, IllegalArgumentException, NoSuchUserException;
+
+ /**
+ * Creates a new user with the specified name.
+ *
+ * @param userName
+ * @return the user
+ */
+ User createUser(String userName, String password, String realEmail) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Remove a user.
+ *
+ * @param id the user id
+ */
+ void removeUser(Object id) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Get a range of users.
+ *
+ * @param offset the offset of the first result to retrieve
+ * @param limit the maximum number of users to retrieve
+ * @return the user set
+ */
+ Set findUsers(int offset, int limit) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Get a range of users.
+ *
+ * @param filter a string filter applied to the user name.
+ * @param offset the offset of the frist result to retrieve
+ * @param limit the maximum number of users to retrieve
+ * @return the user set
+ */
+ Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException, IllegalArgumentException;
+
+ /**
+ * Returns the number of users.
+ *
+ * @return the number of users
+ */
+ int getUserCount() throws IdentityException, IllegalArgumentException;
+}
Property changes on: trunk/identity/src/main/org/jboss/portal/legacy_identity/UserModule.java
___________________________________________________________________
Name: svn:executable
+ *
19 years, 4 months
JBoss Portal SVN: r5881 - in branches/JBoss_Portal_Branch_2_4/portlet: . src/main/org/jboss/portal/portlet/aspects/portlet src/main/org/jboss/portal/portlet/test src/main/org/jboss/portal/test/framework/portlet/universal src/main/org/jboss/portal/test/portlet/jsr168/ext src/main/org/jboss/portal/test/portlet/jsr168/ext/common src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache src/resources/test/jsr168/ext src/
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-16 07:28:47 -0500 (Sat, 16 Dec 2006)
New Revision: 5881
Added:
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/universal/UTP11.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheTestSuite.java
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/web.xml
Modified:
branches/JBoss_Portal_Branch_2_4/portlet/build.xml
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheTestSuite.java
branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1163 : Portlet cache does not take in account window state and modes
Modified: branches/JBoss_Portal_Branch_2_4/portlet/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/build.xml 2006-12-16 12:28:47 UTC (rev 5881)
@@ -227,6 +227,7 @@
<sequential>
<mkdir dir="${build.resources}/test/jsr168/ext/@{test}-war/WEB-INF/classes"/>
<copy todir="${build.resources}/test/jsr168/ext/@{test}-war/WEB-INF/classes">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/test/portlet/jsr168/ext/common/**"/>
<fileset dir="${build.classes}" includes="org/jboss/portal/test/portlet/jsr168/ext/@{test}/**"/>
<fileset dir="${build.classes}" includes="org/jboss/portal/test/framework/portlet/**"/>
</copy>
@@ -372,6 +373,7 @@
<!-- Ext tests -->
<package-ext-test test="nocache"/>
<package-ext-test test="expiringcache"/>
+ <package-ext-test test="neverexpiringcache"/>
<package-ext-test test="preferences"/>
<package-ext-test test="session"/>
<package-ext-test test="portletresponses"/>
@@ -510,8 +512,10 @@
name="org.jboss.portal.test.portlet.jsr168.ext.nocache.NoCacheTestSuite"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.portlet.jsr168.ext.expiringcache.ExpiringCacheTestSuite"/>
+ <test todir="${test.reports}"
+ name="org.jboss.portal.test.portlet.jsr168.ext.neverexpiringcache.NeverExpiringCacheTestSuite"/>
<!--Misc Tests-->
- <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.log4j.Log4jTestSuite"/>
+ <!--<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.log4j.Log4jTestSuite"/>-->
</x-test>
<x-classpath>
<path refid="oswego.concurrent.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ConsumerCacheInterceptor.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -34,6 +34,8 @@
import org.jboss.portal.portlet.result.cache.TimedContent;
import org.jboss.portal.portlet.spi.InvocationContext;
import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
import java.io.Serializable;
@@ -56,6 +58,8 @@
//
StateString navState = renderCtx.getNavigationalState();
+ WindowState windowState = renderCtx.getWindowState();
+ Mode mode = renderCtx.getMode();
//
CacheEntry cachedEntry = (CacheEntry)invocation.getContext().getAttribute(InvocationContext.PRINCIPAL_SCOPE, scopeKey);
@@ -96,6 +100,12 @@
{
useEntry = navState.equals(entryNavState);
}
+
+ // Then check window state equality
+ useEntry &= windowState.equals(cachedEntry.getWindowState());
+
+ // Then check mode equality
+ useEntry &= mode.equals(cachedEntry.getMode());
}
// Use the entry
@@ -137,7 +147,7 @@
// Cache if we can
if (expirationTimeMillis > 0)
{
- CacheEntry cacheEntry = new CacheEntry(navState, renderResult, expirationTimeMillis);
+ CacheEntry cacheEntry = new CacheEntry(navState, windowState, mode, renderResult, expirationTimeMillis);
invocation.getContext().setAttribute(InvocationContext.PRINCIPAL_SCOPE, scopeKey, cacheEntry);
}
}
@@ -170,16 +180,35 @@
/** The timed content. */
private final TimedContent cachedResult;
- public CacheEntry(StateString navigationalState, FragmentResult result, long expirationTimeMillis)
+ /** . */
+ private WindowState windowState;
+
+ /** . */
+ private Mode mode;
+
+ public CacheEntry(StateString navigationalState, WindowState windowState, Mode mode, FragmentResult result, long expirationTimeMillis)
{
if (expirationTimeMillis <= 0)
{
throw new IllegalArgumentException();
}
this.navigationalState = navigationalState;
+ this.windowState = windowState;
+ this.mode = mode;
this.cachedResult = new StrongTimedContent(result, expirationTimeMillis);
}
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
public StateString getNavigationalState()
{
return navigationalState;
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -227,16 +227,20 @@
req.getNavigationContext().setNavigationalState(portlet.getId(), decoder.getNavigationalstate());
//
- if (decoder.getMode() != null)
+ Mode mode = decoder.getMode();
+ if (mode == null)
{
- req.getNavigationContext().setNavigationalState(portlet.getId() + "_mode", decoder.getMode());
+ mode = Mode.VIEW;
}
+ req.getNavigationContext().setNavigationalState(portlet.getId() + "_mode", mode);
//
- if (decoder.getWindowState() != null)
+ WindowState windowState = decoder.getWindowState();
+ if (windowState == null)
{
- req.getNavigationContext().setNavigationalState(portlet.getId() + "_windowstate", decoder.getWindowState());
+ windowState = WindowState.NORMAL;
}
+ req.getNavigationContext().setNavigationalState(portlet.getId() + "_windowstate", windowState);
}
}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/universal/UTP11.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/universal/UTP11.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/framework/portlet/universal/UTP11.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.framework.portlet.universal;
+
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.Joinpoint;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5450 $
+ */
+public class UTP11 extends AbstractUniversalTestPortlet
+{
+ public static ThreadLocal local = new ThreadLocal();
+
+ public static Object holder;
+
+ public static String NAME = "Portlet11";
+
+ public final static Joinpoint RENDER_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_RENDER);
+
+ public final static Joinpoint ACTION_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_ACTION);
+
+ protected String createComponentId()
+ {
+ return NAME;
+ }
+
+ /** Resets helper variables */
+ public void reset()
+ {
+ local = new ThreadLocal();
+ holder = null;
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,394 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr168.ext.common;
+
+import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
+import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.Joinpoint;
+import org.jboss.portal.test.framework.portlet.Sequence;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.portlet.actions.PortletActionTestAction;
+import org.jboss.portal.test.framework.container.result.Result;
+import org.jboss.portal.test.framework.container.result.InvokeGetResult;
+import org.jboss.portal.test.framework.container.result.AssertResult;
+import org.jboss.portal.test.framework.container.result.EndTestResult;
+import org.jboss.portal.common.util.CollectionBuilder;
+
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import javax.portlet.ActionResponse;
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import java.util.Set;
+import java.util.HashSet;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractCacheSequenceBuilder extends SequenceRegistryBuilder
+{
+
+ protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator renderParameterConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+ {
+ public PortletURL createPortletURL(RenderResponse resp)
+ {
+ PortletURL url = resp.createRenderURL();
+ url.setParameter("abc", "def");
+ return url;
+ }
+ public void configureNavigationalState(ActionResponse resp)
+ {
+ resp.setRenderParameter("abc", "fed");
+ }
+ };
+
+ protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator windowStateConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+ {
+ public PortletURL createPortletURL(RenderResponse resp) throws WindowStateException
+ {
+ PortletURL url = resp.createRenderURL();
+ url.setWindowState(WindowState.MAXIMIZED);
+ return url;
+ }
+ public void configureNavigationalState(ActionResponse resp) throws WindowStateException
+ {
+ resp.setWindowState(WindowState.MAXIMIZED);
+ }
+ };
+
+ protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator portletModeConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+ {
+ public PortletURL createPortletURL(RenderResponse resp) throws PortletModeException
+ {
+ PortletURL url = resp.createRenderURL();
+ url.setPortletMode(PortletMode.EDIT);
+ return url;
+ }
+ public void configureNavigationalState(ActionResponse resp) throws PortletModeException
+ {
+ resp.setPortletMode(PortletMode.EDIT);
+ }
+ };
+
+ /**
+ * Overriding the expiration cache to 0 disable the cache on a render or an action/render.
+ */
+ protected void createDisableDuringRender(String testName, SequenceRegistry registry, Joinpoint renderjp, Joinpoint actionjp)
+ {
+ final Set calls = new HashSet();
+ Sequence seq = new Sequence();
+ registry.addSequence(testName, seq);
+
+ //
+ seq.addAction(0, renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ //
+ calls.add("0");
+ response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+
+ // Refresh
+ String url = response.createRenderURL().toString();
+ return new InvokeGetResult(url);
+ }
+ });
+
+ //
+ seq.addAction(1, renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ //
+ calls.add("1");
+ response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+
+ // Refresh
+ String url = response.createActionURL().toString();
+ return new InvokeGetResult(url);
+ }
+ });
+
+ //
+ seq.addAction(2, actionjp, new PortletActionTestAction()
+ {
+ protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
+ //
+ calls.add("2_action");
+ return null;
+ }
+ });
+ seq.addAction(2, renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Content is not cached
+ calls.add("2_render");
+
+ //
+ Set expected = new CollectionBuilder().add("0").add("1").add("2_action").add("2_render").toHashSet();
+ assertEquals(expected, calls);
+
+ // End test
+ return new EndTestResult();
+ }
+ });
+ }
+
+ protected interface NavigationalStateConfigurator
+ {
+ PortletURL createPortletURL(RenderResponse resp) throws PortletException;
+ void configureNavigationalState(ActionResponse resp) throws PortletException;
+ }
+
+ /**
+ * Calling render on the portlet with different render parameters invalidates the cache
+ */
+ protected void createCacheMarkup(
+ String testName,
+ SequenceRegistry registry,
+ Joinpoint p1renderjp,
+ Joinpoint p1actionjp,
+ Joinpoint p2renderjp,
+ final AbstractCacheSequenceBuilder.NavigationalStateConfigurator configurator)
+ {
+ final Set calls = new HashSet();
+ final String[] url = new String[1];
+ Sequence seq = new Sequence();
+ registry.addSequence(testName, seq);
+
+ //
+ seq.addAction(0, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Content is not cached
+ calls.add("0");
+
+ // Create invalidating action url for later use
+ url[0] = response.createActionURL().toString();
+
+ // Refresh
+ return new InvokeGetResult(response.createRenderURL().toString());
+ }
+ });
+
+ //
+ seq.addAction(1, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should not be called
+ calls.add("1");
+ return null;
+ }
+ });
+ seq.addAction(1, p2renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Invalidate with action
+ return new InvokeGetResult(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(2, p1actionjp, new PortletActionTestAction()
+ {
+ protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
+ calls.add("2_action");
+ return null;
+ }
+ });
+ seq.addAction(2, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("2_render");
+
+ // Refresh with different URL
+ PortletURL url = configurator.createPortletURL(response);
+ return new InvokeGetResult(url.toString());
+ }
+ });
+
+ //
+ seq.addAction(3, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("3");
+
+ // Invoke with same different URL
+ PortletURL url = configurator.createPortletURL(response);
+ return new InvokeGetResult(url.toString());
+ }
+ });
+
+ //
+ seq.addAction(4, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should not be called
+ calls.add("4");
+ return null;
+ }
+ });
+ seq.addAction(4, p2renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Invalidate with action
+ return new InvokeGetResult(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(5, p1actionjp, new PortletActionTestAction()
+ {
+ protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
+ calls.add("5_action");
+
+ // Configure the navitional state
+ configurator.configureNavigationalState(response);
+ return null;
+ }
+ });
+ seq.addAction(5, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("5_render");
+
+ // Refresh with different navigational state to check it will be called in the next render phase
+ PortletURL url = response.createRenderURL();
+ return new InvokeGetResult(url.toString());
+ }
+ });
+
+ //
+ seq.addAction(6, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ Set expected = new CollectionBuilder().add("0").add("2_action").add("2_render").add("3").add("5_action").add("5_render").toHashSet();
+ assertEquals(expected, calls);
+
+ // Refresh
+ return new EndTestResult();
+ }
+ });
+ }
+
+ /**
+ * Calling action on the portlet invalidates the cache.
+ */
+ protected void createActionInvalidates(
+ String testName,
+ SequenceRegistry registry,
+ Joinpoint p1renderjp,
+ Joinpoint p1actionjp,
+ Joinpoint p2renderjp)
+ {
+ final Set calls = new HashSet();
+ final String[] url = new String[1];
+ Sequence seq = new Sequence();
+ registry.addSequence(testName, seq);
+
+ //
+ seq.addAction(0, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Content is not cached
+ calls.add("0");
+
+ // Refresh
+ url[0] = response.createActionURL().toString();
+ return new InvokeGetResult(response.createRenderURL().toString());
+ }
+ });
+
+ //
+ seq.addAction(1, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Should no be called
+ calls.add("1");
+ return null;
+ }
+ });
+ seq.addAction(1, p2renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Invalidate
+ return new InvokeGetResult(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(2, p1actionjp, new PortletActionTestAction()
+ {
+ protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
+ {
+ //
+ calls.add("2_action");
+ return null;
+ }
+ });
+ seq.addAction(2, p1renderjp, new PortletRenderTestAction()
+ {
+ protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
+ {
+ // Content is not cached
+ calls.add("2_render");
+
+ //
+ Set expected = new CollectionBuilder().add("0").add("2_action").add("2_render").toHashSet();
+ assertEquals(expected, calls);
+
+ // End test
+ return new EndTestResult();
+ }
+ });
+ }
+
+
+}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -22,46 +22,41 @@
******************************************************************************/
package org.jboss.portal.test.portlet.jsr168.ext.expiringcache;
-import org.jboss.portal.test.framework.portlet.SequenceRegistryBuilder;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
-import org.jboss.portal.test.framework.portlet.Joinpoint;
import org.jboss.portal.test.framework.portlet.Sequence;
import org.jboss.portal.test.framework.portlet.universal.UTP6;
-import org.jboss.portal.test.framework.portlet.universal.UTP1;
+import org.jboss.portal.test.framework.portlet.universal.UTP9;
+import org.jboss.portal.test.framework.portlet.universal.UTP8;
import org.jboss.portal.test.framework.portlet.universal.UTP2;
+import org.jboss.portal.test.framework.portlet.universal.UTP1;
import org.jboss.portal.test.framework.portlet.universal.UTP7;
-import org.jboss.portal.test.framework.portlet.universal.UTP5;
import org.jboss.portal.test.framework.portlet.universal.UTP4;
-import org.jboss.portal.test.framework.portlet.universal.UTP8;
-import org.jboss.portal.test.framework.portlet.universal.UTP9;
+import org.jboss.portal.test.framework.portlet.universal.UTP5;
import org.jboss.portal.test.framework.portlet.universal.UTP10;
import org.jboss.portal.test.framework.portlet.universal.UTP3;
+import org.jboss.portal.test.framework.portlet.universal.UTP11;
import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
-import org.jboss.portal.test.framework.portlet.actions.PortletActionTestAction;
import org.jboss.portal.test.framework.container.result.Result;
import org.jboss.portal.test.framework.container.result.InvokeGetResult;
import org.jboss.portal.test.framework.container.result.EndTestResult;
-import org.jboss.portal.test.framework.container.result.AssertResult;
import org.jboss.portal.test.framework.container.result.FailureResult;
+import org.jboss.portal.test.portlet.jsr168.ext.common.AbstractCacheSequenceBuilder;
import org.jboss.portal.common.util.CollectionBuilder;
import javax.portlet.Portlet;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletException;
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
import javax.portlet.PortletURL;
-import javax.portlet.PortletSecurityException;
-import java.util.Set;
-import java.util.HashSet;
import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class ExpiringCacheSequenceBuilder extends SequenceRegistryBuilder
+public class ExpiringCacheSequenceBuilder extends AbstractCacheSequenceBuilder
{
public void createDisableDuringRenderExpiringCache(SequenceRegistry registry)
@@ -69,80 +64,28 @@
createDisableDuringRender("DisableDuringRenderExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
}
- public void createDisableDuringRenderNeverExpiringCache(SequenceRegistry registry)
+ public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
{
- createDisableDuringRender("DisableDuringRenderNeverExpiringCache", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT);
+ createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
}
- /**
- * Overriding the expiration cache to 0 disable the cache on a render or an action/render.
- */
- private void createDisableDuringRender(String testName, SequenceRegistry registry, Joinpoint renderjp, Joinpoint actionjp)
+ public void createExpiringCacheWithRenderParameters(SequenceRegistry registry)
{
- final Set calls = new HashSet();
- Sequence seq = new Sequence();
- registry.addSequence(testName, seq);
+ createCacheMarkup("ExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
+ }
- //
- seq.addAction(0, renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- //
- calls.add("0");
- response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+ public void createExpiringCacheWithWindowState(SequenceRegistry registry)
+ {
+ createCacheMarkup("ExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+ }
- // Refresh
- String url = response.createRenderURL().toString();
- return new InvokeGetResult(url);
- }
- });
-
- //
- seq.addAction(1, renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- //
- calls.add("1");
- response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
-
- // Refresh
- String url = response.createActionURL().toString();
- return new InvokeGetResult(url);
- }
- });
-
- //
- seq.addAction(2, actionjp, new PortletActionTestAction()
- {
- protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
- {
- //
- calls.add("2_action");
- return null;
- }
- });
- seq.addAction(2, renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Content is not cached
- calls.add("2_render");
-
- //
- Set expected = new CollectionBuilder().add("0").add("1").add("2_action").add("2_render").toHashSet();
- assertEquals(expected, calls);
-
- // End test
- return new EndTestResult();
- }
- });
+ public void createExpiringCacheWithPortletMode(SequenceRegistry registry)
+ {
+ createCacheMarkup("ExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
}
/**
- * Caching happens after a render with the same render parameters for at most 5 seconds
- * Calling render on the portlet with different render parameters invalidates the cache
+ * Check that content is cached for at most 5 seconds in various situations.
*/
public void createExpiringCache(SequenceRegistry registry)
{
@@ -152,7 +95,7 @@
registry.addSequence("ExpiringCache", seq);
//
- seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(0, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -166,7 +109,7 @@
});
//
- seq.addAction(1, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(1, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -175,7 +118,7 @@
return null;
}
});
- seq.addAction(1, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(1, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -185,7 +128,7 @@
});
//
- seq.addAction(2, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(2, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -197,7 +140,7 @@
return null;
}
});
- seq.addAction(2, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(2, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -219,7 +162,7 @@
});
//
- seq.addAction(3, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(3, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -235,7 +178,7 @@
});
//
- seq.addAction(4, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(4, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -248,7 +191,7 @@
});
//
- seq.addAction(5, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(5, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -257,7 +200,7 @@
return null;
}
});
- seq.addAction(5, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(5, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -267,7 +210,7 @@
});
//
- seq.addAction(6, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(6, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -279,7 +222,7 @@
return null;
}
});
- seq.addAction(6, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(6, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -301,7 +244,7 @@
});
//
- seq.addAction(7, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
+ seq.addAction(7, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
{
protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
{
@@ -318,229 +261,4 @@
});
}
- /**
- * Caching happens after a render with the same render parameters for at most 5 seconds
- * Calling render on the portlet with different render parameters invalidates the cache
- */
- public void createNeverExpiringCache(SequenceRegistry registry)
- {
- final Set calls = new HashSet();
- final String[] url = new String[1];
- Sequence seq = new Sequence();
- registry.addSequence("NeverExpiringCache", seq);
-
- //
- seq.addAction(0, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Content is not cached
- calls.add("0");
-
- // Create invalidating action url for later use
- url[0] = response.createActionURL().toString();
-
- // Refresh
- return new InvokeGetResult(response.createRenderURL().toString());
- }
- });
-
- //
- seq.addAction(1, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should not be called
- calls.add("1");
- return null;
- }
- });
- seq.addAction(1, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Invalidate with action
- return new InvokeGetResult(url[0]);
- }
- });
-
- //
- seq.addAction(2, UTP9.ACTION_JOINPOINT, new PortletActionTestAction()
- {
- protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
- {
- calls.add("2_action");
- return null;
- }
- });
- seq.addAction(2, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should be called
- calls.add("2_render");
-
- // Refresh with different render parameters
- PortletURL url = response.createRenderURL();
- url.setParameter("abc", "def");
- return new InvokeGetResult(url.toString());
- }
- });
-
- //
- seq.addAction(3, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should be called
- calls.add("3");
-
- // Invoke the with same render parameters
- PortletURL url = response.createRenderURL();
- url.setParameter("abc", "def");
- return new InvokeGetResult(url.toString());
- }
- });
-
- //
- seq.addAction(4, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should not be called
- calls.add("4");
- return null;
- }
- });
- seq.addAction(4, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Invalidate with action
- return new InvokeGetResult(url[0]);
- }
- });
-
- //
- seq.addAction(5, UTP9.ACTION_JOINPOINT, new PortletActionTestAction()
- {
- protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, IOException
- {
- calls.add("5_action");
- response.setRenderParameter("abc", "fed");
- return null;
- }
- });
- seq.addAction(5, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should be called
- calls.add("5_render");
-
- // Refresh with different render parameters
- PortletURL url = response.createRenderURL();
- return new InvokeGetResult(url.toString());
- }
- });
-
- //
- seq.addAction(6, UTP9.RENDER_JOINPOINT, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- Set expected = new CollectionBuilder().add("0").add("2_action").add("2_render").add("3").add("5_action").add("5_render").toHashSet();
- assertEquals(expected, calls);
-
- // Refresh
- return new EndTestResult();
- }
- });
- }
-
- public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
- {
- createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT);
- }
-
- public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
- {
- createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP7.RENDER_JOINPOINT, UTP7.ACTION_JOINPOINT, UTP8.RENDER_JOINPOINT);
- }
-
- /**
- * Calling action on the portlet invalidates the cache.
- */
- public void createActionInvalidates(
- String testName,
- SequenceRegistry registry,
- Joinpoint p1renderjp,
- Joinpoint p1actionjp,
- Joinpoint p2renderjp)
- {
- final Set calls = new HashSet();
- final String[] url = new String[1];
- Sequence seq = new Sequence();
- registry.addSequence(testName, seq);
-
- //
- seq.addAction(0, p1renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Content is not cached
- calls.add("0");
-
- // Refresh
- url[0] = response.createActionURL().toString();
- return new InvokeGetResult(response.createRenderURL().toString());
- }
- });
-
- //
- seq.addAction(1, p1renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Should no be called
- calls.add("1");
- return null;
- }
- });
- seq.addAction(1, p2renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Invalidate
- return new InvokeGetResult(url[0]);
- }
- });
-
- //
- seq.addAction(2, p1actionjp, new PortletActionTestAction()
- {
- protected AssertResult run(Portlet portlet, ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
- {
- //
- calls.add("2_action");
- return null;
- }
- });
- seq.addAction(2, p1renderjp, new PortletRenderTestAction()
- {
- protected Result run(Portlet portlet, RenderRequest request, RenderResponse response) throws IOException, PortletException
- {
- // Content is not cached
- calls.add("2_render");
-
- //
- Set expected = new CollectionBuilder().add("0").add("2_action").add("2_render").toHashSet();
- assertEquals(expected, calls);
-
- // End test
- return new EndTestResult();
- }
- });
- }
-
}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheTestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheTestSuite.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheTestSuite.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -36,11 +36,11 @@
{
TestSuite suite = new TestSuite("test-jsr168-ext-expiringcache.war");
suite.addTest(new TestCase("DisableDuringRenderExpiringCache"));
- suite.addTest(new TestCase("DisableDuringRenderNeverExpiringCache"));
+ suite.addTest(new TestCase("ActionInvalidatesExpiringCache"));
+ suite.addTest(new TestCase("ExpiringCacheWithRenderParameters"));
+ suite.addTest(new TestCase("ExpiringCacheWithWindowState"));
+ suite.addTest(new TestCase("ExpiringCacheWithPortletMode"));
suite.addTest(new TestCase("ExpiringCache"));
- suite.addTest(new TestCase("NeverExpiringCache"));
- suite.addTest(new TestCase("ActionInvalidatesExpiringCache"));
- suite.addTest(new TestCase("ActionInvalidatesNeverExpiringCache"));
return suite;
}
}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr168.ext.neverexpiringcache;
+
+import org.jboss.portal.test.portlet.jsr168.ext.common.AbstractCacheSequenceBuilder;
+import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.universal.UTP6;
+import org.jboss.portal.test.framework.portlet.universal.UTP1;
+import org.jboss.portal.test.framework.portlet.universal.UTP4;
+import org.jboss.portal.test.framework.portlet.universal.UTP8;
+import org.jboss.portal.test.framework.portlet.universal.UTP2;
+import org.jboss.portal.test.framework.portlet.universal.UTP9;
+import org.jboss.portal.test.framework.portlet.universal.UTP5;
+import org.jboss.portal.test.framework.portlet.universal.UTP7;
+import org.jboss.portal.test.framework.portlet.universal.UTP3;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class NeverExpiringCacheSequenceBuilder extends AbstractCacheSequenceBuilder
+{
+
+ public void createDisableDuringRenderNeverExpiringCache(SequenceRegistry registry)
+ {
+ createDisableDuringRender("DisableDuringRenderNeverExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
+ }
+
+ public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
+ {
+ createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
+ }
+
+ public void createNeverExpiringCacheWithRenderParameters(SequenceRegistry registry)
+ {
+ createCacheMarkup("NeverExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
+ }
+
+ public void createNeverExpiringCacheWithWindowState(SequenceRegistry registry)
+ {
+ createCacheMarkup("NeverExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+ }
+
+ public void createNeverExpiringCacheWithPortletMode(SequenceRegistry registry)
+ {
+ createCacheMarkup("NeverExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheTestSuite.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheTestSuite.java 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheTestSuite.java 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.jsr168.ext.neverexpiringcache;
+
+import junit.framework.Test;
+import org.jboss.portal.test.framework.container.client.TestSuite;
+import org.jboss.portal.test.framework.container.client.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5450 $
+ */
+public class NeverExpiringCacheTestSuite
+{
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("test-jsr168-ext-neverexpiringcache.war");
+ suite.addTest(new TestCase("DisableDuringRenderNeverExpiringCache"));
+ suite.addTest(new TestCase("ActionInvalidatesNeverExpiringCache"));
+ suite.addTest(new TestCase("NeverExpiringCacheWithRenderParameters"));
+ suite.addTest(new TestCase("NeverExpiringCacheWithWindowState"));
+ suite.addTest(new TestCase("NeverExpiringCacheWithPortletMode"));
+ return suite;
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml 2006-12-16 12:28:47 UTC (rev 5881)
@@ -88,7 +88,7 @@
<portlet>
<portlet-name>TestUniversalPortletF</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP6</portlet-class>
- <expiration-cache>-1</expiration-cache>
+ <expiration-cache>5</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
@@ -100,7 +100,6 @@
<portlet>
<portlet-name>TestUniversalPortletG</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP7</portlet-class>
- <expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
@@ -112,8 +111,10 @@
<portlet>
<portlet-name>TestUniversalPortletH</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP8</portlet-class>
+ <expiration-cache>5</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
+ <portlet-mode>edit</portlet-mode>
</supports>
<portlet-info>
<title></title>
@@ -123,7 +124,6 @@
<portlet>
<portlet-name>TestUniversalPortletI</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP9</portlet-class>
- <expiration-cache>-1</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
@@ -135,6 +135,7 @@
<portlet>
<portlet-name>TestUniversalPortletJ</portlet-name>
<portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP10</portlet-class>
+ <expiration-cache>5</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
@@ -142,4 +143,16 @@
<title></title>
</portlet-info>
</portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletK</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP11</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
+ version="1.0">
+
+ <portlet>
+ <portlet-name>TestUniversalPortletA</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP1</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletB</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP2</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletC</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP3</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletD</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP4</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletE</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP5</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletF</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP6</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletG</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP7</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletH</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP8</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>edit</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletI</portlet-name>
+ <portlet-class>org.jboss.portal.test.framework.portlet.universal.UTP9</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
Added: branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/web.xml 2006-12-16 01:44:37 UTC (rev 5880)
+++ branches/JBoss_Portal_Branch_2_4/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/web.xml 2006-12-16 12:28:47 UTC (rev 5881)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+ <listener>
+ <listener-class>org.jboss.portal.test.portlet.jsr168.ext.neverexpiringcache.NeverExpiringCacheSequenceBuilder</listener-class>
+ </listener>
+
+</web-app>
19 years, 4 months
JBoss Portal SVN: r5880 - in trunk/portlet: . src/main/org/jboss/portal/portlet/test src/main/org/jboss/portal/test/portlet/framework src/main/org/jboss/portal/test/portlet/jsr168/ext/common src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache src/resources/test/jsr168/ext/expiringcache-war/WEB-INF src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2006-12-15 20:44:37 -0500 (Fri, 15 Dec 2006)
New Revision: 5880
Added:
trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java
Modified:
trunk/portlet/build.xml
trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
Log:
JBPORTAL-1163 : cache test cover window state and portlet mode
Modified: trunk/portlet/build.xml
===================================================================
--- trunk/portlet/build.xml 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/build.xml 2006-12-16 01:44:37 UTC (rev 5880)
@@ -459,7 +459,6 @@
<x-test>
<!--Spec TCK Assertions tests-->
-<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.DispatcherTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletConfigTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletContextTestCase"/>
@@ -471,10 +470,8 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PortletURLTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.PreferencesTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.tck.WindowStatesTestCase"/>
--->
<!--API Tests-->
-<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.ActionRequestTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.ActionResponseTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.PortalContextTestCase"/>
@@ -488,10 +485,8 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.RenderRequestTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.RenderResponseTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.api.WindowStateTestCase"/>
--->
<!--Ext Tests-->
-<!--
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.DispatcherTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletConfigTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletModeTestCase"/>
@@ -499,13 +494,12 @@
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PortletResponsesTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.PreferencesTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.SessionTestCase"/>
--->
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.ExpiringCacheTestCase"/>
<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NeverExpiringCacheTestCase"/>
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NoCacheTestCase"/>-->
+ <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.ext.NoCacheTestCase"/>
<!--Misc Tests-->
- <!--<test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.Log4jTestCase"/>-->
+ <test todir="${test.reports}" name="org.jboss.portal.test.portlet.jsr168.misc.Log4jTestCase"/>
</x-test>
<x-classpath>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2006-12-16 01:44:37 UTC (rev 5880)
@@ -230,16 +230,20 @@
invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), decoder.getNavigationalstate());
//
- if (decoder.getMode() != null)
+ Mode mode = decoder.getMode();
+ if (mode == null)
{
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode", decoder.getMode());
+ mode = Mode.VIEW;
}
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_mode", mode);
//
- if (decoder.getWindowState() != null)
+ WindowState windowState = decoder.getWindowState();
+ if (windowState == null)
{
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate", decoder.getWindowState());
+ windowState = WindowState.NORMAL;
}
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext() + "_windowstate", windowState);
}
}
Added: trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/framework/UTP11.java 2006-12-16 01:44:37 UTC (rev 5880)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.test.portlet.framework;
+
+import org.jboss.portal.test.framework.portlet.components.AbstractUniversalTestPortlet;
+import org.jboss.portal.test.framework.portlet.Joinpoint;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5568 $
+ */
+public class UTP11 extends AbstractUniversalTestPortlet
+{
+ public static ThreadLocal local = new ThreadLocal();
+
+ public static Object holder;
+
+ public static String NAME = "Portlet11";
+
+ public final static Joinpoint RENDER_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_RENDER);
+
+ public final static Joinpoint ACTION_JOINPOINT = new Joinpoint(NAME, Joinpoint.PORTLET_ACTION);
+
+ protected String createComponentId()
+ {
+ return NAME;
+ }
+
+ /** Resets helper variables */
+ public void reset()
+ {
+ local = new ThreadLocal();
+ holder = null;
+ }
+}
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/common/AbstractCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
@@ -41,6 +41,10 @@
import javax.portlet.RenderRequest;
import javax.portlet.PortletException;
import javax.portlet.ActionRequest;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
import java.util.Set;
import java.util.HashSet;
import java.io.IOException;
@@ -66,6 +70,34 @@
}
};
+ protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator windowStateConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+ {
+ public PortletURL createPortletURL(RenderResponse resp) throws WindowStateException
+ {
+ PortletURL url = resp.createRenderURL();
+ url.setWindowState(WindowState.MAXIMIZED);
+ return url;
+ }
+ public void configureNavigationalState(ActionResponse resp) throws WindowStateException
+ {
+ resp.setWindowState(WindowState.MAXIMIZED);
+ }
+ };
+
+ protected final AbstractCacheSequenceBuilder.NavigationalStateConfigurator portletModeConfigurator = new AbstractCacheSequenceBuilder.NavigationalStateConfigurator()
+ {
+ public PortletURL createPortletURL(RenderResponse resp) throws PortletModeException
+ {
+ PortletURL url = resp.createRenderURL();
+ url.setPortletMode(PortletMode.EDIT);
+ return url;
+ }
+ public void configureNavigationalState(ActionResponse resp) throws PortletModeException
+ {
+ resp.setPortletMode(PortletMode.EDIT);
+ }
+ };
+
/**
* Overriding the expiration cache to 0 disable the cache on a render or an action/render.
*/
@@ -131,188 +163,10 @@
});
}
- /**
- * Caching happens after a render with the same render parameters for at most 5 seconds
- * Calling render on the portlet with different render parameters invalidates the cache
- */
-// public void createExpiringCache(SequenceRegistry registry)
-// {
-// final Set calls = new HashSet();
-// final String[] url = new String[1];
-// Sequence seq = new Sequence();
-// registry.addSequence("ExpiringCache", seq);
-//
-// //
-// seq.addAction(0, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Content is not cached
-// calls.add("0");
-//
-// // Refresh
-// url[0] = response.createRenderURL().toString();
-// return new InvokeGetResponse(url[0]);
-// }
-// });
-//
-// //
-// seq.addAction(1, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Should not be called
-// calls.add("1");
-// return null;
-// }
-// });
-// seq.addAction(1, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Refresh
-// return new InvokeGetResponse(url[0]);
-// }
-// });
-//
-// //
-// seq.addAction(2, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Could be called depending on whether the portal
-// // decides to invoke UTP2 or UTP3 first
-// // so if it's called we need to disable cache otherwise the next
-// // render will probably not be called
-// response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
-// return null;
-// }
-// });
-// seq.addAction(2, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// try
-// {
-// assertFalse(calls.contains("1"));
-//
-// // Wait 5 seconds for the cache entry to be invalid
-// Thread.sleep(5 * 1000);
-//
-// // Refresh
-// return new InvokeGetResponse(url[0]);
-// }
-// catch (InterruptedException e)
-// {
-// return new ErrorResponse(e);
-// }
-// }
-// });
-//
-// //
-// seq.addAction(3, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Should be called
-// calls.add("3");
-//
-// // Invoke the same but with different render parameter
-// PortletURL tmp = response.createRenderURL();
-// tmp.setParameter("abc", "def");
-// url[0] = tmp.toString();
-// return new InvokeGetResponse(url[0]);
-// }
-// });
-//
-// //
-// seq.addAction(4, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Should be called
-// calls.add("4");
-//
-// // Refresh
-// return new InvokeGetResponse(url[0]);
-// }
-// });
-//
-// //
-// seq.addAction(5, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Should not be called
-// calls.add("5");
-// return null;
-// }
-// });
-// seq.addAction(5, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Refresh
-// return new InvokeGetResponse(url[0]);
-// }
-// });
-//
-// //
-// seq.addAction(6, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Could be called depending on whether the portal
-// // decides to invoke UTP2 or UTP3 first
-// // so if it's called we need to disable cache otherwise the next
-// // render will probably not be called
-// response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
-// return null;
-// }
-// });
-// seq.addAction(6, UTP3.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// try
-// {
-// assertFalse(calls.contains("5"));
-//
-// // Wait 5 seconds for the cache entry to be invalid
-// Thread.sleep(5 * 1000);
-//
-// // Refresh
-// return new InvokeGetResponse(url[0]);
-// }
-// catch (InterruptedException e)
-// {
-// return new ErrorResponse(e);
-// }
-// }
-// });
-//
-// //
-// seq.addAction(7, UTP2.RENDER_JOINPOINT, new PortletRenderTestAction()
-// {
-// protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
-// {
-// // Should be called
-// calls.add("7");
-//
-// //
-// Set expected = new CollectionBuilder().add("0").add("3").add("4").add("7").toHashSet();
-// assertEquals(expected, calls);
-//
-// // Refresh
-// return new EndTestResponse();
-// }
-// });
-// }
-
protected interface NavigationalStateConfigurator
{
- PortletURL createPortletURL(RenderResponse resp);
- void configureNavigationalState(ActionResponse resp);
+ PortletURL createPortletURL(RenderResponse resp) throws PortletException;
+ void configureNavigationalState(ActionResponse resp) throws PortletException;
}
/**
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/expiringcache/ExpiringCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
@@ -23,13 +23,36 @@
package org.jboss.portal.test.portlet.jsr168.ext.expiringcache;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
+import org.jboss.portal.test.framework.portlet.PortletTestContext;
+import org.jboss.portal.test.framework.portlet.Sequence;
+import org.jboss.portal.test.framework.portlet.actions.PortletRenderTestAction;
+import org.jboss.portal.test.framework.driver.http.response.InvokeGetResponse;
import org.jboss.portal.test.portlet.framework.UTP1;
import org.jboss.portal.test.portlet.framework.UTP2;
import org.jboss.portal.test.portlet.framework.UTP3;
import org.jboss.portal.test.portlet.framework.UTP4;
import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.portal.test.portlet.framework.UTP7;
+import org.jboss.portal.test.portlet.framework.UTP8;
+import org.jboss.portal.test.portlet.framework.UTP9;
+import org.jboss.portal.test.portlet.framework.UTP10;
+import org.jboss.portal.test.portlet.framework.UTP11;
import org.jboss.portal.test.portlet.jsr168.ext.common.AbstractCacheSequenceBuilder;
+import org.jboss.portal.common.test.driver.DriverResponse;
+import org.jboss.portal.common.test.driver.response.ErrorResponse;
+import org.jboss.portal.common.test.driver.response.EndTestResponse;
+import org.jboss.portal.common.util.CollectionBuilder;
+import javax.portlet.Portlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -42,13 +65,201 @@
createDisableDuringRender("DisableDuringRenderExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
}
- public void createExpiringCache(SequenceRegistry registry)
+ public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
{
- createCacheMarkup("ExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT, renderParameterConfigurator);
+ createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
}
- public void createActionInvalidatesExpiringCache(SequenceRegistry registry)
+ public void createExpiringCacheWithRenderParameters(SequenceRegistry registry)
{
- createActionInvalidates("ActionInvalidatesExpiringCache", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT);
+ createCacheMarkup("ExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
}
+
+ public void createExpiringCacheWithWindowState(SequenceRegistry registry)
+ {
+ createCacheMarkup("ExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+ }
+
+ public void createExpiringCacheWithPortletMode(SequenceRegistry registry)
+ {
+ createCacheMarkup("ExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
+ }
+
+ /**
+ * Check that content is cached for at most 5 seconds in various situations.
+ */
+ public void createExpiringCache(SequenceRegistry registry)
+ {
+ final Set calls = new HashSet();
+ final String[] url = new String[1];
+ Sequence seq = new Sequence();
+ registry.addSequence("ExpiringCache", seq);
+
+ //
+ seq.addAction(0, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Content is not cached
+ calls.add("0");
+
+ // Refresh
+ url[0] = response.createRenderURL().toString();
+ return new InvokeGetResponse(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(1, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should not be called
+ calls.add("1");
+ return null;
+ }
+ });
+ seq.addAction(1, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Refresh
+ return new InvokeGetResponse(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(2, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Could be called depending on whether the portal
+ // decides to invoke UTP2 or UTP3 first
+ // so if it's called we need to disable cache otherwise the next
+ // render will probably not be called
+ response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+ return null;
+ }
+ });
+ seq.addAction(2, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ try
+ {
+ assertFalse(calls.contains("1"));
+
+ // Wait 5 seconds for the cache entry to be invalid
+ Thread.sleep(5 * 1000);
+
+ // Refresh
+ return new InvokeGetResponse(url[0]);
+ }
+ catch (InterruptedException e)
+ {
+ return new ErrorResponse(e);
+ }
+ }
+ });
+
+ //
+ seq.addAction(3, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("3");
+
+ // Invoke the same but with different render parameter
+ PortletURL tmp = response.createRenderURL();
+ tmp.setParameter("abc", "def");
+ url[0] = tmp.toString();
+ return new InvokeGetResponse(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(4, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("4");
+
+ // Refresh
+ return new InvokeGetResponse(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(5, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should not be called
+ calls.add("5");
+ return null;
+ }
+ });
+ seq.addAction(5, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Refresh
+ return new InvokeGetResponse(url[0]);
+ }
+ });
+
+ //
+ seq.addAction(6, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Could be called depending on whether the portal
+ // decides to invoke UTP2 or UTP3 first
+ // so if it's called we need to disable cache otherwise the next
+ // render will probably not be called
+ response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+ return null;
+ }
+ });
+ seq.addAction(6, UTP11.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ try
+ {
+ assertFalse(calls.contains("5"));
+
+ // Wait 5 seconds for the cache entry to be invalid
+ Thread.sleep(5 * 1000);
+
+ // Refresh
+ return new InvokeGetResponse(url[0]);
+ }
+ catch (InterruptedException e)
+ {
+ return new ErrorResponse(e);
+ }
+ }
+ });
+
+ //
+ seq.addAction(7, UTP10.RENDER_JOINPOINT, new PortletRenderTestAction()
+ {
+ protected DriverResponse run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
+ {
+ // Should be called
+ calls.add("7");
+
+ //
+ Set expected = new CollectionBuilder().add("0").add("3").add("4").add("7").toHashSet();
+ assertEquals(expected, calls);
+
+ // Refresh
+ return new EndTestResponse();
+ }
+ });
+ }
+
}
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/jsr168/ext/neverexpiringcache/NeverExpiringCacheSequenceBuilder.java 2006-12-16 01:44:37 UTC (rev 5880)
@@ -28,6 +28,10 @@
import org.jboss.portal.test.portlet.framework.UTP3;
import org.jboss.portal.test.portlet.framework.UTP4;
import org.jboss.portal.test.portlet.framework.UTP5;
+import org.jboss.portal.test.portlet.framework.UTP6;
+import org.jboss.portal.test.portlet.framework.UTP7;
+import org.jboss.portal.test.portlet.framework.UTP8;
+import org.jboss.portal.test.portlet.framework.UTP9;
import org.jboss.portal.test.framework.portlet.SequenceRegistry;
/**
@@ -42,13 +46,23 @@
createDisableDuringRender("DisableDuringRenderNeverExpiringCache", registry, UTP1.RENDER_JOINPOINT, UTP1.ACTION_JOINPOINT);
}
- public void createNeverExpiringCache(SequenceRegistry registry)
+ public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
{
- createCacheMarkup("NeverExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT, renderParameterConfigurator);
+ createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP2.RENDER_JOINPOINT, UTP2.ACTION_JOINPOINT, UTP3.RENDER_JOINPOINT);
}
- public void createActionInvalidatesNeverExpiringCache(SequenceRegistry registry)
+ public void createNeverExpiringCacheWithRenderParameters(SequenceRegistry registry)
{
- createActionInvalidates("ActionInvalidatesNeverExpiringCache", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT);
+ createCacheMarkup("NeverExpiringCacheWithRenderParameters", registry, UTP4.RENDER_JOINPOINT, UTP4.ACTION_JOINPOINT, UTP5.RENDER_JOINPOINT, renderParameterConfigurator);
}
+
+ public void createNeverExpiringCacheWithWindowState(SequenceRegistry registry)
+ {
+ createCacheMarkup("NeverExpiringCacheWithWindowState", registry, UTP6.RENDER_JOINPOINT, UTP6.ACTION_JOINPOINT, UTP7.RENDER_JOINPOINT, windowStateConfigurator);
+ }
+
+ public void createNeverExpiringCacheWithPortletMode(SequenceRegistry registry)
+ {
+ createCacheMarkup("NeverExpiringCacheWithPortletMode", registry, UTP8.RENDER_JOINPOINT, UTP8.ACTION_JOINPOINT, UTP9.RENDER_JOINPOINT, portletModeConfigurator);
+ }
}
Modified: trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/resources/test/jsr168/ext/expiringcache-war/WEB-INF/portlet.xml 2006-12-16 01:44:37 UTC (rev 5880)
@@ -85,4 +85,74 @@
</portlet-info>
</portlet>
+ <portlet>
+ <portlet-name>TestUniversalPortletF</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <expiration-cache>5</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletG</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletH</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP8</portlet-class>
+ <expiration-cache>5</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>edit</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletI</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP9</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletJ</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP10</portlet-class>
+ <expiration-cache>5</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletK</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP11</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>
Modified: trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml
===================================================================
--- trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml 2006-12-16 00:48:38 UTC (rev 5879)
+++ trunk/portlet/src/resources/test/jsr168/ext/neverexpiringcache-war/WEB-INF/portlet.xml 2006-12-16 01:44:37 UTC (rev 5880)
@@ -85,4 +85,51 @@
</portlet-info>
</portlet>
+ <portlet>
+ <portlet-name>TestUniversalPortletF</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP6</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletG</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP7</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletH</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP8</portlet-class>
+ <expiration-cache>-1</expiration-cache>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>edit</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
+ <portlet>
+ <portlet-name>TestUniversalPortletI</portlet-name>
+ <portlet-class>org.jboss.portal.test.portlet.framework.UTP9</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title></title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>
19 years, 4 months