@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class Base64EncodingStrategy extends java.lang.Object implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static Base64EncodingStrategy |
DEFAULT
A base64-encoding strategy that represents a safe default configuration.
|
static Base64EncodingStrategy |
MAXIMAL
A base64-encoding strategy that indicates that the LDAP SDK should perform
the maximum amount of base64 encoding that it considers necessary.
|
static Base64EncodingStrategy |
MINIMAL_COMPLIANT
A base64-encoding strategy that indicates that the LDAP SDK should perform
the minimum amount of encoding required by the specification.
|
static Base64EncodingStrategy |
USER_FRIENDLY_NON_COMPLIANT
A base64-encoding strategy that indicates that the presence of non-ASCII
characters that the LDAP SDK considers displayable should not cause a
value to be encoded.
|
Constructor and Description |
---|
Base64EncodingStrategy(boolean encodeASCIIControlCharacters,
boolean encodeDisplayableNonASCIICharacters,
boolean encodeNonDisplayableNonASCIICharacters,
boolean encodeNonUTF8Data)
Creates a new base64 encoding strategy with the specified settings.
|
Modifier and Type | Method and Description |
---|---|
boolean |
encodeASCIIControlCharacters()
Indicates whether the presence of one or more ASCII control characters
should cause a value to be base64-encoded.
|
boolean |
encodeDisplayableNonASCIICharacters()
Indicates whether the presence of one or more displayable non-ASCII
characters (as determined by the
StaticUtils.isLikelyDisplayableCharacter(int) method) should cause a
value to be base64-encoded. |
boolean |
encodeNonDisplayableNonASCIICharacters()
Indicates whether the presence of one or more non-displayable non-ASCII
characters (as determined by the
StaticUtils.isLikelyDisplayableCharacter(int) method) should cause a
value to be base64-encoded. |
boolean |
encodeNonUTF8Data()
Indicates whether values that do not represent valid UTF-8 strings (as
determined by the
StaticUtils.isValidUTF8(byte[]) method) should be
base64-encoded. |
boolean |
shouldBase64Encode(byte[] value)
Indicates whether the provided value should be base64-encoded in accordance
with this strategy.
|
boolean |
shouldBase64Encode(ByteString value)
Indicates whether the provided value should be base64-encoded in accordance
with this strategy.
|
boolean |
shouldBase64Encode(java.lang.String value)
Indicates whether the provided value should be base64-encoded in accordance
with this strategy.
|
java.lang.String |
toString()
Retrieves a string representation of this base64 encoding strategy.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this base64 encoding strategy to the
provided buffer.
|
@NotNull public static final Base64EncodingStrategy DEFAULT
@NotNull public static final Base64EncodingStrategy MINIMAL_COMPLIANT
@NotNull public static final Base64EncodingStrategy USER_FRIENDLY_NON_COMPLIANT
@NotNull public static final Base64EncodingStrategy MAXIMAL
DEFAULT
strategy.public Base64EncodingStrategy(boolean encodeASCIIControlCharacters, boolean encodeDisplayableNonASCIICharacters, boolean encodeNonDisplayableNonASCIICharacters, boolean encodeNonUTF8Data)
encodeASCIIControlCharacters
- Indicates whether the presence of one or more ASCII control
characters (characters whose Unicode code point is less than
or equal to 0x01F, or is equal to 0x7F) should cause a value
to be base64-encoded. Note that as per RFC 2849, the presence
of the null (0x00), line feed (0x0A), and carriage return
(0x0D) ASCII control characters will always cause a value to
be base64-encoded.encodeDisplayableNonASCIICharacters
- Indicates whether the presence of one or more non-ASCII
characters (characters whose Unicode code point is greater
than 0x7F) that are believed to be displayable (as determined
by the StaticUtils.isLikelyDisplayableCharacter(int)
method) should cause a value to be base64-encoded.encodeNonDisplayableNonASCIICharacters
- Indicates whether the presence of one or more non-ASCII
characters (characters whose Unicode code point is greater
than 0x7F) that are not believed to be displayable (as
determined by the
StaticUtils.isLikelyDisplayableCharacter(int)
method)
should cause a value to be base64-encoded.encodeNonUTF8Data
- Indicates whether non-UTF-8-encoded data should be
base64-encoded. Note that if a value does not represent a
valid UTF-8 string, then the
encodeDisplayableNonASCIICharacters
and
encodeNonDisplayableNonASCIICharacters
arguments will
not be used.public boolean encodeASCIIControlCharacters()
true
if the presence of one or more ASCII control
characters should cause a value to be base64-encoded, or
false
if not.public boolean encodeDisplayableNonASCIICharacters()
StaticUtils.isLikelyDisplayableCharacter(int)
method) should cause a
value to be base64-encoded. Note that this only applies to values that
represent valid UTF-8 strings. Values that are not valid UTF-8 strings
will use the setting represented by the encodeNonUTF8Data
method.
Also note that all non-ASCII characters are required to be base64 encoded
by the LDIF specification, but there may be cases in which it may be
desirable to relax this behavior when displaying to an end user.true
if the presence of one or more displayable
non-ASCII characters should cause a value to be base64-encoded,
or false
if not.public boolean encodeNonDisplayableNonASCIICharacters()
StaticUtils.isLikelyDisplayableCharacter(int)
method) should cause a
value to be base64-encoded. Note that this only applies to values that
represent valid UTF-8 strings. Values that are not valid UTF-8 strings
will use the setting represented by the encodeNonUTF8Data
method.
Also note that all non-ASCII characters are required to be base64 encoded
by the LDIF specification, but there may be cases in which it may be
desirable to relax this behavior when displaying to an end user.true
if the presence of one or more non-displayable
non-ASCII characters should cause a value to be base64-encoded,
or false
if not.public boolean encodeNonUTF8Data()
StaticUtils.isValidUTF8(byte[])
method) should be
base64-encoded. Note that all non-ASCII data (which includes all non-UTF-8
data) is required to be base64 encoded, but there may be cases in which it
may be desirable to relax this behavior when displaying to an end user,
especially when using non-UTF-8 character sets.true
if values that do not represent valid UTF-8 strings
should be base64-encoded, or false
if not.public boolean shouldBase64Encode(@NotNull byte[] value)
value
- The value for which to make the determination. It must not
be null
.true
if the provided value should be base64-encoded in
accordance with this strategy, or false
if not.public boolean shouldBase64Encode(@NotNull java.lang.String value)
value
- The value for which to make the determination. It must not
be null
.true
if the provided value should be base64-encoded in
accordance with this strategy, or false
if not.public boolean shouldBase64Encode(@NotNull ByteString value)
value
- The value for which to make the determination. It must not
be null
.true
if the provided value should be base64-encoded in
accordance with this strategy, or false
if not.@NotNull public java.lang.String toString()
toString
in class java.lang.Object