Package org.osgi.service.event

Examples of org.osgi.service.event.TopicPermission


  private boolean checkPermission(Event event,
                                  SecurityManager securityManager,
                                  String action)
  {
    try {
      TopicPermission permission = new TopicPermission(event.getTopic(), action);
      securityManager.checkPermission(permission);
      return true;
    } catch (AccessControlException e) {
      return false;
    }
View Full Code Here


     */
    public void handleEvent(Event event) {
      try {
        //System.out.println(getName() + " recived an event");

        TopicPermission permissionAquired
          = new TopicPermission((String)event.getProperty
                                (EventConstants.EVENT_TOPIC),"subscribe");
        TopicPermission actualPermission
          = new TopicPermission("com/acme/*","subscribe");

        assertTrue(getName() +"Should not recevice this topic:"
                   +(String)event.getProperty(EventConstants.EVENT_TOPIC),
                   actualPermission.implies(permissionAquired));

        Object message;
        /* try to get the message */
        message = event.getProperty("Synchronus message");
        /* check if message is null */
 
View Full Code Here

      try {

        /* get the topic from the event*/
        String eventTopic = event.getTopic();
        /* make a topic permission from the received topic in order to check it*/
        TopicPermission permissionAccuired = new TopicPermission(eventTopic, "SUBSCRIBE");
        /* make a topic permission from the topic to consume in order to check it*/
        TopicPermission actualPermission = new TopicPermission(topicsToConsume[0], "SUBSCRIBE");
        /* assert if the topic in the event is the same as the topic to listen fore including wildcard */
        assertTrue("The topics was not equal", actualPermission.implies(permissionAccuired));

        Object message;
        /* try to get the message */
        message = event.getProperty("Synchronus message");

View Full Code Here

    public void postEvent(final Event event)
    {
        LOGGER.entering(CLASS_NAME, "postEvent", event);

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(new TopicPermission(event.getTopic(), TopicPermission.PUBLISH));

        Set<EventListener> set = collectListeners(event);

        for (final EventListener el : set)
        {
View Full Code Here

    public void sendEvent(final Event event)
    {
        LOGGER.entering(CLASS_NAME, "sendEvent", event);

        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(new TopicPermission(event.getTopic(), TopicPermission.PUBLISH));

        Set<EventListener> set = collectListeners(event);

        if (!set.isEmpty())
        {
View Full Code Here

        SecurityManager sm = System.getSecurityManager();
        if (sm != null)
        {
            for (String topic : topics)
            {
                if (!service.getClass().getProtectionDomain().implies(new TopicPermission(topic, TopicPermission.SUBSCRIBE)))
                {
                    LOGGER.finest("Service does not have permission to subscribe for topic " + topic + ", ignoring");
                    LOGGER.exiting(CLASS_NAME, "addingService", null);

                    return null;
View Full Code Here

      String eventTopic = event.getTopic();

      try {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null)
          sm.checkPermission(new TopicPermission(eventTopic,
              TopicPermission.PUBLISH));
      } catch (SecurityException e) {
        logError(
            "Caller bundle does not have TopicPermission to publish topic "
                + eventTopic, e);
        throw e;
      }

      Set eventHandlerWrappers = eventHandlerTracker
          .getHandlers(eventTopic);

      SecurityManager sm = System.getSecurityManager();
      Permission perm = (sm == null) ? null : new TopicPermission(
          eventTopic, TopicPermission.SUBSCRIBE);

      CopyOnWriteIdentityMap listeners = new CopyOnWriteIdentityMap();
      Iterator iter = eventHandlerWrappers.iterator();
      while (iter.hasNext()) {
View Full Code Here

TOP

Related Classes of org.osgi.service.event.TopicPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.