Package com.ultikits.ultitools.utils
Class ServerCredential
java.lang.Object
com.ultikits.ultitools.utils.ServerCredential
The per-server UltiCloud credential (protocol v2, prefix
ucs_) and the facts the device
authorization returned with it.
The credential is opaque, never expires and has no refresh token; it is revoked by the owner in the
panel or replaced by a rotation. The secret is readable only through the package-private
bearerValue(), and toString() leaves it out, so a log line built from this object
cannot carry it.
- Since:
- 6.3.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringprivate final long(package private) static final StringThe prefix every server credential carries.private final Stringprivate final Stringprivate final Long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) String(package private) static ServerCredentialfromDocument(Object entry) Reads onecloud_credentialdocument entry.(package private) String(package private) long(package private) String(package private) String(package private) Long(package private) static booleanisWellFormedSecret(String credential) (package private) static LongparseUserId(Number value) (package private) ServerCredentialThe same link with a rotated secret (plan 22-21, D-10): server id, owner, name and link time are kept, exactly asServerCredentialStore.replace(java.lang.String, java.lang.String, java.lang.String)keeps them on disk.private static LongstoredUserId(Object value) Reads legacy decimal text only at the persistence boundary, never on the REST wire.private static StringtoString()
-
Field Details
-
FIELD_CREDENTIAL
- See Also:
-
FIELD_CREDENTIAL_ID
- See Also:
-
FIELD_SERVER_ID
- See Also:
-
FIELD_USER_ID
- See Also:
-
FIELD_SERVER_NAME
- See Also:
-
FIELD_LINKED_AT
- See Also:
-
SECRET_PREFIX
The prefix every server credential carries.- See Also:
-
credential
-
credentialId
-
serverId
-
userId
-
serverName
-
linkedAt
private final long linkedAt
-
-
Constructor Details
-
ServerCredential
ServerCredential(String credential, String credentialId, String serverId, Long userId, String serverName, long linkedAt) - Parameters:
credential- theucs_secret; must start withSECRET_PREFIXcredentialId- the credential's public id, ornullserverId- the server's public id (a ULID); must be non-emptyuserId- the linking owner's id, ornullserverName- the name the owner chose on the confirmation page, ornulllinkedAt- when the link was made, epoch milliseconds
-
-
Method Details
-
isWellFormedSecret
- Parameters:
credential- the candidate secret- Returns:
trueif it has theucs_prefix and at least one character after it
-
fromDocument
Reads onecloud_credentialdocument entry.- Parameters:
entry- the value stored under the key, as parsed byCredentialStore- Returns:
- the credential, or
nullif the entry is not an object, the secret is not well formed or the server id is missing
-
text
-
storedUserId
Reads legacy decimal text only at the persistence boundary, never on the REST wire. -
parseUserId
- Returns:
- the exact contract integer in [1, 2^53 - 1], or null; never truncates or wraps
-
toDocument
- Returns:
- the document entry
ServerCredentialStorewrites undercloud_credential
-
rotated
The same link with a rotated secret (plan 22-21, D-10): server id, owner, name and link time are kept, exactly asServerCredentialStore.replace(java.lang.String, java.lang.String, java.lang.String)keeps them on disk.- Parameters:
rotatedSecret- the newucs_secretrotatedId- the new credential's public id- Returns:
- the rotated credential
-
bearerValue
String bearerValue()- Returns:
- the secret, for the
Authorization: Bearerheader only -- never log it
-
getCredentialId
String getCredentialId()- Returns:
- the credential's public id, or
null
-
getServerId
String getServerId()- Returns:
- the server's public id (a ULID); never
null
-
getUserId
Long getUserId()- Returns:
- the linking owner's id, or
null
-
getServerName
String getServerName()- Returns:
- the server name chosen on the confirmation page, or
null
-
getLinkedAt
long getLinkedAt()- Returns:
- when the link was made, epoch milliseconds
-
toString
-