Class EventAdminSecurityDecorator
java.lang.Object
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
Constructors Constructor Description EventAdminSecurityDecorator(org.osgi.framework.Bundle bundle, org.osgi.service.event.EventAdmin admin)The constructor of this decorator. -
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object o)Overridesequals()and delegates the call to the decorated service instance.inthashCode()OverrideshashCode()and returns the hash code of the decorated service instance.voidpostEvent(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.voidsendEvent(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.
-
Constructor Details
-
EventAdminSecurityDecorator
public EventAdminSecurityDecorator(org.osgi.framework.Bundle bundle, org.osgi.service.event.EventAdmin admin)The constructor of this decorator. The given bundle and permission factory will be used to determine appropriate permissions for any call topostEvent()orsendEvent(), respectively. This method then in turn throw aSecurityExceptionin case the given bundle doesn't pass the check.- Parameters:
bundle- The calling bundle used to determine appropriate permissionsadmin- The decorated service instance
-
-
Method Details
-
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. ASecurityExceptionis thrown in case it has not. Otherwise, the event is posted using this decorator's service instance.- Specified by:
postEventin interfaceorg.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. ASecurityExceptionis thrown in case it has not. Otherwise, the event is posted using this decorator's service instance.- Specified by:
sendEventin interfaceorg.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()OverrideshashCode()and returns the hash code of the decorated service instance.- Overrides:
hashCodein classjava.lang.Object- Returns:
- The hash code of the decorated service instance
- See Also:
Object.hashCode(),EventAdmin
-
equals
public boolean equals(java.lang.Object o)Overridesequals()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:
equalsin classjava.lang.Object- Parameters:
o- The object to compare with this decorator's service instance- See Also:
Object.equals(java.lang.Object),EventAdmin
-