Class Base32Support
java.lang.Object
net.shibboleth.utilities.java.support.codec.Base32Support
public final class Base32Support extends Object
Helper class for working with
Base32
.
This helper class specifically addresses that waste of the Apache Codec encode/decode static methods creating new
instances of the Base32
for every operation. It also provides the helper method to produce both chunked and
unchunked encoded content as strings.
-
Field Summary
Fields Modifier and Type Field Description static boolean
CHUNKED
Chunk the encoded data into 76-character lines broken by CRLF characters.private static org.apache.commons.codec.binary.Base32
CHUNKED_ENCODER
Encoder used to produce chunked output.static boolean
UNCHUNKED
Do not chunk encoded data.private static org.apache.commons.codec.binary.Base32
UNCHUNKED_ENCODER
Encoder used to produce unchunked output. -
Constructor Summary
Constructors Modifier Constructor Description private
Base32Support()
Constructor. -
Method Summary
-
Field Details
-
CHUNKED
public static final boolean CHUNKEDChunk the encoded data into 76-character lines broken by CRLF characters.- See Also:
- Constant Field Values
-
UNCHUNKED
public static final boolean UNCHUNKEDDo not chunk encoded data.- See Also:
- Constant Field Values
-
CHUNKED_ENCODER
@Nonnull private static final org.apache.commons.codec.binary.Base32 CHUNKED_ENCODEREncoder used to produce chunked output. -
UNCHUNKED_ENCODER
@Nonnull private static final org.apache.commons.codec.binary.Base32 UNCHUNKED_ENCODEREncoder used to produce unchunked output.
-
-
Constructor Details
-
Base32Support
private Base32Support()Constructor.
-
-
Method Details
-
encode
@Nonnull public static String encode(@Nonnull byte[] data, boolean chunked) throws EncodingExceptionBase32 encodes the given binary data.- Parameters:
data
- data to encodechunked
- whether the encoded data should be chunked or not- Returns:
- the base32 encoded data
- Throws:
EncodingException
- when anyException
is thrown from the underlying encoder, or the output is null.
-
decode
Decodes (un)chunked Base32 encoded data.- Parameters:
data
- Base32 encoded data- Returns:
- the decoded data
- Throws:
DecodingException
- when anException
is thrown from the underlying decoder, or the output is null.
-