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


Java XMPPServer类代码示例

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


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

示例1: getMostPreferredConnectionURL

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
/**
 * Generates an URL on which client / BOSH connections are expected.
 *
 * This method will verify if the websocket plugin is available. If it is, the websocket endpoint is returned. When
 * websocket is not available, the http-bind endpoint is returned.
 *
 * The request that is made to this servlet is used to determine if the client prefers secure/encrypted connections
 * (https, wss) over plain ones (http, ws), and to determine what the server address and port is.
 *
 * @param request the request to this servlet.
 * @return An URI (never null).
 * @throws URISyntaxException When an URI could not be constructed.
 */
public static URI getMostPreferredConnectionURL( HttpServletRequest request ) throws URISyntaxException
{
    Log.debug( "[{}] Generating BOSH URL based on {}", request.getRemoteAddr(), request.getRequestURL() );
    if ( XMPPServer.getInstance().getPluginManager().getPlugin( "websocket" ) != null )
    {
        Log.debug( "[{}] Websocket plugin is available. Returning a websocket address.", request.getRemoteAddr() );
        final String websocketScheme;
        if ( request.getScheme().endsWith( "s" ) )
        {
            websocketScheme = "wss";
        }
        else
        {
            websocketScheme = "ws";
        }

        return new URI( websocketScheme, null, request.getServerName(), request.getServerPort(), "/ws", null, null);
    }
    else
    {
        Log.debug( "[{}] No Websocket plugin available. Returning an HTTP-BIND address.", request.getRemoteAddr() );
        return new URI( request.getScheme(), null, request.getServerName(), request.getServerPort(), "/http-bind/", null, null);
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:38,代码来源:ConfigServlet.java

示例2: getWebappURL

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
public URL getWebappURL()
{
    try
    {
        final String protocol = "https"; // No point in providing the non-SSL protocol, as webRTC won't work there.
        final String host = XMPPServer.getInstance().getServerInfo().getHostname();
        final int port = HttpBindManager.getInstance().getHttpBindSecurePort();
        final String path;
        if ( publicWebApp != null )
        {
            path = publicWebApp.getContextPath();
        }
        else
        {
            path = new OFMeetConfig().getWebappContextPath();
        }

        return new URL( protocol, host, port, path );
    }
    catch ( MalformedURLException e )
    {
        Log.error( "Unable to compose the webapp URL", e );
        return null;
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:26,代码来源:OfMeetPlugin.java

示例3: sessionDestroyed

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
public void sessionDestroyed(Session session)
{
	Log.debug("OfMeet Plugin -  sessionDestroyed "+ session.getAddress().toString() + "\n" + ((ClientSession) session).getPresence().toXML());

	boolean skypeAvailable = XMPPServer.getInstance().getPluginManager().getPlugin("ofskype") != null;

	if (OfMeetAzure.skypeids.containsKey(session.getAddress().getNode()))
	{
		String sipuri = OfMeetAzure.skypeids.remove(session.getAddress().getNode());

		IQ iq = new IQ(IQ.Type.set);
		iq.setFrom(session.getAddress());
		iq.setTo(XMPPServer.getInstance().getServerInfo().getXMPPDomain());

		Element child = iq.setChildElement("request", "http://igniterealtime.org/protocol/ofskype");
		child.setText("{'action':'stop_skype_user', 'sipuri':'" + sipuri + "'}");
		XMPPServer.getInstance().getIQRouter().route(iq);

		Log.info("OfMeet Plugin - closing skype session " + sipuri);
	}
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:22,代码来源:OfMeetPlugin.java

示例4: asUserNameOfDomain

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
/**
 * AuthFactory supports both a bare username, as well as [email protected] However, UserManager only accepts the bare
 * username. If the provided value includes a domain, return only the node-part (after verifying that it's actually
 * a user of our domain).
 *
 * @param username A authentication ID, either as '[email protected]' or 'user' (not null, not empty)
 * @return the 'user' part (never null).
 */
public static String asUserNameOfDomain( String username )
{
    final String[] parts = username.split( "@", 2 );
    if ( parts.length > 1 )
    {
        if ( XMPPServer.getInstance().getServerInfo().getXMPPDomain().equals( parts[ 1 ] ) )
        {
            username = parts[ 0 ];
        }
        else
        {
            return null;
        }
    }

    return username;
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:26,代码来源:OfMeetLoginService.java

示例5: setUserProperties

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
private void setUserProperties(String username, IQ reply, JSONObject requestJSON)
{
    Element childElement = reply.setChildElement("response", "http://igniterealtime.org/protocol/ofmeet");

    try {
        UserManager userManager = XMPPServer.getInstance().getUserManager();
        User user = userManager.getUser(username);

        if (requestJSON != null)
        {
            Iterator<?> keys = requestJSON.keys();

            while( keys.hasNext() )
            {
                String key = (String)keys.next();
                String value = requestJSON.getString(key);

                user.getProperties().put(key, value);
            }
        }

    } catch (Exception e) {
        reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, "User " + username + " " + requestJSON.toString() + " " + e));
        return;
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:27,代码来源:OfMeetIQHandler.java

示例6: sendSignalMessage

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
/**
 * Send the signal message asynchronously.
 *
 * @param signalMessage
 */
protected void sendSignalMessage(final Message signalMessage) {
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Sending signal message:{}", signalMessage);
  }
  ExecutorService service = MMXExecutors.getOrCreate(SERVER_ACK_SENDER_POOL,
      10);
  service.submit(new Runnable() {
    @Override
    public void run() {
      PacketRouter router = XMPPServer.getInstance().getPacketRouter();
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Sending signal message:{}", signalMessage);
      }
      router.route(signalMessage);
    }
  });
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXMessageHandlingRule.java

示例7: routeGeoEvent

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
public void routeGeoEvent(final IQ geoIQ) {
  if (componentJids.isEmpty()) {
    // nothing to do
    LOGGER.debug("no external component registered for geo event");
    return;
  }
  String geoService = selectGeoService();
  if (geoService != null && geoService.length() > 0) {
    Message geoMessage = buildGeoMessageFromPubSubIQ(geoIQ);
    if (geoMessage != null) {
      geoMessage.setTo(geoService);
      // TODO create a new message ID?
      geoMessage.setID(geoIQ.getID());
      LOGGER.debug("Sending geo event to external component: " + geoService);
      // start attaching the pieces
      PacketRouter router = XMPPServer.getInstance().getPacketRouter();
      router.route(geoMessage);
    }
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:21,代码来源:GeoEventDispatcher.java

示例8: 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;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:17,代码来源:MMXAppManager.java

示例9: handleListUsers

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
IQ handleListUsers(IQ packet, JID from, String appId, String payload)
    throws UnauthorizedException {
  ListOfUserId userIds = GsonData.getGson().fromJson(payload, ListOfUserId.class);
  HashMap<String, UserInfo> map = new HashMap<String, UserInfo>(userIds.size());
  UserManager userManager = XMPPServer.getInstance().getUserManager();
  for (UserId userId : userIds) {
    String uid = userId.getUserId().toLowerCase();
    String userName = JIDUtil.makeNode(uid, appId);
    try {
      User user = userManager.getUser(userName);
      map.put(uid, new UserInfo()
        .setUserId(uid)
        .setDisplayName(user.getName())
        .setEmail(user.getEmail()));
    } catch (UserNotFoundException e) {
      // Ignored.
    }
  }
  IQ response = IQUtils.createResultIQ(packet, GsonData.getGson().toJson(map));
  return response;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:22,代码来源:MMXUserHandler.java

示例10: handleGetUser

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
IQ handleGetUser(IQ packet, JID from, String appId, String payload) 
    throws UnauthorizedException {
  String userName;
  UserId userId = UserId.fromJson(payload);
  if (userId == null || userId.getUserId() == null)
    userName = from.getNode();
  else
    userName = JIDUtil.makeNode(userId.getUserId().toLowerCase(), appId);
  
  try {
    UserManager userManager = XMPPServer.getInstance().getUserManager();
    User user = userManager.getUser(userName);
    UserInfo accountInfo = new UserInfo()
      .setUserId(userId.getUserId())
      .setDisplayName(user.getName())
      .setEmail(user.getEmail());
    IQ response = IQUtils.createResultIQ(packet, accountInfo.toJson());
    return response;
  } catch (UserNotFoundException e) {
    return IQUtils.createErrorIQ(packet,
        UserOperationStatusCode.USER_NOT_FOUND.getMessage(),
        UserOperationStatusCode.USER_NOT_FOUND.getCode());
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:25,代码来源:MMXUserHandler.java

示例11: 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

示例12: 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();
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:28,代码来源:UserResource.java

示例13: logSessionStatus

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
/**
 * Logs the status of the session.
 */
private void logSessionStatus() {
    final DomainPair pair = new DomainPair(XMPPServer.getInstance().getServerInfo().getXMPPDomain(), domain);
    OutgoingServerSession session = XMPPServer.getInstance().getSessionManager().getOutgoingServerSession(pair);
    if (session != null) {
        int connectionStatus = session.getStatus();
        switch(connectionStatus) {
        case Session.STATUS_CONNECTED:
            Log.info("Session is connected.");
            break;
        case Session.STATUS_CLOSED:
            Log.info("Session is closed.");
            break;
        case Session.STATUS_AUTHENTICATED:
            Log.info("Session is authenticated.");
            break;
        }
    } else {
        Log.info("Failed to establish server to server session.");
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:S2STestService.java

示例14: getConversations

import org.jivesoftware.openfire.XMPPServer; //导入依赖的package包/类
/**
 * Retrieves all the existing conversations from the system.
 *
 * @return a Map of ConversationInfo objects.
 */
public Map<String, ConversationInfo> getConversations(boolean formatParticipants) {
    Map<String, ConversationInfo> cons = new HashMap<String, ConversationInfo>();
    MonitoringPlugin plugin = (MonitoringPlugin)XMPPServer.getInstance().getPluginManager()
        .getPlugin(MonitoringConstants.NAME);
    ConversationManager conversationManager =
        (ConversationManager)plugin.getModule(ConversationManager.class);
    Collection<Conversation> conversations = conversationManager.getConversations();
    List<Conversation> lConversations =
        Arrays.asList(conversations.toArray(new Conversation[conversations.size()]));
    for (Iterator<Conversation> i = lConversations.iterator(); i.hasNext();) {
        Conversation con = i.next();
        ConversationInfo info = toConversationInfo(con, formatParticipants);
        cons.put(Long.toString(con.getConversationID()), info);
    }
    return cons;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:ConversationUtils.java

示例15: 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


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