Package com.storedobject.core
Class AutoLogin
java.lang.Object
com.storedobject.core.StoredObject
com.storedobject.core.AutoLogin
- All Implemented Interfaces:
Displayable
,StringFiller
,HasId
-
Field Summary
Fields inherited from class com.storedobject.core.StoredObject
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static AutoLogin
createLogin4JWT
(TransactionManager tm, SystemUser su, String clientId, boolean signed) Creates a new AutoLogin instance for issuing JSON Web Tokens (JWTs).Generates a JSON Web Token (JWT) using the current object's signing or encryption secrets, system user ID, and other predefined values.static String
generateJWT
(String signingSecretBase64, String encryptionSecretBase64, String subject, String issuer, String audience, long ttlSeconds, Map<String, Object> additionalClaims) Issue a signed or encrypted JWT.static AutoLogin
getLogin4JWT
(String clientId) Retrieves an instance of theAutoLogin
class based on the given client ID.int
static String
getLoginMethodValue
(int value) static String[]
Gets the unique index condition of this object.getVia()
static void
static ObjectIterator
<AutoLogin> Retrieves an iterator of AutoLogin objects associated with the provided SystemUser where the login method is specifically configured for JWT (LoginMethod = 0).void
Reissues a JSON Web Token (JWT) for the current AutoLogin instance.void
setEncryptionSecret
(String encryptionSecret) void
setLoginMethod
(int loginMethod) void
setSigningSecret
(String signingSecret) void
setSystemUser
(Id systemUserId) void
setSystemUser
(SystemUser systemUser) void
setSystemUser
(BigDecimal idValue) void
void
The system will invoke this whenever the object is saved to the DB.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, getContemporaryOf, 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, 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, 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
-
AutoLogin
public AutoLogin()
-
-
Method Details
-
columns
-
indices
-
getUniqueCondition
Description copied from class:StoredObject
Gets the unique index condition of this object.- Overrides:
getUniqueCondition
in classStoredObject
- Returns:
- Unique index condition.
-
setVia
-
getVia
-
setSigningSecret
-
getSigningSecret
-
setEncryptionSecret
-
getEncryptionSecret
-
setSystemUser
-
setSystemUser
-
setSystemUser
-
getSystemUserId
-
getSystemUser
-
setLoginMethod
public void setLoginMethod(int loginMethod) -
getLoginMethod
-
getLoginMethodValues
-
getLoginMethodValue
-
getLoginMethodValue
-
validateData
Description copied from class:StoredObject
The system will invoke this whenever the object is saved to the DB. It will be invoked in all cases while creating new objects and updating/deleting/undeleting existing objects. If any exception is raised by this method, the process of saving to the DB will be abandoned.
Note: This method is mainly used to validate the data of all attributes of the object, and it may be used by others for validating the object. For example, front-end data-entry systems can use this method for validating the object.
- Overrides:
validateData
in classStoredObject
- Parameters:
tm
- Current transaction manager.- Throws:
Exception
- If data is invalid.
-
getPayload
-
listLogin4JWT
Retrieves an iterator of AutoLogin objects associated with the provided SystemUser where the login method is specifically configured for JWT (LoginMethod = 0).- Parameters:
su
- The SystemUser instance for which the AutoLogin information will be retrieved.- Returns:
- An ObjectIterator of AutoLogin objects matching the specified criteria.
-
getLogin4JWT
Retrieves an instance of theAutoLogin
class based on the given client ID. The client ID is converted to a code and a case-insensitive condition is constructed to fetch the corresponding instance from the database.- Parameters:
clientId
- The client ID used to identify theAutoLogin
instance.- Returns:
- The
AutoLogin
instance retrieved from the database, ornull
if no matching instance is found.
-
createLogin4JWT
public static AutoLogin createLogin4JWT(TransactionManager tm, SystemUser su, String clientId, boolean signed) throws Exception Creates a new AutoLogin instance for issuing JSON Web Tokens (JWTs). The method associates the AutoLogin instance with a specified SystemUser and generates either a signing or encryption secret based on the `signed` parameter. If a client ID is provided, it ensures the client ID is unique; otherwise, a new unique client ID is generated.- Parameters:
tm
- The transaction manager used to manage transactional operations.su
- The SystemUser to associate with the AutoLogin instance.clientId
- The client ID to associate with the AutoLogin; if null, a new unique ID is generated. Throws an exception if the provided client ID is a duplicate.signed
- If true, generates a signing secret; if false, generates an encryption secret.- Returns:
- A newly created AutoLogin instance configured for JWT issuance.
- Throws:
Exception
- If an error occurs during the creation or saving of the AutoLogin, or if a duplicate client ID is detected.
-
reissueJWT
Reissues a JSON Web Token (JWT) for the current AutoLogin instance. This method ensures that the JWT is properly updated by regenerating a signing or encryption secret as needed and saving the changes using the provided transaction manager. If the login method is not configured for JWT (LoginMethod != 0), an exception is thrown to indicate improper usage.- Parameters:
tm
- The TransactionManager instance used to save the updated AutoLogin instance. It manages the transactional operations required for the reissue process.- Throws:
Exception
- If the current AutoLogin object is not configured for JWT issuance, or if an error occurs during transactional operations.
-
generateJWT
Generates a JSON Web Token (JWT) using the current object's signing or encryption secrets, system user ID, and other predefined values.- Returns:
- Compact JWT string.
-
generateJWT
public static String generateJWT(String signingSecretBase64, String encryptionSecretBase64, String subject, String issuer, String audience, long ttlSeconds, Map<String, Object> additionalClaims) Issue a signed or encrypted JWT.- Parameters:
signingSecretBase64
- Base64-encoded HMAC secret (use for JWS), optional.encryptionSecretBase64
- Base64-encoded AES secret (use for JWE), optional.subject
- Subject claim ("sub").issuer
- Issuer claim ("iss"), nullable.audience
- Audience claim ("aud"), nullable.ttlSeconds
- Token lifetime in seconds; if less than or equal to 0, no exp claim is added.additionalClaims
- Extra claims to embed; nullable.- Returns:
- Compact JWT string.
-