@Override public XMPPPacketReader create() throws Exception { XMPPPacketReader parser = new XMPPPacketReader(); parser.setXPPFactory( xppFactory ); return parser; }
/** * <p>Reads a Document from the given stream</p> * * @param in <code>InputStream</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(InputStream in) throws DocumentException, IOException, XmlPullParserException { return read(createReader(in)); }
/** * Adds the <code>ElementHandler</code> to be called when the * specified path is encounted. * * @param path is the path to be handled * @param handler is the <code>ElementHandler</code> to be called * by the event based processor. */ public void addHandler(String path, ElementHandler handler) { getDispatchHandler().addHandler(path, handler); }
/** * <p>Reads a Document from the given <code>Reader</code></p> * * @param reader is the reader for the input * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(Reader reader) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(reader); return parseDocument(); }
VerifyResult result = VerifyResult.error; try { reader = new XMPPPacketReader(); reader.setXPPFactory(FACTORY); reader.getXPPParser().setInput(new InputStreamReader(socket.getInputStream(), CHARSET));
@Override protected void compressionSuccessful() throws XmlPullParserException, IOException { XmlPullParser xpp = socketReader.reader.getXPPParser(); // Skip the opening stream sent by the client for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) { eventType = xpp.next(); } super.compressionSuccessful(); } }
socket.setSoTimeout(5000); XMPPPacketReader reader = new XMPPPacketReader(); inputStream = socket.getInputStream(); reader.getXPPParser().setInput(new InputStreamReader( inputStream, StandardCharsets.UTF_8 )); XmlPullParser xpp = reader.getXPPParser(); for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) { eventType = xpp.next(); Element features = reader.parseDocument().getRootElement(); if (features != null) { if (directTLS) {
/** * <p>Reads a Document from the given <code>File</code></p> * * @param file is the <code>File</code> to read from. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. * @throws java.net.MalformedURLException if a URL could not be made for the given File */ public Document read(File file) throws DocumentException, IOException, XmlPullParserException { String systemID = file.getAbsolutePath(); return read(new BufferedReader(new FileReader(file)), systemID); }
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()); }
MXParser parser = reader.getXPPParser(); parser.setInput(new StringReader(stanza)); createSession(parser); Element doc = reader.read(new StringReader(stanza)).getRootElement(); if (doc == null) {
public Document parseDocument() throws DocumentException, IOException, XmlPullParserException { DocumentFactory df = getDocumentFactory(); Document document = df.createDocument(); Element parent = null; XmlPullParser pp = getXPPParser(); int count = 0; while (true) {
public MXParser getXPPParser() throws XmlPullParserException { if (xppParser == null) { xppParser = (MXParser) getXPPFactory().newPullParser(); } return xppParser; }
/** * Returns the last time a full Document was read or a heartbeat was received. Hearbeats * are represented as whitespaces received while a Document is not being parsed. * * @return the time in milliseconds when the last document or heartbeat was received. */ long getLastActive() { return reader.getLastActive(); }
/** * <p>Reads a Document from the given array of characters</p> * * @param text is the text to parse * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. */ public Document read(char[] text) throws DocumentException, IOException, XmlPullParserException { getXPPParser().setInput(new CharArrayReader(text)); return parseDocument(); }
socket.setSoTimeout(RemoteServerManager.getSocketTimeout()); XMPPPacketReader reader = new XMPPPacketReader(); reader.setXPPFactory(FACTORY); input = socket.getInputStream(); reader.getXPPParser().setInput(new InputStreamReader( ServerTrafficCounter.wrapInputStream(input), CHARSET)); XmlPullParser xpp = reader.getXPPParser(); for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) { eventType = xpp.next();
/** * Returns the last time a full Document was read or a heartbeat was received. Hearbeats * are represented as whitespaces or \n received while a Document is not being parsed. * * @return the time in milliseconds when the last document or heartbeat was received. */ public long getLastActive() { long lastHeartbeat = 0; try { lastHeartbeat = getXPPParser().getLastHeartbeat(); } catch (XmlPullParserException e) {} return lastActive > lastHeartbeat ? lastActive : lastHeartbeat; }
socket.setSoTimeout(5000); XMPPPacketReader reader = new XMPPPacketReader(); reader.getXPPParser().setInput(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); XmlPullParser xpp = reader.getXPPParser(); for (int eventType = xpp.getEventType(); eventType != XmlPullParser.START_TAG;) { eventType = xpp.next(); Element features = reader.parseDocument().getRootElement(); if (features != null) { log.debug( "Check if both us as well as the remote server have enabled STARTTLS and/or dialback ..." );
/** * <p>Reads a Document from the given URL or filename.</p> * <p> * If the systemID contains a <code>':'</code> character then it is * assumed to be a URL otherwise its assumed to be a file name. * If you want finer grained control over this mechansim then please * explicitly pass in either a {@link URL} or a {@link File} instance * instead of a {@link String} to denote the source of the document. * </p> * * @param systemID is a URL for a document or a file name. * @return the newly created Document instance * @throws DocumentException if an error occurs during parsing. * @throws java.net.MalformedURLException if a URL could not be made for the given File */ public Document read(String systemID) throws DocumentException, IOException, XmlPullParserException { if (systemID.indexOf(':') >= 0) { // lets assume its a URL return read(new URL(systemID)); } else { // lets assume that we are given a file name return read(new File(systemID)); } }
Element doc; try { doc = reader.parseDocument().getRootElement();
MXParser parser = reader.getXPPParser(); parser.setInput(new StringReader(stanza)); createSession(parser); Element doc = reader.read(new StringReader(stanza)).getRootElement(); if (doc == null) {