Class InMemoryTicketComponentImpl
- java.lang.Object
-
- org.alfresco.repo.security.authentication.InMemoryTicketComponentImpl
-
- All Implemented Interfaces:
TicketComponent
public class InMemoryTicketComponentImpl extends java.lang.Object implements TicketComponent
Store tickets in memory. They can be distributed in a cluster via the cache- Author:
- andyh
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InMemoryTicketComponentImpl.ExpiryMode
static class
InMemoryTicketComponentImpl.Ticket
Ticket
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
GRANTED_AUTHORITY_TICKET_PREFIX
Ticket prefix
-
Constructor Summary
Constructors Constructor Description InMemoryTicketComponentImpl()
IOC constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
clearCurrentSecurityContext()
void
clearCurrentTicket()
Clear the current ticketint
countTickets(boolean nonExpiredOnly)
Count tickets This may be higher than the user count, since a user can have more than one ticket/sessionboolean
equals(java.lang.Object obj)
java.lang.String
getAuthorityForTicket(java.lang.String ticketString)
Get the authority for the given ticketjava.lang.String
getCurrentTicket(java.lang.String userName, boolean autoCreate)
Get the current ticketjava.lang.String
getNewTicket(java.lang.String userName)
Register a new ticketjava.util.Set<java.lang.String>
getUsersWithTickets(boolean nonExpiredOnly)
Get set of users with tickets This may be lower than the ticket count, since a user can have more than one ticket/sessionboolean
getUseSingleTicketPerUser()
Does this ticket component support a single ticket per user or one ticket for each time they login?int
hashCode()
void
invalidateTicketById(java.lang.String ticketString)
Invalidate the tickets by idvoid
invalidateTicketByUser(java.lang.String userName)
Invalidate all user ticketsint
invalidateTickets(boolean expiredOnly)
Invalidate ticketsvoid
setExpiryMode(java.lang.String expiryMode)
How should tickets expire.void
setOneOff(boolean oneOff)
Deprecated.void
setTicketsCache(SimpleCache<java.lang.String,InMemoryTicketComponentImpl.Ticket> ticketsCache)
Set the ticket cache to support clusteringvoid
setTicketsExpire(boolean ticketsExpire)
Do tickets expirevoid
setUsernameKey(SimpleCache<java.lang.String,java.lang.String> usernameKey)
Set the usernameKey cache as secondary map for supporting cache clusteringvoid
setUseSingleTicketPerUser(boolean useSingleTicketPerUser)
void
setValidDuration(java.lang.String validDuration)
How long are tickets valid (XML duration as a string)java.lang.String
validateTicket(java.lang.String ticketString)
Check that a certificate is valid and can be used in place of a login.
-
-
-
Field Detail
-
GRANTED_AUTHORITY_TICKET_PREFIX
public static final java.lang.String GRANTED_AUTHORITY_TICKET_PREFIX
Ticket prefix- See Also:
- Constant Field Values
-
-
Method Detail
-
setTicketsCache
public void setTicketsCache(SimpleCache<java.lang.String,InMemoryTicketComponentImpl.Ticket> ticketsCache)
Set the ticket cache to support clustering
-
setUsernameKey
public void setUsernameKey(SimpleCache<java.lang.String,java.lang.String> usernameKey)
Set the usernameKey cache as secondary map for supporting cache clustering
-
setUseSingleTicketPerUser
public void setUseSingleTicketPerUser(boolean useSingleTicketPerUser)
- Parameters:
useSingleTicketPerUser
- the useSingleTicketPerUser to set
-
getUseSingleTicketPerUser
public boolean getUseSingleTicketPerUser()
Description copied from interface:TicketComponent
Does this ticket component support a single ticket per user or one ticket for each time they login?- Specified by:
getUseSingleTicketPerUser
in interfaceTicketComponent
- Returns:
- the useSingleTicketPerUser
-
setOneOff
@Deprecated public void setOneOff(boolean oneOff)
Deprecated.Are tickets single use
-
setTicketsExpire
public void setTicketsExpire(boolean ticketsExpire)
Do tickets expire
-
setExpiryMode
public void setExpiryMode(java.lang.String expiryMode)
How should tickets expire.
-
setValidDuration
public void setValidDuration(java.lang.String validDuration)
How long are tickets valid (XML duration as a string)
-
getNewTicket
public java.lang.String getNewTicket(java.lang.String userName) throws AuthenticationException
Description copied from interface:TicketComponent
Register a new ticket- Specified by:
getNewTicket
in interfaceTicketComponent
- Parameters:
userName
- String- Returns:
- - the ticket
- Throws:
AuthenticationException
-
validateTicket
public java.lang.String validateTicket(java.lang.String ticketString) throws AuthenticationException
Description copied from interface:TicketComponent
Check that a certificate is valid and can be used in place of a login. Tickets may be rejected because:- The certificate does not exists
- The status of the user has changed
- The user is locked
- The account has expired
- The credentials have expired
- The account is disabled
- The ticket may have expired
- The ticked my be invalid by timed expiry
- An attemp to reuse a once only ticket
- Specified by:
validateTicket
in interfaceTicketComponent
- Parameters:
ticketString
- String- Returns:
- - the user name
- Throws:
AuthenticationException
-
invalidateTicketById
public void invalidateTicketById(java.lang.String ticketString)
Description copied from interface:TicketComponent
Invalidate the tickets by id- Specified by:
invalidateTicketById
in interfaceTicketComponent
- Parameters:
ticketString
- String
-
getUsersWithTickets
public java.util.Set<java.lang.String> getUsersWithTickets(boolean nonExpiredOnly)
Description copied from interface:TicketComponent
Get set of users with tickets This may be lower than the ticket count, since a user can have more than one ticket/session- Specified by:
getUsersWithTickets
in interfaceTicketComponent
- Parameters:
nonExpiredOnly
- true for non expired tickets, false for all (including expired) tickets
-
countTickets
public int countTickets(boolean nonExpiredOnly)
Description copied from interface:TicketComponent
Count tickets This may be higher than the user count, since a user can have more than one ticket/session- Specified by:
countTickets
in interfaceTicketComponent
- Parameters:
nonExpiredOnly
- true for non expired tickets, false for all (including expired) tickets- Returns:
- int number of tickets
-
invalidateTickets
public int invalidateTickets(boolean expiredOnly)
Description copied from interface:TicketComponent
Invalidate tickets- Specified by:
invalidateTickets
in interfaceTicketComponent
- Parameters:
expiredOnly
- true for EXPIRED tickets, false for ALL (including non-expired) tickets- Returns:
- int count of invalidated tickets
-
invalidateTicketByUser
public void invalidateTicketByUser(java.lang.String userName)
Description copied from interface:TicketComponent
Invalidate all user tickets- Specified by:
invalidateTicketByUser
in interfaceTicketComponent
- Parameters:
userName
- String
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getAuthorityForTicket
public java.lang.String getAuthorityForTicket(java.lang.String ticketString)
Description copied from interface:TicketComponent
Get the authority for the given ticket- Specified by:
getAuthorityForTicket
in interfaceTicketComponent
- Parameters:
ticketString
- String- Returns:
- the authority
-
getCurrentTicket
public java.lang.String getCurrentTicket(java.lang.String userName, boolean autoCreate)
Description copied from interface:TicketComponent
Get the current ticket- Specified by:
getCurrentTicket
in interfaceTicketComponent
- Parameters:
userName
- StringautoCreate
- should we create one automatically if there isn't one?- Returns:
- - the ticket
-
clearCurrentTicket
public void clearCurrentTicket()
Description copied from interface:TicketComponent
Clear the current ticket- Specified by:
clearCurrentTicket
in interfaceTicketComponent
-
clearCurrentSecurityContext
public static void clearCurrentSecurityContext()
-
-