Class AdminUISessionService
java.lang.Object
io.jans.ca.plugin.adminui.service.adminui.AdminUISessionService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.jans.as.model.config.adminui.AdminConfLoads the Admin UI configuration entry from persistence.io.jans.as.client.TokenResponsegetApiProtectionToken(String ujwtString, io.jans.configapi.core.model.adminui.AUIConfiguration auiConfiguration) Obtains an API protection access token for the Admin UI backend using client credentials and a user-info JWT.getClaims(io.jans.as.model.jwt.Jwt jwtObj) Extracts the claims from a Jwt into a map keyed by claim name.io.jans.configapi.core.model.adminui.AdminUISessiongetSession(String sessionId) Load the Admin UI session corresponding to the given session identifier.Exchange token request parameters with the authorization server and return parsed token response parameters.booleanisCachedTokenValid(String token, io.jans.configapi.core.model.adminui.AUIConfiguration auiConfiguration) Checks whether a cached token is active by calling the Admin UI introspection endpoint.voidRemoves all AdminUISession entries whose expirationDate is earlier than the current time.voidupdateSessionExpiryDate(io.jans.configapi.core.model.adminui.AdminUISession adminUISession) Updates the expiration time of an Admin UI session based on user activity.
-
Constructor Details
-
AdminUISessionService
public AdminUISessionService()
-
-
Method Details
-
getSession
Load the Admin UI session corresponding to the given session identifier.- Parameters:
sessionId- the session identifier used to build the session DN- Returns:
- the matching AdminUISession, or `null` if no session is found or an error occurs
-
updateSessionExpiryDate
public void updateSessionExpiryDate(io.jans.configapi.core.model.adminui.AdminUISession adminUISession) Updates the expiration time of an Admin UI session based on user activity.After a successful login, an
AdminUISessionis persisted in the database with an expiration date derived from the configured session timeout. On each subsequent request, this method may extend the session expiration to enforce an idle-based logout policy.The session expiration is refreshed only when:
- The session and its expiration date are not
null - More than 30 seconds has passed since the session was last updated
This approach prevents frequent database updates while ensuring that an active user session remains valid and a force logout occurs only when the application has been idle longer than the configured
max_idle_time.- Parameters:
adminUISession- the persisted Admin UI session to be evaluated and updated
- The session and its expiration date are not
-
removeAllExpiredSessions
public void removeAllExpiredSessions()Removes all AdminUISession entries whose expirationDate is earlier than the current time. This method queries sessions under the service's session base DN and deletes any persisted AdminUISession whose expiration date has already passed. -
isCachedTokenValid
public boolean isCachedTokenValid(String token, io.jans.configapi.core.model.adminui.AUIConfiguration auiConfiguration) throws com.fasterxml.jackson.core.JsonProcessingException Checks whether a cached token is active by calling the Admin UI introspection endpoint.- Parameters:
token- the token to introspect; may be null or emptyauiConfiguration- configuration holding the introspection endpoint URL- Returns:
- `true` if the introspection response contains `"active": true`, `false` otherwise
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- if the introspection response body cannot be parsed as JSON
-
getApiProtectionToken
public io.jans.as.client.TokenResponse getApiProtectionToken(String ujwtString, io.jans.configapi.core.model.adminui.AUIConfiguration auiConfiguration) throws io.jans.util.security.StringEncrypter.EncryptionException, io.jans.configapi.core.model.exception.ConfigApiApplicationException Obtains an API protection access token for the Admin UI backend using client credentials and a user-info JWT.- Parameters:
ujwtString- the user-info JWT to include in the token request; must be non-null and non-empty to generate a tokenauiConfiguration- configuration containing the backend token endpoint, client ID, encrypted client secret, and redirect URI- Returns:
- a TokenResponse containing the access token, or `null` if `ujwtString` is null or empty
- Throws:
io.jans.util.security.StringEncrypter.EncryptionException- if decrypting the client secret failscom.fasterxml.jackson.core.JsonProcessingException- if parsing token responses failsio.jans.configapi.core.model.exception.ConfigApiApplicationException
-
getToken
public Map<String,Object> getToken(io.jans.as.client.TokenRequest tokenRequest, String tokenEndpoint, String userInfoJwt) throws io.jans.configapi.core.model.exception.ConfigApiApplicationException Exchange token request parameters with the authorization server and return parsed token response parameters.- Parameters:
tokenRequest- token request details (grant type, client credentials, redirect URI; may include authorization code and PKCE verifier)tokenEndpoint- the token endpoint URL to calluserInfoJwt- optional user-info JWT to include as the `ujwt` parameter- Returns:
- a map of token response parameters (for example `access_token`, `expires_in`) with any `token_type` entry removed
- Throws:
io.jans.configapi.core.model.exception.ConfigApiApplicationException- if the HTTP exchange fails or the response cannot be parsed as JSON
-
fetchAdminUIConfiguration
public io.jans.as.model.config.adminui.AdminConf fetchAdminUIConfiguration()Loads the Admin UI configuration entry from persistence.- Returns:
- the AdminConf instance stored at ADMIN_UI_CONFIG_DN, or
nullif not found
-
getClaims
Extracts the claims from a Jwt into a map keyed by claim name.- Parameters:
jwtObj- the Jwt to extract claims from; may be null- Returns:
- a map of claim names to their values. Values are `String`, `Integer`, `Long`, `Boolean`, `List
` for JSON arrays, or `JSONObject`; returns an empty map if `jwtObj` is null or contains no claims
-