Class Value
- All Implemented Interfaces:
Proxy
A SecretValue contains a password or other secret value.
Use get() to get the actual secret data, such as a password.
The secret data is not necessarily null-terminated, unless the content type
is "text/plain".
Each SecretValue has a content type. For passwords, this is text/plain.
Use getContentType() to look at the content type.
SecretValue is reference counted and immutable. The secret data is only
freed when all references have been released via unref().
-
Constructor Summary
ConstructorsConstructorDescriptionValue(MemorySegment address) Create a Value proxy instance for the provided memory address.Create aSecretValuefor the secret data passed in. -
Method Summary
Modifier and TypeMethodDescriptionstatic ValueCreate aSecretValuefor the secret data passed in.byte[]get()Get the secret data in theSecretValue.Get the content type of the secret value, such astext/plain.@Nullable StringgetText()Get the secret data in theSecretValueif it contains a textual value.static @Nullable TypegetType()Get the GType of the Value classref()Add another reference to theSecretValue.voidunref()Unreference aSecretValue.unrefToPassword(Out<Long> length) Unreference aSecretValueand steal the secret data inSecretValueas nonpageable memory.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Value
Create a Value proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Value
Create aSecretValuefor the secret data passed in.The secret data is copied into non-pageable 'secure' memory.
If the length is less than zero, then
secretis assumed to be null-terminated.- Parameters:
secret- the secret datalength- the length of the datacontentType- the content type of the data
-
-
Method Details
-
getType
-
full
Create aSecretValuefor the secret data passed in.The secret data is not copied, and will later be freed with the
destroyfunction.If the length is less than zero, then
secretis assumed to be null-terminated.- Parameters:
secret- the secret datalength- the length of the datacontentType- the content type of the data- Returns:
- the new
SecretValue
-
get
public byte[] get()Get the secret data in theSecretValue.The value is not necessarily null-terminated unless it was created with
Value(java.lang.String, long, java.lang.String)or a null-terminated string was passed tofull(java.lang.String, long, java.lang.String).- Returns:
- the secret data
-
getContentType
Get the content type of the secret value, such astext/plain.- Returns:
- the content type
-
getText
Get the secret data in theSecretValueif it contains a textual value.The content type must be
text/plain.- Returns:
- the value
-
ref
-
unref
public void unref()Unreference aSecretValue.When the last reference is gone, then the value will be freed.
-
unrefToPassword
Unreference aSecretValueand steal the secret data inSecretValueas nonpageable memory.- Parameters:
length- the length of the secret- Returns:
- a new password string stored in nonpageable memory
which must be freed with
Secret.passwordFree(java.lang.String)when done - Since:
- 0.19.0
-