当前位置: 首页>>代码示例>>Java>>正文


Java XMPPServer.isLocal方法代码示例

本文整理汇总了Java中org.jivesoftware.openfire.XMPPServer.isLocal方法的典型用法代码示例。如果您正苦于以下问题:Java XMPPServer.isLocal方法的具体用法?Java XMPPServer.isLocal怎么用?Java XMPPServer.isLocal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.openfire.XMPPServer的用法示例。


在下文中一共展示了XMPPServer.isLocal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAdmin

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
   * Check if the <code>from</code> has admin capability.  Only the escaped
   * node part (userID) is validate.  TODO: it is not clear how the Openfire
   * stores the node as escaped or unescaped JID.
   *
   * @param from A full JID or bare JID.
   * @return
   */
  public static boolean isAdmin(JID from) {
    XMPPServer server = XMPPServer.getInstance();
    if (server.isLocal(from)) {
      String userId = from.getNode();
      for (JID admin : server.getAdmins()) {
//        if (JID.equals(admin.getNode(), userId)) {
//          return true;
//        }
        String adminNode = admin.getNode();
        if (adminNode.equals(userId)) {
          return true;
        }
      }
    }
    return false;
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:25,代码来源:Helper.java

示例2: run

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public void run() {
    // Send the last published items for the contacts on availableSessionJID's roster.
    try {
        final XMPPServer server = XMPPServer.getInstance();
        final Roster roster = server.getRosterManager().getRoster(availableSessionJID.getNode());
        for (final RosterItem item : roster.getRosterItems()) {
            if (server.isLocal(item.getJid()) && (item.getSubStatus() == RosterItem.SUB_BOTH ||
                    item.getSubStatus() == RosterItem.SUB_TO)) {
                PEPService pepService = pepServiceManager.getPEPService(item.getJid().toBareJID());
                if (pepService != null) {
                    pepService.sendLastPublishedItems(availableSessionJID);
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        // Do nothing
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:21,代码来源:IQPEPHandler.java

示例3: isConversationJID

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
 * Returns true if the specified JID should be recorded in a conversation.
 *
 * @param jid
 *            the JID.
 * @return true if the JID should be recorded in a conversation.
 */
private boolean isConversationJID(JID jid) {
    // Ignore conversations when there is no jid
    if (jid == null) {
        return false;
    }
    XMPPServer server = XMPPServer.getInstance();
    if (jid.getNode() == null) {
        return false;
    }

    // Always accept local JIDs or JIDs related to gateways
    // (this filters our components, MUC, pubsub, etc. except gateways).
    if (server.isLocal(jid) || gateways.contains(jid.getDomain())) {
        return true;
    }

    // If not a local JID, always record it.
    if (!jid.getDomain().endsWith(serverInfo.getXMPPDomain())) {
        return true;
    }

    // Otherwise return false.
    return false;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:32,代码来源:ConversationManager.java

示例4: run

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void run() {
    // Send the last published items for the contacts on availableSessionJID's roster.
    try {
        final XMPPServer server = XMPPServer.getInstance();
        final Roster roster = server.getRosterManager().getRoster(availableSessionJID.getNode());
        for (final RosterItem item : roster.getRosterItems()) {
            if (server.isLocal(item.getJid()) && (item.getSubStatus() == RosterItem.SUB_BOTH ||
                    item.getSubStatus() == RosterItem.SUB_TO)) {
                PEPService pepService = pepServiceManager.getPEPService(item.getJid().toBareJID());
                if (pepService != null) {
                    pepService.sendLastPublishedItems(availableSessionJID);
                }
            }
        }
    }
    catch (UserNotFoundException e) {
        // Do nothing
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:20,代码来源:IQPEPHandler.java

示例5: isConversationJID

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
 * Returns true if the specified JID should be recorded in a conversation.
 *
 * @param jid the JID.
 * @return true if the JID should be recorded in a conversation.
 */
private boolean isConversationJID(JID jid) {
    // Ignore conversations when there is no jid
    if (jid == null) {
        return false;
    }
    XMPPServer server = XMPPServer.getInstance();
    if (jid.getNode() == null) {
        return false;
    }

    // Always accept local JIDs or JIDs related to gateways
    // (this filters our components, MUC, pubsub, etc. except gateways).
    if (server.isLocal(jid) || gateways.contains(jid.getDomain())) {
        return true;
    }

    // If not a local JID, always record it.
    if (!jid.getDomain().endsWith(serverInfo.getXMPPDomain())) {
        return true;
    }

    // Otherwise return false.
    return false;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:31,代码来源:ConversationManager.java

示例6: isConversationJID

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
 * Returns true if the specified JID should be recorded in a conversation.
 * 
 * @param jid
 *            the JID.
 * @return true if the JID should be recorded in a conversation.
 */
private boolean isConversationJID(JID jid) {
	// Ignore conversations when there is no jid
	if (jid == null) {
		return false;
	}
	XMPPServer server = XMPPServer.getInstance();
	if (jid.getNode() == null) {
		return false;
	}

	// Always accept local JIDs or JIDs related to gateways
	// (this filters our components, MUC, pubsub, etc. except gateways).
	if (server.isLocal(jid) || gateways.contains(jid.getDomain())) {
		return true;
	}

	// If not a local JID, always record it.
	if (!jid.getDomain().endsWith(serverInfo.getXMPPDomain())) {
		return true;
	}

	// Otherwise return false.
	return false;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:ConversationManager.java

示例7: canSubscribe

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
    // Let node owners and sysadmins always subscribe to the node
    if (node.isAdmin(owner)) {
        return true;
    }
    for (JID nodeOwner : node.getOwners()) {
        if (nodeOwner.equals(owner)) {
            return true;
        }
    }
    // Check that the subscriber is a local user
    XMPPServer server = XMPPServer.getInstance();
    if (server.isLocal(owner)) {
        GroupManager gMgr = GroupManager.getInstance();
        Collection<String> nodeGroups = node.getRosterGroupsAllowed();
        for (String groupName : nodeGroups) {
            try {
                Group group = gMgr.getGroup(groupName);
                // access allowed if the node group is visible to the subscriber
                if (server.getRosterManager().isGroupVisible(group, owner)) {
                    return true;
                }
            } catch (GroupNotFoundException gnfe){ 
                // ignore
            }
        }
    }
    else {
        // Subscriber is a remote user. This should never happen.
        Log.warn("Node with access model Roster has a remote user as subscriber: " +
                node.getNodeID());
    }
    return false;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:36,代码来源:RosterAccess.java

示例8: getGroupNames

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public Collection<String> getGroupNames(JID user) {
    // Get DN of specified user
    XMPPServer server = XMPPServer.getInstance();
    String username;
    if (!manager.isPosixMode()) {
        // Check if the user exists (only if user is a local user)
        if (!server.isLocal(user)) {
            return Collections.emptyList();
        }
        username = JID.unescapeNode(user.getNode());
        try {
            username = manager.findUserDN(username) + "," + manager.getUsersBaseDN(username);
        }
        catch (Exception e) {
            Log.error("Could not find user in LDAP " + username);
            return Collections.emptyList();
        }
    }
    else {
        username = server.isLocal(user) ? JID.unescapeNode(user.getNode()) : user.toString();
    }
    // Do nothing if the user is empty or null
    if (username == null || "".equals(username)) {
        return Collections.emptyList();
    }
    return search(manager.getGroupMemberField(), username);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:LdapGroupProvider.java

示例9: canSubscribe

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
       // Let node owners and sysadmins always subcribe to the node
       if (node.isAdmin(owner)) {
           return true;
       }
       // Get the only owner of the node
       JID nodeOwner = node.getOwners().iterator().next();
       // Give access to the owner of the roster :)
       if (nodeOwner.toBareJID().equals(owner.toBareJID())) {
           return true;
       }
       // Get the roster of the node owner
       XMPPServer server = XMPPServer.getInstance();
       // Check that the node owner is a local user
       if (server.isLocal(nodeOwner)) {
           try {
               Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
               RosterItem item = roster.getRosterItem(owner);
               // Check that the subscriber is subscribe to the node owner's presence
               return item != null && (RosterItem.SUB_BOTH == item.getSubStatus() ||
                       RosterItem.SUB_FROM == item.getSubStatus());
           }
           catch (UserNotFoundException e) {
               return false;
           }
       }
       else {
           // Owner of the node is a remote user. This should never happen.
           Log.warn("Node with access model Presence has a remote user as owner: " +
                   node.getNodeID());
           return false;
       }
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:35,代码来源:PresenceAccess.java

示例10: getUserID

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
 * Returns the Clearspace user id the user by JID.
 *
 * @param user JID of user to retrieve ID of.
 * @return The ID number of the user in Clearspace.
 * @throws org.jivesoftware.openfire.user.UserNotFoundException
 *          If the user was not found.
 */
protected long getUserID(JID user) throws UserNotFoundException {
    // User's id are only for local users
    XMPPServer server = XMPPServer.getInstance();
    if (!server.isLocal(user)) {
        throw new UserNotFoundException("Cannot load user of remote server: " + user.toString());
    }
    return getUserID(user.getNode());
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:17,代码来源:ClearspaceManager.java

示例11: canSubscribe

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
       // Let node owners and sysadmins always subcribe to the node
       if (node.isAdmin(owner)) {
           return true;
       }
       XMPPServer server = XMPPServer.getInstance();
       for (JID nodeOwner : node.getOwners()) {
        // Give access to the owner of the roster :)
        if (nodeOwner.equals(owner.toBareJID())) {
            return true;
        }
        // Check that the node owner is a local user
        if (server.isLocal(nodeOwner)) {
            try {
                Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
                RosterItem item = roster.getRosterItem(owner);
                // Check that the subscriber is subscribe to the node owner's presence
                return item != null && (RosterItem.SUB_BOTH == item.getSubStatus() ||
                        RosterItem.SUB_FROM == item.getSubStatus());
            }
            catch (UserNotFoundException e) {
            	// Do nothing
            }
        }
        else {
            // Owner of the node is a remote user. This should never happen.
            Log.warn("Node with access model Presence has a remote user as owner: " +
                    node.getNodeID());
        }
       }
       return false;
   }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:34,代码来源:PresenceAccess.java

示例12: canSubscribe

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
@Override
public boolean canSubscribe(Node node, JID owner, JID subscriber) {
       // Let node owners and sysadmins always subscribe to the node
       if (node.isAdmin(owner)) {
           return true;
       }
       for (JID nodeOwner : node.getOwners()) {
           if (nodeOwner.equals(owner)) {
               return true;
           }
       }
       // Check that the subscriber is a local user
       XMPPServer server = XMPPServer.getInstance();
       if (server.isLocal(owner)) {
           GroupManager gMgr = GroupManager.getInstance();
       	Collection<String> nodeGroups = node.getRosterGroupsAllowed();
       	for (String groupName : nodeGroups) {
       		try {
        		Group group = gMgr.getGroup(groupName);
        		// access allowed if the node group is visible to the subscriber
        		if (server.getRosterManager().isGroupVisible(group, owner)) {
        			return true;
        		}
       		} catch (GroupNotFoundException gnfe){ 
       			// ignore
       		}
       	}
       }
       else {
           // Subscriber is a remote user. This should never happen.
           Log.warn("Node with access model Roster has a remote user as subscriber: " +
                   node.getNodeID());
       }
       return false;
   }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:36,代码来源:RosterAccess.java

示例13: getGroupNames

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public Collection<String> getGroupNames(JID user) {
    // Get DN of specified user
    XMPPServer server = XMPPServer.getInstance();
    String username;
    if (!manager.isPosixMode()) {
        // Check if the user exists (only if user is a local user)
        if (!server.isLocal(user)) {
            return Collections.emptyList();
        }
        username = JID.unescapeNode(user.getNode());
        try {
            username = manager.findUserDN(username) + "," + manager.getUsersBaseDN(username);
        }
        catch (Exception e) {
            Log.error("Could not find user in LDAP " + username);
            return Collections.emptyList();
        }
    }
    else {
        username = server.isLocal(user) ? JID.unescapeNode(user.getNode()) : user.toString();
    }
    // Do nothing if the user is empty or null
    if (username == null || "".equals(username)) {
        return Collections.emptyList();
    }
	return search(manager.getGroupMemberField(), username);
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:28,代码来源:LdapGroupProvider.java

示例14: archiveMessage

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void archiveMessage(Session session, Message message, boolean incoming)
{
    final XMPPServer server = XMPPServer.getInstance();
    final ArchivedMessage.Direction direction;
    final ArchivedMessage archivedMessage;
    final Conversation conversation;
    final JID ownerJid;
    final JID withJid;

    // TODO support groupchat
    if (message.getType() != Message.Type.chat && message.getType() != Message.Type.normal)
    {
        return;
    }

    if (server.isLocal(message.getFrom()) && incoming)
    {
        ownerJid = message.getFrom();
        withJid = message.getTo();
        // sent by the owner => to
        direction = ArchivedMessage.Direction.to;
    }
    else if (server.isLocal(message.getTo()) && ! incoming)
    {
        ownerJid = message.getTo();
        withJid = message.getFrom();
        // received by the owner => from
        direction = ArchivedMessage.Direction.from;
    }
    else
    {
        return;
    }

    archivedMessage = ArchiveFactory.createArchivedMessage(session, message, direction, withJid);
    if (archivedMessage.isEmpty())
    {
        return;
    }

    conversation = determineConversation(ownerJid, withJid, message.getSubject(), message.getThread(), archivedMessage);
    archivedMessage.setConversation(conversation);

    persistenceManager.createMessage(archivedMessage);
    if (indexManager != null)
    {
        indexManager.indexObject(archivedMessage);
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:50,代码来源:ArchiveManagerImpl.java

示例15: isExternal

import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private boolean isExternal(XMPPServer server, JID jid) {
    return !server.isLocal(jid) || gateways.contains(jid.getDomain());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:4,代码来源:ConversationManager.java


注:本文中的org.jivesoftware.openfire.XMPPServer.isLocal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。