/** * The server is challenging the SASL mechanism for the stanza he just sent. Send a * response to the server's challenge. * * @param challenge a base64 encoded string representing the challenge. * @throws IOException if an exception sending the response occurs. */ public void challengeReceived(String challenge) throws IOException { byte response[]; if(challenge != null) { response = sc.evaluateChallenge(Base64.decode(challenge)); } else { response = sc.evaluateChallenge(new byte[0]); } Packet responseStanza; if (response == null) { responseStanza = new Response(); } else { responseStanza = new Response(Base64.encodeBytes(response,Base64.DONT_BREAK_LINES)); } // Send the authentication to the server getSASLAuthentication().send(responseStanza); }
/** * The server is challenging the SASL mechanism for the stanza he just sent. Send a * response to the server's challenge. * * @param challenge a base64 encoded string representing the challenge. * @throws java.io.IOException if an exception sending the response occurs. */ public void challengeReceived(String challenge) throws IOException { byte response[]; if(challenge != null) { response = sc.evaluateChallenge(Base64.decode(challenge)); } else { response = sc.evaluateChallenge(new byte[0]); } Packet responseStanza; if (response == null) { responseStanza = new Response(); } else { responseStanza = new Response(Base64.encodeBytes(response,Base64.DONT_BREAK_LINES)); } // Send the authentication to the server getSASLAuthentication().send(responseStanza); }
/** * Computes and returns the hash of the specified <tt>capsString</tt> using * the specified <tt>hashAlgorithm</tt>. * * @param hashAlgorithm the name of the algorithm to be used to generate the * hash * @param capsString the capabilities string that we'd like to compute a * hash for. * * @return the hash of <tt>capsString</tt> computed by the specified * <tt>hashAlgorithm</tt> or <tt>null</tt> if generating the hash has failed */ private static String capsToHash(String hashAlgorithm, String capsString) { try { MessageDigest md = MessageDigest.getInstance(hashAlgorithm); byte[] digest = md.digest(capsString.getBytes()); return Base64.encodeBytes(digest); } catch (NoSuchAlgorithmException nsae) { logger.error( "Unsupported XEP-0115: Entity Capabilities hash algorithm: " + hashAlgorithm); return null; } }
/** * The server is challenging the SASL mechanism for the stanza he just sent. Send a * response to the server's challenge. * * @param challenge a base64 encoded string representing the challenge. * @throws IOException if an exception sending the response occurs. */ @Override public void challengeReceived(String challenge) throws IOException { byte response[]; if(challenge != null) { response = sc.evaluateChallenge(Base64.decode(challenge)); } else { response = sc.evaluateChallenge(null); } String authenticationText = null; if(null != response) { authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES); } if((null == authenticationText) || (authenticationText.equals(""))) { authenticationText = "="; } // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
protected void authenticate() throws IOException, XMPPException { String authenticationText = null; try { if(sc.hasInitialResponse()) { byte[] response = sc.evaluateChallenge(new byte[0]); authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES); } } catch (SaslException e) { throw new XMPPException("SASL authentication failed", e); } // Send the authentication to the server getSASLAuthentication().send(new AuthMechanism(getName(), authenticationText)); }
/** * Calculate Entity Caps version string * * @param capsString * @return */ private static String capsToHash(String capsString) { try { MessageDigest md = MessageDigest.getInstance(HASH_METHOD_CAPS); byte[] digest = md.digest(capsString.getBytes()); return Base64.encodeBytes(digest); } catch (NoSuchAlgorithmException nsae) { return null; } }
public void challengeReceived(String challenge) throws IOException { // Build the challenge response stanza encoding the response text StringBuilder stanza = new StringBuilder(); byte response[]; if (challenge != null) { response = sc.evaluateChallenge(Base64.decode(challenge)); } else { response = sc.evaluateChallenge(null); } String authenticationText=""; if (response != null) { // fix from 3.1.1 authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); if (authenticationText.equals("")) { authenticationText = "="; } } stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append(authenticationText); stanza.append("</response>"); // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
@Override public void challengeReceived(String challenge) throws IOException { byte[] response = null; if (challenge != null) { String decodedChallenge = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedChallenge); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); String composedResponse = "method=" + URLEncoder.encode(method, "utf-8") + "&nonce=" + URLEncoder.encode(nonce, "utf-8") + "&access_token=" + URLEncoder.encode(accessToken, "utf-8") + "&api_key=" + URLEncoder.encode(apiKey, "utf-8") + "&call_id=0" + "&v=" + URLEncoder.encode(version, "utf-8"); response = composedResponse.getBytes(); } String authenticationText = ""; if (response != null) { authenticationText = Base64.encodeBytes(response); } // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
@Override protected void authenticate() throws IOException, XMPPException { final StringBuilder stanza = new StringBuilder(); byte response[] = null; stanza.append("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"" + "mechanism=\"X-OAUTH2\"" + "auth:service=\"oauth2\"" + "xmlns:auth= \"http://www.google.com/talk/protocol/auth\">"); String composedResponse = "\0" + authenticationId + "\0" + password; response = composedResponse.getBytes("UTF-8"); String authenticationText = ""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } stanza.append(authenticationText); stanza.append("</auth>"); Packet authPacket = new Packet() { @Override public String toXML() { return stanza.toString(); } }; getSASLAuthentication().send(authPacket); }
public byte[] getPropertyBytes(String id) { String value = properties.getProperty(id); if (value != null) return Base64.decode(value); return null; }
public void challengeReceived(String challenge) throws IOException { //StringBuilder stanza = new StringBuilder(); byte response[]; if (challenge != null) response = sc.evaluateChallenge(Base64.decode(challenge)); else //response = sc.evaluateChallenge(null); response = sc.evaluateChallenge(new byte[0]); //String authenticationText = ""; Packet responseStanza; //if(response != null) //{ //authenticationText = Base64.encodeBytes(response, 8); //if(authenticationText.equals("")) //authenticationText = "="; if (response == null) { responseStanza = new Response(); } else { responseStanza = new Response(Base64.encodeBytes(response, Base64.DONT_BREAK_LINES)); } //} //stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); //stanza.append(authenticationText); //stanza.append("</response>"); //getSASLAuthentication().send(stanza.toString()); getSASLAuthentication().send(responseStanza); }
public byte[] getPropertyBytes(String id) { String value = mProperties.getProperty(id); if (value != null) return Base64.decode(value); return null; }
private static String capsToHash(String capsString) { try { MessageDigest md = MessageDigest.getInstance(HASH_METHOD_CAPS); byte[] digest = md.digest(capsString.getBytes()); return Base64.encodeBytes(digest); } catch (NoSuchAlgorithmException nsae) { return null; } }
@Override protected void authenticate() throws IOException, XMPPException { String authenticationText = null; try { if (sc.hasInitialResponse()) { byte[] response = sc.evaluateChallenge(new byte[0]); authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } } catch (SaslException e) { throw new XMPPException("SASL authentication failed", e); } // Send the authentication to the server getSASLAuthentication().send(new GoogleOAuthMechanism(authenticationText)); }
@Override public void challengeReceived(String challenge) throws IOException { byte[] response = null; if (challenge != null) { String decodedChallenge = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedChallenge); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); long callId = new GregorianCalendar().getTimeInMillis(); String sig = "api_key=" + apiKey + "call_id=" + callId + "method=" + method + "nonce=" + nonce + "access_token=" + sessionKey + "v=" + version; try { sig = md5(sig); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } String composedResponse = "api_key=" + URLEncoder.encode(apiKey, "utf-8") + "&call_id=" + callId + "&method=" + URLEncoder.encode(method, "utf-8") + "&nonce=" + URLEncoder.encode(nonce, "utf-8") + "&access_token=" + URLEncoder.encode(sessionKey, "utf-8") + "&v=" + URLEncoder.encode(version, "utf-8") + "&sig=" + URLEncoder.encode(sig, "utf-8"); response = composedResponse.getBytes("utf-8"); } String authenticationText = ""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
public void challengeReceived(String challenge) throws IOException { // Build the challenge response stanza encoding the response text final StringBuilder stanza = new StringBuilder(); byte response[] = null; if (challenge != null) { String decodedResponse = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedResponse); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); Long callId = new GregorianCalendar().getTimeInMillis()/1000; String sig = "api_key="+apiKey +"call_id="+callId +"method="+method +"nonce="+nonce +"session_key="+sessionKey +"v="+version +sessionSecret; try { sig = MD5(sig); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } String composedResponse = "api_key="+apiKey+"&" +"call_id="+callId+"&" +"method="+method+"&" +"nonce="+nonce+"&" +"session_key="+sessionKey+"&" +"v="+version+"&" +"sig="+sig; response = composedResponse.getBytes(); } String authenticationText=""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append(authenticationText); stanza.append("</response>"); // Send the authentication to the server getSASLAuthentication().send(new Packet(){ @Override public String toXML() { return stanza.toString(); } }); }
public void challengeReceived(String challenge) throws IOException { // Build the challenge response stanza encoding the response text final StringBuilder stanza = new StringBuilder(); byte response[] = null; if (challenge != null) { String decodedResponse = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedResponse); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); Long callId = new GregorianCalendar().getTimeInMillis() / 1000; String sig = "api_key=" + apiKey + "call_id=" + callId + "method=" + method + "nonce=" + nonce + "session_key=" + sessionKey + "v=" + version + sessionSecret; try { sig = MD5(sig); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } String composedResponse = "api_key=" + apiKey + "&" + "call_id=" + callId + "&" + "method=" + method + "&" + "nonce=" + nonce + "&" + "session_key=" + sessionKey + "&" + "v=" + version + "&" + "sig=" + sig; response = composedResponse.getBytes(); } String authenticationText = ""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append(authenticationText); stanza.append("</response>"); // Send the authentication to the server getSASLAuthentication().send(new Packet() { @Override public String toXML() { return stanza.toString(); } }); }
public String encode(String s) { return Base64.encodeBytes(s.getBytes()); }
public String decode(String s) { return new String(Base64.decode(s)); }
public void challengeReceived(String challenge) throws IOException { // Build the challenge response stanza encoding the response text StringBuilder stanza = new StringBuilder(); byte response[] = null; if (challenge != null) { String decodedResponse = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedResponse); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); Long callId = new GregorianCalendar().getTimeInMillis()/1000; String sig = "api_key="+apiKey +"call_id="+callId +"method="+method +"nonce="+nonce +"access_token="+accessToken +"v="+version +appSecret; try { sig = MD5(sig); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } String composedResponse = "api_key="+apiKey+"&" +"call_id="+callId+"&" +"method="+method+"&" +"nonce="+nonce+"&" +"access_token="+accessToken+"&" +"v="+version+"&" +"sig="+sig; response = composedResponse.getBytes(); } String authenticationText=""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append(authenticationText); stanza.append("</response>"); // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
public void challengeReceived(String challenge) throws IOException { // Build the challenge response stanza encoding the response text StringBuilder stanza = new StringBuilder(); byte response[] = null; if (challenge != null) { String decodedResponse = new String(Base64.decode(challenge)); Map<String, String> parameters = getQueryMap(decodedResponse); String version = "1.0"; String nonce = parameters.get("nonce"); String method = parameters.get("method"); Long callId = new GregorianCalendar().getTimeInMillis()/1000; String sig = "api_key="+apiKey +"call_id="+callId +"method="+method +"nonce="+nonce +"session_key="+sessionKey +"v="+version +appSecret; try { sig = MD5(sig); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException(e); } String composedResponse = "api_key="+apiKey+"&" +"call_id="+callId+"&" +"method="+method+"&" +"nonce="+nonce+"&" +"session_key="+sessionKey+"&" +"v="+version+"&" +"sig="+sig; response = composedResponse.getBytes(); } String authenticationText=""; if (response != null) { authenticationText = Base64.encodeBytes(response, Base64.DONT_BREAK_LINES); } stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">"); stanza.append(authenticationText); stanza.append("</response>"); // Send the authentication to the server getSASLAuthentication().send(new Response(authenticationText)); }
public void setProperty(String id, byte[] value) { properties.setProperty(id, new String(Base64.encodeBytes(value))); }