use of org.jivesoftware.openfire.server.OutgoingServerSocketReader in project Openfire by igniterealtime.
the class LocalOutgoingServerSession method attemptSASLexternal.
private static LocalOutgoingServerSession attemptSASLexternal(SocketConnection connection, MXParser xpp, XMPPPacketReader reader, DomainPair domainPair, String id, StringBuilder openingStream) throws DocumentException, IOException, XmlPullParserException {
final Logger log = LoggerFactory.getLogger(Log.getName() + "[EXTERNAL SASL for: " + domainPair + " (Stream ID: " + id + ")]");
log.debug("Starting EXTERNAL SASL.");
if (doExternalAuthentication(domainPair.getLocal(), connection, reader)) {
log.debug("EXTERNAL SASL was successful.");
// SASL was successful so initiate a new stream
connection.deliverRawText(openingStream.toString());
// Reset the parser
// xpp.resetInput();
// // Reset the parser to use the new secured reader
xpp.setInput(new InputStreamReader(connection.getTLSStreamHandler().getInputStream(), StandardCharsets.UTF_8));
// Skip the opening stream sent by the server
for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG; ) {
eventType = xpp.next();
}
// SASL authentication was successful so create new OutgoingServerSession
id = xpp.getAttributeValue("", "id");
StreamID streamID = new BasicStreamIDFactory().createStreamID(id);
LocalOutgoingServerSession session = new LocalOutgoingServerSession(domainPair.getLocal(), connection, new OutgoingServerSocketReader(reader), streamID);
connection.init(session);
// Set the remote domain name as the address of the session
session.setAddress(new JID(null, domainPair.getRemote(), null));
// Set that the session was created using TLS+SASL (no server dialback)
session.usingServerDialback = false;
return session;
} else {
log.debug("EXTERNAL SASL failed.");
return null;
}
}
Aggregations