Package com.unboundid.ldif
Class Base64EncodingStrategy
java.lang.Object
com.unboundid.ldif.Base64EncodingStrategy
- All Implemented Interfaces:
Serializable
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class Base64EncodingStrategy
extends Object
implements Serializable
This class defines a set of properties that can be used to indicate which
types of optional base64-encoding should be performed by the LDAP SDK.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Base64EncodingStrategyA base64-encoding strategy that represents a safe default configuration.static final Base64EncodingStrategyA base64-encoding strategy that indicates that the LDAP SDK should perform the maximum amount of base64 encoding that it considers necessary.static final Base64EncodingStrategyA base64-encoding strategy that indicates that the LDAP SDK should perform the minimum amount of encoding required by the specification.static final Base64EncodingStrategyA 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 Summary
ConstructorsConstructorDescriptionBase64EncodingStrategy(boolean encodeASCIIControlCharacters, boolean encodeDisplayableNonASCIICharacters, boolean encodeNonDisplayableNonASCIICharacters, boolean encodeNonUTF8Data) Creates a new base64 encoding strategy with the specified settings. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether the presence of one or more ASCII control characters should cause a value to be base64-encoded.booleanIndicates whether the presence of one or more displayable non-ASCII characters (as determined by theStaticUtils.isLikelyDisplayableCharacter(int)method) should cause a value to be base64-encoded.booleanIndicates whether the presence of one or more non-displayable non-ASCII characters (as determined by theStaticUtils.isLikelyDisplayableCharacter(int)method) should cause a value to be base64-encoded.booleanIndicates whether values that do not represent valid UTF-8 strings (as determined by theStaticUtils.isValidUTF8(byte[])method) should be base64-encoded.booleanshouldBase64Encode(byte[] value) Indicates whether the provided value should be base64-encoded in accordance with this strategy.booleanshouldBase64Encode(ByteString value) Indicates whether the provided value should be base64-encoded in accordance with this strategy.booleanshouldBase64Encode(String value) Indicates whether the provided value should be base64-encoded in accordance with this strategy.toString()Retrieves a string representation of this base64 encoding strategy.voidtoString(StringBuilder buffer) Appends a string representation of this base64 encoding strategy to the provided buffer.
-
Field Details
-
DEFAULT
A base64-encoding strategy that represents a safe default configuration. This includes:- The presence of ASCII control characters will cause a value to be base64-encoded. This is not required by the LDIF specification, but is recommended.
- The presence of any non-ASCII characters (whether they may be displayable or not) will cause a value to be base64-encoded as required by the LDIF specification.
- The presence of non-UTF-8 data will cause a value to be base64-encoded as required by the LDIF specification.
-
MINIMAL_COMPLIANT
A base64-encoding strategy that indicates that the LDAP SDK should perform the minimum amount of encoding required by the specification. The presence of ASCII control characters (other than NUL, LF, and CR, which must always be base64-encoded) will not cause values to be encoded. However, the presence of any non-ASCII characters or non-UTF-8 data will cause a value to be base64-=encoded as required by the LDIF specification. -
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. ASCII control characters, non-displayable non-ASCII characters, and non-UTF-8 data will cause a value to be base64-encoded. Note that this NOT compliant with the LDIF specification (which technically requires base64 encoding for all non-ASCII data), but it may be user friendly in some cases. -
MAXIMAL
A base64-encoding strategy that indicates that the LDAP SDK should perform the maximum amount of base64 encoding that it considers necessary. Any ASCII control characters, any non-ASCII data, and any non-UTF-8 data will cause a value to be base64 encoded. This is equivalent to theDEFAULTstrategy.
-
-
Constructor Details
-
Base64EncodingStrategy
public Base64EncodingStrategy(boolean encodeASCIIControlCharacters, boolean encodeDisplayableNonASCIICharacters, boolean encodeNonDisplayableNonASCIICharacters, boolean encodeNonUTF8Data) Creates a new base64 encoding strategy with the specified settings.- Parameters:
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 theStaticUtils.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 theStaticUtils.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 theencodeDisplayableNonASCIICharactersandencodeNonDisplayableNonASCIICharactersarguments will not be used.
-
-
Method Details
-
encodeASCIIControlCharacters
Indicates whether the presence of one or more ASCII control characters should cause a value to be base64-encoded. ASCII control characters other than NUL, LF, and CR are not required to be base64-encoded by the LDIF specification, but it is generally recommended that they be encoded.- Returns:
trueif the presence of one or more ASCII control characters should cause a value to be base64-encoded, orfalseif not.
-
encodeDisplayableNonASCIICharacters
Indicates whether the presence of one or more displayable non-ASCII characters (as determined by theStaticUtils.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 theencodeNonUTF8Datamethod. 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.- Returns:
trueif the presence of one or more displayable non-ASCII characters should cause a value to be base64-encoded, orfalseif not.
-
encodeNonDisplayableNonASCIICharacters
Indicates whether the presence of one or more non-displayable non-ASCII characters (as determined by theStaticUtils.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 theencodeNonUTF8Datamethod. 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.- Returns:
trueif the presence of one or more non-displayable non-ASCII characters should cause a value to be base64-encoded, orfalseif not.
-
encodeNonUTF8Data
Indicates whether values that do not represent valid UTF-8 strings (as determined by theStaticUtils.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.- Returns:
trueif values that do not represent valid UTF-8 strings should be base64-encoded, orfalseif not.
-
shouldBase64Encode
Indicates whether the provided value should be base64-encoded in accordance with this strategy.- Parameters:
value- The value for which to make the determination. It must not benull.- Returns:
trueif the provided value should be base64-encoded in accordance with this strategy, orfalseif not.
-
shouldBase64Encode
Indicates whether the provided value should be base64-encoded in accordance with this strategy.- Parameters:
value- The value for which to make the determination. It must not benull.- Returns:
trueif the provided value should be base64-encoded in accordance with this strategy, orfalseif not.
-
shouldBase64Encode
Indicates whether the provided value should be base64-encoded in accordance with this strategy.- Parameters:
value- The value for which to make the determination. It must not benull.- Returns:
trueif the provided value should be base64-encoded in accordance with this strategy, orfalseif not.
-
toString
Retrieves a string representation of this base64 encoding strategy. -
toString
Appends a string representation of this base64 encoding strategy to the provided buffer.- Parameters:
buffer- The buffer to which the string representation should be appended.
-