Class Utils
- java.lang.Object
-
- org.forgerock.openam.radius.common.Utils
-
public final class Utils extends Object
Debugging tool for serializing into space separated hex values for each byte of a sequence of octets or for reading such a formatted string into a sequence of octets. For example, rfc 2865 includes examples that show such space delimited hex strings in sections 7.1 through 7.3. These can readily be used in unit tests as sources for sequences to test instantiation from such wire sequences our set of java objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ByteBuffertoBuffer(String spacedHex)Convert the spaced hex form of a String into a ByteBuffer.static byte[]toByteArray(String spacedHex)Convert the spaced hex form of a String into a byte array.static StringtoHexAndPrintableChars(byte[] bytes)Returns a String that reflects as much as we can safely print to output having two sequences.static StringtoSpacedHex(ByteBuffer bfr)Converts a ByteBuffer's contents to a spaced hex string with each byte represented as a two hex characters with each pair of characters except for the last pair separated from the following pair by a space character such as "01 06 6e 65 6d 6f".
-
-
-
Method Detail
-
toSpacedHex
public static final String toSpacedHex(ByteBuffer bfr)
Converts a ByteBuffer's contents to a spaced hex string with each byte represented as a two hex characters with each pair of characters except for the last pair separated from the following pair by a space character such as "01 06 6e 65 6d 6f". This particluar sequence happens to be the wire representation of a UserNameAttribute containing a name of "nemo".- Parameters:
bfr- The buffer to convert to hexadecimal character form.- Returns:
- The converted representation of the buffer contents.
-
toByteArray
public static byte[] toByteArray(String spacedHex)
Convert the spaced hex form of a String into a byte array.- Parameters:
spacedHex- the string containing spaced hexadecimal values to be converted to a byte array.- Returns:
- a byte array holding the binary representation of the spaced hex values.
-
toBuffer
public static ByteBuffer toBuffer(String spacedHex)
Convert the spaced hex form of a String into a ByteBuffer.- Parameters:
spacedHex- the string containing spaced hexadecimal values to be converted to a byte array.- Returns:
- a ByteBuffer holding the binary representation of the spaced hex values.
-
toHexAndPrintableChars
public static String toHexAndPrintableChars(byte[] bytes)
Returns a String that reflects as much as we can safely print to output having two sequences. The first sequence being a square brace delimited array of hexadecimal character values separated by spaces delimited with one pair for each byte. The second is delineated by braces and contains ascii characters for values 40 to 126 and a period character for all other values with each character representing on of the hexadecimal pairs. Example- Parameters:
bytes- the binary bytes to be converted to hexadecimal string representation.- Returns:
- the string of hexadecimal characters representing the content of the bytes.
-
-