/** * Encodes a byte array into a base64 String. * * @param data a byte array to encode. * @return a base64 encode String. */ public static String encodeBase64(byte[] data) { return encodeBase64(data, false); }
/** * Encodes a byte array into a bse64 String. * * @param data The byte arry to encode. * @param lineBreaks True if the encoding should contain line breaks and false if it should not. * @return A base64 encoded String. */ public static String encodeBase64(byte[] data, boolean lineBreaks) { return encodeBase64(data, 0, data.length, lineBreaks); }
/** * Encodes a byte array into a bse64 String. * * @param data The byte arry to encode. * @param lineBreaks True if the encoding should contain line breaks and false if it should not. * @return A base64 encoded String. */ public static String encodeBase64(byte[] data, boolean lineBreaks) { return encodeBase64(data, 0, data.length, lineBreaks); }
/** * Encodes a byte array into a base64 String. * * @param data a byte array to encode. * @return a base64 encode String. */ public static String encodeBase64(byte[] data) { return encodeBase64(data, false); }
/** * Encodes a byte array into a bse64 String. * * @param data The byte arry to encode. * @param lineBreaks True if the encoding should contain line breaks and false if it should not. * @return A base64 encoded String. */ public static String encodeBase64(byte[] data, boolean lineBreaks) { return encodeBase64(data, 0, data.length, lineBreaks); }
/** * Encodes a byte array into a base64 String. * * @param data a byte array to encode. * @return a base64 encode String. */ public static String encodeBase64(byte[] data) { return encodeBase64(data, false); }
/** * Encodes a String as a base64 String. * * @param data a String to encode. * @return a base64 encoded String. */ public static String encodeBase64(String data) { byte [] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); } return encodeBase64(bytes); }
/** * Encodes a String as a base64 String. * * @param data a String to encode. * @return a base64 encoded String. */ public static String encodeBase64(String data) { byte [] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); } return encodeBase64(bytes); }
/** * Encodes a String as a base64 String. * * @param data a String to encode. * @return a base64 encoded String. */ public static String encodeBase64(String data) { byte [] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); } return encodeBase64(bytes); }
/** * Encodes a String as a base64 String. * * @param data a String to encode. * @return a base64 encoded String. */ public static String encodeBase64(String data) { byte [] bytes = null; try { bytes = data.getBytes("ISO-8859-1"); } catch (UnsupportedEncodingException uee) { uee.printStackTrace(); } return encodeBase64(bytes); }
/** * Specify the bytes for the avatar to use. * * @param bytes the bytes of the avatar. */ public void setAvatar(byte[] bytes) { String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>"); }
/** * Specify the bytes for the avatar to use. * * @param bytes the bytes of the avatar. */ public void setAvatar(byte[] bytes) { if (bytes == null) { // Remove avatar (if any) from mappings otherUnescapableFields.remove("PHOTO"); return; } // Otherwise, add to mappings. String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true); }
/** * Specify the bytes for the avatar to use. * * @param bytes the bytes of the avatar. */ public void setAvatar(byte[] bytes) { if (bytes == null) { // Remove avatar (if any) from mappings otherUnescapableFields.remove("PHOTO"); return; } // Otherwise, add to mappings. String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true); }
/** * Specify the bytes for the avatar to use as well as the mime type. * * @param bytes the bytes of the avatar. * @param mimeType the mime type of the avatar. */ public void setAvatar(byte[] bytes, String mimeType) { if (bytes == null) { // Remove avatar (if any) from mappings otherUnescapableFields.remove("PHOTO"); return; } // Otherwise, add to mappings. String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>" + mimeType + "</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true); }
/** * Specify the bytes for the avatar to use. * * @param bytes the bytes of the avatar. */ public void setAvatar(byte[] bytes) { if (bytes == null) { // Remove avatar (if any) from mappings otherUnescapableFields.remove("PHOTO"); return; } // Otherwise, add to mappings. String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true); }
/** * Specify the bytes for the avatar to use as well as the mime type. * * @param bytes the bytes of the avatar. * @param mimeType the mime type of the avatar. */ public void setAvatar(byte[] bytes, String mimeType) { if (bytes == null) { // Remove avatar (if any) from mappings otherUnescapableFields.remove("PHOTO"); return; } // Otherwise, add to mappings. String encodedImage = StringUtils.encodeBase64(bytes); avatar = encodedImage; setField("PHOTO", "<TYPE>" + mimeType + "</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true); }
private synchronized void flushBuffer() throws IOException { // do nothing if no data to send available if (bufferPointer == 0) { return; } // create data packet String enc = StringUtils.encodeBase64(buffer, 0, bufferPointer, false); DataPacketExtension data = new DataPacketExtension(byteStreamRequest.getSessionID(), this.seq, enc); // write to XMPP stream writeToXML(data); // reset buffer pointer bufferPointer = 0; // increment sequence, considering sequence overflow this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1); }
private synchronized void flushBuffer() throws IOException { // do nothing if no data to send available if (bufferPointer == 0) { return; } // create data packet String enc = StringUtils.encodeBase64(buffer, 0, bufferPointer, false); DataPacketExtension data = new DataPacketExtension(byteStreamRequest.getSessionID(), this.seq, enc); // write to XMPP stream writeToXML(data); // reset buffer pointer bufferPointer = 0; // increment sequence, considering sequence overflow this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1); }
private synchronized void flushBuffer() throws IOException { // do nothing if no data to send available if (bufferPointer == 0) { return; } // create data packet String enc = StringUtils.encodeBase64(buffer, 0, bufferPointer, false); DataPacketExtension data = new DataPacketExtension(byteStreamRequest.getSessionID(), this.seq, enc); // write to XMPP stream writeToXML(data); // reset buffer pointer bufferPointer = 0; // increment sequence, considering sequence overflow this.seq = (this.seq + 1 == 65535 ? 0 : this.seq + 1); }
protected void authenticate() throws IOException, XMPPException { String authenticationText = null; try { if(sc.hasInitialResponse()) { byte[] response = sc.evaluateChallenge(new byte[0]); authenticationText = StringUtils.encodeBase64(response, false); } } catch (SaslException e) { throw new XMPPException("SASL authentication failed", e); } // Send the authentication to the server getSASLAuthentication().send(new AuthMechanism(getName(), authenticationText)); }