• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java LocalSession类的典型用法和代码示例

java 2次浏览

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

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

示例1: destroy

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void destroy()
{
    // terminate any active websocket sessions
    SessionManager sm = XMPPServer.getInstance().getSessionManager();
    for (ClientSession session : sm.getSessions()) {
        if (session instanceof LocalSession) {
            Object ws = ((LocalSession) session).getSessionData("ws");
            if (ws != null && (Boolean) ws) {
                session.close();
            }
        }
    }

    super.destroy();
}
 

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

示例2: process

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
/**
 * Handle presence updates that affect roster subscriptions.
 *
 * @param presence The presence presence to handle
 * @throws PacketException if the packet is null or the packet could not be routed.
 */
public void process(Presence presence) throws PacketException {
    try {
        process((Packet)presence);
    }
    catch (UnauthorizedException e) {
        try {
            LocalSession session = (LocalSession) sessionManager.getSession(presence.getFrom());
            presence = presence.createCopy();
            if (session != null) {
                presence.setFrom(new JID(null, session.getServerName(), null, true));
                presence.setTo(session.getAddress());
            }
            else {
                JID sender = presence.getFrom();
                presence.setFrom(presence.getTo());
                presence.setTo(sender);
            }
            presence.setError(PacketError.Condition.not_authorized);
            deliverer.deliver(presence);
        }
        catch (Exception err) {
            Log.error(LocaleUtils.getLocalizedString("admin.error"), err);
        }
    }
}
 

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

示例3: stop

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void stop() {
    try {
        // Send the close stream header to all connected connections
        for (RoutableChannelHandler route : routes.values()) {
            if (route instanceof LocalSession) {
                LocalSession session = (LocalSession) route;
                try {
                    // Notify connected client that the server is being shut down
                    session.getConnection().systemShutdown();
                }
                catch (Throwable t) {
                    // Ignore.
                }
            }
        }
    }
    catch (Exception e) {
        // Ignore.
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:21,
代码来源:LocalRoutingTable.java

示例4: doSharedSecretAuthentication

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static Status doSharedSecretAuthentication(LocalSession session, Element doc)
        throws UnsupportedEncodingException
{
    String secretDigest;
    String response = doc.getTextTrim();
    if (response == null || response.length() == 0) {
        // No info was provided so send a challenge to get it
        sendChallenge(session, new byte[0]);
        return Status.needResponse;
    }

    // Parse data and obtain username & password
    String data = new String(StringUtils.decodeBase64(response), CHARSET);
    StringTokenizer tokens = new StringTokenizer(data, "\0");
    tokens.nextToken();
    secretDigest = tokens.nextToken();
    if (authenticateSharedSecret(secretDigest)) {
        authenticationSuccessful(session, null, null);
        return Status.authenticated;
    }
    // Otherwise, authentication failed.
    authenticationFailed(session);
    return Status.failed;
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:25,
代码来源:SASLAuthentication.java

示例5: authenticationFailed

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static void authenticationFailed(LocalSession session) {
    StringBuilder reply = new StringBuilder(80);
    reply.append("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
    reply.append("<not-authorized/></failure>");
    session.deliverRawText(reply.toString());
    // Give a number of retries before closing the connection
    Integer retries = (Integer) session.getSessionData("authRetries");
    if (retries == null) {
        retries = 1;
    }
    else {
        retries = retries + 1;
    }
    session.setSessionData("authRetries", retries);
    if (retries >= JiveGlobals.getIntProperty("xmpp.auth.retries", 3) ) {
        // Close the connection
        session.close();
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:20,
代码来源:SASLAuthentication.java

示例6: doSharedSecretAuthentication

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static Status doSharedSecretAuthentication(LocalSession session, Element doc)
        throws UnsupportedEncodingException
{
    String secretDigest;
    String response = doc.getTextTrim();
    if (response == null || response.length() == 0) {
        // No info was provided so send a challenge to get it
        sendChallenge(session, new byte[0]);
        return Status.needResponse;
    }

    // Parse data and obtain username & password
    String data = new String(StringUtils.decodeBase64(response), CHARSET);
    StringTokenizer tokens = new StringTokenizer(data, "\0");
    tokens.nextToken();
    secretDigest = tokens.nextToken();
    if (authenticateSharedSecret(secretDigest)) {
        authenticationSuccessful(session, null, null);
        return Status.authenticated;
    }
    // Otherwise, authentication failed.
    authenticationFailed(session, Failure.NOT_AUTHORIZED);
    return Status.failed;
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:25,
代码来源:SASLAuthentication.java

示例7: authenticationFailed

点赞 3

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static void authenticationFailed(LocalSession session, Failure failure) {
    StringBuilder reply = new StringBuilder(80);
    reply.append("<failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><");
    reply.append(failure.toString());
    reply.append("/></failure>");
    session.deliverRawText(reply.toString());
    // Give a number of retries before closing the connection
    Integer retries = (Integer) session.getSessionData("authRetries");
    if (retries == null) {
        retries = 1;
    }
    else {
        retries = retries + 1;
    }
    session.setSessionData("authRetries", retries);
    if (retries >= JiveGlobals.getIntProperty("xmpp.auth.retries", 3) ) {
        // Close the connection
        session.close();
    }
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:21,
代码来源:SASLAuthentication.java

示例8: stop

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void stop() {
    try {
        // Send the close stream header to all connected connections
        Set<LocalSession> sessions = new HashSet<>();
        sessions.addAll(preAuthenticatedSessions.values());
        sessions.addAll(componentsSessions);
        for (LocalIncomingServerSession incomingSession : incomingServerSessions.values()) {
            sessions.add(incomingSession);
        }
        for (LocalConnectionMultiplexerSession multiplexer : connnectionManagerSessions.values()) {
            sessions.add(multiplexer);
        }

        for (LocalSession session : sessions) {
            try {
                // Notify connected client that the server is being shut down
                if (!session.isDetached()) {
                    session.getConnection().systemShutdown();
                }
            }
            catch (Throwable t) {
                // Ignore.
            }
        }
    }
    catch (Exception e) {
        // Ignore.
    }
}
 

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

示例9: StreamManager

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public StreamManager(LocalSession session) {
    String address;
    try {
        address = session.getConnection().getHostAddress();
    }
    catch ( UnknownHostException e )
    {
        address = null;
    }

    this.Log = LoggerFactory.getLogger(StreamManager.class + "["+ (address == null ? "(unknown address)" : address) +"]" );
    this.session = session;
}
 

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

示例10: stop

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void stop() {
    try {
        // Send the close stream header to all connected connections
        Set<LocalSession> sessions = new HashSet<LocalSession>();
        sessions.addAll(preAuthenticatedSessions.values());
        sessions.addAll(componentsSessions);
        for (LocalIncomingServerSession incomingSession : incomingServerSessions.values()) {
            sessions.add(incomingSession);
        }
        for (LocalConnectionMultiplexerSession multiplexer : connnectionManagerSessions.values()) {
            sessions.add(multiplexer);
        }

        for (LocalSession session : sessions) {
            try {
                // Notify connected client that the server is being shut down
                session.getConnection().systemShutdown();
            }
            catch (Throwable t) {
                // Ignore.
            }
        }
    }
    catch (Exception e) {
        // Ignore.
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:28,
代码来源:LocalSessionManager.java

示例11: doAnonymousAuthentication

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static Status doAnonymousAuthentication(LocalSession session) {
    if (XMPPServer.getInstance().getIQAuthHandler().isAnonymousAllowed()) {
        // Verify that client can connect from his IP address
        boolean forbidAccess = false;
        try {
            String hostAddress = session.getConnection().getHostAddress();
            if (!LocalClientSession.getAllowedAnonymIPs().isEmpty() &&
                    !LocalClientSession.getAllowedAnonymIPs().containsKey(hostAddress)) {
                byte[] address = session.getConnection().getAddress();
                String range1 = (address[0] & 0xff) + "." + (address[1] & 0xff) + "." +
                        (address[2] & 0xff) +
                        ".*";
                String range2 = (address[0] & 0xff) + "." + (address[1] & 0xff) + ".*.*";
                String range3 = (address[0] & 0xff) + ".*.*.*";
                if (!LocalClientSession.getAllowedAnonymIPs().containsKey(range1) &&
                        !LocalClientSession.getAllowedAnonymIPs().containsKey(range2) &&
                        !LocalClientSession.getAllowedAnonymIPs().containsKey(range3)) {
                    forbidAccess = true;
                }
            }
        } catch (UnknownHostException e) {
            forbidAccess = true;
        }
        if (forbidAccess) {
            authenticationFailed(session);
            return Status.failed;
        }
        // Just accept the authentication :)
        authenticationSuccessful(session, null, null);
        return Status.authenticated;
    }
    else {
        // anonymous login is disabled so close the connection
        authenticationFailed(session);
        return Status.failed;
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:38,
代码来源:SASLAuthentication.java

示例12: authenticationSuccessful

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static void authenticationSuccessful(LocalSession session, String username,
        byte[] successData) {
    if (username != null && LockOutManager.getInstance().isAccountDisabled(username)) {
        // Interception!  This person is locked out, fail instead!
        LockOutManager.getInstance().recordFailedLogin(username);
        authenticationFailed(session);
        return;
    }
    StringBuilder reply = new StringBuilder(80);
    reply.append("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"");
    if (successData != null) {
        String successData_b64 = StringUtils.encodeBase64(successData).trim();
        reply.append(">").append(successData_b64).append("</success>");
    }
    else {
        reply.append("/>");
    }
    session.deliverRawText(reply.toString());
    // We only support SASL for c2s
    if (session instanceof ClientSession) {
        ((LocalClientSession) session).setAuthToken(new AuthToken(username));
    }
    else if (session instanceof IncomingServerSession) {
        String hostname = username;
        // Add the validated domain as a valid domain. The remote server can
        // now send packets from this address
        ((LocalIncomingServerSession) session).addValidatedDomain(hostname);
    }
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:30,
代码来源:SASLAuthentication.java

示例13: doAnonymousAuthentication

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static Status doAnonymousAuthentication(LocalSession session) {
    if (XMPPServer.getInstance().getIQAuthHandler().isAnonymousAllowed()) {
        // Verify that client can connect from his IP address
        boolean forbidAccess = false;
        try {
            String hostAddress = session.getConnection().getHostAddress();
            if (!LocalClientSession.getAllowedAnonymIPs().isEmpty() &&
                    !LocalClientSession.getAllowedAnonymIPs().containsKey(hostAddress)) {
                byte[] address = session.getConnection().getAddress();
                String range1 = (address[0] & 0xff) + "." + (address[1] & 0xff) + "." +
                        (address[2] & 0xff) +
                        ".*";
                String range2 = (address[0] & 0xff) + "." + (address[1] & 0xff) + ".*.*";
                String range3 = (address[0] & 0xff) + ".*.*.*";
                if (!LocalClientSession.getAllowedAnonymIPs().containsKey(range1) &&
                        !LocalClientSession.getAllowedAnonymIPs().containsKey(range2) &&
                        !LocalClientSession.getAllowedAnonymIPs().containsKey(range3)) {
                    forbidAccess = true;
                }
            }
        } catch (UnknownHostException e) {
            forbidAccess = true;
        }
        if (forbidAccess) {
            authenticationFailed(session, Failure.NOT_AUTHORIZED);
            return Status.failed;
        }
        // Just accept the authentication :)
        authenticationSuccessful(session, null, null);
        return Status.authenticated;
    }
    else {
        // anonymous login is disabled so close the connection
        authenticationFailed(session, Failure.NOT_AUTHORIZED);
        return Status.failed;
    }
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:38,
代码来源:SASLAuthentication.java

示例14: authenticationSuccessful

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
private static void authenticationSuccessful(LocalSession session, String username,
        byte[] successData) {
    if (username != null && LockOutManager.getInstance().isAccountDisabled(username)) {
        // Interception!  This person is locked out, fail instead!
        LockOutManager.getInstance().recordFailedLogin(username);
        authenticationFailed(session, Failure.ACCOUNT_DISABLED);
        return;
    }
    StringBuilder reply = new StringBuilder(80);
    reply.append("<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"");
    if (successData != null) {
        String successData_b64 = StringUtils.encodeBase64(successData).trim();
        reply.append(">").append(successData_b64).append("</success>");
    }
    else {
        reply.append("/>");
    }
    session.deliverRawText(reply.toString());
    // We only support SASL for c2s
    if (session instanceof ClientSession) {
        ((LocalClientSession) session).setAuthToken(new AuthToken(username));
    }
    else if (session instanceof IncomingServerSession) {
        String hostname = username;
        // Add the validated domain as a valid domain. The remote server can
        // now send packets from this address
        ((LocalIncomingServerSession) session).addValidatedDomain(hostname);
    }
}
 

开发者ID:idwanglu2010,
项目名称:openfire,
代码行数:30,
代码来源:SASLAuthentication.java

示例15: AnonymousSaslServer

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public AnonymousSaslServer( LocalSession session )
{
    this.session = session;
}
 

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

示例16: reinit

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void reinit(LocalSession session) {
    this.socket.setXmppSession((LocalClientSession)session);
    super.reinit(session);
}
 

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

示例17: setSession

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void setSession(LocalSession session) {
    this.session = session;
}
 

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

示例18: init

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void init(LocalSession owner) {
    session = owner;
}
 

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

示例19: reinit

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void reinit(LocalSession owner) {
    session = owner;
}
 

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

示例20: init

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void init(LocalSession session) {
    this.session = session;
}
 

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

示例21: reinit

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void reinit(LocalSession session) {
    this.session = session;
}
 

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

示例22: reinit

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
@Override
public void reinit(LocalSession owner) {
    session = owner;
    StanzaHandler stanzaHandler = getStanzaHandler();
    stanzaHandler.setSession(owner);
}
 

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

示例23: init

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void init(LocalSession owner) {
    session = owner;
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:4,
代码来源:SocketConnection.java

示例24: init

点赞 2

import org.jivesoftware.openfire.session.LocalSession; //导入依赖的package包/类
public void init(LocalSession session) {
    this.session = session;
}
 

开发者ID:coodeer,
项目名称:g3server,
代码行数:4,
代码来源:VirtualConnection.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)