本文整理汇总了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;
}
示例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
}
}
示例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;
}
示例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
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例15: isExternal
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private boolean isExternal(XMPPServer server, JID jid) {
return !server.isLocal(jid) || gateways.contains(jid.getDomain());
}