本文整理汇总了Java中org.dom4j.io.XMPPPacketReader类的典型用法代码示例。如果您正苦于以下问题:Java XMPPPacketReader类的具体用法?Java XMPPPacketReader怎么用?Java XMPPPacketReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMPPPacketReader类属于org.dom4j.io包,在下文中一共展示了XMPPPacketReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onTextMethod
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@OnWebSocketMessage
public void onTextMethod(String stanza)
{
XMPPPacketReader reader = null;
try {
reader = readerPool.borrowObject();
Document doc = reader.read(new StringReader(stanza));
if (xmppSession == null) {
initiateSession(doc.getRootElement());
} else {
processStanza(doc.getRootElement());
}
} catch (Exception ex) {
Log.error("Failed to process XMPP stanza", ex);
} finally {
if (reader != null) {
readerPool.returnObject(reader);
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:22,代码来源:XmppWebSocket.java
示例2: attemptDialbackOverTLS
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static LocalOutgoingServerSession attemptDialbackOverTLS(Connection connection, XMPPPacketReader reader, String localDomain, String remoteDomain, String id) {
final Logger log = LoggerFactory.getLogger( Log.getName() + "[Dialback over TLS for: " + localDomain + " to: " + remoteDomain + " (Stream ID: " + id + ")]" );
if (ServerDialback.isEnabled() || ServerDialback.isEnabledForSelfSigned()) {
log.debug("Trying to connecting using dialback over TLS.");
ServerDialback method = new ServerDialback(connection, localDomain);
OutgoingServerSocketReader newSocketReader = new OutgoingServerSocketReader(reader);
if (method.authenticateDomain(newSocketReader, localDomain, remoteDomain, id)) {
log.debug("Dialback over TLS was successful.");
StreamID streamID = new BasicStreamIDFactory().createStreamID(id);
LocalOutgoingServerSession session = new LocalOutgoingServerSession(localDomain, connection, newSocketReader, streamID);
connection.init(session);
// Set the hostname as the address of the session
session.setAddress(new JID(null, remoteDomain, null));
return session;
}
else {
log.debug("Dialback over TLS failed");
return null;
}
}
else {
log.debug("Skipping server dialback attempt as it has been disabled by local configuration.");
return null;
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:LocalOutgoingServerSession.java
示例3: SocketReader
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
/**
* Creates a dedicated reader for a socket.
*
* @param router the router for sending packets that were read.
* @param routingTable the table that keeps routes to registered services.
* @param serverName the name of the server this socket is working for.
* @param socket the socket to read from.
* @param connection the connection being read.
* @param useBlockingMode true means that the server will use a thread per connection.
*/
public SocketReader(PacketRouter router, RoutingTable routingTable, String serverName,
Socket socket, SocketConnection connection, boolean useBlockingMode) {
this.serverName = serverName;
this.router = router;
this.routingTable = routingTable;
this.connection = connection;
connection.setSocketReader(this);
// Reader is associated with a new XMPPPacketReader
reader = new XMPPPacketReader();
reader.setXPPFactory(factory);
// Set the blocking reading mode to use
readingMode = new BlockingReadingMode(socket, this);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:SocketReader.java
示例4: messageReceived
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
// Get the stanza handler for this session
StanzaHandler handler = (StanzaHandler) session.getAttribute(HANDLER);
// Get the parser to use to process stanza. For optimization there is going
// to be a parser for each running thread. Each Filter will be executed
// by the Executor placed as the first Filter. So we can have a parser associated
// to each Thread
final XMPPPacketReader parser = PARSER_CACHE.get();
// Update counter of read btyes
updateReadBytesCounter(session);
//System.out.println("RCVD: " + message);
// 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);
final Connection connection = (Connection) session.getAttribute(CONNECTION);
if ( connection != null ) {
connection.close();
}
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:ConnectionHandler.java
示例5: attemptDialbackOverTLS
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static LocalOutgoingServerSession attemptDialbackOverTLS(Connection connection, XMPPPacketReader reader, String domain, String hostname, String id) {
final Logger log = LoggerFactory.getLogger(LocalOutgoingServerSession.class.getName()+"['"+hostname+"']");
if (ServerDialback.isEnabled() || ServerDialback.isEnabledForSelfSigned()) {
log.debug("Trying to connecting using dialback over TLS.");
ServerDialback method = new ServerDialback(connection, domain);
OutgoingServerSocketReader newSocketReader = new OutgoingServerSocketReader(reader);
if (method.authenticateDomain(newSocketReader, domain, hostname, id)) {
log.debug("Dialback over TLS was successful.");
StreamID streamID = new BasicStreamIDFactory().createStreamID(id);
LocalOutgoingServerSession session = new LocalOutgoingServerSession(domain, connection, newSocketReader, streamID);
connection.init(session);
// Set the hostname as the address of the session
session.setAddress(new JID(null, hostname, null));
return session;
}
else {
log.debug("Dialback over TLS failed");
return null;
}
}
else {
log.debug("Skipping server dialback attempt as it has been disabled by local configuration.");
return null;
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:26,代码来源:LocalOutgoingServerSession.java
示例6: testStanzaWithComments
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
public void testStanzaWithComments() throws Exception {
String msg1 = "<iq from=\"[email protected]/spark\"><query xmlns=\"jabber:iq:privacy\"><!-- silly comment --></query></iq>";
in.putString(msg1, Charset.forName(CHARSET).newEncoder());
in.flip();
// Fill parser with byte buffer content and parse it
parser.read(in);
// Make verifications
assertTrue("No messages were found in stanza", parser.areThereMsgs());
String[] values = parser.getMsgs();
assertEquals("Wrong number of parsed stanzas", 1, values.length);
assertEquals("Wrong stanza was parsed", msg1, values[0]);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(MXParser.class.getName(), null);
factory.setNamespaceAware(true);
XMPPPacketReader xmppReader = new XMPPPacketReader();
xmppReader.setXPPFactory(factory);
Element doc = xmppReader.read(new StringReader(values[0])).getRootElement();
assertNotNull(doc);
assertEquals(msg1, doc.asXML());
}
开发者ID:igniterealtime,项目名称:Openfire-connectionmanager,代码行数:22,代码来源:XMLLightweightParserTest.java
示例7: initializePool
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private synchronized void initializePool() {
if (readerPool == null) {
readerPool = new GenericObjectPool<XMPPPacketReader>(new XMPPPPacketReaderFactory());
readerPool.setMaxTotal(-1);
readerPool.setBlockWhenExhausted(false);
readerPool.setTestOnReturn(true);
readerPool.setTimeBetweenEvictionRunsMillis(JiveConstants.MINUTE);
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:XmppWebSocket.java
示例8: validateObject
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@Override
public boolean validateObject(PooledObject<XMPPPacketReader> po) {
// reset the input for the pooled parser
try {
po.getObject().getXPPParser().resetInput();
return true;
} catch (XmlPullParserException xppe) {
Log.error("Failed to reset pooled parser; evicting from pool", xppe);
return false;
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:XMPPPPacketReaderFactory.java
示例9: attemptSASLexternal
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static LocalOutgoingServerSession attemptSASLexternal(SocketConnection connection, MXParser xpp, XMPPPacketReader reader, String localDomain, String remoteDomain, String id, StringBuilder openingStream) throws DocumentException, IOException, XmlPullParserException {
final Logger log = LoggerFactory.getLogger( Log.getName() + "[EXTERNAL SASL for: " + localDomain + " to: " + remoteDomain + " (Stream ID: " + id + ")]" );
log.debug("Starting EXTERNAL SASL.");
if (doExternalAuthentication(localDomain, 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(localDomain, connection, new OutgoingServerSocketReader(reader), streamID);
connection.init(session);
// Set the hostname as the address of the session
session.setAddress(new JID(null, remoteDomain, 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;
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:35,代码来源:LocalOutgoingServerSession.java
示例10: doExternalAuthentication
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static boolean doExternalAuthentication(String localDomain, SocketConnection connection,
XMPPPacketReader reader) throws DocumentException, IOException, XmlPullParserException {
StringBuilder sb = new StringBuilder();
sb.append("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"EXTERNAL\">");
sb.append(StringUtils.encodeBase64(localDomain));
sb.append("</auth>");
connection.deliverRawText(sb.toString());
Element response = reader.parseDocument().getRootElement();
return response != null && "success".equals(response.getName());
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:13,代码来源:LocalOutgoingServerSession.java
示例11: initialValue
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@Override
protected XMPPPacketReader initialValue() {
XMPPPacketReader parser = new XMPPPacketReader();
factory.setNamespaceAware(true);
parser.setXPPFactory(factory);
return parser;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:HttpSession.java
示例12: initialValue
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@Override
protected XMPPPacketReader initialValue()
{
final XMPPPacketReader parser = new XMPPPacketReader();
parser.setXPPFactory( factory );
return parser;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:8,代码来源:ConnectionHandler.java
示例13: process
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
public void process(String stanza, XMPPPacketReader reader)
throws Exception {
boolean initialStream = stanza.startsWith("<stream:stream");
if (!sessionCreated || initialStream) {
if (!initialStream) {
// Ignore <?xml version="1.0"?>
return;
}
// Found an stream:stream tag...
if (!sessionCreated) {
sessionCreated = true;
MXParser parser = reader.getXPPParser();
parser.setInput(new StringReader(stanza));
createSession(parser);
}
return;
}
// Verify if end of stream was requested
if (stanza.equals("</stream:stream>")) {
session.close();
return;
}
// Ignore <?xml version="1.0"?> stanzas sent by clients
if (stanza.startsWith("<?xml")) {
return;
}
// Create DOM object from received stanza
Element doc = reader.read(new StringReader(stanza)).getRootElement();
if (doc == null) {
return;
}
process(doc);
}
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:36,代码来源:StanzaHandler.java
示例14: process
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
public void process(String stanza, XMPPPacketReader reader)
throws Exception {
boolean initialStream = stanza.startsWith("<stream:stream");
if (!sessionCreated || initialStream) {
if (!initialStream) {
return; // Ignore <?xml version="1.0"?>
}
if (!sessionCreated) {
sessionCreated = true;
MXParser parser = reader.getXPPParser();
parser.setInput(new StringReader(stanza));
createSession(parser);
}
return;
}
// If end of stream was requested
if (stanza.equals("</stream:stream>")) {
session.close();
return;
}
// Ignore <?xml version="1.0"?>
if (stanza.startsWith("<?xml")) {
return;
}
// Create DOM object
Element doc = reader.read(new StringReader(stanza)).getRootElement();
if (doc == null) {
return;
}
processDoc(doc);
}
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:33,代码来源:StanzaHandler.java
示例15: attemptSASLexternal
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static LocalOutgoingServerSession attemptSASLexternal(SocketConnection connection, MXParser xpp, XMPPPacketReader reader, String domain, String hostname, String id, StringBuilder openingStream) throws DocumentException, IOException, XmlPullParserException {
final Logger log = LoggerFactory.getLogger(LocalOutgoingServerSession.class.getName()+"['"+hostname+"']");
log.debug("Starting EXTERNAL SASL.");
if (doExternalAuthentication(domain, 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();
// 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(domain,
connection, new OutgoingServerSocketReader(reader), streamID);
connection.init(session);
// Set the hostname as the address of the session
session.setAddress(new JID(null, hostname, 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;
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:33,代码来源:LocalOutgoingServerSession.java
示例16: doExternalAuthentication
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private static boolean doExternalAuthentication(String domain, SocketConnection connection,
XMPPPacketReader reader) throws DocumentException, IOException, XmlPullParserException {
StringBuilder sb = new StringBuilder();
sb.append("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"EXTERNAL\">");
sb.append(StringUtils.encodeBase64(domain));
sb.append("</auth>");
connection.deliverRawText(sb.toString());
Element response = reader.parseDocument().getRootElement();
return response != null && "success".equals(response.getName());
}
开发者ID:coodeer,项目名称:g3server,代码行数:13,代码来源:LocalOutgoingServerSession.java
示例17: initialValue
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
@Override
protected XMPPPacketReader initialValue() {
XMPPPacketReader parser = new XMPPPacketReader();
factory.setNamespaceAware(true);
parser.setXPPFactory(factory);
return parser;
}
开发者ID:coodeer,项目名称:g3server,代码行数:8,代码来源:HttpSession.java
示例18: secureConnection
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private boolean secureConnection(XMPPPacketReader reader, StringBuilder openingStream)
throws Exception {
Log.debug("CM - Indicating we want TLS to " + serverName);
connection.deliverRawText("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
MXParser xpp = reader.getXPPParser();
// Wait for the <proceed> response
Element proceed = reader.parseDocument().getRootElement();
if (proceed != null && proceed.getName().equals("proceed")) {
Log.debug("CM - Negotiating TLS with " + serverName);
connection.startTLS(true, serverName);
Log.debug("CM - TLS negotiation with " + serverName + " was successful");
// TLS negotiation was successful so initiate a new stream
connection.deliverRawText(openingStream.toString());
// Reset the parser to use the new secured reader
xpp.setInput(
new InputStreamReader(connection.getTLSStreamHandler().getInputStream(),
CHARSET));
// Skip new stream element
for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) {
eventType = xpp.next();
}
// Get new stream features
features = reader.parseDocument().getRootElement();
return true;
} else {
Log.debug("CM - Error, <proceed> was not received");
}
return false;
}
开发者ID:igniterealtime,项目名称:Openfire-connectionmanager,代码行数:33,代码来源:ConnectionWorkerThread.java
示例19: doHandshake
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
private boolean doHandshake(String streamID, XMPPPacketReader reader) throws Exception {
String password = JiveGlobals.getXMLProperty("xmpp.password");
if (password == null) {
// No password was configued in the connection manager
Log.debug("CM - No password was found. Configure xmpp.password property");
return false;
}
MessageDigest digest;
// Create a message digest instance.
try {
digest = MessageDigest.getInstance("SHA");
}
catch (NoSuchAlgorithmException e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
return false;
}
digest.update(streamID.getBytes());
String key = StringUtils.encodeHex(digest.digest(password.getBytes()));
Log.debug("OS - Sent handshake to host: " + serverName + " id: " + streamID);
// Send handshake to server
StringBuilder sb = new StringBuilder();
sb.append("<handshake>").append(key).append("</handshake>");
connection.deliverRawText(sb.toString());
// Wait for the <handshake> response
Element proceed = reader.parseDocument().getRootElement();
if (proceed != null && proceed.getName().equals("handshake")) {
Log.debug("OS - Handshake was SUCCESSFUL with host: " + serverName + " id: " +
streamID);
return true;
}
Log.debug("OS - Handshake FAILED with host: " + serverName + " id: " + streamID);
return false;
}
开发者ID:igniterealtime,项目名称:Openfire-connectionmanager,代码行数:38,代码来源:ConnectionWorkerThread.java
示例20: testParsing
import org.dom4j.io.XMPPPacketReader; //导入依赖的package包/类
public void testParsing() throws Exception {
String stanza = "<presence type=\"unavailable\" from=\"[email protected]/tsung\" to=\"[email protected]\"/>";
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(MXParser.class.getName(), null);
factory.setNamespaceAware(true);
XMPPPacketReader xmppReader = new XMPPPacketReader();
xmppReader.setXPPFactory(factory);
Element doc = xmppReader.read(new StringReader(stanza)).getRootElement();
assertNotNull(doc);
assertEquals(stanza, doc.asXML());
}
开发者ID:igniterealtime,项目名称:Openfire-connectionmanager,代码行数:13,代码来源:XMLLightweightParserTest.java
注:本文中的org.dom4j.io.XMPPPacketReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论