Package com.protegrity.ap.java
Class SessionHandler
java.lang.Object
com.protegrity.ap.java.SessionHandler
Manages user sessions for Protector operations.
This class handles session creation, validation, and lifecycle management including timeout detection. Sessions are validated based on a configurable time-to-live duration.
- Since:
- 1.0.1
-
Constructor Summary
ConstructorsConstructorDescriptionSessionHandler(int sessionTimeout) Constructs a new SessionHandler with the specified timeout. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseSession(SessionObject session) Deprecated.This method uses reflection to clear fields and may not be reliable.createSession(String apiUser) Creates a new session for the specified user.getLastError(SessionObject session) Gets the last error message for the session.getUser(SessionObject session) Gets the username associated with the session.voidsetLastError(SessionObject session, String errorMessage) Sets the last error message for the session.
-
Constructor Details
-
SessionHandler
public SessionHandler(int sessionTimeout) Constructs a new SessionHandler with the specified timeout.- Parameters:
sessionTimeout- session timeout in minutes
-
-
Method Details
-
createSession
Creates a new session for the specified user.- Parameters:
apiUser- the username for the session- Returns:
- a new SessionObject
- Throws:
ProtectorException- if the username is null or empty
-
closeSession
Deprecated.This method uses reflection to clear fields and may not be reliable.Closes a session by clearing all session fields.- Parameters:
session- the session to close- Throws:
ProtectorException- if closing the session fails
-
getUser
Gets the username associated with the session.- Parameters:
session- the session to query- Returns:
- the username
- Throws:
ProtectorException- if the session is invalid or expired
-
setLastError
Sets the last error message for the session.- Parameters:
session- the session to updateerrorMessage- the error message to set- Throws:
ProtectorException- if setting the error fails
-
getLastError
Gets the last error message for the session.- Parameters:
session- the session to query- Returns:
- the last error message, or null if no error occurred
- Throws:
ProtectorException- if getting the error fails
-