Author: julien(a)jboss.com
Date: 2007-02-07 10:25:12 -0500 (Wed, 07 Feb 2007)
New Revision: 6183
Added:
trunk/core/src/main/org/jboss/portal/core/identity/
trunk/core/src/main/org/jboss/portal/core/identity/DashboardBridge.java
trunk/core/src/main/org/jboss/portal/core/identity/SecurityBridge.java
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventManagerService.java
Removed:
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
Log:
JBPORTAL-1237 : delete user does not delete dashboard settings for the user
Added: trunk/core/src/main/org/jboss/portal/core/identity/DashboardBridge.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/identity/DashboardBridge.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/identity/DashboardBridge.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * 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.core.identity;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.event.IdentityEventListener;
+import org.jboss.portal.identity.event.IdentityEvent;
+import org.jboss.portal.identity.event.IdentityEventEmitter;
+import org.jboss.portal.identity.event.UserDestroyedEvent;
+import org.jboss.portal.core.model.CustomizationManager;
+
+/**
+ * Use identity destroy events to destroy corresponding dashboards.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DashboardBridge extends AbstractJBossService implements
IdentityEventListener
+{
+
+ /** . */
+ private IdentityEventEmitter identityEventEmitter;
+
+ /** . */
+ private CustomizationManager customizationManager;
+
+ public IdentityEventEmitter getIdentityEventEmitter()
+ {
+ return identityEventEmitter;
+ }
+
+ public void setIdentityEventEmitter(IdentityEventEmitter identityEventEmitter)
+ {
+ this.identityEventEmitter = identityEventEmitter;
+ }
+
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
+ protected void startService() throws Exception
+ {
+ identityEventEmitter.addListener(this);
+ }
+
+ protected void stopService() throws Exception
+ {
+ identityEventEmitter.removeListener(this);
+ }
+
+ public void onEvent(IdentityEvent event)
+ {
+ if (event instanceof UserDestroyedEvent)
+ {
+ UserDestroyedEvent destroyedEvent = (UserDestroyedEvent)event;
+
+ //
+ log.debug("User (userName=" + destroyedEvent.getUserName() +
",id=" + destroyedEvent.getUserId() +
+ " ) is destroyed, will destroy its dashboard");
+
+ //
+ customizationManager.destroyDashboard(destroyedEvent.getUserName());
+ }
+ }
+}
Added: trunk/core/src/main/org/jboss/portal/core/identity/SecurityBridge.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/identity/SecurityBridge.java
(rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/identity/SecurityBridge.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -0,0 +1,98 @@
+/******************************************************************************
+ * 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.core.identity;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.identity.event.IdentityEventListener;
+import org.jboss.portal.identity.event.IdentityEventEmitter;
+import org.jboss.portal.identity.event.IdentityEvent;
+import org.jboss.portal.identity.event.UserDestroyedEvent;
+import org.jboss.security.auth.login.DynamicLoginConfigMBean;
+
+/**
+ * Use identity destroy events to destroy corresponding dashboards.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SecurityBridge extends AbstractJBossService implements
IdentityEventListener
+{
+
+ /** . */
+ private IdentityEventEmitter identityEventEmitter;
+
+ /** . */
+ private DynamicLoginConfigMBean dynamicLoginConfig;
+
+ public IdentityEventEmitter getIdentityEventEmitter()
+ {
+ return identityEventEmitter;
+ }
+
+ public void setIdentityEventEmitter(IdentityEventEmitter identityEventEmitter)
+ {
+ this.identityEventEmitter = identityEventEmitter;
+ }
+
+ public DynamicLoginConfigMBean getDynamicLoginConfig()
+ {
+ return dynamicLoginConfig;
+ }
+
+ public void setDynamicLoginConfig(DynamicLoginConfigMBean dynamicLoginConfig)
+ {
+ this.dynamicLoginConfig = dynamicLoginConfig;
+ }
+
+ protected void startService() throws Exception
+ {
+ identityEventEmitter.addListener(this);
+ }
+
+ protected void stopService() throws Exception
+ {
+ identityEventEmitter.removeListener(this);
+ }
+
+ public void onEvent(IdentityEvent event)
+ {
+ if (event instanceof UserDestroyedEvent)
+ {
+ final UserDestroyedEvent destroyedEvent = (UserDestroyedEvent)event;
+
+ //
+ log.debug("User (userName=" + destroyedEvent.getUserName() +
",id=" + destroyedEvent.getUserId() +
+ " ) is destroyed, will invalidate security manager cache instead
");
+
+ //
+ try
+ {
+ dynamicLoginConfig.flushAuthenticationCaches();
+ }
+ catch (Exception e)
+ {
+ log.warn("Error while flushing authentication cache", e);
+ }
+ }
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-02-07
13:46:53 UTC (rev 6182)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -34,6 +34,7 @@
import org.jboss.portal.core.model.portal.DuplicatePortalObjectException;
import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
+import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
import org.jboss.portal.core.impl.model.content.portlet.PortletContent;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -274,6 +275,19 @@
return dashboardPortal;
}
+ public void destroyDashboard(String userId)
+ {
+ try
+ {
+ PortalContainer dashboardContext =
(PortalContainer)portalObjectContainer.getObject(dashboardContextObjectId);
+ dashboardContext.destroyChild(userId);
+ }
+ catch (NoSuchPortalObjectException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
private String getUserId(User user)
{
return user.getUserName();
Modified: trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-02-07
13:46:53 UTC (rev 6182)
+++ trunk/core/src/main/org/jboss/portal/core/model/CustomizationManager.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -72,4 +72,9 @@
* @return
*/
boolean isDashboard(PortalObject object, User user);
+
+ /**
+ * @param userId
+ */
+ void destroyDashboard(String userId);
}
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 2007-02-07
13:46:53 UTC (rev 6182)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-02-07
15:25:12 UTC (rev 6183)
@@ -439,13 +439,22 @@
<!--Identity-->
<mbean
+ code="org.jboss.portal.identity.service.IdentityEventManagerService"
+ name="portal:service=IdentityEventManager"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <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>-->
+ <depends
+ optional-attribute-name="IdentityEventBroadcaster"
+
proxy-type="attribute">portal:service=IdentityEventManager</depends>
<attribute
name="JndiName">java:/portal/IdentityServiceController</attribute>
<attribute name="RegisterMBeans">true</attribute>
<attribute
name="ConfigFile">conf/identity/identity-config.xml</attribute>
@@ -584,6 +593,34 @@
<attribute name="DashboardContextId">dashboard</attribute>
</mbean>
+ <!-- Integrate identity -->
+ <mbean
+ code="org.jboss.portal.core.identity.DashboardBridge"
+ name="portal:service=IdentityDashboardBridge"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="IdentityEventEmitter"
+
proxy-type="attribute">portal:service=IdentityEventManager</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+
proxy-type="attribute">portal:service=CustomizationManager</depends>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.identity.SecurityBridge"
+ name="portal:service=IdentitySecurityBridge"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="IdentityEventEmitter"
+
proxy-type="attribute">portal:service=IdentityEventManager</depends>
+ <depends
+ optional-attribute-name="DynamicLoginConfig"
+
proxy-type="attribute">portal:service=JAASLoginModule</depends>
+ </mbean>
+
<!-- Command factories -->
<mbean
code="org.jboss.portal.core.controller.command.mapper.DelegatingCommandFactoryService"
Modified:
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-02-07
13:46:53 UTC (rev 6182)
+++
trunk/identity/src/main/org/jboss/portal/identity/IdentityServiceControllerImpl.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -29,6 +29,7 @@
import org.jboss.portal.identity.IdentityContextImpl;
import org.jboss.portal.identity.IdentityServiceController;
import org.jboss.portal.identity.event.IdentityEventBroadcaster;
+import org.jboss.portal.identity.event.IdentityEvent;
import org.jboss.portal.identity.config.metadata.IdentityConfigurationMetaData;
import org.jboss.portal.identity.config.metadata.ModuleMetaData;
import org.jboss.portal.identity.config.metadata.ConfigOptionMetaData;
@@ -39,7 +40,6 @@
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.portal.identity.service.IdentityEventService;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
@@ -84,6 +84,8 @@
*/
protected List beans;
+
+
protected void startService() throws Exception
{
if (jndiName != null)
@@ -130,20 +132,24 @@
}
- //IdentityEventBroadcaster
- IdentityEventBroadcaster broadcaster = null;
- try
+ // IdentityEventBroadcaster
+ IdentityEventBroadcaster broadcaster = identityEventBroadcaster;
+ if(broadcaster == null)
{
- broadcaster = instantiateIdentityEventBroadcaster();
- if(broadcaster != null)
+ broadcaster = new IdentityEventBroadcaster()
{
- identityContext.register(broadcaster,
IdentityContext.TYPE_IDENTITY_EVENT_BROADCASTER);
- }
- else
- {
- throw new NullPointerException();
- }
+ public void fireEvent(IdentityEvent event)
+ {
+ // Noop
+ }
+ };
}
+
+ //
+ try
+ {
+ identityContext.register(broadcaster,
IdentityContext.TYPE_IDENTITY_EVENT_BROADCASTER);
+ }
catch (Throwable throwable)
{
throw new IdentityException("Unable to install
IdentityEventBroadcaster", throwable);
@@ -550,18 +556,6 @@
}
- /**
- * Instantiates IdentityEventBroadcaster and register proper events in it
- * @return
- */
- private IdentityEventBroadcaster instantiateIdentityEventBroadcaster()
- {
- return new IdentityEventService();
- }
-
-
-
-
public IdentityContext getIdentityContext()
{
return identityContext;
Modified: trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2007-02-07
13:46:53 UTC (rev 6182)
+++ trunk/identity/src/main/org/jboss/portal/identity/auth/UserPrincipal.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -52,4 +52,23 @@
{
return "PortalPrincipal[" + name + "]";
}
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Principal)
+ {
+ Principal that = (Principal)o;
+ return name.equals(that.getName());
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
}
Copied:
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventManagerService.java
(from rev 6182,
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java)
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventManagerService.java
(rev 0)
+++
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventManagerService.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.event.IdentityEventBroadcaster;
+import org.jboss.portal.identity.event.IdentityEventListener;
+import org.jboss.portal.identity.event.IdentityEvent;
+import org.jboss.portal.identity.event.IdentityEventEmitter;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityEventManagerService extends AbstractJBossService implements
IdentityEventBroadcaster, IdentityEventEmitter
+{
+
+ /** . */
+ private final CopyOnWriteRegistry listeners;
+
+ public IdentityEventManagerService()
+ {
+ listeners = new CopyOnWriteRegistry();
+ }
+
+ public void addListener(IdentityEventListener listener)
+ {
+ listeners.register(listener, listener);
+ }
+
+ public void removeListener(IdentityEventListener listener)
+ {
+ listeners.unregister(listener);
+ }
+
+ public void fireEvent(IdentityEvent event)
+ {
+ for (Iterator i = listeners.getRegistrations().iterator();i.hasNext();)
+ {
+ IdentityEventListener listener = (IdentityEventListener)i.next();
+ try
+ {
+ listener.onEvent(event);
+ }
+ catch (Exception e)
+ {
+ log.error("Listener " + listener + " threw an exception during
event firing " + event, e);
+ }
+ }
+ }
+}
Deleted:
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java
===================================================================
---
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java 2007-02-07
13:46:53 UTC (rev 6182)
+++
trunk/identity/src/main/org/jboss/portal/identity/service/IdentityEventService.java 2007-02-07
15:25:12 UTC (rev 6183)
@@ -1,74 +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.identity.service;
-
-import org.jboss.portal.identity.event.IdentityEventBroadcaster;
-import org.jboss.portal.identity.event.IdentityEventListener;
-import org.jboss.portal.identity.event.IdentityEvent;
-import org.jboss.portal.identity.event.IdentityEventEmitter;
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class IdentityEventService extends AbstractJBossService implements
IdentityEventBroadcaster, IdentityEventEmitter
-{
-
- /** . */
- private final CopyOnWriteRegistry listeners;
-
- public IdentityEventService()
- {
- listeners = new CopyOnWriteRegistry();
- }
-
- public void addListener(IdentityEventListener listener)
- {
- listeners.register(listener, listener);
- }
-
- public void removeListener(IdentityEventListener listener)
- {
- listeners.unregister(listener);
- }
-
- public void fireEvent(IdentityEvent event)
- {
- for (Iterator i = listeners.getRegistrations().iterator();i.hasNext();)
- {
- IdentityEventListener listener = (IdentityEventListener)i.next();
- try
- {
- listener.onEvent(event);
- }
- catch (Exception e)
- {
- log.error("Listener " + listener + " threw an exception during
event firing " + event, e);
- }
- }
- }
-}