Class InMemoryTicketComponentImpl
- java.lang.Object
-
- org.alfresco.repo.security.authentication.InMemoryTicketComponentImpl
-
- All Implemented Interfaces:
TicketComponent
public class InMemoryTicketComponentImpl extends 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 classInMemoryTicketComponentImpl.ExpiryModestatic classInMemoryTicketComponentImpl.TicketTicket
-
Field Summary
Fields Modifier and Type Field Description static StringGRANTED_AUTHORITY_TICKET_PREFIXTicket 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 voidclearCurrentSecurityContext()voidclearCurrentTicket()Clear the current ticketintcountTickets(boolean nonExpiredOnly)Count tickets This may be higher than the user count, since a user can have more than one ticket/sessionbooleanequals(Object obj)StringgetAuthorityForTicket(String ticketString)Get the authority for the given ticketStringgetCurrentTicket(String userName, boolean autoCreate)Get the current ticketStringgetNewTicket(String userName)Register a new ticketSet<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/sessionbooleangetUseSingleTicketPerUser()Does this ticket component support a single ticket per user or one ticket for each time they login?inthashCode()voidinvalidateTicketById(String ticketString)Invalidate the tickets by idvoidinvalidateTicketByUser(String userName)Invalidate all user ticketsintinvalidateTickets(boolean expiredOnly)Invalidate ticketsvoidsetExpiryMode(String expiryMode)How should tickets expire.voidsetOneOff(boolean oneOff)Deprecated.voidsetTicketsCache(SimpleCache<String,InMemoryTicketComponentImpl.Ticket> ticketsCache)Set the ticket cache to support clusteringvoidsetTicketsExpire(boolean ticketsExpire)Do tickets expirevoidsetUsernameToTicketIdCache(SimpleCache<String,String> usernameToTicketIdCache)Set the usernameToTicketIdCache as secondary map for supporting cache clusteringvoidsetUseSingleTicketPerUser(boolean useSingleTicketPerUser)voidsetValidDuration(String validDuration)How long are tickets valid (XML duration as a string)StringvalidateTicket(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 String GRANTED_AUTHORITY_TICKET_PREFIX
Ticket prefix- See Also:
- Constant Field Values
-
-
Method Detail
-
setTicketsCache
public void setTicketsCache(SimpleCache<String,InMemoryTicketComponentImpl.Ticket> ticketsCache)
Set the ticket cache to support clustering
-
setUsernameToTicketIdCache
public void setUsernameToTicketIdCache(SimpleCache<String,String> usernameToTicketIdCache)
Set the usernameToTicketIdCache 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:TicketComponentDoes this ticket component support a single ticket per user or one ticket for each time they login?- Specified by:
getUseSingleTicketPerUserin 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(String expiryMode)
How should tickets expire.
-
setValidDuration
public void setValidDuration(String validDuration)
How long are tickets valid (XML duration as a string)
-
getNewTicket
public String getNewTicket(String userName) throws AuthenticationException
Description copied from interface:TicketComponentRegister a new ticket- Specified by:
getNewTicketin interfaceTicketComponent- Parameters:
userName- String- Returns:
- - the ticket
- Throws:
AuthenticationException
-
validateTicket
public String validateTicket(String ticketString) throws AuthenticationException
Description copied from interface:TicketComponentCheck 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:
validateTicketin interfaceTicketComponent- Parameters:
ticketString- String- Returns:
- - the user name
- Throws:
AuthenticationException
-
invalidateTicketById
public void invalidateTicketById(String ticketString)
Description copied from interface:TicketComponentInvalidate the tickets by id- Specified by:
invalidateTicketByIdin interfaceTicketComponent- Parameters:
ticketString- String
-
getUsersWithTickets
public Set<String> getUsersWithTickets(boolean nonExpiredOnly)
Description copied from interface:TicketComponentGet 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:
getUsersWithTicketsin interfaceTicketComponent- Parameters:
nonExpiredOnly- true for non expired tickets, false for all (including expired) tickets
-
countTickets
public int countTickets(boolean nonExpiredOnly)
Description copied from interface:TicketComponentCount tickets This may be higher than the user count, since a user can have more than one ticket/session- Specified by:
countTicketsin 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:TicketComponentInvalidate tickets- Specified by:
invalidateTicketsin interfaceTicketComponent- Parameters:
expiredOnly- true for EXPIRED tickets, false for ALL (including non-expired) tickets- Returns:
- int count of invalidated tickets
-
invalidateTicketByUser
public void invalidateTicketByUser(String userName)
Description copied from interface:TicketComponentInvalidate all user tickets- Specified by:
invalidateTicketByUserin interfaceTicketComponent- Parameters:
userName- String
-
getAuthorityForTicket
public String getAuthorityForTicket(String ticketString)
Description copied from interface:TicketComponentGet the authority for the given ticket- Specified by:
getAuthorityForTicketin interfaceTicketComponent- Parameters:
ticketString- String- Returns:
- the authority
-
getCurrentTicket
public String getCurrentTicket(String userName, boolean autoCreate)
Description copied from interface:TicketComponentGet the current ticket- Specified by:
getCurrentTicketin 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:TicketComponentClear the current ticket- Specified by:
clearCurrentTicketin interfaceTicketComponent
-
clearCurrentSecurityContext
public static void clearCurrentSecurityContext()
-
-