当前位置: 首页>>代码示例>>Java>>正文


Java Base64类代码示例

本文整理汇总了Java中org.jivesoftware.smack.util.Base64的典型用法代码示例。如果您正苦于以下问题:Java Base64类的具体用法?Java Base64怎么用?Java Base64使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Base64类属于org.jivesoftware.smack.util包,在下文中一共展示了Base64类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:SASLMechanism.java

示例2: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:msdx,项目名称:AndroidPNClient,代码行数:27,代码来源:SASLMechanism.java

示例3: capsToHash

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:zhaozw,项目名称:android-1,代码行数:30,代码来源:EntityCapsManager.java

示例4: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:jitsi,项目名称:jitsi,代码行数:30,代码来源:SASLDigestMD5Mechanism.java

示例5: authenticate

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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));
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:15,代码来源:SASLMechanism.java

示例6: capsToHash

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:16,代码来源:EntityCapsManager.java

示例7: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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));
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:MySASLDigestMD5Mechanism.java

示例8: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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));
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:FacebookSASLDigestMD5Mechanism.java

示例9: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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));
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:29,代码来源:MySASLDigestMD5Mechanism.java

示例10: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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));
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:28,代码来源:FacebookSASLDigestMD5Mechanism.java

示例11: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
@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));
}
 
开发者ID:jonathangerbaud,项目名称:KlyphMessenger,代码行数:32,代码来源:SASLXFacebookPlatformMechanism.java

示例12: authenticate

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
@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);
}
 
开发者ID:nickglobal,项目名称:TvPoo,代码行数:31,代码来源:GTalkOAuthSASLMechanism.java

示例13: getPropertyBytes

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
public byte[] getPropertyBytes(String id) {
    String value = properties.getProperty(id);

    if (value != null)
        return Base64.decode(value);
    return null;
}
 
开发者ID:prive,项目名称:prive-android,代码行数:8,代码来源:OtrSmTest.java

示例14: challengeReceived

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
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);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:29,代码来源:MySASLDigestMD5Mechanism.java

示例15: getPropertyBytes

import org.jivesoftware.smack.util.Base64; //导入依赖的package包/类
public byte[] getPropertyBytes(String id) {
    String value = mProperties.getProperty(id);

    if (value != null)
        return Base64.decode(value);
    return null;
}
 
开发者ID:prive,项目名称:prive-android,代码行数:8,代码来源:OtrAndroidKeyManagerImpl.java


注:本文中的org.jivesoftware.smack.util.Base64类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。