コード例 #1
0
  public SipXVCardProvider() {
    super();

    defaultProvider = new DefaultVCardProvider();

    String clientConfig = getConfDir() + MONGO_CLIENT_CONFIG;
    try {
      UnfortunateLackOfSpringSupportFactory.initialize(clientConfig);
      if (new File("/tmp/sipx.properties").exists()) {
        System.getProperties().load(new FileInputStream(new File("/tmp/sipx.properties")));
      }

    } catch (Exception e) {
      logger.error(e);
    }

    String cacheName = "SipXVCardCache";
    vcardCache = CacheFactory.createCache(cacheName);

    logger.info(this.getClass().getName() + " starting XML RPC server ...");
    try {
      VCardRpcServer vcardRpcServer = new VCardRpcServer(ContactInfoHandlerImp.class);
      vcardRpcServer.start();
      logger.info(this.getClass().getName() + " initialized");
    } catch (Exception ex) {
      logger.error(ex);
    }
  }
コード例 #2
0
  private Collection<JID> getGroupMembers(String groupName) {
    Cache<String, Collection<JID>> groupMembershipCache =
        CacheFactory.createLocalCache(GROUP_MEMBERSHIP_CACHE_NAME);
    Collection<JID> members = groupMembershipCache.get(groupName);
    if (members != null) {
      return members;
    }

    try {
      List<String> users = manager.getGroupMembers(groupName);
      Collection<JID> results = new ArrayList<JID>();

      for (String username : users) {
        results.add(server.createJID(username, null));
      }

      groupMembershipCache.put(groupName, results);
      return results;

    } catch (RemoteException re) {
      LOG.error("Failure to get the members of crowd group:" + String.valueOf(groupName), re);
    }

    groupMembershipCache.put(groupName, new ArrayList<JID>());
    return Collections.emptyList();
  }
コード例 #3
0
  public CrowdGroupProvider() {
    String propertyValue = JiveGlobals.getProperty(JIVE_CROWD_GROUPS_CACHE_TTL_SECS);
    int ttl =
        (propertyValue == null || propertyValue.trim().length() == 0)
            ? CACHE_TTL
            : Integer.parseInt(propertyValue);

    Cache<String, Collection<JID>> groupMembershipCache =
        CacheFactory.createLocalCache(GROUP_MEMBERSHIP_CACHE_NAME);
    groupMembershipCache.setMaxCacheSize(-1);
    groupMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API

    Cache<JID, Collection<String>> userMembershipCache =
        CacheFactory.createLocalCache(USER_MEMBERSHIP_CACHE_NAME);
    userMembershipCache.setMaxCacheSize(-1);
    userMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API

    Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache =
        CacheFactory.createLocalCache(GROUP_CACHE_NAME);
    groupCache.setMaxCacheSize(-1);
    groupCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API
  }
コード例 #4
0
 /**
  * Processes packets that were sent to this service. Currently only packets that were sent from
  * registered components are being processed. In the future, we may also process packet of trusted
  * clients. Trusted clients may be able to execute ad-hoc commands such as adding or removing
  * components.
  *
  * @param packet the packet to process.
  */
 @Override
 public void process(Packet packet) throws PacketException {
   List<Component> components = getComponents(packet.getFrom());
   // Only process packets that were sent by registered components
   if (!components.isEmpty()) {
     if (packet instanceof IQ && IQ.Type.result == ((IQ) packet).getType()) {
       IQ iq = (IQ) packet;
       Element childElement = iq.getChildElement();
       if (childElement != null) {
         String namespace = childElement.getNamespaceURI();
         if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
           // Add a disco item to the server for the component that supports disco
           Element identity = childElement.element("identity");
           if (identity == null) {
             // Do nothing since there are no identities in the disco#info packet
             return;
           }
           try {
             XMPPServer.getInstance()
                 .getIQDiscoItemsHandler()
                 .addComponentItem(packet.getFrom().toBareJID(), identity.attributeValue("name"));
             for (Component component : components) {
               if (component instanceof ComponentSession.ExternalComponent) {
                 ComponentSession.ExternalComponent externalComponent =
                     (ComponentSession.ExternalComponent) component;
                 externalComponent.setName(identity.attributeValue("name"));
                 externalComponent.setType(identity.attributeValue("type"));
                 externalComponent.setCategory(identity.attributeValue("category"));
               }
             }
           } catch (Exception e) {
             Log.error(
                 "Error processing disco packet of components: "
                     + components
                     + " - "
                     + packet.toXML(),
                 e);
           }
           // Store the IQ disco#info returned by the component
           addComponentInfo(iq);
           // Notify listeners that a component answered the disco#info request
           notifyComponentInfo(iq);
           // Alert other cluster nodes
           CacheFactory.doClusterTask(new NotifyComponentInfo(iq));
         }
       }
     }
   }
 }
コード例 #5
0
  public Group getGroup(String name) throws GroupNotFoundException {
    try {
      Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache =
          CacheFactory.createLocalCache(GROUP_CACHE_NAME);
      org.jivesoftware.openfire.crowd.jaxb.Group group = groupCache.get(name);
      if (group == null) {
        group = manager.getGroup(name);
        groupCache.put(name, group);
      }
      Collection<JID> members = getGroupMembers(name);
      Collection<JID> admins = Collections.emptyList();
      return new Group(name, group.description, members, admins);

    } catch (RemoteException re) {
      LOG.error("Failure to load group:" + String.valueOf(name), re);
      throw new GroupNotFoundException(re);
    }
  }
コード例 #6
0
  public Collection<String> getGroupNames(JID user) {
    Cache<JID, Collection<String>> userMembershipCache =
        CacheFactory.createCache(USER_MEMBERSHIP_CACHE_NAME);
    Collection<String> groups = userMembershipCache.get(user);
    if (groups != null) {
      return groups;
    }

    try {
      groups = manager.getUserGroups(user.getNode());
      userMembershipCache.put(user, groups);
      return groups;
    } catch (RemoteException re) {
      LOG.error("Failure to load the groups of user:" + String.valueOf(user), re);
    }

    userMembershipCache.put(user, new ArrayList<String>());
    return Collections.emptyList();
  }
コード例 #7
0
  /**
   * Handles packets that includes a data form. The data form was sent using an element with name
   * "x" and namespace "jabber:x:data".
   *
   * @param senderRole the role of the user that sent the data form.
   * @param formElement the element that contains the data form specification.
   * @throws ForbiddenException if the user does not have enough privileges.
   * @throws ConflictException If the room was going to lose all of its owners.
   */
  private void handleDataFormElement(MUCRole senderRole, Element formElement)
      throws ForbiddenException, ConflictException {
    DataForm completedForm = new DataForm(formElement);

    switch (completedForm.getType()) {
      case cancel:
        // If the room was just created (i.e. is locked) and the owner cancels the configuration
        // form then destroy the room
        if (room.isLocked()) {
          room.destroyRoom(null, null);
        }
        break;

      case submit:
        // The owner is requesting an instant room
        if (completedForm.getFields().isEmpty()) {
          // Do nothing
        }
        // The owner is requesting a reserved room or is changing the current configuration
        else {
          processConfigurationForm(completedForm, senderRole);
        }
        // If the room was locked, unlock it and send to the owner the "room is now unlocked"
        // message
        if (room.isLocked() && !room.isManuallyLocked()) {
          room.unlock(senderRole);
        }
        if (!room.isDestroyed) {
          // Let other cluster nodes that the room has been updated
          CacheFactory.doClusterTask(new RoomUpdatedEvent(room));
        }
        break;

      default:
        Log.warn("cannot handle data form element: " + formElement.asXML());
        break;
    }
  }
コード例 #8
0
  /**
   * Removes a given component. Unlike {@link #removeComponent(String)} this method will just remove
   * a single component instead of all components associated to the subdomain. External components
   * may connect several times and register for the same subdomain. This method just removes a
   * singled connection not all of them.
   *
   * @param subdomain the subdomain of the component's address.
   * @param component specific component to remove.
   */
  public void removeComponent(String subdomain, Component component) {
    if (component == null) {
      return;
    }
    synchronized (routables) {
      Log.debug("InternalComponentManager: Unregistering component for domain: " + subdomain);
      RoutableComponents routable = routables.get(subdomain);
      routable.removeComponent(component);
      if (routable.numberOfComponents() == 0) {
        routables.remove(subdomain);

        JID componentJID = new JID(subdomain + "." + serverDomain);

        // Remove the route for the service provided by the component
        routingTable.removeComponentRoute(componentJID);

        // Ask the component to shutdown
        component.shutdown();

        if (!routingTable.hasComponentRoute(componentJID)) {
          // Remove the disco item from the server for the component that is being removed
          IQDiscoItemsHandler iqDiscoItemsHandler =
              XMPPServer.getInstance().getIQDiscoItemsHandler();
          if (iqDiscoItemsHandler != null) {
            iqDiscoItemsHandler.removeComponentItem(componentJID.toBareJID());
          }
          removeComponentInfo(componentJID);
          // Notify listeners that an existing component has been unregistered
          notifyComponentUnregistered(componentJID);
          // Alert other nodes of component removed event
          CacheFactory.doClusterTask(new NotifyComponentUnregistered(componentJID));
        }
        Log.debug("InternalComponentManager: Component unregistered for domain: " + subdomain);
      } else {
        Log.debug("InternalComponentManager: Other components still tied to domain: " + subdomain);
      }
    }
  }
コード例 #9
0
  private void init() {
    // Register the trust manager to use when using HTTPS
    Protocol easyhttps =
        new Protocol("https", (ProtocolSocketFactory) new SSLProtocolSocketFactory(this), 443);
    Protocol.registerProtocol("https", easyhttps);

    // Convert XML based provider setup to Database based
    JiveGlobals.migrateProperty("clearspace.uri");
    JiveGlobals.migrateProperty("clearspace.sharedSecret");

    // Make sure that all Clearspace components are set up, unless they were overridden
    // Note that the auth provider is our way of knowing that we are set up with Clearspace,
    // so don't bother checking to set it.
    if (isEnabled()) {
      if (JiveGlobals.getProperty("provider.user.className") == null) {
        JiveGlobals.setProperty(
            "provider.user.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
      }
      if (JiveGlobals.getProperty("provider.group.className") == null) {
        JiveGlobals.setProperty(
            "provider.group.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
      }
      if (JiveGlobals.getProperty("provider.vcard.className") == null) {
        JiveGlobals.setProperty(
            "provider.vcard.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
      }
      if (JiveGlobals.getProperty("provider.lockout.className") == null) {
        JiveGlobals.setProperty(
            "provider.lockout.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
      }
      if (JiveGlobals.getProperty("provider.securityAudit.className") == null) {
        JiveGlobals.setProperty(
            "provider.securityAudit.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
      }
      if (JiveGlobals.getProperty("provider.admin.className") == null) {
        JiveGlobals.setProperty(
            "provider.admin.className",
            "org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider");
      }
    }

    this.uri = properties.get("clearspace.uri");
    if (uri != null) {
      if (!this.uri.endsWith("/")) {
        this.uri = this.uri + "/";
      }
      // Updates the host/port attributes based on the uri
      updateHostPort();
    }
    sharedSecret = properties.get("clearspace.sharedSecret");

    // Creates the cache maps
    userIDCache = new DefaultCache<String, Long>("clearspace.userid", 1000, JiveConstants.DAY);
    groupIDCache = new DefaultCache<String, Long>("clearspace.groupid", 1000, JiveConstants.DAY);
    usernameCache = new DefaultCache<Long, String>("clearspace.username", 1000, JiveConstants.DAY);

    if (Log.isDebugEnabled()) {
      StringBuilder buf = new StringBuilder();
      buf.append("Created new ClearspaceManager() instance, fields:\n");
      buf.append("\t URI: ").append(uri).append("\n");
      buf.append("\t sharedSecret: ").append(sharedSecret).append("\n");

      Log.debug("ClearspaceManager: " + buf.toString());
    }

    // Init nonce cache
    nonceCache = CacheFactory.createCache("Clearspace SSO Nonce");
    // Init nonce generator
    nonceGenerator = new Random();
  }
コード例 #10
0
 /** Default constructor creates the cache. */
 public DefaultFileTransferManager() {
   super("File Transfer Manager");
   fileTransferMap = CacheFactory.createCache(CACHE_NAME);
   InterceptorManager.getInstance().addInterceptor(new MetaFileTransferInterceptor());
 }
コード例 #11
0
  @Override
  public void addComponent(String subdomain, Component component) throws ComponentException {
    synchronized (routables) {
      RoutableComponents routable = routables.get(subdomain);
      if (routable != null && routable.hasComponent(component)) {
        // This component has already registered with this subdomain.
        // TODO: Is this all we should do?  Should we return an error?
        return;
      }
      Log.debug("InternalComponentManager: Registering component for domain: " + subdomain);
      JID componentJID = new JID(subdomain + "." + serverDomain);
      boolean notifyListeners = false;
      if (routable != null) {
        routable.addComponent(component);
      } else {
        routable = new RoutableComponents(componentJID, component);
        routables.put(subdomain, routable);

        if (!routingTable.hasComponentRoute(componentJID)) {
          notifyListeners = true;
        }
        // Add the route to the new service provided by the component
        routingTable.addComponentRoute(componentJID, routable);
      }

      // Initialize the new component
      try {
        component.initialize(componentJID, this);
        component.start();

        if (notifyListeners) {
          // Notify listeners that a new component has been registered
          notifyComponentRegistered(componentJID);
          // Alert other nodes of new registered domain event
          CacheFactory.doClusterTask(new NotifyComponentRegistered(componentJID));
        }

        // Check for potential interested users.
        checkPresences();
        // Send a disco#info request to the new component. If the component provides information
        // then it will be added to the list of discoverable server items.
        checkDiscoSupport(component, componentJID);
        Log.debug("InternalComponentManager: Component registered for domain: " + subdomain);
      } catch (Exception e) {
        // Unregister the component's domain
        routable.removeComponent(component);
        if (e instanceof ComponentException) {
          // Rethrow the exception
          throw (ComponentException) e;
        }
        // Rethrow the exception
        throw new ComponentException(e);
      } finally {
        if (routable.numberOfComponents() == 0) {
          // If there are no more components associated with this subdomain, remove it.
          routables.remove(subdomain);
          // Remove the route
          XMPPServer.getInstance().getRoutingTable().removeComponentRoute(componentJID);
        }
      }
    }
  }
コード例 #12
0
 private PrivacyListManager() {
   // Create the cache of privacy lists
   String cacheName = "Privacy Lists";
   listsCache = CacheFactory.createCache(cacheName);
 }
コード例 #13
0
 /** Constructs a new offline message store. */
 public OfflineMessageStore() {
   super("Offline Message Store");
   sizeCache = CacheFactory.createCache("Offline Message Size");
 }