XMPP as SBI support: implementation of core XMPP and Xmpp Device Provider

State machine handled by XmppSession interface, most of tests implemented

XmppDeviceFactory re-designed, tests updated

pom and BUCK files updated

Change-Id: I4c6955e091169c945415084cbb000c61b474c0fc
diff --git a/protocols/xmpp/core/api/src/main/java/org/onosproject/xmpp/core/stream/XmppStreamOpen.java b/protocols/xmpp/core/api/src/main/java/org/onosproject/xmpp/core/stream/XmppStreamOpen.java
new file mode 100644
index 0000000..967296b
--- /dev/null
+++ b/protocols/xmpp/core/api/src/main/java/org/onosproject/xmpp/core/stream/XmppStreamOpen.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.xmpp.core.stream;
+
+import org.dom4j.Attribute;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.xmpp.packet.JID;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.List;
+
+/**
+ * Abstracts XMPP stream open event.
+ */
+public class XmppStreamOpen implements XmppStreamEvent {
+
+    public static final String QNAME = "stream";
+
+    private Element element;
+
+    public XmppStreamOpen(Element element) {
+        this.element = element;
+    }
+
+    @Override
+    public String toXml() {
+        StringWriter out = new StringWriter();
+        XMLWriter writer = new XMLWriter(out, OutputFormat.createCompactFormat());
+        try {
+            out.write("<");
+            writer.write(element.getQualifiedName());
+            for (Attribute attr : (List<Attribute>) element.attributes()) {
+                writer.write(attr);
+            }
+            writer.write(Namespace.get(this.element.getNamespacePrefix(), this.element.getNamespaceURI()));
+            writer.write(Namespace.get("jabber:client"));
+            out.write(">");
+        } catch (IOException ex) {
+            ex.printStackTrace();
+        }
+        return out.toString();
+    }
+
+    public JID getFromJid() {
+        String jid = this.element.attribute("from").getValue();
+        return new JID(jid);
+    }
+
+    public Element getElement() {
+        return this.element;
+    }
+
+    public JID getToJid() {
+        String jid = this.element.attribute("to").getValue();
+        return new JID(jid);
+    }
+}