Author: sohil.shah(a)jboss.com
Date: 2009-08-08 15:40:48 -0400 (Sat, 08 Aug 2009)
New Revision: 13705
Added:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/LocalEventObserver.java
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEventingSystem.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/Event.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventBus.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventObserver.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/HotDeployEvent.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/LocalEventBus.java
Modified:
modules/authorization/trunk/.project
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/enforcement/EnforcementCache.java
modules/authorization/trunk/agent/src/main/resources/META-INF/authz-config.xml
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/features/TestPolicyUpdating.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java
modules/authorization/trunk/policy-server/src/main/resources/META-INF/authz-config.xml
Log:
Policy Hot Deployment implementation
* EnforcementCache Invalidation implemented
Modified: modules/authorization/trunk/.project
===================================================================
--- modules/authorization/trunk/.project 2009-08-08 15:36:17 UTC (rev 13704)
+++ modules/authorization/trunk/.project 2009-08-08 19:40:48 UTC (rev 13705)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>module-authorization</name>
+ <name>jboss-authz-trunk</name>
<comment></comment>
<projects>
</projects>
@@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>net.sourceforge.metrics.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>net.sourceforge.metrics.nature</nature>
</natures>
</projectDescription>
Modified:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/enforcement/EnforcementCache.java
===================================================================
---
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/enforcement/EnforcementCache.java 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/enforcement/EnforcementCache.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -75,7 +75,11 @@
enforcementResponse.setAttribute(EnforcementResponse.CACHED, new Date());
}
- //TODO: Add Cache Invalidation Operations
+ //Add Cache Invalidation Operations
+ public void clear()
+ {
+ this.responseCache.clear();
+ }
//---------------------------------------------------------------------------------------------------------------------------------------------
private Integer getCacheEntryKey(EnforcementContext enforcementContext)
{
Added:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/LocalEventObserver.java
===================================================================
---
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/LocalEventObserver.java
(rev 0)
+++
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/LocalEventObserver.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -0,0 +1,95 @@
+/*
+* 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.security.authz.agent.services;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.security.authz.tools.GeneralTool;
+
+import org.jboss.security.authz.agent.enforcement.EnforcementCache;
+
+import org.jboss.security.authz.policy.server.event.EventBus;
+import org.jboss.security.authz.policy.server.event.EventObserver;
+import org.jboss.security.authz.policy.server.event.Event;
+import org.jboss.security.authz.policy.server.event.HotDeployEvent;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class LocalEventObserver implements EventObserver
+{
+ private static Logger log = Logger.getLogger(LocalEventObserver.class);
+
+ private String id;
+ private EventBus eventBus;
+ private EnforcementCache enforcementCache;
+
+ public LocalEventObserver()
+ {
+ }
+
+ public void start()
+ {
+ this.id = GeneralTool.generateUniqueId();
+ this.eventBus.subscribe(this);
+ }
+
+ public void stop()
+ {
+ this.eventBus.unsubscribe(this);
+ }
+
+ public EventBus getEventBus()
+ {
+ return eventBus;
+ }
+
+ public void setEventBus(EventBus eventBus)
+ {
+ this.eventBus = eventBus;
+ }
+
+ public EnforcementCache getEnforcementCache()
+ {
+ return enforcementCache;
+ }
+
+ public void setEnforcementCache(EnforcementCache enforcementCache)
+ {
+ this.enforcementCache = enforcementCache;
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------
+ public void accept(Event event)
+ {
+ if(event instanceof HotDeployEvent)
+ {
+ this.enforcementCache.clear();
+ }
+ }
+
+ public String getId()
+ {
+ return this.id;
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------
+
+}
Modified: modules/authorization/trunk/agent/src/main/resources/META-INF/authz-config.xml
===================================================================
---
modules/authorization/trunk/agent/src/main/resources/META-INF/authz-config.xml 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/agent/src/main/resources/META-INF/authz-config.xml 2009-08-08
19:40:48 UTC (rev 13705)
@@ -9,6 +9,15 @@
<bean name="/agent/EnforcementStateGenerator"
class="org.jboss.security.authz.agent.services.EnforcementStateGenerator">
</bean>
+ <bean name="/agent/ServerEventObserver"
class="org.jboss.security.authz.agent.services.LocalEventObserver">
+ <property name="eventBus">
+ <inject bean="/policy-server/EventBus"/>
+ </property>
+ <property name="enforcementCache">
+ <inject bean="/agent/EnforcementCache"/>
+ </property>
+ </bean>
+
<bean name="/agent/EnforcementCache"
class="org.jboss.security.authz.agent.enforcement.EnforcementCache">
</bean>
Modified:
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/features/TestPolicyUpdating.java
===================================================================
---
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/features/TestPolicyUpdating.java 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/features/TestPolicyUpdating.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -92,9 +92,8 @@
this.assertServerState();
//Enforce and make sure new Rules apply
- //TODO: Remove This when Cache Invalidations are implemented!!!
- EnforcementContext enforcementContext = this.createEnforcementContext(contextResource,
action);
- enforcementContext.setIgnoreCache(true);
+ //EnforcementCache must also get invalidated........
+ EnforcementContext enforcementContext = this.createEnforcementContext(contextResource,
action);
this.enforce(enforcementContext, false);
}
@@ -148,9 +147,8 @@
this.assertServerState();
//Enforce and make sure new Rules apply
- //TODO: Remove This when Cache Invalidations are implemented!!!
- EnforcementContext enforcementContext = this.createEnforcementContext(contextResource,
action);
- enforcementContext.setIgnoreCache(true);
+ //EnforcementCache must also get invalidated........
+ EnforcementContext enforcementContext = this.createEnforcementContext(contextResource,
action);
this.enforce(enforcementContext, false);
}
//
------------------------------------------------------------------------------------------------------------------------------------------------------
Added:
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEventingSystem.java
===================================================================
---
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEventingSystem.java
(rev 0)
+++
modules/authorization/trunk/agent/src/test/java/org/jboss/security/authz/agent/services/TestEventingSystem.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -0,0 +1,49 @@
+/*
+* 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.security.authz.agent.services;
+
+import junit.framework.TestCase;
+
+import org.jboss.security.authz.bootstrap.ServiceContainer;
+
+import org.jboss.security.authz.policy.server.event.EventBus;
+import org.jboss.security.authz.policy.server.event.HotDeployEvent;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class TestEventingSystem extends TestCase
+{
+ private EventBus eventBus;
+
+ protected void setUp() throws Exception
+ {
+ ServiceContainer.bootstrap();
+ this.eventBus =
(EventBus)ServiceContainer.lookup("/policy-server/EventBus");
+ }
+ //---------------------------------------------------------------------------------------------------------------------------------------------------------------
+ public void testHotDeployEvent() throws Exception
+ {
+ HotDeployEvent event = new HotDeployEvent("policyUri://blahblah");
+ this.eventBus.deliver(event);
+ }
+}
Modified:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/PolicyServer.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -37,6 +37,7 @@
import org.jboss.security.authz.policy.server.spi.PolicyStore;
import org.jboss.security.authz.policy.server.plugin.EnterprisePolicyFinderModule;
import org.jboss.security.authz.policy.server.plugin.DroolsRuleManager;
+import org.jboss.security.authz.policy.server.event.EventBus;
import org.jboss.security.xacml.sunxacml.finder.PolicyFinderModule;
@@ -53,6 +54,7 @@
private PolicyStore policyStore;
private EnterprisePolicyFinderModule policyFinderModule;
private DroolsRuleManager ruleManager;
+ private EventBus eventBus;
public PolicyServer()
{
@@ -72,6 +74,7 @@
this.policyFinderModule = (EnterprisePolicyFinderModule) module;
this.policyFinderModule.setPolicyStore(this.policyStore);
this.policyFinderModule.setRuleManager(this.ruleManager);
+ this.policyFinderModule.setEventBus(this.eventBus);
this.policyFinderModule.bootup();
}
}
@@ -116,7 +119,16 @@
{
this.ruleManager = ruleManager;
}
+
+ public EventBus getEventBus()
+ {
+ return eventBus;
+ }
+ public void setEventBus(EventBus eventBus)
+ {
+ this.eventBus = eventBus;
+ }
// --------Enforcement Phase
//
services--------------------------------------------------------------------------------------------------------------------------
/**
@@ -173,6 +185,7 @@
{
// Update an existing Policy
this.policyFinderModule.updatePolicy(policy, policyMetaData);
+
}
}
@@ -186,7 +199,7 @@
{
try
{
- this.policyFinderModule.deletePolicy(this.policyStore.readPolicy(policyUri));
+ this.policyFinderModule.deletePolicy(this.policyStore.readPolicy(policyUri), true);
}
catch (PolicyException pe)
{
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/Event.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/Event.java
(rev 0)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/Event.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -0,0 +1,40 @@
+/*
+* 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.security.authz.policy.server.event;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public abstract class Event implements Serializable
+{
+ private static final long serialVersionUID = -1523445160945618953L;
+
+ private Date timestamp;
+
+ public Date getTimestamp()
+ {
+ return timestamp;
+ }
+}
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventBus.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventBus.java
(rev 0)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventBus.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -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.security.authz.policy.server.event;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public interface EventBus
+{
+ public void subscribe(EventObserver observer);
+ public void unsubscribe(EventObserver observer);
+ public void deliver(Event event);
+}
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventObserver.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventObserver.java
(rev 0)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/EventObserver.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -0,0 +1,31 @@
+/*
+* 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.security.authz.policy.server.event;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public interface EventObserver
+{
+ public String getId();
+ public void accept(Event event);
+}
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/HotDeployEvent.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/HotDeployEvent.java
(rev 0)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/HotDeployEvent.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -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.security.authz.policy.server.event;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class HotDeployEvent extends Event
+{
+ private static final long serialVersionUID = 8832241139903871033L;
+
+ private String policyUri;
+
+ public HotDeployEvent(String policyUri)
+ {
+
+ }
+
+ public String getPolicyUri()
+ {
+ return policyUri;
+ }
+}
Added:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/LocalEventBus.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/LocalEventBus.java
(rev 0)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/event/LocalEventBus.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -0,0 +1,86 @@
+/*
+* 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.security.authz.policy.server.event;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class LocalEventBus implements EventBus
+{
+ private static Logger log = Logger.getLogger(LocalEventBus.class);
+
+ private Map<String, EventObserver> registry;
+
+ public LocalEventBus()
+ {
+
+ }
+
+ public void start()
+ {
+ this.registry = new HashMap<String, EventObserver>();
+ }
+
+ public void stop()
+ {
+ this.registry = null;
+ }
+ //----------------------------------------------------------------------------------------------------------------------------------------
+ public void deliver(Event event)
+ {
+ Collection<EventObserver> observers = this.registry.values();
+ if(observers != null)
+ {
+ for(EventObserver observer: observers)
+ {
+ observer.accept(event);
+ }
+ }
+ }
+
+ public void subscribe(EventObserver observer)
+ {
+ if(observer == null || observer.getId() == null || observer.getId().trim().length() ==
0)
+ {
+ new IllegalArgumentException("Observer or its Id Cannot be Null");
+ }
+
+ registry.put(observer.getId(), observer);
+ }
+
+ public void unsubscribe(EventObserver observer)
+ {
+ if(observer == null || observer.getId() == null || observer.getId().trim().length() ==
0)
+ {
+ //Ignore......No State Changes occur...No Harm No Foul...let things flow.....
+ return;
+ }
+
+ registry.remove(observer.getId());
+ }
+}
Modified:
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java
===================================================================
---
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/policy-server/src/main/java/org/jboss/security/authz/policy/server/plugin/EnterprisePolicyFinderModule.java 2009-08-08
19:40:48 UTC (rev 13705)
@@ -34,10 +34,11 @@
import org.jboss.security.authz.model.PolicyException;
import org.jboss.security.authz.model.Rule;
import org.jboss.security.authz.model.Expression;
-import org.jboss.security.authz.model.DroolsRuleExpression;
+import org.jboss.security.authz.policy.server.event.EventBus;
import org.jboss.security.authz.policy.server.spi.PolicyStore;
import org.jboss.security.authz.policy.server.PolicyServerException;
import org.jboss.security.authz.tools.GeneralTool;
+import org.jboss.security.authz.policy.server.event.HotDeployEvent;
import org.jboss.security.xacml.sunxacml.EvaluationCtx;
import org.jboss.security.xacml.sunxacml.finder.PolicyFinder;
@@ -75,6 +76,7 @@
private PolicyReader reader;
private PolicyStore policyStore;
private DroolsRuleManager ruleManager;
+ private EventBus eventBus;
private DynamicPolicyCollection policies;
@@ -102,6 +104,16 @@
{
this.ruleManager = ruleManager;
}
+
+ public EventBus getEventBus()
+ {
+ return eventBus;
+ }
+
+ public void setEventBus(EventBus eventBus)
+ {
+ this.eventBus = eventBus;
+ }
// -----------PolicyFinderModule
//
Implementation------------------------------------------------------------------------------------------------------------
/**
@@ -230,14 +242,17 @@
public void updatePolicy(Policy oldPolicy, PolicyMetaData newPolicy) throws
PolicyServerException
{
- this.deletePolicy(oldPolicy);
+ this.deletePolicy(oldPolicy, false);
//TODO: This hot deployment should be done out-of-band
//and new policy should then be deployed into the rule engine
this.newPolicy(newPolicy);
+
+ HotDeployEvent hotDeployEvent = new HotDeployEvent(oldPolicy.getPolicyUri());
+ this.eventBus.deliver(hotDeployEvent);
}
- public void deletePolicy(Policy policy) throws PolicyServerException
+ public void deletePolicy(Policy policy, boolean mustHotDeploy) throws
PolicyServerException
{
try
{
@@ -265,6 +280,12 @@
//Delete this Policy from the Policy Store
this.policyStore.deletePolicy(policy.getPolicyUri());
+
+ if(mustHotDeploy)
+ {
+ HotDeployEvent hotDeployEvent = new HotDeployEvent(policy.getPolicyUri());
+ this.eventBus.deliver(hotDeployEvent);
+ }
}
}
catch (PolicyException pe)
Modified:
modules/authorization/trunk/policy-server/src/main/resources/META-INF/authz-config.xml
===================================================================
---
modules/authorization/trunk/policy-server/src/main/resources/META-INF/authz-config.xml 2009-08-08
15:36:17 UTC (rev 13704)
+++
modules/authorization/trunk/policy-server/src/main/resources/META-INF/authz-config.xml 2009-08-08
19:40:48 UTC (rev 13705)
@@ -13,6 +13,9 @@
<property name="ruleManager">
<inject bean="/policy-server/DroolsRuleManager"/>
</property>
+ <property name="eventBus">
+ <inject bean="/policy-server/EventBus"/>
+ </property>
</bean>
<bean name="/policy-server/PolicyDecisionPoint"
class="org.jboss.security.authz.policy.server.decision.PolicyDecisionPoint">
@@ -29,8 +32,11 @@
<property name="hibernateService">
<inject bean="/policy-server/HibernateService"/>
</property>
+ </bean>
+
+ <bean name="/policy-server/HibernateService"
class="org.jboss.security.authz.policy.server.tools.HibernateService">
</bean>
- <bean name="/policy-server/HibernateService"
class="org.jboss.security.authz.policy.server.tools.HibernateService">
+ <bean name="/policy-server/EventBus"
class="org.jboss.security.authz.policy.server.event.LocalEventBus">
</bean>
</deployment>
\ No newline at end of file