Package org.jivesoftware.openfire

Examples of org.jivesoftware.openfire.Connection


     * @param hostName the address's hostname of the client or null if using old connection manager.
     * @param hostAddress the textual representation of the address of the client or null if using old CM.
     * @return true if a session was created or false if the client should disconnect.
     */
    public boolean createClientSession(String connectionManagerDomain, String streamID, String hostName, String hostAddress) {
        Connection connection = new ClientSessionConnection(connectionManagerDomain, hostName, hostAddress);
        // Check if client is allowed to connect from the specified IP address. Ignore the checking if connection
        // manager is old version and is not passing client's address
        byte[] address = null;
        try {
            address = connection.getAddress();
        } catch (UnknownHostException e) {
            // Ignore
        }
        if (address == null || LocalClientSession.isAllowed(connection)) {
            LocalClientSession session =
View Full Code Here


            if (!verify) {
                authenticationSuccessful(session, hostname, null);
                return Status.authenticated;
            }
            // Check that hostname matches the one provided in a certificate
            Connection connection = session.getConnection();
           
            for (Certificate certificate : connection.getPeerCertificates()) {
                for (String identity : CertificateManager.getPeerIdentities((X509Certificate) certificate)) {
                    // Verify that either the identity is the same as the hostname, or for wildcarded
                    // identities that the hostname ends with .domainspecified or -is- domainspecified.
                    if ((identity.startsWith("*.")
                         && (hostname.endsWith(identity.replace("*.", "."))
                             || hostname.equals(identity.replace("*.", ""))))
                            || hostname.equals(identity)) {
                        authenticationSuccessful(session, hostname, null);
                        return Status.authenticated;
                    }
                }
            }

        }
        else if (session instanceof LocalClientSession) {
            // Client EXTERNALL login
            Log.debug("SASLAuthentication: EXTERNAL authentication via SSL certs for c2s connection");
           
            // This may be null, we will deal with that later
            String username = new String(StringUtils.decodeBase64(doc.getTextTrim()), CHARSET);
            String principal = "";
            ArrayList<String> principals = new ArrayList<String>();
            Connection connection = session.getConnection();
            if (connection.getPeerCertificates().length < 1) {
                Log.debug("SASLAuthentication: EXTERNAL authentication requested, but no certificates found.");
                authenticationFailed(session);
                return Status.failed;
            }

            for (Certificate certificate : connection.getPeerCertificates()) {
                principals.addAll(CertificateManager.getPeerIdentities((X509Certificate)certificate));
            }

            if(principals.size() == 1) {
                principal = principals.get(0);
View Full Code Here

    }

    @Override
  public void sessionClosed(IoSession session) throws Exception {
        // Get the connection for this session
        Connection connection = (Connection) session.getAttribute(CONNECTION);
        // Inform the connection that it was closed
        connection.close();
    }
View Full Code Here

   */
    @Override
  public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
        if (session.getIdleCount(status) > 1) {
            // Get the connection for this session
            final Connection connection = (Connection) session.getAttribute(CONNECTION);
          // Close idle connection
          if (Log.isDebugEnabled()) {
              Log.debug("ConnectionHandler: Closing connection that has been idle: " + connection);
          }
          connection.close();
        }
    }
View Full Code Here

        // Let the stanza handler process the received stanza
        try {
            handler.process((String) message, parser);
        } catch (Exception e) {
            Log.error("Closing connection due to error while processing message: " + message, e);
            Connection connection = (Connection) session.getAttribute(CONNECTION);
            connection.close();
        }
    }
View Full Code Here

            IQPingHandler.NAMESPACE);
        pingRequest.setFrom(serverName);
        pingRequest.setTo(entity);
       
              // Get the connection for this session
              final Connection connection = (Connection) session.getAttribute(CONNECTION);

            if (Log.isDebugEnabled()) {
                Log.debug("ConnectionHandler: Pinging connection that has been idle: " + connection);
            }

            connection.deliver(pingRequest);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jivesoftware.openfire.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.