本文整理汇总了Java中org.jivesoftware.smack.util.Base64.encodeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.encodeBytes方法的具体用法?Java Base64.encodeBytes怎么用?Java Base64.encodeBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.util.Base64
的用法示例。
在下文中一共展示了Base64.encodeBytes方法的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);
}
示例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);
}
示例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;
}
}
示例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));
}
示例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));
}
示例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;
}
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例13: 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);
}
示例14: 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;
}
}
示例15: capsToHash
import org.jivesoftware.smack.util.Base64; //导入方法依赖的package包/类
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;
}
}