Author: shane.bryzak(a)jboss.com
Date: 2010-07-16 02:29:33 -0400 (Fri, 16 Jul 2010)
New Revision: 13411
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
take identityType into account for queries
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-16
03:36:40 UTC (rev 13410)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManagerImpl.java 2010-07-16
06:29:33 UTC (rev 13411)
@@ -16,6 +16,7 @@
import org.jboss.seam.transaction.Transactional;
import org.picketlink.idm.api.Credential;
import org.picketlink.idm.api.Group;
+import org.picketlink.idm.api.IdentitySearchCriteria;
import org.picketlink.idm.api.IdentitySession;
import org.picketlink.idm.api.Role;
import org.picketlink.idm.api.RoleType;
@@ -230,17 +231,14 @@
public Collection<User> findUsers(String filter)
{
- identity.checkPermission(RESOURCE_IDENTITY, PERMISSION_READ);
- UserQueryBuilder builder = identitySession.createUserQueryBuilder();
- UserQuery userQuery = builder.createQuery();
-
+ IdentitySearchCriteria criteria = new IdentitySearchCriteriaImpl();
try
{
- return identitySession.execute(userQuery);
+ return identitySession.getPersistenceManager().findUser(criteria);
}
- catch (QueryException ex)
+ catch (IdentityException e)
{
- throw new RuntimeException("Error querying users", ex);
+ throw new RuntimeException(e);
}
}
Modified:
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
---
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-16
03:36:40 UTC (rev 13410)
+++
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-07-16
06:29:33 UTC (rev 13411)
@@ -1272,11 +1272,19 @@
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<?> criteria = builder.createQuery(identityClass);
- criteria.from(identityClass);
+ Root<?> root = criteria.from(identityClass);
Property<?> identityNameProp = modelProperties.get(PROPERTY_IDENTITY_NAME);
+ Property<?> identityTypeProp = modelProperties.get(PROPERTY_IDENTITY_TYPE);
List<Predicate> predicates = new ArrayList<Predicate>();
+
+ if (identityType != null)
+ {
+ predicates.add(builder.equal(root.get(identityTypeProp.getName()),
+ lookupIdentityType(identityType.getName(), em)));
+ }
+
criteria.where(predicates.toArray(new Predicate[0]));
List<?> results = em.createQuery(criteria).getResultList();
Show replies by date