本文整理汇总了Java中org.jivesoftware.openfire.XMPPServer.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java XMPPServer.getInstance方法的具体用法?Java XMPPServer.getInstance怎么用?Java XMPPServer.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.XMPPServer
的用法示例。
在下文中一共展示了XMPPServer.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUser
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private User createUser(String userName, String password, String displayName)
throws UserAlreadyExistsException {
if (userName.length() >= 64) {
throw new IllegalArgumentException("user name too long");
}
boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword");
if (usePlainPassword && password.length() >= 32) {
throw new IllegalArgumentException("password too long");
}
XMPPServer server = XMPPServer.getInstance();
User user = server.getUserManager().createUser(userName, password,
displayName, null);
return user;
}
示例2: 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;
}
示例3: logout
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
* Disconnect an XMPP session of a user identified by an oauth token.
* @param headers
* @return
*/
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("logout")
public Response logout(@Context HttpHeaders headers) {
TokenInfo tokenInfo = RestUtils.getAuthTokenInfo(headers);
if (tokenInfo == null) {
return RestUtils.getUnauthJAXRSResp();
}
JID from = RestUtils.createJID(tokenInfo);
XMPPServer xmppSrv = XMPPServer.getInstance();
SessionManager sessionMgr = xmppSrv.getSessionManager();
ClientSession session = sessionMgr.getSession(from);
if (session == null) {
ErrorResponse response = new ErrorResponse(ErrorCode.USER_NOT_LOGIN,
String.format("Session is not found: %s [%s]", from, tokenInfo.getUserName()));
return RestUtils.getJAXRSResp(Response.Status.GONE, response);
}
// Terminate the session now.
session.close();
return RestUtils.getOKJAXRSResp();
}
示例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: enableService
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void enableService(boolean enabled, boolean persistent) {
if (isServiceEnabled() == enabled) {
// Do nothing if the service status has not changed
return;
}
XMPPServer server = XMPPServer.getInstance();
if (!enabled) {
// Disable disco information
server.getIQDiscoItemsHandler().removeServerItemsProvider(this);
// Stop the service/module
stop();
}
if (persistent) {
MUCPersistenceManager.setProperty(chatServiceName, "enabled", Boolean.toString(enabled));
}
serviceEnabled = enabled;
if (enabled) {
// Start the service/module
start();
// Enable disco information
server.getIQDiscoItemsHandler().addServerItemsProvider(this);
}
}
示例6: initializePlugin
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
server = XMPPServer.getInstance();
userManager = server.getUserManager();
secret = JiveGlobals.getProperty("plugin.userservice.secret", "");
// If no secret key has been assigned to the user service yet, assign a random one.
if (secret.equals("")){
secret = StringUtils.randomString(8);
setSecret(secret);
}
// See if the service is enabled or not.
enabled = JiveGlobals.getBooleanProperty("plugin.userservice.enabled", false);
// Get the list of IP addresses that can use this service. An empty list means that this filter is disabled.
allowedIPs = StringUtils.stringToCollection(JiveGlobals.getProperty("plugin.userservice.allowedIPs", ""));
// Listen to system property events
PropertyEventDispatcher.addListener(this);
}
示例7: buildPluginsUpdateList
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
/**
* Recreate the list of plugins that need to be updated based on the list of
* available plugins at igniterealtime.org.
*/
private void buildPluginsUpdateList() {
// Reset list of plugins that need to be updated
pluginUpdates = new ArrayList<Update>();
XMPPServer server = XMPPServer.getInstance();
// Compare local plugins versions with latest ones
for (Plugin plugin : server.getPluginManager().getPlugins()) {
String pluginName = server.getPluginManager().getName(plugin);
AvailablePlugin latestPlugin = availablePlugins.get(pluginName);
String currentVersion = server.getPluginManager().getVersion(plugin);
if (latestPlugin != null &&
latestPlugin.getLatestVersion().compareTo(currentVersion) > 0) {
// Check if the update can run in the current version of the server
String serverVersion =
XMPPServer.getInstance().getServerInfo().getVersion().getVersionString();
if (serverVersion.compareTo(latestPlugin.getMinServerVersion()) >= 0) {
Update update = new Update(pluginName, latestPlugin.getLatestVersion(),
latestPlugin.getChangelog(), latestPlugin.getURL());
pluginUpdates.add(update);
}
}
}
}
示例8: MainInterceptor
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public MainInterceptor() {
Log.info("Created MainInterceptor for GoJara Plugin.");
server = XMPPServer.getInstance();
RosterManager rosterManager = server.getRosterManager();
AbstractRemoteRosterProcessor iqRegisteredProcessor = new DiscoIQRegisteredProcessor();
AbstractRemoteRosterProcessor iqRosterPayloadProcessor = new IQRosterPayloadProcessor(rosterManager);
AbstractRemoteRosterProcessor nonPersistantProcessor = new NonPersistantRosterProcessor(rosterManager);
AbstractRemoteRosterProcessor statisticsProcessor = new StatisticsProcessor();
AbstractRemoteRosterProcessor updateToComponentProcessor = new ClientToComponentUpdateProcessor(activeTransports);
AbstractRemoteRosterProcessor whitelistProcessor = new WhitelistProcessor(activeTransports);
AbstractRemoteRosterProcessor mucfilterProcessor = new MucFilterProcessor();
AbstractRemoteRosterProcessor gojaraAdminProcessor = new GojaraAdminProcessor();
packetProcessors.put("sparkIQRegistered", iqRegisteredProcessor);
packetProcessors.put("iqRosterPayload", iqRosterPayloadProcessor);
packetProcessors.put("handleNonPersistant", nonPersistantProcessor);
packetProcessors.put("statisticsProcessor", statisticsProcessor);
packetProcessors.put("clientToComponentUpdate", updateToComponentProcessor);
packetProcessors.put("whitelistProcessor", whitelistProcessor);
packetProcessors.put("mucfilterProcessor", mucfilterProcessor);
packetProcessors.put("gojaraAdminProcessor", gojaraAdminProcessor);
frozen = false;
}
示例9: initializePlugin
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
server = XMPPServer.getInstance();
userManager = server.getUserManager();
rosterManager = server.getRosterManager();
secret = JiveGlobals.getProperty("plugin.userservice.secret", "");
// If no secret key has been assigned to the user service yet, assign a random one.
if (secret.equals("")){
secret = StringUtils.randomString(8);
setSecret(secret);
}
// See if the service is enabled or not.
enabled = JiveGlobals.getBooleanProperty("plugin.userservice.enabled", false);
// Get the list of IP addresses that can use this service. An empty list means that this filter is disabled.
allowedIPs = StringUtils.stringToCollection(JiveGlobals.getProperty("plugin.userservice.allowedIPs", ""));
// Listen to system property events
PropertyEventDispatcher.addListener(this);
}
示例10: destroyPlugin
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public void destroyPlugin() {
XMPPServer server = XMPPServer.getInstance();
IQRouter iqRouter = server.getIQRouter();
iqRouter.removeHandler(mIQAppRegHandler);
iqRouter.removeHandler(mIQDevRegHandler);
iqRouter.removeHandler(mIQUserRegHandler);
iqRouter.removeHandler(mIQMessageStateHandler);
iqRouter.removeHandler(mIQPubSubHandler);
iqRouter.removeHandler(mIQWakeupNSHandler);
iqRouter.removeHandler(mIQPushNSHandler);
iqRouter.removeHandler(mIQMsgAckNSHandler);
InterceptorManager.getInstance().removeInterceptor(mmxPacketInterceptor);
wakeupExecutionManager.stopWakeupExecution();
timeoutExecutionManager.stopTimeoutCheck();
// shutdown geo event dispatcher
contextDispatcher.shutdown();
//Teardown the APNS Connection pool
APNSConnectionPoolImpl.teardown();
adminAPIServer.stop();
publicAPIServer.stop();
// disable the pub/sub wakeup
server.getPubSubModule().setWakeupProvider(null);
try {
ObjectName mbeanName = new ObjectName(MMXServerConstants.MMX_MBEAN_NAME);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.unregisterMBean(mbeanName);
} catch(Exception e) {
Log.error("destroyPlugin : error unregistering mbean={}", MMXServerConstants.MMX_MBEAN_NAME);
}
apnsFeedbackProcessExecutionManager.stop();
Log.info("App Management Plugin is destroyed");
}
示例11: startProxy
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private void startProxy() {
connectionManager.processConnections(bindInterface, getProxyPort());
routingTable.addComponentRoute(getAddress(), this);
XMPPServer server = XMPPServer.getInstance();
server.getIQDiscoItemsHandler().addServerItemsProvider(this);
}
示例12: create
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
public PEPService create(JID owner) {
// Return an error if the packet is from an anonymous, unregistered user
// or remote user
if (!XMPPServer.getInstance().isLocal(owner)
|| !UserManager.getInstance().isRegisteredUser(owner.getNode())) {
throw new IllegalArgumentException(
"Request must be initiated by a local, registered user, but is not: "
+ owner);
}
PEPService pepService = null;
final String bareJID = owner.toBareJID();
final Lock lock = CacheFactory.getLock(owner, pepServices);
try {
lock.lock();
pepService = pepServices.get(bareJID);
if (pepService == null) {
pepService = new PEPService(XMPPServer.getInstance(), bareJID);
pepServices.put(bareJID, pepService);
if (Log.isDebugEnabled()) {
Log.debug("PEPService created for : " + bareJID);
}
}
} finally {
lock.unlock();
}
return pepService;
}
示例13: 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;
}
示例14: stopSTUNService
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private void stopSTUNService() {
XMPPServer server = XMPPServer.getInstance();
server.getIQDiscoInfoHandler().removeServerFeature(NAMESPACE);
if (stunIQHandler != null) {
server.getIQRouter().removeHandler(stunIQHandler);
stunIQHandler = null;
}
}
示例15: PacketCopier
import org.jivesoftware.openfire.XMPPServer; //导入方法依赖的package包/类
private PacketCopier() {
// Add the new instance as a listener of component events. We need to react when
// a component is no longer valid
InternalComponentManager.getInstance().addListener(this);
XMPPServer server = XMPPServer.getInstance();
serverName = server.getServerInfo().getXMPPDomain();
routingTable = server.getRoutingTable();
// Add new instance to the PacketInterceptors list
InterceptorManager.getInstance().addInterceptor(this);
// Create a new task and schedule it with the new timeout
packetsTask = new ProcessPacketsTask();
timer.schedule(packetsTask, 5000, 5000);
}