• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StreamError类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: negotiateTLS

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
* 协商TLS协议
* 
* @return
*/
  private boolean negotiateTLS() {
      if (connection.getTlsPolicy() == Connection.TLSPolicy.disabled) {
	// 设置not_authorized错误
          StreamError error = new StreamError(
                  StreamError.Condition.not_authorized);
          connection.deliverRawText(error.toXML());
          connection.close();
	log.warn("当TLS从未提供服务时,将请求初始化,关闭连接 : " + connection);
          return false;
      }
// 客户要求使用TLS安全连接
      try {
          startTLS();
      } catch (Exception e) {
	log.error("在协商TLS时发生错误:", e);
          connection
                  .deliverRawText("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\">");
          connection.close();
          return false;
      }
      return true;
  }
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:28,代码来源:StanzaHandler.java


示例2: closeStream

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private void closeStream(StreamError streamError)
{
    if (isWebSocketOpen()) {

        if (streamError != null) {
            deliver(streamError.toXML());
        }

        StringBuilder sb = new StringBuilder(250);
        sb.append("<close ");
        sb.append("xmlns='").append(FRAMING_NAMESPACE).append("'");
        sb.append("/>");
        deliver(sb.toString());
        closeWebSocket();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:XmppWebSocket.java


示例3: authenticate

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Authenticates the connection manager. Shared secret is validated with the one provided
 * by the connection manager. If everything went fine then the session will have a status
 * of "authenticated" and the connection manager will receive the client configuration
 * options.
 *
 * @param digest the digest provided by the connection manager with the handshake stanza.
 * @return true if the connection manager was sucessfully authenticated.
 */
public boolean authenticate(String digest) {
    // Perform authentication. Wait for the handshake (with the secret key)
    String anticipatedDigest = AuthFactory.createDigest(getStreamID().getID(),
            ConnectionMultiplexerManager.getDefaultSecret());
    // Check that the provided handshake (secret key + sessionID) is correct
    if (!anticipatedDigest.equalsIgnoreCase(digest)) {
        Log.debug("LocalConnectionMultiplexerSession: [ConMng] Incorrect handshake for connection manager with domain: " +
                getAddress().getDomain());
        //  The credentials supplied by the initiator are not valid (answer an error
        // and close the connection)
        conn.deliverRawText(new StreamError(StreamError.Condition.not_authorized).toXML());
        // Close the underlying connection
        conn.close();
        return false;
    }
    else {
        // Component has authenticated fine
        setStatus(STATUS_AUTHENTICATED);
        // Send empty handshake element to acknowledge success
        conn.deliverRawText("<handshake></handshake>");
        Log.debug("LocalConnectionMultiplexerSession: [ConMng] Connection manager was AUTHENTICATED with domain: " + getAddress());
        sendClientOptions();
        return true;
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:35,代码来源:LocalConnectionMultiplexerSession.java


示例4: negotiateTLS

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private boolean negotiateTLS() {
    if (connection.getTlsPolicy() == Connection.TLSPolicy.disabled) {
        // Set the not_authorized error
        StreamError error = new StreamError(
                StreamError.Condition.not_authorized);
        connection.deliverRawText(error.toXML());
        connection.close();
        log.warn("TLS requested by initiator when TLS was never offered"
                + " by server. Closing connection : " + connection);
        return false;
    }
    // Client requested to secure the connection using TLS.
    try {
        startTLS();
    } catch (Exception e) {
        log.error("Error while negotiating TLS", e);
        connection
                .deliverRawText("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\">");
        connection.close();
        return false;
    }
    return true;
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:24,代码来源:StanzaHandler.java


示例5: negotiateTLS

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Tries to secure the connection using TLS. If the connection is secured then reset
 * the parser to use the new secured reader. But if the connection failed to be secured
 * then send a <failure> stanza and close the connection.
 *
 * @return true if the connection was secured.
 */
private boolean negotiateTLS() {
    if (connection.getTlsPolicy() == Connection.TLSPolicy.disabled) {
        // Set the not_authorized error
        StreamError error = new StreamError(StreamError.Condition.not_authorized);
        // Deliver stanza
        connection.deliverRawText(error.toXML());
        // Close the underlying connection
        connection.close();
        // Log a warning so that admins can track this case from the server side
        Log.warn("TLS requested by initiator when TLS was never offered by server. " +
                "Closing connection : " + connection);
        return false;
    }
    // Client requested to secure the connection using TLS. Negotiate TLS.
    try {
        startTLS();
    }
    catch (Exception e) {
        Log.error("Error while negotiating TLS", e);
        connection.deliverRawText("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\">");
        connection.close();
        return false;
    }
    return true;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:33,代码来源:StanzaHandler.java


示例6: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
* 创建Session
* 
* @param xpp
*            xmlpull解析器
* @throws XmlPullParserException
*             xmlpull解析器异常
* @throws IOException
*             IO异常
*/
  private void createSession(XmlPullParser xpp)
          throws XmlPullParserException, IOException {
      for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
          eventType = xpp.next();
      }
// 基于所发送的命名空间创建正确的会话
      String namespace = xpp.getNamespace(null);
      if ("jabber:client".equals(namespace)) {
          session = ClientSession.createSession(serverName, connection, xpp);
          if (session == null) {
              StringBuilder sb = new StringBuilder(250);
              sb.append("<?xml version='1.0' encoding='UTF-8'?>");
              sb.append("<stream:stream from=\"").append(serverName);
              sb.append("\" id=\"").append(randomString(5));
              sb.append("\" xmlns=\"").append(xpp.getNamespace(null));
              sb.append("\" xmlns:stream=\"").append(
                      xpp.getNamespace("stream"));
              sb.append("\" version=\"1.0\">");

		// 响应中的一个糟糕的命名空间前缀
              StreamError error = new StreamError(
                      StreamError.Condition.bad_namespace_prefix);
              sb.append(error.toXML());
              connection.deliverRawText(sb.toString());
              connection.close();
		log.warn("由于bad_namespace_prefix关闭session在数据流的头部: " + namespace);
          }
      }
  }
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:40,代码来源:StanzaHandler.java


示例7: terminateSessions

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Terminate open session for the user with specified user name. Username should be complete ie it should
 * include the % appid.
 * @param username
 */
public static void terminateSessions(String username) throws ServerNotInitializedException {
  final StreamError error = new StreamError(StreamError.Condition.not_authorized);
  for (ClientSession session : getSessionManager().getSessions(username) ) {
    LOGGER.info("Terminating session for user with name:{}", username);
    session.deliverRawText(error.toXML());
    session.close();
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:14,代码来源:UserManagerService.java


示例8: onError

import org.xmpp.packet.StreamError; //导入依赖的package包/类
@OnWebSocketError
public void onError(Throwable error)
{
    Log.error("Error detected; session: " + wsSession, error);
    closeStream(new StreamError(StreamError.Condition.internal_server_error));
    try {
        if (wsSession != null) {
            wsSession.disconnect();
        }
    } catch ( Exception e ) {
        Log.error("Error disconnecting websocket", e);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:XmppWebSocket.java


示例9: closeNeverSecuredConnection

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Close the connection since TLS was mandatory and the entity never negotiated TLS. Before
 * closing the connection a stream error will be sent to the entity.
 */
void closeNeverSecuredConnection() {
    // Set the not_authorized error
    StreamError error = new StreamError(StreamError.Condition.not_authorized);
    // Deliver stanza
    connection.deliverRawText(error.toXML());
    // Close the underlying connection
    connection.close();
    // Log a warning so that admins can track this case from the server side
    Log.warn("TLS was required by the server and connection was never secured. " +
            "Closing connection : " + connection);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:SocketReader.java


示例10: deleteUser

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private static void deleteUser(User oldUser) {
    UserManager.getInstance().deleteUser(oldUser);
    final StreamError error = new StreamError(StreamError.Condition.not_authorized);
    for (ClientSession sess : SessionManager.getInstance().getSessions(oldUser.getUsername())) {
        sess.deliverRawText(error.toXML());
        sess.close();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:9,代码来源:JustMarriedPlugin.java


示例11: closeSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Sends an unsupported version error and name of client the user attempted to connect with.
 *
 * @param session    the users current session.
 * @param clientName the name of the client they were connecting with.
 */
private void closeSession(final Session session, String clientName) {
    // Increase the number of logins not allowed by 1.
    disconnects.incrementAndGet();

    Log.debug("Closed connection to client attempting to connect from " + clientName);

    // Send message information user.
    final Message message = new Message();
    message.setFrom(serviceName + "." + componentManager.getServerName());
    message.setTo(session.getAddress());

    message.setBody("You are using an invalid client, and therefore will be disconnected. "
            + "Please ask your system administrator for client choices.");

    // Send Message
    sendPacket(message);

    // Disconnect user after 5 seconds.
    taskEngine.schedule(new TimerTask() {
        @Override
        public void run() {
            // Include the not-authorized error in the response
            StreamError error = new StreamError(StreamError.Condition.policy_violation);
            session.deliverRawText(error.toXML());
            // Close the underlying connection
            session.close();
        }
    }, 5000);


}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:SparkManager.java


示例12: disableUser

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Disable user.
 *
 * @param username
 *            the username
 * @throws ServiceException
 *             the service exception
 */
public void disableUser(String username) throws ServiceException {
    getAndCheckUser(username);
    lockOutManager.disableAccount(username, null, null);
    
    if (lockOutManager.isAccountDisabled(username)) {
        final StreamError error = new StreamError(StreamError.Condition.not_authorized);
        for (ClientSession sess : SessionManager.getInstance().getSessions(username)) {
            sess.deliverRawText(error.toXML());
            sess.close();
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:21,代码来源:UserServiceController.java


示例13: removeUserSessions

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Removes the user sessions.
 *
 * @param username the username
 * @throws ServiceException the service exception
 */
public void removeUserSessions(String username) throws ServiceException {
    final StreamError error = new StreamError(StreamError.Condition.not_authorized);
    for (ClientSession session : SessionManager.getInstance().getSessions(username)) {
        session.deliverRawText(error.toXML());
        session.close();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:14,代码来源:SessionController.java


示例14: deleteUser

import org.xmpp.packet.StreamError; //导入依赖的package包/类
/**
 * Delete user.
 *
 * @param oldUser
 *            the old user
 */
private static void deleteUser(User oldUser) {
    UserManager.getInstance().deleteUser(oldUser);
    LockOutManager.getInstance().enableAccount(oldUser.getUsername());
    final StreamError error = new StreamError(StreamError.Condition.not_authorized);
    for (ClientSession sess : SessionManager.getInstance().getSessions(oldUser.getUsername())) {
        sess.deliverRawText(error.toXML());
        sess.close();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:JustMarriedController.java


示例15: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private void createSession(XmlPullParser xpp)
        throws XmlPullParserException, IOException {
    for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
        eventType = xpp.next();
    }
    // Create the correct session based on the sent namespace
    String namespace = xpp.getNamespace(null);
    if ("jabber:client".equals(namespace)) {
        session = ClientSession.createSession(serverName, connection, xpp);
        if (session == null) {
            StringBuilder sb = new StringBuilder(250);
            sb.append("<?xml version='1.0' encoding='UTF-8'?>");
            sb.append("<stream:stream from=\"").append(serverName);
            sb.append("\" id=\"").append(randomString(5));
            sb.append("\" xmlns=\"").append(xpp.getNamespace(null));
            sb.append("\" xmlns:stream=\"").append(
                    xpp.getNamespace("stream"));
            sb.append("\" version=\"1.0\">");

            // bad-namespace-prefix in the response
            StreamError error = new StreamError(
                    StreamError.Condition.bad_namespace_prefix);
            sb.append(error.toXML());
            connection.deliverRawText(sb.toString());
            connection.close();
            log
                    .warn("Closing session due to bad_namespace_prefix in stream header: "
                            + namespace);
        }
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:32,代码来源:StanzaHandler.java


示例16: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
protected void createSession(XmlPullParser xpp)
        throws XmlPullParserException, IOException {
    for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
        eventType = xpp.next();
    }

    // Create the correct session based on the sent namespace     
    boolean ssCreated = createSession(xpp.getNamespace(null), serverName,
            xpp, connection);

    // No session was created because of an invalid namespace prefix
    if (!ssCreated) {
        StringBuilder sb = new StringBuilder(250);
        sb.append("<?xml version='1.0' encoding='");
        sb.append(CHARSET);
        sb.append("'?>");
        sb.append("<stream:stream ");
        sb.append("from=\"").append(serverName).append("\" ");
        sb.append("id=\"").append(StringUtils.randomString(5))
                .append("\" ");
        sb.append("xmlns=\"").append(xpp.getNamespace(null)).append("\" ");
        sb.append("xmlns:stream=\"").append(xpp.getNamespace("stream"))
                .append("\" ");
        sb.append("version=\"1.0\">");

        // Include the bad-namespace-prefix in the response
        StreamError error = new StreamError(
                StreamError.Condition.bad_namespace_prefix);
        sb.append(error.toXML());
        connection.deliverRawText(sb.toString());
        connection.close();
        log
                .warn("Closing session due to bad_namespace_prefix in stream header. Prefix: "
                        + xpp.getNamespace(null)
                        + ". Connection: "
                        + connection);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:39,代码来源:StanzaHandler.java


示例17: processIQ

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private void processIQ(Element doc) {
    log.debug("processIQ()...");
    IQ packet;
    try {
        packet = getIQ(doc);
    } catch (IllegalArgumentException e) {
        log.debug("Rejecting packet. JID malformed", e);
        IQ reply = new IQ();
        if (!doc.elements().isEmpty()) {
            reply.setChildElement(((Element) doc.elements().get(0))
                    .createCopy());
        }
        reply.setID(doc.attributeValue("id"));
        reply.setTo(session.getAddress());
        if (doc.attributeValue("to") != null) {
            reply.getElement().addAttribute("from",
                    doc.attributeValue("to"));
        }
        reply.setError(PacketError.Condition.jid_malformed);
        session.process(reply);
        return;
    }
    if (packet.getID() == null
            && Config.getBoolean("xmpp.server.validation.enabled", false)) {
        // IQ packets MUST have an 'id' attribute
        StreamError error = new StreamError(
                StreamError.Condition.invalid_xml);
        session.deliverRawText(error.toXML());
        session.close();
        return;
    }

    packet.setFrom(session.getAddress());
    router.route(packet);
    session.incrementClientPacketCount();
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:37,代码来源:StanzaHandler.java


示例18: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private void createSession(XmlPullParser xpp)
        throws XmlPullParserException, IOException {
    for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
        eventType = xpp.next();
    }

    // Create the correct session based on the sent namespace
    String namespace = xpp.getNamespace(null);
    if ("jabber:client".equals(namespace)) {
        session = ClientSession.createSession(serverName, xpp, connection);
        // If no session was created
        if (session == null) {
            StringBuilder sb = new StringBuilder(250);
            sb.append("<?xml version='1.0' encoding='");
            sb.append(CHARSET);
            sb.append("'?>");
            sb.append("<stream:stream ");
            sb.append("from=\"").append(serverName).append("\" ");
            sb.append("id=\"").append(StringUtils.randomString(5)).append(
                    "\" ");
            sb.append("xmlns=\"").append(xpp.getNamespace(null)).append(
                    "\" ");
            sb.append("xmlns:stream=\"").append(xpp.getNamespace("stream"))
                    .append("\" ");
            sb.append("version=\"1.0\">");

            // Include the bad-namespace-prefix in the response
            StreamError error = new StreamError(
                    StreamError.Condition.bad_namespace_prefix);
            sb.append(error.toXML());
            connection.deliverRawText(sb.toString());
            connection.close();
            log
                    .warn("Closing session due to bad_namespace_prefix in stream header. Prefix: "
                            + xpp.getNamespace(null)
                            + ". Connection: "
                            + connection);
        }
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:41,代码来源:StanzaHandler.java


示例19: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
protected void createSession(XmlPullParser xpp)
        throws XmlPullParserException, IOException {
    for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
        eventType = xpp.next();
    }

    // Create the correct session based on the sent namespace     
    boolean ssCreated = createSession(xpp.getNamespace(null), serverName,
            xpp, connection);

    // If no session was created because of an invalid namespace prefix
    if (!ssCreated) {
        StringBuilder sb = new StringBuilder(250);
        sb.append("<?xml version='1.0' encoding='");
        sb.append(CHARSET);
        sb.append("'?>");
        sb.append("<stream:stream ");
        sb.append("from=\"").append(serverName).append("\" ");
        sb.append("id=\"").append(StringUtils.randomString(5))
                .append("\" ");
        sb.append("xmlns=\"").append(xpp.getNamespace(null)).append("\" ");
        sb.append("xmlns:stream=\"").append(xpp.getNamespace("stream"))
                .append("\" ");
        sb.append("version=\"1.0\">");

        // Include the bad-namespace-prefix in the response
        StreamError error = new StreamError(
                StreamError.Condition.bad_namespace_prefix);
        sb.append(error.toXML());
        connection.deliverRawText(sb.toString());
        connection.close();
        log
                .warn("Closing session due to bad_namespace_prefix in stream header. Prefix: "
                        + xpp.getNamespace(null)
                        + ". Connection: "
                        + connection);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:39,代码来源:StanzaHandler.java


示例20: createSession

import org.xmpp.packet.StreamError; //导入依赖的package包/类
private void createSession(XmlPullParser xpp)
        throws XmlPullParserException, IOException {
    for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
        eventType = xpp.next();
    }

    // Create the correct session based on the sent namespace
    String namespace = xpp.getNamespace(null);
    if ("jabber:client".equals(namespace)) {
        session = ClientSession.createSession(serverName, connection, xpp);
        // If no session was created
        if (session == null) {
            StringBuilder sb = new StringBuilder(250);
            sb.append("<?xml version='1.0' encoding='UTF-8'?>");
            sb.append("<stream:stream ");
            sb.append("from=\"").append(serverName).append("\" ");
            sb.append("id=\"").append(StringUtils.randomString(5)).append(
                    "\" ");
            sb.append("xmlns=\"").append(xpp.getNamespace(null)).append(
                    "\" ");
            sb.append("xmlns:stream=\"").append(xpp.getNamespace("stream"))
                    .append("\" ");
            sb.append("version=\"1.0\">");

            // Include the bad-namespace-prefix in the response
            StreamError error = new StreamError(
                    StreamError.Condition.bad_namespace_prefix);
            sb.append(error.toXML());
            connection.deliverRawText(sb.toString());
            connection.close();
            log
                    .warn("Closing session due to bad_namespace_prefix in stream header. Prefix: "
                            + xpp.getNamespace(null)
                            + ". Connection: "
                            + connection);
        }
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:39,代码来源:StanzaHandler.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JspPropertyGroupDescriptor类代码示例发布时间:2022-05-22
下一篇:
Java Flag类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap