Author: chris.laprun(a)jboss.com
Date: 2009-05-16 16:58:53 -0400 (Sat, 16 May 2009)
New Revision: 13384
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/CachedLDAPRoleModuleWrapper.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/IdentityCacheService.java
Log:
- Updated for changes in identity API.
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/CachedLDAPRoleModuleWrapper.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/CachedLDAPRoleModuleWrapper.java 2009-05-16
20:54:29 UTC (rev 13383)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/CachedLDAPRoleModuleWrapper.java 2009-05-16
20:58:53 UTC (rev 13384)
@@ -1,38 +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.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.core.identity.cache;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.Role;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.ldap.LDAPRoleImpl;
import org.jboss.portal.identity.ldap.LDAPRoleModule;
-import org.jboss.portal.identity.ldap.LDAPRoleImpl;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.Role;
-import org.jboss.portal.identity.IdentityException;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
-import java.util.List;
-import java.util.HashSet;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
@@ -62,6 +63,18 @@
return ldapRoleModule.findRoleByName(name);
}
+ public Role findRoleByDisplayName(String displayName) throws IdentityException,
IllegalArgumentException
+ {
+ Role role = cacheService.findRoleByDisplayName(displayName);
+
+ if (role != null)
+ {
+ return role;
+ }
+
+ return ldapRoleModule.findRoleByDisplayName(displayName);
+ }
+
public Set findRolesByNames(String[] names) throws IdentityException,
IllegalArgumentException
{
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/IdentityCacheService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/IdentityCacheService.java 2009-05-16
20:54:29 UTC (rev 13383)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/identity/cache/IdentityCacheService.java 2009-05-16
20:58:53 UTC (rev 13384)
@@ -1,24 +1,25 @@
-/*
-* 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.
-*/
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, 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.core.identity.cache;
@@ -46,6 +47,8 @@
protected ThreadLocal<Map<String, Role>> roleNameCache = new
ThreadLocal<Map<String, Role>>();
+ protected ThreadLocal<Map<String, Role>> roleDisplayNameCache = new
ThreadLocal<Map<String, Role>>();
+
protected ThreadLocal<Map<Object, Role>> roleIdCache = new
ThreadLocal<Map<Object, Role>>();
@@ -55,6 +58,7 @@
userIdCache.set(null);
profileCache.set(null);
roleNameCache.set(null);
+ roleDisplayNameCache.set(null);
roleIdCache.set(null);
log.debug("Identity cache invalidated");
@@ -96,6 +100,15 @@
return roleNameCache.get();
}
+ private Map<String, Role> getRoleDisplayNameCache()
+ {
+ if (roleDisplayNameCache.get() == null)
+ {
+ roleDisplayNameCache.set(new HashMap<String, Role>());
+ }
+ return roleDisplayNameCache.get();
+ }
+
private Map<Object, Role> getRoleIdCache()
{
if (roleIdCache.get() == null)
@@ -171,10 +184,11 @@
{
getRoleIdCache().put(role.getId(), role);
getRoleNameCache().put(role.getName(), role);
+ getRoleDisplayNameCache().put(role.getDisplayName(), role);
if (log.isDebugEnabled())
{
- log.debug("Role cached for id=" + role.getId() + ";
name=" + role.getName());
+ log.debug("Role cached for id=" + role.getId() + ";
name=" + role.getName() + "; display name=" + role.getDisplayName());
}
}
}
@@ -186,10 +200,11 @@
{
getRoleIdCache().put(role.getId(), null);
getRoleNameCache().put(role.getName(), null);
+ getRoleDisplayNameCache().put(role.getDisplayName(), null);
if (log.isDebugEnabled())
{
- log.debug("Role invalidated in cache for id=" + role.getId() +
"; name=" + role.getName());
+ log.debug("Role invalidated in cache for id=" + role.getId() +
"; name=" + role.getName() + "; display name=" +
role.getDisplayName());
}
}
}
@@ -242,6 +257,18 @@
return role;
}
+ public Role findRoleByDisplayName(String displayName)
+ {
+ Role role = getRoleDisplayNameCache().get(displayName);
+
+ if (role != null && log.isDebugEnabled())
+ {
+ log.debug("Role retrieved from cache for display name=" +
role.getDisplayName());
+ }
+
+ return role;
+ }
+
public Role findRoleById(Object id)
{
Role role = getRoleIdCache().get(id);