Class Base64EncodingStrategy

java.lang.Object
com.unboundid.ldif.Base64EncodingStrategy
All Implemented Interfaces:
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 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 the DEFAULT strategy.
  • 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 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.
  • Method Details

    • encodeASCIIControlCharacters

      public boolean 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:
      true if the presence of one or more ASCII control characters should cause a value to be base64-encoded, or false if not.
    • 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. 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.
      Returns:
      true if the presence of one or more displayable non-ASCII characters should cause a value to be base64-encoded, or false if not.
    • 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. 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.
      Returns:
      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.
    • encodeNonUTF8Data

      public 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. 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:
      true if values that do not represent valid UTF-8 strings should be base64-encoded, or false if not.
    • shouldBase64Encode

      public boolean shouldBase64Encode(@NotNull byte[] value)
      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 be null.
      Returns:
      true if the provided value should be base64-encoded in accordance with this strategy, or false if not.
    • shouldBase64Encode

      public boolean shouldBase64Encode(@NotNull String value)
      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 be null.
      Returns:
      true if the provided value should be base64-encoded in accordance with this strategy, or false if not.
    • shouldBase64Encode

      public boolean shouldBase64Encode(@NotNull ByteString value)
      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 be null.
      Returns:
      true if the provided value should be base64-encoded in accordance with this strategy, or false if not.
    • toString

      Retrieves a string representation of this base64 encoding strategy.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this base64 encoding strategy.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      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.