Class AccessTicket
java.lang.Object
io.goobi.viewer.model.security.tickets.AccessTicket
Represents a time-limited access ticket that grants a user access to a restricted record or download,
persisted in the
access_tickets database table.
Tickets are issued in response to access requests and are protected by a BCrypt-hashed password. A ticket transitions from a pending request (no password hash) to an active grant once a password is set, and expires after a configurable validity period.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumClassifies the resource scope anAccessTicketcontrols access to. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Sets the dates.booleancheckPassword(String password) voidextend(long days) Extends the ticket by anotherdaysdays.getEmail()getId()Getter for the fieldid.getLabel()Returns the title of the associated record, with a fallback to PI.getPi()getTitle()getType()booleanisActive()booleanbooleanvoidreset()Resets the ticket's password and expiration date.voidsetDateCreated(LocalDateTime dateCreated) voidvoidsetExpirationDate(LocalDateTime expirationDate) voidSetter for the fieldid.voidsetPassword(String password) voidsetPasswordHash(String passwordHash) voidvoidsetRequestMessage(String requestMessage) voidvoid
-
Field Details
-
VALIDITY_DAYS
public static final int VALIDITY_DAYSDefault validity for a ticket in days.- See Also:
-
SALT
Static salt for password hashes.- See Also:
-
RANDOM
Random object for password generation. -
bcrypt
-
-
Constructor Details
-
AccessTicket
public AccessTicket()
-
-
Method Details
-
isActive
public boolean isActive()- Returns:
- true if ticket granted and not expired; false otherwise
-
isExpired
public boolean isExpired()- Returns:
- true if expiration date is in the past; false otherwise
-
isRequest
public boolean isRequest()- Returns:
- true if ticket is requested but not yet issued; false otherwise
-
checkPassword
- Parameters:
password- Password to check- Returns:
- true if password correct; false otherwise
-
activate
public void activate()Sets the dates. -
extend
public void extend(long days) Extends the ticket by anotherdaysdays.- Parameters:
days- Number of days to extend
-
reset
public void reset()Resets the ticket's password and expiration date. -
getDefaultValidityAsString
- Returns:
VALIDITY_DAYS
-
getLabel
Returns the title of the associated record, with a fallback to PI.- Returns:
- title if present; otherwise pi
-
getId
Getter for the fieldid.- Returns:
- the database primary key for this access ticket
-
setId
Setter for the fieldid.- Parameters:
id- the database identifier to set
-
getType
-
setType
-
getDateCreated
-
setDateCreated
-
getExpirationDate
-
setExpirationDate
-
getPassword
-
setPassword
-
getPasswordHash
-
setPasswordHash
-
getEmail
-
setEmail
-
getPi
-
setPi
-
getTitle
-
setTitle
-
getRequestMessage
-
setRequestMessage
-