Package org.forgerock.util.encode
Class Base64url
java.lang.Object
org.forgerock.util.encode.Base64url
Makes use of the
Base64
class to encode and decode to and from URL-safe Base64. The encoder
omits padding characters.-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Decodes the given Base64url encoded String into a byte array.static byte[]
decodeStrict
(String content) Decodes the given Base64url encoded String into a byte array.static String
decodeToString
(String content) Decodes the given Base64url encoded string into a String.static String
encode
(byte[] content) Encodes the given byte array into a Base64url encoded String.static String
Encodes the given UTF-8 encoded String into a Base64url encoded String.
-
Method Details
-
decode
Decodes the given Base64url encoded String into a byte array. This version returnsnull
if the input is invalid for compatibility with the previous implementation. UsedecodeStrict(String)
to throw an exception for invalid input instead.- Parameters:
content
- The Base64url encoded String to decode.- Returns:
- The decoded byte[] array or
null
if the input was not valid base64url.
-
decodeStrict
Decodes the given Base64url encoded String into a byte array.- Parameters:
content
- The Base64url encoded String to decode.- Returns:
- The decoded byte[] array.
- Throws:
IllegalArgumentException
- if the input is not valid base64url.
-
decodeToString
Decodes the given Base64url encoded string into a String.- Parameters:
content
- The Base64url encoded String to decode.- Returns:
- The decoded String or
null
if the input was not valid base64url.
-
encode
Encodes the given byte array into a Base64url encoded String.- Parameters:
content
- The byte array to encode.- Returns:
- The Base64url encoded byte array.
-
encode
Encodes the given UTF-8 encoded String into a Base64url encoded String.- Parameters:
content
- The String to encode.- Returns:
- The Base64url encoded String.
-