From 2bf63fc8d2a4b84e051d28e670c7c74b039e2545 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 25 Apr 2018 13:54:25 +0300 Subject: www: no more xmpp --- .../server/xmpp/router/StreamComponentServer.java | 58 ---------------------- 1 file changed, 58 deletions(-) delete mode 100644 juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java (limited to 'juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java') diff --git a/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java b/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java deleted file mode 100644 index 5e2f6f82..00000000 --- a/juick-server-xmpp/src/main/java/com/juick/server/xmpp/router/StreamComponentServer.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.juick.server.xmpp.router; - -import com.juick.xmpp.extensions.Handshake; -import org.apache.commons.codec.digest.DigestUtils; -import org.xmlpull.v1.XmlPullParserException; -import rocks.xmpp.addr.Jid; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.UUID; - -/** - * Created by vitalyster on 30.01.2017. - */ -public class StreamComponentServer extends Stream { - - private String streamId, secret; - - public String getStreamId() { - return streamId; - } - - - public StreamComponentServer(InputStream is, OutputStream os, String password) throws XmlPullParserException { - super(null, null, is, os); - secret = password; - streamId = UUID.randomUUID().toString(); - } - @Override - public void handshake() throws XmlPullParserException, IOException { - parser.next(); - if (!parser.getName().equals("stream") - || !parser.getNamespace(null).equals(StreamNamespaces.NS_COMPONENT_ACCEPT) - || !parser.getNamespace("stream").equals(StreamNamespaces.NS_STREAM)) { - throw new IOException("invalid stream"); - } - Jid domain = Jid.of(parser.getAttributeValue(null, "to")); - if (streamHandler.filter(null, domain)) { - send(new XMPPError(XMPPError.Type.cancel, "forbidden").toString()); - throw new IOException("invalid domain"); - } - from = domain; - to = domain; - send(String.format("", StreamNamespaces.NS_STREAM, StreamNamespaces.NS_COMPONENT_ACCEPT, from.asBareJid().toEscapedString(), streamId)); - Handshake handshake = Handshake.parse(parser); - boolean authenticated = handshake.getValue().equals(DigestUtils.sha1Hex(streamId + secret)); - setLoggedIn(authenticated); - if (!authenticated) { - send(new XMPPError(XMPPError.Type.cancel, "not-authorized").toString()); - streamHandler.fail(new IOException("stream:stream, failed authentication")); - return; - } - send(new Handshake().toString()); - streamHandler.ready(); - } -} -- cgit v1.2.3