use of org.jivesoftware.openfire.session.LocalSession in project Openfire by igniterealtime.
the class WebSocketPlugin method destroyPlugin.
@Override
public void destroyPlugin() {
// 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();
}
}
}
ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
contexts.removeHandler(contextHandler);
contextHandler = null;
pluginClassLoader = null;
}
use of org.jivesoftware.openfire.session.LocalSession in project Openfire by igniterealtime.
the class NIOConnection method reinit.
@Override
public void reinit(LocalSession owner) {
session = owner;
StanzaHandler stanzaHandler = getStanzaHandler();
stanzaHandler.setSession(owner);
// during the callback. OF-2014
for (final Map.Entry<ConnectionCloseListener, Object> entry : closeListeners.entrySet()) {
if (entry.getValue() instanceof LocalSession) {
entry.setValue(owner);
}
}
}
use of org.jivesoftware.openfire.session.LocalSession in project Openfire by igniterealtime.
the class LocalSessionManager method stop.
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.
}
}
use of org.jivesoftware.openfire.session.LocalSession in project Openfire by igniterealtime.
the class SaslServerFactoryImpl method createSaslServer.
@Override
public SaslServer createSaslServer(String mechanism, String protocol, String serverName, Map<String, ?> props, CallbackHandler cbh) throws SaslException {
if (!Arrays.asList(getMechanismNames(props)).contains(mechanism)) {
Log.debug("This implementation is unable to create a SaslServer instance for the {} mechanism using the provided properties.", mechanism);
return null;
}
switch(mechanism.toUpperCase()) {
case "PLAIN":
if (cbh == null) {
Log.debug("Unable to instantiate {} SaslServer: A callbackHandler with support for Password, Name, and AuthorizeCallback required.", mechanism);
return null;
}
return new SaslServerPlainImpl(protocol, serverName, props, cbh);
case "SCRAM-SHA-1":
return new ScramSha1SaslServer();
case "ANONYMOUS":
if (!props.containsKey(LocalSession.class.getCanonicalName())) {
Log.debug("Unable to instantiate {} SaslServer: Provided properties do not contain a LocalSession instance.", mechanism);
return null;
} else {
final LocalSession session = (LocalSession) props.get(LocalSession.class.getCanonicalName());
return new AnonymousSaslServer(session);
}
case "EXTERNAL":
if (!props.containsKey(LocalSession.class.getCanonicalName())) {
Log.debug("Unable to instantiate {} SaslServer: Provided properties do not contain a LocalSession instance.", mechanism);
return null;
} else {
final Object session = props.get(LocalSession.class.getCanonicalName());
if (session instanceof LocalClientSession) {
return new ExternalClientSaslServer((LocalClientSession) session);
}
if (session instanceof LocalIncomingServerSession) {
return new ExternalServerSaslServer((LocalIncomingServerSession) session);
}
Log.debug("Unable to instantiate {} Sasl Server: Provided properties contains neither LocalClientSession nor LocalIncomingServerSession instance.", mechanism);
return null;
}
case JiveSharedSecretSaslServer.NAME:
return new JiveSharedSecretSaslServer();
default:
// Fail fast - this should not be possible, as the first check in this method already verifies wether the mechanism is supported.
throw new IllegalStateException();
}
}
use of org.jivesoftware.openfire.session.LocalSession in project Openfire by igniterealtime.
the class OpenfireWebSocketServlet method destroy.
@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) {
Log.debug("Closing session as websocket servlet is being destroyed: {}", session);
session.close();
}
}
}
super.destroy();
}
Aggregations