-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Support text indexes with encryption #1797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
driver-core/src/main/com/mongodb/client/model/vault/TextOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.mongodb.client.model.vault; | ||
|
||
import com.mongodb.annotations.Alpha; | ||
import com.mongodb.annotations.Reason; | ||
import com.mongodb.lang.Nullable; | ||
import org.bson.BsonDocument; | ||
|
||
/** | ||
* Text options for a Queryable Encryption field that supports text queries. | ||
* | ||
* <p>Note: TextOptions is in Alpha and subject to backwards breaking changes. | ||
* | ||
* @since 5.6 | ||
* @mongodb.server.release 8.2 | ||
* @mongodb.driver.manual /core/queryable-encryption/ queryable encryption | ||
*/ | ||
@Alpha(Reason.SERVER) | ||
public class TextOptions { | ||
private Boolean caseSensitive; | ||
private Boolean diacriticSensitive; | ||
@Nullable | ||
private BsonDocument prefixOptions; | ||
@Nullable | ||
private BsonDocument suffixOptions; | ||
@Nullable | ||
private BsonDocument substringOptions; | ||
|
||
/** | ||
* Construct a new instance | ||
*/ | ||
public TextOptions() { | ||
} | ||
|
||
/** | ||
* @return true if text indexes for this field are case sensitive. | ||
*/ | ||
public boolean getCaseSensitive() { | ||
return caseSensitive; | ||
} | ||
|
||
/** | ||
* Set case sensitivity | ||
* | ||
* @param caseSensitive true if text indexes are case sensitive | ||
* @return this | ||
*/ | ||
public TextOptions caseSensitive(final boolean caseSensitive) { | ||
this.caseSensitive = caseSensitive; | ||
return this; | ||
} | ||
|
||
/** | ||
* @return true if text indexes are diacritic sensitive | ||
*/ | ||
public boolean getDiacriticSensitive() { | ||
return diacriticSensitive; | ||
} | ||
|
||
/** | ||
* Set diacritic sensitivity | ||
* | ||
* @param diacriticSensitive true if text indexes are diacritic sensitive | ||
* @return this | ||
*/ | ||
public TextOptions diacriticSensitive(final boolean diacriticSensitive) { | ||
this.diacriticSensitive = diacriticSensitive; | ||
return this; | ||
} | ||
|
||
/** | ||
* Set the prefix options. | ||
* | ||
* <p>Expected to be a {@link BsonDocument} in the format of:</p> | ||
* | ||
* <pre> | ||
* {@code | ||
* { | ||
* // strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error. | ||
* strMinQueryLength: BsonInt32, | ||
* // strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error. | ||
* strMaxQueryLength: BsonInt32 | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* @param prefixOptions the prefix options or null | ||
* @return this | ||
*/ | ||
public TextOptions prefixOptions(@Nullable final BsonDocument prefixOptions) { | ||
this.prefixOptions = prefixOptions; | ||
return this; | ||
} | ||
|
||
/** | ||
* @see #prefixOptions(BsonDocument) | ||
* @return the prefix options document or null | ||
*/ | ||
@Nullable | ||
public BsonDocument getPrefixOptions() { | ||
return prefixOptions; | ||
} | ||
|
||
/** | ||
* Set the suffix options. | ||
* | ||
* <p>Expected to be a {@link BsonDocument} in the format of:</p> | ||
* | ||
* <pre> | ||
* {@code | ||
* { | ||
* // strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error. | ||
* strMinQueryLength: BsonInt32, | ||
* // strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error. | ||
* strMaxQueryLength: BsonInt32 | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* @param suffixOptions the suffix options or null | ||
* @return this | ||
*/ | ||
public TextOptions suffixOptions(@Nullable final BsonDocument suffixOptions) { | ||
this.suffixOptions = suffixOptions; | ||
return this; | ||
} | ||
|
||
/** | ||
* @see #suffixOptions(BsonDocument) | ||
* @return the suffix options document or null | ||
*/ | ||
@Nullable | ||
public BsonDocument getSuffixOptions() { | ||
return suffixOptions; | ||
} | ||
|
||
/** | ||
* Set the substring options. | ||
* | ||
* <p>Expected to be a {@link BsonDocument} in the format of:</p> | ||
* | ||
* <pre> | ||
* {@code | ||
* { | ||
* // strMaxLength is the maximum allowed length to insert. Inserting longer strings will error. | ||
* strMaxLength: BsonInt32, | ||
* // strMinQueryLength is the minimum allowed query length. Querying with a shorter string will error. | ||
* strMinQueryLength: BsonInt32, | ||
* // strMaxQueryLength is the maximum allowed query length. Querying with a longer string will error. | ||
* strMaxQueryLength: BsonInt32 | ||
* } | ||
* } | ||
* </pre> | ||
* | ||
* @param substringOptions the substring options or null | ||
* @return this | ||
*/ | ||
public TextOptions substringOptions(@Nullable final BsonDocument substringOptions) { | ||
this.substringOptions = substringOptions; | ||
return this; | ||
} | ||
|
||
/** | ||
* @see #substringOptions(BsonDocument) | ||
* @return the substring options document or null | ||
*/ | ||
@Nullable | ||
public BsonDocument getSubstringOptions() { | ||
return substringOptions; | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now part of the Spec and ensures that fresh encryption collections are made. This ensures
__safeContent__
values are predictable and testable.