(JabberDataBlock data)
| 64 | } |
| 65 | |
| 66 | public int blockArrived(JabberDataBlock data) { |
| 67 | //System.out.println(data.toString()); |
| 68 | if (data.getTagName().equals("features")) { |
| 69 | //#if TLS |
| 70 | JabberDataBlock starttls=data.getChildBlock("starttls"); |
| 71 | if (starttls!=null && starttls.isJabberNameSpace("urn:ietf:params:xml:ns:xmpp-tls")) { |
| 72 | |
| 73 | /* if (starttls.getChildBlock("required") != null) { |
| 74 | listener.loginFailed("TLS required"); |
| 75 | }*/ |
| 76 | |
| 77 | JabberDataBlock askTls=new JabberDataBlock("starttls"); |
| 78 | askTls.setNameSpace("urn:ietf:params:xml:ns:xmpp-tls"); |
| 79 | stream.send(askTls); |
| 80 | StaticData.getInstance().roster.setProgress("TLS negotiation", 39); |
| 81 | return JabberBlockListener.BLOCK_PROCESSED; |
| 82 | //if |
| 83 | |
| 84 | /* |
| 85 | * tls avaiable from server, but user does not want to use it. |
| 86 | * just ignore this feature and allow auth to take place |
| 87 | */ |
| 88 | } |
| 89 | //#endif |
| 90 | //#if ZLIB |
| 91 | //# JabberDataBlock compr = data.getChildBlock("compression"); |
| 92 | //# if (compr != null && account.useCompression()) { |
| 93 | //# if (compr.getChildBlockByText("zlib") != null) { |
| 94 | //# // negotiating compression |
| 95 | //# JabberDataBlock askCompr = new JabberDataBlock("compress"); |
| 96 | //# askCompr.setNameSpace("http://jabber.org/protocol/compress"); |
| 97 | //# askCompr.addChild("method", "zlib"); |
| 98 | //# stream.send(askCompr); |
| 99 | //# listener.loginMessage(SR.MS_ZLIB, 43); |
| 100 | //# return JabberBlockListener.BLOCK_PROCESSED; |
| 101 | //# } |
| 102 | //# } |
| 103 | //#endif |
| 104 | JabberDataBlock mech = data.getChildBlock("mechanisms"); |
| 105 | if (mech != null) { |
| 106 | Vector availableMechanisms = SaslMechanism.parseMechanisms(mech); |
| 107 | if (availableMechanisms.contains(SASL_X_OAUTH2)) { |
| 108 | account.isGoogle = true; |
| 109 | } |
| 110 | selectedMechanism = SaslFactory |
| 111 | .getPreferredMechanism(account, stream, availableMechanisms); |
| 112 | if (selectedMechanism == null) { |
| 113 | // no more method found |
| 114 | listener.loginFailed("SASL: Unknown mechanisms"); |
| 115 | return JabberBlockListener.NO_MORE_BLOCKS; |
| 116 | } |
| 117 | // first stream - step 1. selecting authentication mechanism |
| 118 | //common body |
| 119 | JabberDataBlock auth = new JabberDataBlock("auth"); |
| 120 | auth.setNameSpace(SaslFactory.NS_SASL); |
| 121 | String initialMessage = |
| 122 | selectedMechanism.init(account.JID, |
| 123 | Strconv.unicodeToUTF(account.password)); |
nothing calls this directly
no test coverage detected