Package org.graylog2.security.encryption
Class EncryptedValue
java.lang.Object
org.graylog2.security.encryption.EncryptedValue
This is a container for encrypted values. It is supposed to be used when storing encrypted values in MongoDB (JSON)
and also serialize it in HTTP responses. When storing the value in the database, the JSON serialization looks
different than when it's serialized in a HTTP response.
Check org.graylog2.security.encryption.EncryptedValueTest
for usage examples.
Expected structure for deserialization without active database attribute
This takes a new value and theEncryptedValueDeserializer
automatically creates an
encrypted value for it. (admin wants to set a new password via HTTP request)
// Setting a new password
{
"set_value": "set a new password"
}
// Alternative to set a new password (pass a string instead of an object)
"set a new password"
// Keep existing value
{
"keep_value": true
}
// Delete existing value
{
"delete_value": true
}
Expected structure for deserialization with active database attribute
In this case the value is just deserialized as it is. (reading from MongoDB)
{
"encrypted_value": "the encrypted value",
"salt": "the encryption salt"
}
Serialized structure without active database attribute
In this case the serialized JSON only contains an indicator if a value is set and doesn't contain the encrypted value and the salt. (when value is returned in a HTTP response)
{
"is_set": true
}
Serialized structure with active database attribute
In this case the serialized JSON contains the encrypted value and the salt. (when storing the value in MongoDB)
{
"encrypted_value": "the encrypted value",
"salt": "the encryption salt"
}
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic EncryptedValue.Builder
builder()
static EncryptedValue
static EncryptedValue
static EncryptedValue
abstract boolean
abstract boolean
boolean
isSet()
abstract String
salt()
abstract String
value()
-
Constructor Details
-
EncryptedValue
public EncryptedValue()
-
-
Method Details
-
value
-
salt
-
isKeepValue
public abstract boolean isKeepValue() -
isDeleteValue
public abstract boolean isDeleteValue() -
isSet
public boolean isSet() -
createUnset
-
createWithKeepValue
-
createWithDeleteValue
-
builder
-