Class ApiKey
java.lang.Object
com.codename1.backend.security.apikey.ApiKey
What a server keeps about an API key: who it acts for, what it may do, whether it has been revoked, and the SHA-256 by which a presented key is recognized. The key itself is not here and cannot be had from this.
The prefix and the last four characters are kept for showing a person which
key a row is -- cn1_...x7Qa -- which is all of a key that should ever be
shown again.
-
Constructor Details
-
ApiKey
public ApiKey(String id, String owner, List<String> scopes, String hash, String prefix, String lastFour, boolean revoked) - Parameters:
id- the key's own id, for naming it in a list and revoking itowner- whom requests made with the key are from:Authentication.getName()scopes- what the key grants; each becomes the authoritySCOPE_xhash- the lowercase hexadecimal SHA-256 of the key, asApiKeyGenerator.hash(String)computes itprefix- the prefix the key was made withlastFour- the key's last four charactersrevoked- whether the key has been withdrawn
-
-
Method Details
-
getId
-
getOwner
-
getScopes
-
getHash
-
getPrefix
-
getLastFour
-
isRevoked
public boolean isRevoked() -
getDisplayName
The key as it may be shown: its prefix and its last four characters. -
revoke
This key, withdrawn. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-