Package com.storedobject.core
Class APIToken
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.core.APIToken
- All Implemented Interfaces:
Displayable
,StringFiller
,HasId
Represents an API token object used for managing and validating access tokens
associated with different purposes and clients in the system.
The class extends
StoredObject
, allowing it to be persisted and
manipulated within the system's data model.- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Defines the columns for the APIToken class.static APIToken
get
(String purpose, SystemUser user) Retrieves anAPIToken
that matches the given purpose and is associated with the specifiedSystemUser
or their groups.Retrieves the client ID associated with this instance, if applicable.Retrieves the project ID associated with this instance, if applicable.Retrieves the purpose associated with the API token.getToken()
Retrieves the token associated with this API token instance.static int
hints()
Provides the hint value by combining multiple hint constants that indicate certain characteristics of the object.static void
Adds an index to the specifiedIndices
collection.static String[]
links()
Retrieves the link definitions associated with this class.void
setClientID
(String clientID) Sets the client ID associated with this API token.void
setProjectID
(String projectID) Sets the project ID associated with this API token instance.void
setPurpose
(String purpose) Sets the purpose of the API token.void
Sets the token for the API.void
Validates the data for the current instance of APIToken.Methods inherited from class com.storedobject.core.StoredObject
addLink, addLink, addLink, addLink, addLink, addLink, addLink, addLink, checkCurrency, checkCurrency, checkForDuplicate, checkForDuplicate, checkTimeZone, checkTransaction, clearObjectLinks, contemporary, copy, copy, count, count, count, count, count, count, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countLinks, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, countMasters, create, created, delete, delete, delete, deleted, directUpdate, equals, exists, exists, exists, exists, exists, existsFileData, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLink, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsLinks, existsMaster, existsMaster, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, existsMasters, family, family, family, fill, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getAttachment, getAttachmentId, getChildren, getDeleted, getDeleted, getExistsCondition, getExistsCondition, getFileData, getFileData, getHistorical, getId, getKeyIndex, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getMaster, getNotExistsCondition, getNotExistsCondition, getParent, getParent, getParent, getParentId, getParentId, getParentId, getRelated, getRelated, getTransaction, getTransactionId, getTransactionIP, getUnique, getUniqueCondition, hashCode, inserted, isModified, isVirtual, list, list, list, list, list, list, list, list, list, list, list, list, list, listDeletedIds, listFileData, listFileData, listHistory, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listLinks, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listMasters, listTree, listTree, listTree, listTree, listViaQuery, listViaQuery, load, load, load, load, loaded, loading, makeNew, makeVirtual, migrate, moduleName, nextVersion, objectLink, objectLink, objectLink, objectLinks, objectLinks, old, person, previousVersion, previousVersion, query, query, query, query, query, query, query, query, query, query, query, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryLinks, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, queryMasters, reload, reload, reloaded, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeAllLinks, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeLink, removeReverseLinks, removeReverseLinks, save, save, save, save, save, save, save, save, save, save, save, save, save, save, saved, saving, setMaster, setRawValue, setTransaction, stringify, tableName, timestamp, toCode, toDisplay, toString, transacting, undelete, undelete, undeleted, updated, user, userId, validate, validateChildAttach, validateChildDetach, validateChildUpdate, validateDelete, validateInsert, validateParentAttach, validateParentDetach, validateParentUpdate, validateUndelete, validateUpdate, valueEquals
-
Constructor Details
-
APIToken
public APIToken()Default constructor for the APIToken class. Initializes a new instance of the APIToken object. This constructor does not set any fields or properties and is primarily intended for creating an empty token object.
-
-
Method Details
-
columns
Defines the columns for the APIToken class.- Parameters:
columns
- the column object used to define and add the required columns for the APIToken class.
-
indices
Adds an index to the specifiedIndices
collection. The index is based on the column list "lower(Purpose)".- Parameters:
indices
- theIndices
collection to which the index will be added
-
hints
public static int hints()Provides the hint value by combining multiple hint constants that indicate certain characteristics of the object. Combines ObjectHint.SMALL and ObjectHint.SMALL_LIST.- Returns:
- An integer representing the bitwise combination of the hint constants ObjectHint.SMALL and ObjectHint.SMALL_LIST.
-
links
Retrieves the link definitions associated with this class. Each definition indicates the relationships or connections between this object and other entities or groups.- Returns:
- An array of strings, where each string represents a link definition in the format: "EntityName|FullyQualifiedClassName|||AttributesDescriptor".
-
setPurpose
Sets the purpose of the API token.- Parameters:
purpose
- The purpose to associate with the API token.
-
getPurpose
-
setClientID
Sets the client ID associated with this API token.- Parameters:
clientID
- The client identifier to be set.
-
getClientID
-
setToken
Sets the token for the API.- Parameters:
token
- the token to be set
-
getProjectID
-
setProjectID
Sets the project ID associated with this API token instance.- Parameters:
projectID
- The project identifier to be set.
-
getToken
-
validateData
Validates the data for the current instance of APIToken. Ensures that the required fields have appropriate non-empty values and perform any necessary validation logic.- Overrides:
validateData
in classStoredObject
- Parameters:
tm
- The transaction manager used to handle the validation process.- Throws:
Invalid_Value
- If the value of the "purpose" or "token" field is empty or invalid.Exception
- If an error occurs during the validation process.
-
get
Retrieves anAPIToken
that matches the given purpose and is associated with the specifiedSystemUser
or their groups.- Parameters:
purpose
- the purpose for which the token is required. This will be converted to a lower-case code internally.user
- the system user requesting the token. The method checks if the token is linked to this user or any of their associated groups.- Returns:
- the
APIToken
matching the given purpose and linked to the user or their groups, ornull
if no matching token is found.
-