Java 类org.jivesoftware.smack.util.Base64 实例源码

项目:EIM    文件:SASLMechanism.java   
/**
 * 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);
}
项目:androidpn_enhanced_client    文件:SASLMechanism.java   
/**
 * 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);
}
项目:AndroidPNClient    文件:SASLMechanism.java   
/**
 * 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);
}
项目:android-1    文件:EntityCapsManager.java   
/**
 * 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;
    }
}
项目:jitsi    文件:SASLDigestMD5Mechanism.java   
/**
 * 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));
}
项目:jitsi    文件:EntityCapsManager.java   
/**
 * 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;
    }
}
项目:telegraph    文件:SASLMechanism.java   
/**
 * 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);
}
项目:NewCommunication-Android    文件:SASLMechanism.java   
/**
 * 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);
}
项目:EIM    文件:SASLMechanism.java   
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));
}
项目:androidpn_enhanced_client    文件:SASLMechanism.java   
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));
}
项目:xmppsupport_v2    文件:EntityCapsManager.java   
/**
 * 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;
    }
}
项目:AndroidPNClient    文件:SASLMechanism.java   
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));
}
项目:Openfire    文件:MySASLDigestMD5Mechanism.java   
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));
}
项目:Openfire    文件:FacebookSASLDigestMD5Mechanism.java   
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));
}
项目:g3server    文件:MySASLDigestMD5Mechanism.java   
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));
}
项目:g3server    文件:FacebookSASLDigestMD5Mechanism.java   
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));
}
项目:openfire    文件:MySASLDigestMD5Mechanism.java   
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));
}
项目:openfire    文件:FacebookSASLDigestMD5Mechanism.java   
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));
}
项目:KlyphMessenger    文件:SASLXFacebookPlatformMechanism.java   
@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));
}
项目:TvPoo    文件:GTalkOAuthSASLMechanism.java   
@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);
}
项目:prive-android    文件:OtrSmTest.java   
public byte[] getPropertyBytes(String id) {
    String value = properties.getProperty(id);

    if (value != null)
        return Base64.decode(value);
    return null;
}
项目:prive-android    文件:MySASLDigestMD5Mechanism.java   
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);
}
项目:prive-android    文件:OtrAndroidKeyManagerImpl.java   
public byte[] getPropertyBytes(String id) {
    String value = mProperties.getProperty(id);

    if (value != null)
        return Base64.decode(value);
    return null;
}
项目:telegraph    文件:SASLMechanism.java   
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));
}
项目:telegraph    文件:EntityCapsManager.java   
/**
 * 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;
    }
}
项目:NewCommunication-Android    文件:SASLMechanism.java   
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));
}
项目:NewCommunication-Android    文件:EntityCapsManager.java   
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;
    }
}
项目:Beem    文件:SASLGoogleOAuth2Mechanism.java   
@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));
   }
项目:beem-fork-xmpp    文件:SASLGoogleOAuth2Mechanism.java   
@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));
   }
项目:openfire-bespoke    文件:MySASLDigestMD5Mechanism.java   
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));
}
项目:openfire-bespoke    文件:FacebookSASLDigestMD5Mechanism.java   
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));
}
项目:whackpad    文件:SASLXFacebookPlatformMechanism.java   
@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));
}
项目:androidPN-client.    文件:SASLFacebookConnect.java   
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();
}

           });
   }
项目:xmppsupport_v2    文件:SASLFacebookConnect.java   
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();
        }

    });
}
项目:xmppsupport_v2    文件:Base64Encoder.java   
public String encode(String s) {
    return Base64.encodeBytes(s.getBytes());
}
项目:xmppsupport_v2    文件:Base64Encoder.java   
public String decode(String s) {
    return new String(Base64.decode(s));
}
项目:Openfire    文件:FacebookConnectSASLMechanism.java   
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));
}
项目:g3server    文件:FacebookConnectSASLMechanism.java   
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));
}
项目:openfire    文件:FacebookConnectSASLMechanism.java   
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));
}
项目:prive-android    文件:OtrSmTest.java   
public void setProperty(String id, byte[] value) {
    properties.setProperty(id, new String(Base64.encodeBytes(value)));
}