org.apache.felix.eventadmin.impl.security
Class EventAdminSecurityDecorator

java.lang.Object
  extended by org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator
All Implemented Interfaces:
org.osgi.service.event.EventAdmin

public class EventAdminSecurityDecorator
extends java.lang.Object
implements org.osgi.service.event.EventAdmin

This class is a decorator for an EventAdmin service. It secures the service by checking any call from a given bundle (i.e., the caller) to the admins post or send methods for the appropriate permissions based on a given permission factory. This methods then in turn throw a SecurityException in case the given bundle doesn't pass the check or delegate the call to decorated service instance, respectively.

Author:
Felix Project Team

Constructor Summary
EventAdminSecurityDecorator(org.osgi.framework.Bundle bundle, org.osgi.service.event.EventAdmin admin, TopicPermissions topicPermissions)
          The constructor of this decorator.
 
Method Summary
 boolean equals(java.lang.Object o)
          Overrides equals() and delegates the call to the decorated service instance.
 int hashCode()
          Overrides hashCode() and returns the hash code of the decorated service instance.
 void postEvent(org.osgi.service.event.Event event)
          This method checks whether the given (i.e., calling) bundle has appropriate permissions to post an event to the targeted topic.
 void sendEvent(org.osgi.service.event.Event event)
          This method checks whether the given (i.e., calling) bundle has appropriate permissions to send an event to the targeted topic.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventAdminSecurityDecorator

public EventAdminSecurityDecorator(org.osgi.framework.Bundle bundle,
                                   org.osgi.service.event.EventAdmin admin,
                                   TopicPermissions topicPermissions)
The constructor of this decorator. The given bundle and permission factory will be used to determine appropriate permissions for any call to postEvent() or sendEvent(), respectively. This method then in turn throw a SecurityException in case the given bundle doesn't pass the check.

Parameters:
bundle - The calling bundle used to determine appropriate permissions
admin - The decorated service instance
topicPermissions - The permission factory
Method Detail

postEvent

public void postEvent(org.osgi.service.event.Event event)
This method checks whether the given (i.e., calling) bundle has appropriate permissions to post an event to the targeted topic. A SecurityException is thrown in case it has not. Otherwise, the event is posted using this decorator's service instance.

Specified by:
postEvent in interface org.osgi.service.event.EventAdmin
Parameters:
event - The event that should be posted
See Also:
EventAdmin.postEvent(org.osgi.service.event.Event)

sendEvent

public void sendEvent(org.osgi.service.event.Event event)
This method checks whether the given (i.e., calling) bundle has appropriate permissions to send an event to the targeted topic. A SecurityException is thrown in case it has not. Otherwise, the event is posted using this decorator's service instance.

Specified by:
sendEvent in interface org.osgi.service.event.EventAdmin
Parameters:
event - The event that should be send
See Also:
EventAdmin.sendEvent(org.osgi.service.event.Event)

hashCode

public int hashCode()
Overrides hashCode() and returns the hash code of the decorated service instance.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code of the decorated service instance
See Also:
Object.hashCode(), EventAdmin

equals

public boolean equals(java.lang.Object o)
Overrides equals() and delegates the call to the decorated service instance. In case that o is an instance of this class it passes o's service instance instead of o.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare with this decorator's service instance
See Also:
Object.equals(java.lang.Object), EventAdmin