Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class ApiKey
- Object
- 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.
Constructors
public ApiKey(String id, String owner, List<String> scopes, String hash, String prefix, String lastFour, boolean revoked) |
Methods
Inherited methods
Constructor details
ApiKey
public ApiKey(String id, String owner, List<String> scopes, String hash, String prefix, String lastFour, boolean revoked)Parameters
idString- the key’s own id, for naming it in a list and revoking it
ownerString- whom requests made with the key are from:
Authentication.getName() scopesList<String>- what the key grants; each becomes the authority
SCOPE_x hashString- the lowercase hexadecimal SHA-256 of the key, as
ApiKeyGenerator.hashcomputes it prefixString- the prefix the key was made with
lastFourString- the key’s last four characters
revokedboolean- whether the key has been withdrawn
Method details
getId
public String getId()getOwner
public String getOwner()getScopes
public List<String> getScopes()getHash
public String getHash()getPrefix
public String getPrefix()getLastFour
public String getLastFour()isRevoked
public boolean isRevoked()getDisplayName
public String getDisplayName()The key as it may be shown: its prefix and its last four characters.
revoke
public ApiKey revoke()This key, withdrawn.
toString
public String toString()Returns 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())