Class EncryptOptions

java.lang.Object
com.mongodb.client.model.vault.EncryptOptions

public class EncryptOptions extends Object
The options for explicit encryption.
Since:
3.11
  • Constructor Details

    • EncryptOptions

      public EncryptOptions(String algorithm)
      Construct an instance with the given algorithm.
      Parameters:
      algorithm - the encryption algorithm
      See Also:
  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Gets the encryption algorithm, which must be either:
      • AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic
      • AEAD_AES_256_CBC_HMAC_SHA_512-Random
      • Indexed
      • Unindexed
      • Range
      • String

      The "String" algorithm supports Queryable Encryption prefix, suffix, and substring string queries. Use the "String" algorithm with query types "prefix"/"suffix"/"substring" (server 9.0+) or the deprecated aliases "prefixPreview"/"suffixPreview"/"substringPreview" (server 8.2 to pre-9.0).

      Returns:
      the encryption algorithm
    • getKeyId

      @Nullable public BsonBinary getKeyId()
      Gets the key identifier.

      Identifies the data key by its _id value. The value is a UUID (binary subtype 4).

      Returns:
      the key identifier
    • getKeyAltName

      @Nullable public String getKeyAltName()
      Gets the alternate name with which to look up the key.

      Identifies the alternate key name to look up the key by.

      Returns:
      the alternate name
    • keyId

      public EncryptOptions keyId(BsonBinary keyId)
      Sets the key identifier
      Parameters:
      keyId - the key identifier
      Returns:
      this
      See Also:
    • keyAltName

      public EncryptOptions keyAltName(String keyAltName)
      Sets the alternate key name
      Parameters:
      keyAltName - the alternate key name
      Returns:
      this
      See Also:
    • contentionFactor

      public EncryptOptions contentionFactor(@Nullable Long contentionFactor)
      The contention factor.

      It is an error to set contentionFactor when algorithm is not "Indexed" or "Range".

      Parameters:
      contentionFactor - the contention factor, which must be >= 0 or null.
      Returns:
      this
      Since:
      4.7
      Since server release
      7.0
    • getContentionFactor

      @Nullable public Long getContentionFactor()
      Gets the contention factor.
      Returns:
      the contention factor
      Since:
      4.7
      See Also:
      Since server release
      7.0
    • queryType

      public EncryptOptions queryType(@Nullable String queryType)
      The QueryType.

      Currently, we support only "equality", "range", "prefix", "suffix", "substring", "prefixPreview", "suffixPreview" or "substringPreview" queryType.

      The "prefix", "suffix", "substring", "prefixPreview", "suffixPreview" and "substringPreview" query types are only valid with the "String" algorithm. "prefixPreview"/"suffixPreview"/"substringPreview" are deprecated aliases supported for servers 8.2 to pre-9.0; use "prefix"/"suffix"/"substring" on server 9.0+.

      It is an error to set queryType when the algorithm is not "Indexed", "Range" or "String".

      Parameters:
      queryType - the query type
      Returns:
      this
      Since:
      4.7
      Since server release
      7.0
    • getQueryType

      @Nullable public String getQueryType()
      Gets the QueryType.

      See queryType(String) for the supported query types.

      Returns:
      the queryType or null
      Since:
      4.7
      See Also:
      Since server release
      7.0
    • rangeOptions

      public EncryptOptions rangeOptions(@Nullable RangeOptions rangeOptions)
      The RangeOptions

      It is an error to set RangeOptions when the algorithm is not "Range".

      Parameters:
      rangeOptions - the range options
      Returns:
      this
      Since:
      4.9
      MongoDB documentation
      queryable encryption
      Since server release
      8.0
    • getRangeOptions

      @Nullable public RangeOptions getRangeOptions()
      Gets the RangeOptions
      Returns:
      the range options or null if not set
      Since:
      4.9
      MongoDB documentation
      queryable encryption
      Since server release
      8.0
    • textOptions

      @Deprecated @Alpha(SERVER) public EncryptOptions textOptions(@Nullable TextOptions textOptions)
      Deprecated.
      The TextOptions

      It is an error to set TextOptions when the algorithm is not "String".

      Parameters:
      textOptions - the text options
      Returns:
      this
      Since:
      5.6
      MongoDB documentation
      queryable encryption
      Since server release
      8.2
    • getTextOptions

      @Deprecated @Alpha(SERVER) @Nullable public TextOptions getTextOptions()
      Deprecated.
      Use getStringOptions() instead.
      Gets the TextOptions
      Returns:
      the text options or null if not set
      Since:
      5.6
      See Also:
      MongoDB documentation
      queryable encryption
      Since server release
      8.2
    • stringOptions

      public EncryptOptions stringOptions(@Nullable StringOptions stringOptions)
      The StringOptions

      It is an error to set StringOptions when the algorithm is not "String".

      Parameters:
      stringOptions - the string options
      Returns:
      this
      Since:
      5.9
      MongoDB documentation
      queryable encryption
      Since server release
      8.2
    • getStringOptions

      @Nullable public StringOptions getStringOptions()
      Gets the StringOptions
      Returns:
      the string options or null if not set
      Since:
      5.9
      See Also:
      MongoDB documentation
      queryable encryption
      Since server release
      8.2
    • toString

      public String toString()
      Overrides:
      toString in class Object