/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @return the text node * @since 1.4 */ public static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, NO_OPTIONS); } // end encodeBytes
/** * Apply base64 decoding on the message and return the byte array * @param encodedString * @return */ public static byte[] base64Decode(String encodedString) { if (encodedString == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "encodedString"); return Base64.decode(encodedString); }
/** * Encodes up to the first three bytes of array <var>threeBytes</var> and returns a four-byte array in Base64 notation. The * actual number of significant bytes in your array is given by <var>numSigBytes</var>. The array <var>threeBytes</var> * needs only be as big as <var>numSigBytes</var>. Code can reuse a byte array by passing a four-byte array as * <var>b4</var>. * * @param b4 A reusable byte array to reduce array instantiation * @param threeBytes the array to convert * @param numSigBytes the number of significant bytes in your array * @return four byte array in Base64 notation. * @since 1.5.1 */ private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes) { encode3to4(threeBytes, 0, numSigBytes, b4, 0); return b4; } // end encode3to4
BinarySecretType serverBinarySecret = new BinarySecretType(); serverBinarySecret.setType(WSTrustConstants.BS_TYPE_NONCE); serverBinarySecret.setValue(Base64.encodeBytes(serverSecret).getBytes()); if (clientEntropy != null) clientSecret = Base64.decode(new String(WSTrustUtil.getBinarySecret(clientEntropy))); serverEntropy = new EntropyType(); serverEntropy.addAny(serverBinarySecret); try combinedSecret = Base64.encodeBytes(WSTrustUtil.P_SHA1(clientSecret, serverSecret, (int) keySize / 8)) .getBytes();
/** * Serializes an object and returns the Base64-encoded version of that serialized object. If the object cannot be serialized * or there is another error, the method will return <tt>null</tt>. The object is not GZip-compressed before being encoded. * * @param serializableObject The object to encode * @return The Base64-encoded object * @since 1.4 */ public static String encodeObject(java.io.Serializable serializableObject) { return encodeObject(serializableObject, NO_OPTIONS); } // end encodeObject
b4[b4Posn++] = sbiCrop; if (b4Posn > 3) { outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn); b4Posn = 0;
BinarySecretType serverBinarySecret = new BinarySecretType(); serverBinarySecret.setType(WSTrustConstants.BS_TYPE_NONCE); serverBinarySecret.setValue(Base64.encodeBytes(serverSecret).getBytes()); if (clientEntropy != null) clientSecret = Base64.decode(new String(WSTrustUtil.getBinarySecret(clientEntropy))); serverEntropy = new EntropyType(); serverEntropy.addAny(serverBinarySecret); try combinedSecret = Base64.encodeBytes(WSTrustUtil.P_SHA1(clientSecret, serverSecret, (int) keySize / 8)) .getBytes();
/** * Serializes an object and returns the Base64-encoded * version of that serialized object. If the object * cannot be serialized or there is another error, * the method will return <tt>null</tt>. * The object is not GZip-compressed before being encoded. * * @param serializableObject The object to encode * @return The Base64-encoded object * @since 1.4 */ public static String encodeObject(java.io.Serializable serializableObject) { return encodeObject(serializableObject, NO_OPTIONS); } // end encodeObject
if (b4Posn > 3) outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn); b4Posn = 0;
/** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. * * @param source The data to convert * @return the encode bytes * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * Apply base64 decoding on the message and return the byte array * @param encodedString * @return */ public static byte[] base64Decode(String encodedString) { if (encodedString == null) throw new IllegalArgumentException(ErrorCodes.NULL_ARGUMENT + "encodedString"); return Base64.decode(encodedString); }
BinarySecretType serverBinarySecret = new BinarySecretType(); serverBinarySecret.setType(WSTrustConstants.BS_TYPE_NONCE); serverBinarySecret.setValue(Base64.encodeBytes(serverSecret).getBytes()); clientSecret = Base64.decode(new String(WSTrustUtil.getBinarySecret(clientEntropy))); serverEntropy = new EntropyType(); serverEntropy.addAny(serverBinarySecret); combinedSecret = Base64.encodeBytes(WSTrustUtil.P_SHA1(clientSecret, serverSecret, (int) keySize / 8)) .getBytes();
/** * Encodes up to the first three bytes of array <var>threeBytes</var> * and returns a four-byte array in Base64 notation. * The actual number of significant bytes in your array is * given by <var>numSigBytes</var>. * The array <var>threeBytes</var> needs only be as big as * <var>numSigBytes</var>. * Code can reuse a byte array by passing a four-byte array as <var>b4</var>. * * @param b4 A reusable byte array to reduce array instantiation * @param threeBytes the array to convert * @param numSigBytes the number of significant bytes in your array * @return four byte array in Base64 notation. * @since 1.5.1 */ private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes) { encode3to4(threeBytes, 0, numSigBytes, b4, 0); return b4; } // end encode3to4
/** * Serializes an object and returns the Base64-encoded * version of that serialized object. If the object * cannot be serialized or there is another error, * the method will return <tt>null</tt>. * The object is not GZip-compressed before being encoded. * * @param serializableObject The object to encode * @return The Base64-encoded object * @since 1.4 */ public static String encodeObject(java.io.Serializable serializableObject) { return encodeObject(serializableObject, NO_OPTIONS); } // end encodeObject
if (b4Posn > 3) outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn); b4Posn = 0;
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @return the encode bytes * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * Base64 decode followed by Deflate decoding * * @param encodedString * @return */ public static InputStream base64DeflateDecode(String encodedString) { byte[] base64decodedMsg = Base64.decode(encodedString); return DeflateUtil.decode(base64decodedMsg); }
/** * Encodes up to the first three bytes of array <var>threeBytes</var> * and returns a four-byte array in Base64 notation. * The actual number of significant bytes in your array is * given by <var>numSigBytes</var>. * The array <var>threeBytes</var> needs only be as big as * <var>numSigBytes</var>. * Code can reuse a byte array by passing a four-byte array as <var>b4</var>. * * @param b4 A reusable byte array to reduce array instantiation * @param threeBytes the array to convert * @param numSigBytes the number of significant bytes in your array * @return four byte array in Base64 notation. * @since 1.5.1 */ private static byte[] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes) { encode3to4(threeBytes, 0, numSigBytes, b4, 0); return b4; } // end encode3to4
/** * Encodes a byte array into Base64 notation. * Does not GZip-compress data. * * @param source The data to convert * @return the encode bytes * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * Base64 decode followed by Deflate decoding * @param encodedString * @return */ public static InputStream base64DeflateDecode(String encodedString) { byte[] base64decodedMsg = Base64.decode(encodedString); return DeflateUtil.decode(base64decodedMsg); }