[jboss-svn-commits] JBL Code SVN: r38331 - in labs/jbossforums/branches/forums130P27: authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri May 24 15:47:26 EDT 2013


Author: sviluppatorefico
Date: 2013-05-24 15:47:25 -0400 (Fri, 24 May 2013)
New Revision: 38331

Modified:
   labs/jbossforums/branches/forums130P27/.classpath
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/RolePortal.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/UserPortal.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/MembershipModulePL.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/RolePL.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserPL.java
   labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/resources/forums-authz-plugin.sar/META-INF/acl-permissions.xml
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/RolePortal.java
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/UserPortal.java
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/MembershipModulePL.java
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/RolePL.java
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java
   labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserPL.java
   labs/jbossforums/branches/forums130P27/readme.txt
Log:
Ended the picketlink integration

Modified: labs/jbossforums/branches/forums130P27/.classpath
===================================================================
--- labs/jbossforums/branches/forums130P27/.classpath	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/.classpath	2013-05-24 19:47:25 UTC (rev 38331)
@@ -11,7 +11,7 @@
 	<classpathentry kind="lib" path="thirdparty/jakarta-log4j/lib/log4j.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-system/lib/jboss-system.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-system/lib/jboss-jmx.jar"/>
-	<classpathentry kind="lib" path="thirdparty/facelets/lib/jsf-facelets.jar"/>
+	<classpathentry kind="lib" path="thirdparty/facelets/lib/jsf-facelets.jar" sourcepath="/Users/flashboss/.m2/repository/com/sun/facelets/jsf-facelets/1.1.15.B1/jsf-facelets-1.1.15.B1-sources.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-system/lib/mail.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-common-lib.jar"/>
 	<classpathentry kind="lib" path="thirdparty/oswego-concurrent/lib/concurrent.jar"/>
@@ -26,7 +26,7 @@
 	<classpathentry kind="lib" path="thirdparty/jboss-jaae-engine/lib/jboss-acl.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-jaae-engine/lib/jboss-security-common.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-jaae-engine/lib/jboss-identity-management.jar"/>
-	<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-identity-lib.jar"/>
+	<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-identity-lib.jar" sourcepath="/identity"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-system/lib/jboss-common.jar"/>
 	<classpathentry kind="lib" path="thirdparty/dom4j/lib/dom4j.jar"/>
 	<classpathentry kind="lib" path="thirdparty/javassist/lib/javassist.jar"/>
@@ -49,6 +49,6 @@
 	<classpathentry kind="lib" path="thirdparty/beanshell/lib/bsh.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-hibernate/lib/hibernate-entitymanager.jar"/>
 	<classpathentry kind="lib" path="thirdparty/jboss-hibernate/lib/hibernate-annotations.jar"/>
-	<classpathentry kind="lib" path="thirdparty/picketlink/lib/picketlink-idm-1.1.5.CR01.jar" sourcepath="/picketlink-idm-auth"/>
+	<classpathentry kind="lib" path="thirdparty/picketlink/lib/picketlink-idm-1.1.5.CR01.jar" sourcepath="/picketlink-idm-api"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/RolePortal.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/RolePortal.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/RolePortal.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -4,28 +4,38 @@
 
 public class RolePortal implements Role {
 
+	private String displayName;
+	private Object id;
+	private String name;
+	
+	public RolePortal(Role group) {
+		displayName = group.getDisplayName();
+		id = group.getId();
+		name = group.getName();
+	}
+
 	@Override
 	public String getDisplayName() {
 		// TODO Auto-generated method stub
-		return null;
+		return displayName;
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getName() {
 		// TODO Auto-generated method stub
-		return null;
+		return name;
 	}
 
 	@Override
 	public void setDisplayName(String arg0) {
 		// TODO Auto-generated method stub
-		
+		this.displayName = arg0;
 	}
 
 }

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/UserPortal.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/UserPortal.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/jbportal/UserPortal.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -5,20 +5,24 @@
 
 public class UserPortal implements User {
 
+	private Object id;
+	private String userName;
+	
 	public UserPortal(User user) {
-		
+		id = user.getId();
+		userName = user.getUserName();
 	}
 	
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getUserName() {
 		// TODO Auto-generated method stub
-		return null;
+		return userName;
 	}
 
 	@Override

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/MembershipModulePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/MembershipModulePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/MembershipModulePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -1,5 +1,7 @@
 package org.jboss.forums.security.picketlink;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 import javax.naming.InitialContext;
@@ -19,10 +21,8 @@
 	private static MembershipModule currentInstance;
 
 	public MembershipModulePL() throws Exception {
-		IdentitySessionFactory identitySessionFactory = (IdentitySessionFactory) new InitialContext()
-				.lookup("java:/IdentitySessionFactory");
-		IdentitySession identitySession = identitySessionFactory
-				.createIdentitySession("idm_realm");
+		IdentitySessionFactory identitySessionFactory = (IdentitySessionFactory) new InitialContext().lookup("java:/IdentitySessionFactory");
+		IdentitySession identitySession = identitySessionFactory.createIdentitySession("idm_realm");
 		relationshipManager = identitySession.getRelationshipManager();
 	}
 
@@ -34,8 +34,7 @@
 	}
 
 	@Override
-	public void assignRoles(User arg0, Set arg1) throws IdentityException,
-			IllegalArgumentException {
+	public void assignRoles(User arg0, Set arg1) throws IdentityException, IllegalArgumentException {
 		try {
 			relationshipManager.associateUsersByKeys(arg0.getUserName(), arg1);
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
@@ -44,8 +43,7 @@
 	}
 
 	@Override
-	public void assignUsers(Role arg0, Set arg1) throws IdentityException,
-			IllegalArgumentException {
+	public void assignUsers(Role arg0, Set arg1) throws IdentityException, IllegalArgumentException {
 		try {
 			relationshipManager.associateGroupsByKeys(arg0.getName(), arg1);
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
@@ -55,11 +53,15 @@
 	}
 
 	@Override
-	public Set findRoleMembers(String arg0, int arg1, int arg2, String arg3)
-			throws IdentityException, IllegalArgumentException {
+	public Set findRoleMembers(String arg0, int arg1, int arg2, String arg3) throws IdentityException, IllegalArgumentException {
 		Set roleMembers = null;
 		try {
-			relationshipManager.findRelatedGroups(arg0, "", null);
+			Collection<org.picketlink.idm.api.Group> groups = relationshipManager.findRelatedGroups(arg0, "", null);
+			if (groups != null && groups.size() > 0) {
+				roleMembers = new HashSet<RolePL>();
+				for (org.picketlink.idm.api.Group group : groups)
+					roleMembers.add(new RolePL(group));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -67,11 +69,15 @@
 	}
 
 	@Override
-	public Set getRoles(User arg0) throws IdentityException,
-			IllegalArgumentException {
+	public Set getRoles(User arg0) throws IdentityException, IllegalArgumentException {
 		Set roles = null;
 		try {
-			relationshipManager.findAssociatedGroups(arg0.getUserName(), null);
+			Collection<org.picketlink.idm.api.Group> groups = relationshipManager.findAssociatedGroups(arg0.getUserName(), null);
+			if (groups != null && groups.size() > 0) {
+				roles = new HashSet<RolePL>();
+				for (org.picketlink.idm.api.Group group : groups)
+					roles.add(new RolePL(group));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -79,11 +85,15 @@
 	}
 
 	@Override
-	public Set getUsers(Role arg0) throws IdentityException,
-			IllegalArgumentException {
+	public Set getUsers(Role arg0) throws IdentityException, IllegalArgumentException {
 		Set users = null;
 		try {
-			relationshipManager.findAssociatedUsers(arg0.getName(), true, null);
+			Collection<org.picketlink.idm.api.User> plusers = relationshipManager.findAssociatedUsers(arg0.getName(), true, null);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<UserPL>();
+				for (org.picketlink.idm.api.User user : plusers)
+					users.add(new UserPL(user));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/RolePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/RolePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/RolePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -4,28 +4,38 @@
 
 public class RolePL implements Role {
 
+	private String displayName;
+	private Object id;
+	private String name;
+	
+	public RolePL(org.picketlink.idm.api.Group group) {
+		displayName = group.getName();
+		id = group.getKey();
+		name = group.getName();
+	}
+	
 	@Override
 	public String getDisplayName() {
 		// TODO Auto-generated method stub
-		return null;
+		return displayName;
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getName() {
 		// TODO Auto-generated method stub
-		return null;
+		return name;
 	}
 
 	@Override
 	public void setDisplayName(String arg0) {
 		// TODO Auto-generated method stub
-		
+		this.displayName = arg0;
 	}
 
 }

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserModulePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -1,5 +1,7 @@
 package org.jboss.forums.security.picketlink;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 import javax.naming.InitialContext;
@@ -12,6 +14,8 @@
 import org.picketlink.idm.api.IdentitySession;
 import org.picketlink.idm.api.IdentitySessionFactory;
 import org.picketlink.idm.api.PersistenceManager;
+import org.picketlink.idm.api.UnsupportedCriterium;
+import org.picketlink.idm.impl.api.IdentitySearchCriteriaImpl;
 
 public class UserModulePL implements UserModule {
 
@@ -73,13 +77,16 @@
 	@Override
 	public User findUserByUserName(String arg0) throws IdentityException,
 			IllegalArgumentException, NoSuchUserException {
-		IdentitySearchCriteria identitySearchCriteria = null;
+		IdentitySearchCriteria identitySearchCriteria = new IdentitySearchCriteriaImpl();
 		User user = null;
 		try {
-			user = new UserPL((org.picketlink.idm.api.User) persistenceManager
-					.findUser(identitySearchCriteria).toArray()[0]);
+			identitySearchCriteria.nameFilter(arg0);
+			user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(identitySearchCriteria).toArray()[0]);
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
+		} catch (UnsupportedCriterium e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 		return user;
 	}
@@ -90,7 +97,10 @@
 		IdentitySearchCriteria identitySearchCriteria = null;
 		Set users = null;
 		try {
-			persistenceManager.findUser(identitySearchCriteria);
+			Collection<org.picketlink.idm.api.User> plusers = persistenceManager.findUser(identitySearchCriteria);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<org.picketlink.idm.api.User>(plusers);
+			}		
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -103,7 +113,10 @@
 		IdentitySearchCriteria identitySearchCriteria = null;
 		Set users = null;
 		try {
-			persistenceManager.findUser(identitySearchCriteria);
+			Collection<org.picketlink.idm.api.User> plusers = persistenceManager.findUser(identitySearchCriteria);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<org.picketlink.idm.api.User>(plusers);
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserPL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserPL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/main/org/jboss/forums/security/picketlink/UserPL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -5,26 +5,30 @@
 
 public class UserPL implements User {
 
+	private String id;
+	private String userName;
+
 	public UserPL(org.picketlink.idm.api.User user) {
-		
+		id = user.getId();
+		userName = user.getKey();
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getUserName() {
 		// TODO Auto-generated method stub
-		return null;
+		return userName;
 	}
 
 	@Override
 	public void updatePassword(String arg0) throws IdentityException {
 		// TODO Auto-generated method stub
-		
+
 	}
 
 	@Override

Modified: labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/resources/forums-authz-plugin.sar/META-INF/acl-permissions.xml
===================================================================
--- labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/resources/forums-authz-plugin.sar/META-INF/acl-permissions.xml	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/authz-jaae-plugin/src/resources/forums-authz-plugin.sar/META-INF/acl-permissions.xml	2013-05-24 19:47:25 UTC (rev 38331)
@@ -52,6 +52,23 @@
 		<!-- Moderator Tool permissions -->			
 	</role>
 	
+	<!-- just a regular registered user -->	
+	<role name="Users" id="users">
+		<!-- Forums Admin Tool permissions -->		
+		
+		<!-- Message Board permissions -->		
+		<permission action="readForum"/>
+		<permission action="post"/>
+		<!-- permission to edit only my own posts -->
+		<permission action="editPost">
+			<criteria for="editPost://ui">param[0].poster.user.userName.equals(identity.identity.userName)</criteria>
+			<criteria for="editPost://action">target.post.poster.user.userName.equals(identity.identity.userName)</criteria>
+		</permission>
+		
+		
+		<!-- Moderator Tool permissions -->			
+	</role>
+	
 	<!-- users with Admin privileges -->	
 	<role name="Admin" id="admin">
 		<!-- Forums Admin Tool permissions -->			
@@ -67,6 +84,21 @@
 		<permission action="all"/>		
 	</role>		
 	
+	<!-- users with Admin privileges -->	
+	<role name="Administrators" id="administrators">
+		<!-- Forums Admin Tool permissions -->			
+		
+		
+		<!-- Message Board permissions -->
+		
+		
+		
+		<!-- Moderator Tool permissions -->			
+		
+		<!-- wild card permission -->
+		<permission action="all"/>		
+	</role>		
+	
 	<!-- 
 		deployment specific roles......just examples of how fine grained permissions can be assigned
 		this is an example of how the rules would possibly setup for JBoss.org Forums...

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/RolePortal.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/RolePortal.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/RolePortal.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -4,28 +4,38 @@
 
 public class RolePortal implements Role {
 
+	private String displayName;
+	private Object id;
+	private String name;
+	
+	public RolePortal(Role group) {
+		displayName = group.getDisplayName();
+		id = group.getId();
+		name = group.getName();
+	}
+
 	@Override
 	public String getDisplayName() {
 		// TODO Auto-generated method stub
-		return null;
+		return displayName;
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getName() {
 		// TODO Auto-generated method stub
-		return null;
+		return name;
 	}
 
 	@Override
 	public void setDisplayName(String arg0) {
 		// TODO Auto-generated method stub
-		
+		this.displayName = arg0;
 	}
 
 }

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/UserPortal.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/UserPortal.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/jbportal/UserPortal.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -5,20 +5,24 @@
 
 public class UserPortal implements User {
 
+	private Object id;
+	private String userName;
+	
 	public UserPortal(User user) {
-		
+		id = user.getId();
+		userName = user.getUserName();
 	}
 	
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getUserName() {
 		// TODO Auto-generated method stub
-		return null;
+		return userName;
 	}
 
 	@Override

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/MembershipModulePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/MembershipModulePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/MembershipModulePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -1,5 +1,7 @@
 package org.jboss.portlet.forums.auth.picketlink;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 import javax.naming.InitialContext;
@@ -55,11 +57,15 @@
 	}
 
 	@Override
-	public Set findRoleMembers(String arg0, int arg1, int arg2, String arg3)
-			throws IdentityException, IllegalArgumentException {
+	public Set findRoleMembers(String arg0, int arg1, int arg2, String arg3) throws IdentityException, IllegalArgumentException {
 		Set roleMembers = null;
 		try {
-			relationshipManager.findRelatedGroups(arg0, "", null);
+			Collection<org.picketlink.idm.api.Group> groups = relationshipManager.findRelatedGroups(arg0, "", null);
+			if (groups != null && groups.size() > 0) {
+				roleMembers = new HashSet<RolePL>();
+				for (org.picketlink.idm.api.Group group : groups)
+					roleMembers.add(new RolePL(group));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -67,11 +73,15 @@
 	}
 
 	@Override
-	public Set getRoles(User arg0) throws IdentityException,
-			IllegalArgumentException {
+	public Set getRoles(User arg0) throws IdentityException, IllegalArgumentException {
 		Set roles = null;
 		try {
-			relationshipManager.findAssociatedGroups(arg0.getUserName(), null);
+			Collection<org.picketlink.idm.api.Group> groups = relationshipManager.findAssociatedGroups(arg0.getUserName(), null);
+			if (groups != null && groups.size() > 0) {
+				roles = new HashSet<RolePL>();
+				for (org.picketlink.idm.api.Group group : groups)
+					roles.add(new RolePL(group));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -79,11 +89,15 @@
 	}
 
 	@Override
-	public Set getUsers(Role arg0) throws IdentityException,
-			IllegalArgumentException {
+	public Set getUsers(Role arg0) throws IdentityException, IllegalArgumentException {
 		Set users = null;
 		try {
-			relationshipManager.findAssociatedUsers(arg0.getName(), true, null);
+			Collection<org.picketlink.idm.api.User> plusers = relationshipManager.findAssociatedUsers(arg0.getName(), true, null);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<UserPL>();
+				for (org.picketlink.idm.api.User user : plusers)
+					users.add(new UserPL(user));
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/RolePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/RolePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/RolePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -4,28 +4,38 @@
 
 public class RolePL implements Role {
 
+	private String displayName;
+	private Object id;
+	private String name;
+	
+	public RolePL(org.picketlink.idm.api.Group group) {
+		displayName = group.getName();
+		id = group.getKey();
+		name = group.getName();
+	}
+	
 	@Override
 	public String getDisplayName() {
 		// TODO Auto-generated method stub
-		return null;
+		return displayName;
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getName() {
 		// TODO Auto-generated method stub
-		return null;
+		return name;
 	}
 
 	@Override
 	public void setDisplayName(String arg0) {
 		// TODO Auto-generated method stub
-		
+		this.displayName = arg0;	
 	}
 
 }

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserModulePL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -1,5 +1,7 @@
 package org.jboss.portlet.forums.auth.picketlink;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 import javax.naming.InitialContext;
@@ -12,6 +14,8 @@
 import org.picketlink.idm.api.IdentitySession;
 import org.picketlink.idm.api.IdentitySessionFactory;
 import org.picketlink.idm.api.PersistenceManager;
+import org.picketlink.idm.api.UnsupportedCriterium;
+import org.picketlink.idm.impl.api.IdentitySearchCriteriaImpl;
 
 public class UserModulePL implements UserModule {
 
@@ -20,10 +24,8 @@
 	private static UserModule currentInstance;
 
 	private UserModulePL() throws Exception {
-		IdentitySessionFactory identitySessionFactory = (IdentitySessionFactory) new InitialContext()
-				.lookup("java:/IdentitySessionFactory");
-		IdentitySession identitySession = identitySessionFactory
-				.createIdentitySession("idm_realm");
+		IdentitySessionFactory identitySessionFactory = (IdentitySessionFactory) new InitialContext().lookup("java:/IdentitySessionFactory");
+		IdentitySession identitySession = identitySessionFactory.createIdentitySession("idm_realm");
 		persistenceManager = identitySession.getPersistenceManager();
 	}
 
@@ -35,8 +37,7 @@
 	}
 
 	@Override
-	public User createUser(String arg0, String arg1) throws IdentityException,
-			IllegalArgumentException {
+	public User createUser(String arg0, String arg1) throws IdentityException, IllegalArgumentException {
 		User user = null;
 		try {
 			user = new UserPL(persistenceManager.createUser(arg0));
@@ -47,8 +48,7 @@
 	}
 
 	@Override
-	public User findUserById(Object arg0) throws IdentityException,
-			IllegalArgumentException, NoSuchUserException {
+	public User findUserById(Object arg0) throws IdentityException, IllegalArgumentException, NoSuchUserException {
 		User user = null;
 		try {
 			user = new UserPL(persistenceManager.findUser((String) arg0));
@@ -59,8 +59,7 @@
 	}
 
 	@Override
-	public User findUserById(String arg0) throws IdentityException,
-			IllegalArgumentException, NoSuchUserException {
+	public User findUserById(String arg0) throws IdentityException, IllegalArgumentException, NoSuchUserException {
 		User user = null;
 		try {
 			user = new UserPL(persistenceManager.findUser(arg0));
@@ -71,15 +70,17 @@
 	}
 
 	@Override
-	public User findUserByUserName(String arg0) throws IdentityException,
-			IllegalArgumentException, NoSuchUserException {
-		IdentitySearchCriteria identitySearchCriteria = null;
+	public User findUserByUserName(String arg0) throws IdentityException, IllegalArgumentException, NoSuchUserException {
+		IdentitySearchCriteria identitySearchCriteria = new IdentitySearchCriteriaImpl();
 		User user = null;
 		try {
-			user = new UserPL((org.picketlink.idm.api.User) persistenceManager
-					.findUser(identitySearchCriteria).toArray()[0]);
+			identitySearchCriteria.nameFilter(arg0);
+			user = new UserPL((org.picketlink.idm.api.User) persistenceManager.findUser(identitySearchCriteria).toArray()[0]);
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
+		} catch (UnsupportedCriterium e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 		return user;
 	}
@@ -90,7 +91,10 @@
 		IdentitySearchCriteria identitySearchCriteria = null;
 		Set users = null;
 		try {
-			persistenceManager.findUser(identitySearchCriteria);
+			Collection<org.picketlink.idm.api.User> plusers = persistenceManager.findUser(identitySearchCriteria);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<org.picketlink.idm.api.User>(plusers);
+			}		
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -103,7 +107,10 @@
 		IdentitySearchCriteria identitySearchCriteria = null;
 		Set users = null;
 		try {
-			persistenceManager.findUser(identitySearchCriteria);
+			Collection<org.picketlink.idm.api.User> plusers = persistenceManager.findUser(identitySearchCriteria);
+			if (plusers != null && plusers.size() > 0) {
+				users = new HashSet<org.picketlink.idm.api.User>(plusers);
+			}
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}
@@ -111,8 +118,7 @@
 	}
 
 	@Override
-	public int getUserCount() throws IdentityException,
-			IllegalArgumentException {
+	public int getUserCount() throws IdentityException, IllegalArgumentException {
 		int count = 0;
 		try {
 			count = persistenceManager.getUserCount();
@@ -123,11 +129,9 @@
 	}
 
 	@Override
-	public void removeUser(Object arg0) throws IdentityException,
-			IllegalArgumentException {
+	public void removeUser(Object arg0) throws IdentityException, IllegalArgumentException {
 		try {
-			persistenceManager.removeUser(
-					persistenceManager.findUser((String) arg0), true);
+			persistenceManager.removeUser(persistenceManager.findUser((String) arg0), true);
 		} catch (org.picketlink.idm.common.exception.IdentityException ie) {
 			ie.printStackTrace();
 		}

Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserPL.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserPL.java	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/auth/picketlink/UserPL.java	2013-05-24 19:47:25 UTC (rev 38331)
@@ -5,20 +5,24 @@
 
 public class UserPL implements User {
 
+	private String id;
+	private String userName;
+	
 	public UserPL(org.picketlink.idm.api.User user) {
-		
+		id = user.getId();
+		userName = user.getKey();
 	}
 
 	@Override
 	public Object getId() {
 		// TODO Auto-generated method stub
-		return null;
+		return id;
 	}
 
 	@Override
 	public String getUserName() {
 		// TODO Auto-generated method stub
-		return null;
+		return userName;
 	}
 
 	@Override

Modified: labs/jbossforums/branches/forums130P27/readme.txt
===================================================================
--- labs/jbossforums/branches/forums130P27/readme.txt	2013-05-22 02:01:12 UTC (rev 38330)
+++ labs/jbossforums/branches/forums130P27/readme.txt	2013-05-24 19:47:25 UTC (rev 38331)
@@ -1,4 +1,7 @@
-Forums need picketlink as identity manager. To install it follow the steps:
+If you don't use jboss portal, Forums need picketlink as identity manager. To install it follow the steps:
 
-1- take thirdparty/picketlink/lib/*.jar and put in the lib directory of the application server. 
-In jboss 5/6 you are forced to put it in /server/$conf/lib
\ No newline at end of file
+1-  download picketlink from svn from http://anonsvn.jboss.org/repos/picketlink/idm/tags/1.1.5.CR01/
+2 - go in example/auth
+3 - modify the realm name in all codes. It must become from realm://JBossIdentity to idm_realm (JBoss Forums read it)  
+4 - launch mvn install
+5 - copy the file target/idm-example-auth.sar in the server/default/deploy directory of jboss
\ No newline at end of file



More information about the jboss-svn-commits mailing list