本文整理了Java中org.jivesoftware.smack.util.stringencoder.Base64
类的一些代码示例,展示了Base64
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64
类的具体详情如下:
包路径:org.jivesoftware.smack.util.stringencoder.Base64
类名称:Base64
暂无
代码示例来源:origin: igniterealtime/Smack
/**
* Create a HashElement from pre-calculated values.
* @param algorithm the algorithm that was used.
* @param hashB64 the checksum in base 64.
*/
public HashElement(HashManager.ALGORITHM algorithm, String hashB64) {
this.algorithm = algorithm;
this.hash = Base64.decode(hashB64);
this.hashB64 = hashB64;
}
代码示例来源:origin: igniterealtime/Smack
public static final String encode(String string) {
try {
return encodeToString(string.getBytes(StringUtils.UTF8));
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException("UTF-8 not supported", e);
}
}
代码示例来源:origin: igniterealtime/Smack
public static final byte[] encode(byte[] input) {
return encode(input, 0, input.length);
}
代码示例来源:origin: igniterealtime/Smack
/**
* The server is challenging the SASL mechanism for the stanza he just sent. Send a
* response to the server's challenge.
*
* @param challengeString a base64 encoded string representing the challenge.
* @param finalChallenge true if this is the last challenge send by the server within the success stanza
* @throws SmackException exception
* @throws InterruptedException if the connection is interrupted
*/
public final void challengeReceived(String challengeString, boolean finalChallenge) throws SmackException, InterruptedException {
byte[] challenge = Base64.decode((challengeString != null && challengeString.equals("=")) ? "" : challengeString);
byte[] response = evaluateChallenge(challenge);
if (finalChallenge) {
return;
}
Response responseStanza;
if (response == null) {
responseStanza = new Response();
}
else {
responseStanza = new Response(Base64.encodeToString(response));
}
// Send the authentication to the server
connection.sendNonza(responseStanza);
}
代码示例来源:origin: igniterealtime/Smack
@Override
public List<Exception> initialize() {
if (SystemUtil.onAndroid()) {
// @formatter:off
throw new RuntimeException(
"You need to remove the smack-java7 dependency/jar from your build, " +
"as it does not run on Android. " +
"Use smack-android instead.");
// @formatter:on
}
SmackConfiguration.setDefaultHostnameVerifier(new XmppHostnameVerifier());
Base64.setEncoder(Java7Base64Encoder.getInstance());
Base64UrlSafeEncoder.setEncoder(Java7Base64UrlSafeEncoder.getInstance());
return null;
}
代码示例来源:origin: igniterealtime/Smack
private static String saslLayerString(String string) {
return Base64.decodeToString(string);
}
}
代码示例来源:origin: igniterealtime/Smack
String channelBinding = "c=" + Base64.encodeToString(getCBindInput());
String clientFinalMessageWithoutProof = channelBinding + ",r=" + rvalue;
if (keys == null) {
byte[] saltedPassword = hi(saslPrep(password), Base64.decode(salt), iterations);
String clientFinalMessage = clientFinalMessageWithoutProof + ",p=" + Base64.encodeToString(clientProof);
state = State.RESPONSE_SENT;
return toBytes(clientFinalMessage);
case RESPONSE_SENT:
String clientCalculatedServerFinalMessage = "v=" + Base64.encodeToString(serverSignature);
if (!clientCalculatedServerFinalMessage.equals(challengeString)) {
throw new SmackException("Server final message does not match calculated one");
代码示例来源:origin: igniterealtime/Smack
@Override
public List<Exception> initialize() {
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
Base64.setEncoder(AndroidBase64Encoder.getInstance());
Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance());
return null;
}
代码示例来源:origin: igniterealtime/Smack
/***
* This method tests 2 StringUtil methods - decodeBase64(String) and decodeBase64(byte[]).
*/
public void testDecodeBase64() {
String input = "";
String output = "";
assertEquals(Base64.decodeToString(input), output);
input = "Zm9vIGJhciAxMjM=";
output = "foo bar 123";
assertEquals(Base64.decodeToString(input), output);
input = "PQ==";
output = "=";
assertEquals(Base64.decodeToString(input), output);
input = "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5CgkiPyEuQHt9W10oKTsnLC4vPD4jJCVeJio=";
output = "abcdefghijklmnopqrstuvwxyz0123456789\n\t\"?!.@{}[]();',./<>#$%^&*";
assertEquals(Base64.decodeToString(input), output);
}
}
代码示例来源:origin: igniterealtime/Smack
private static HashMap<Integer, String> base64EncodePreKeys(HashMap<Integer, byte[]> preKeys) {
if (preKeys == null) {
return null;
}
HashMap<Integer, String> converted = new HashMap<>();
for (Integer id : preKeys.keySet()) {
converted.put(id, Base64.encodeToString(preKeys.get(id)));
}
return converted;
}
代码示例来源:origin: igniterealtime/Smack
public byte[] getIncomingSoundBytes() {
return Base64.decode(incomingSound);
}
代码示例来源:origin: org.igniterealtime.smack/smack-core
/**
* The server is challenging the SASL mechanism for the stanza he just sent. Send a
* response to the server's challenge.
*
* @param challengeString a base64 encoded string representing the challenge.
* @param finalChallenge true if this is the last challenge send by the server within the success stanza
* @throws SmackException exception
* @throws InterruptedException if the connection is interrupted
*/
public final void challengeReceived(String challengeString, boolean finalChallenge) throws SmackException, InterruptedException {
byte[] challenge = Base64.decode((challengeString != null && challengeString.equals("=")) ? "" : challengeString);
byte[] response = evaluateChallenge(challenge);
if (finalChallenge) {
return;
}
Response responseStanza;
if (response == null) {
responseStanza = new Response();
}
else {
responseStanza = new Response(Base64.encodeToString(response));
}
// Send the authentication to the server
connection.sendNonza(responseStanza);
}
代码示例来源:origin: igniterealtime/Smack
public static final String encodeToString(byte[] input) {
byte[] bytes = encode(input);
try {
return new String(bytes, StringUtils.USASCII);
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
代码示例来源:origin: org.igniterealtime.smack/smack-android
@Override
public List<Exception> initialize() {
SmackConfiguration.setDefaultHostnameVerifier(new StrictHostnameVerifier());
Base64.setEncoder(AndroidBase64Encoder.getInstance());
Base64UrlSafeEncoder.setEncoder(AndroidBase64UrlSafeEncoder.getInstance());
return null;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Constructor to create a Bundle Element from decoded byte arrays.
*
* @param signedPreKeyId id
* @param signedPreKey signedPreKey
* @param signedPreKeySig signedPreKeySignature
* @param identityKey identityKey
* @param preKeys HashMap of preKeys
*/
public OmemoBundleElement(int signedPreKeyId, byte[] signedPreKey, byte[] signedPreKeySig, byte[] identityKey, HashMap<Integer, byte[]> preKeys) {
this(signedPreKeyId,
signedPreKey != null ? Base64.encodeToString(signedPreKey) : null,
signedPreKeySig != null ? Base64.encodeToString(signedPreKeySig) : null,
identityKey != null ? Base64.encodeToString(identityKey) : null,
base64EncodePreKeys(preKeys));
this.signedPreKey = signedPreKey;
this.signedPreKeySignature = signedPreKeySig;
this.identityKey = identityKey;
this.preKeys = preKeys;
}
代码示例来源:origin: igniterealtime/Smack
public byte[] getOutgoingSoundBytes() {
return Base64.decode(outgoingSound);
}
代码示例来源:origin: org.igniterealtime.smack/smack-core
String channelBinding = "c=" + Base64.encodeToString(getCBindInput());
String clientFinalMessageWithoutProof = channelBinding + ",r=" + rvalue;
if (keys == null) {
byte[] saltedPassword = hi(saslPrep(password), Base64.decode(salt), iterations);
String clientFinalMessage = clientFinalMessageWithoutProof + ",p=" + Base64.encodeToString(clientProof);
state = State.RESPONSE_SENT;
return toBytes(clientFinalMessage);
case RESPONSE_SENT:
String clientCalculatedServerFinalMessage = "v=" + Base64.encodeToString(serverSignature);
if (!clientCalculatedServerFinalMessage.equals(challengeString)) {
throw new SmackException("Server final message does not match calculated one");
代码示例来源:origin: igniterealtime/Smack
public static final String encodeToString(byte[] input, int offset, int len) {
byte[] bytes = encode(input, offset, len);
try {
return new String(bytes, StringUtils.USASCII);
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
}
代码示例来源:origin: igniterealtime/Smack
/**
* Get the content in a Base64 encoded String.
*
* @return the content in a Base64 encoded String
*/
public String getContentBase64Encoded() {
if (contentString == null) {
contentString = Base64.encodeToString(getContent());
}
return contentString;
}
代码示例来源:origin: igniterealtime/Smack
/**
* Return the byte representation of the avatar(if one exists), otherwise returns null if
* no avatar could be found.
* <b>Example 1</b>
* <pre>
* // Load Avatar from VCard
* byte[] avatarBytes = vCard.getAvatar();
*
* // To create an ImageIcon for Swing applications
* ImageIcon icon = new ImageIcon(avatar);
*
* // To create just an image object from the bytes
* ByteArrayInputStream bais = new ByteArrayInputStream(avatar);
* try {
* Image image = ImageIO.read(bais);
* }
* catch (IOException e) {
* e.printStackTrace();
* }
* </pre>
*
* @return byte representation of avatar.
*/
public byte[] getAvatar() {
if (photoBinval == null) {
return null;
}
return Base64.decode(photoBinval);
}
内容来源于网络,如有侵权,请联系作者删除!