Class PutUserRequest
java.lang.Object
org.elasticsearch.client.security.PutUserRequest
- All Implemented Interfaces:
Validatable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
public final class PutUserRequest extends java.lang.Object implements Validatable, org.elasticsearch.common.xcontent.ToXContentObject
Request object to create or update a user in the native realm.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PutUserRequest(User user, char[] password, boolean enabled, RefreshPolicy refreshPolicy)
Deprecated. -
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
char[]
getPassword()
RefreshPolicy
getRefreshPolicy()
User
getUser()
int
hashCode()
boolean
isEnabled()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
static PutUserRequest
updateUser(User user, boolean enabled, RefreshPolicy refreshPolicy)
Update an existing user in the native realm without modifying their password.java.util.Optional<ValidationException>
validate()
Perform validation.static PutUserRequest
withPassword(User user, char[] password, boolean enabled, RefreshPolicy refreshPolicy)
Create or update a user in the native realm, with the user's new or updated password specified in plaintext.static PutUserRequest
withPasswordHash(User user, char[] passwordHash, boolean enabled, RefreshPolicy refreshPolicy)
Create or update a user in the native realm, with the user's new or updated password specified as a cryptographic hash.
-
Constructor Details
-
PutUserRequest
@Deprecated public PutUserRequest(User user, @Nullable char[] password, boolean enabled, @Nullable RefreshPolicy refreshPolicy)Deprecated.Creates a new request that is used to create or update a user in the native realm.- Parameters:
user
- the user to be created or updatedpassword
- the password of the user. The password array is not modified by this class. It is the responsibility of the caller to clear the password after receiving a response.enabled
- true if the user is enabled and allowed to access elasticsearchrefreshPolicy
- the refresh policy for the request.
-
-
Method Details
-
withPassword
public static PutUserRequest withPassword(User user, char[] password, boolean enabled, RefreshPolicy refreshPolicy)Create or update a user in the native realm, with the user's new or updated password specified in plaintext.- Parameters:
user
- the user to be created or updatedpassword
- the password of the user. The password array is not modified by this class. It is the responsibility of the caller to clear the password after receiving a response.enabled
- true if the user is enabled and allowed to access elasticsearchrefreshPolicy
- the refresh policy for the request.
-
withPasswordHash
public static PutUserRequest withPasswordHash(User user, char[] passwordHash, boolean enabled, RefreshPolicy refreshPolicy)Create or update a user in the native realm, with the user's new or updated password specified as a cryptographic hash.- Parameters:
user
- the user to be created or updatedpasswordHash
- the hash of the password of the user. It must be in the correct format for the password hashing algorithm in use on this elasticsearch cluster. The array is not modified by this class. It is the responsibility of the caller to clear the hash after receiving a response.enabled
- true if the user is enabled and allowed to access elasticsearchrefreshPolicy
- the refresh policy for the request.
-
updateUser
Update an existing user in the native realm without modifying their password.- Parameters:
user
- the user to be created or updatedenabled
- true if the user is enabled and allowed to access elasticsearchrefreshPolicy
- the refresh policy for the request.
-
getUser
-
getPassword
@Nullable public char[] getPassword() -
isEnabled
public boolean isEnabled() -
getRefreshPolicy
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
validate
Description copied from interface:Validatable
Perform validation. This method does not have to be overridden in the event that no validation needs to be done, or the validation was done during object construction time. AValidationException
that is not null is assumed to contain validation errors and will be thrown.- Specified by:
validate
in interfaceValidatable
- Returns:
- An
Optional
ValidationException
that contains a list of validation errors.
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
java.io.IOException
-