Package com.atlassian.crowd.service
Class TransactionalRememberMeService
java.lang.Object
com.atlassian.crowd.service.TransactionalRememberMeService
- All Implemented Interfaces:
CrowdRememberMeService
@Transactional
public class TransactionalRememberMeService
extends Object
implements CrowdRememberMeService
-
Constructor Summary
ConstructorDescriptionTransactionalRememberMeService
(CrowdRememberMeTokenDAO tokenDAO, CrowdRememberMeConfiguration rememberMeConfiguration, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, Clock clock, org.springframework.transaction.PlatformTransactionManager transactionManager) -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.springframework.security.core.Authentication>
authenticate
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Attempts to authenticate a request using the remember-me cookie provided on the request.io.atlassian.fugue.Pair<InternalCrowdRememberMeToken,
InternalCrowdRememberMeToken> void
Clears all expired remember me tokensvoid
Clears all remember me tokens for all the usersvoid
clearAllTokensForDirectory
(Long directoryId) Clears all remember me tokens for the users belonging to the given directoryIdvoid
clearAllTokensForSeries
(String series) Clears all remember me tokens for the user with given seriesvoid
clearAllTokensForUserInDirectory
(String username, Long directoryId) Clears all remember me tokens for the user with given username, and directory idvoid
createCookie
(org.springframework.security.core.Authentication authentication, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Generates a new remember-me token for the user and sets the corresponding cookie on the response.protected InternalCrowdRememberMeToken
extractToken
(javax.servlet.http.Cookie cookie) Retrieves current configurationprotected String
getRemoteAddress
(javax.servlet.http.HttpServletRequest request) now()
void
removeCookie
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Clears the remember-me cookie and removes all remember-me tokens for the corresponding seriesvoid
saveConfiguration
(CrowdSpecificRememberMeSettings configuration) Validates and stores passed configuration, ifCrowdSpecificRememberMeSettings.isEnabled()
happens to befalse
all existing tokens will be expired immediately
-
Constructor Details
-
TransactionalRememberMeService
public TransactionalRememberMeService(CrowdRememberMeTokenDAO tokenDAO, CrowdRememberMeConfiguration rememberMeConfiguration, com.atlassian.security.random.SecureTokenGenerator tokenGenerator, Clock clock, org.springframework.transaction.PlatformTransactionManager transactionManager)
-
-
Method Details
-
authenticate
@Nullable public Optional<org.springframework.security.core.Authentication> authenticate(@Nonnull javax.servlet.http.HttpServletRequest request, @Nonnull javax.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeService
Attempts to authenticate a request using the remember-me cookie provided on the request. If authentication succeeds, a new remember-me token is created for the user and a new cookie is set on the response. If authentication fails for any reason, the cookie is cleared on the response.- Specified by:
authenticate
in interfaceCrowdRememberMeService
- Parameters:
request
- the requestresponse
- the response- Returns:
- the authenticated user, or
Optional.empty()
if authentication failed.
-
createCookie
public void createCookie(@Nonnull org.springframework.security.core.Authentication authentication, @Nonnull javax.servlet.http.HttpServletRequest request, @Nonnull javax.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeService
Generates a new remember-me token for the user and sets the corresponding cookie on the response. This will cancel an existing remember me cookie if such was provided..- Specified by:
createCookie
in interfaceCrowdRememberMeService
- Parameters:
authentication
- valid authentication containing the user contextrequest
- the requestresponse
- the response
-
removeCookie
public void removeCookie(@Nonnull javax.servlet.http.HttpServletRequest request, @Nonnull javax.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeService
Clears the remember-me cookie and removes all remember-me tokens for the corresponding series- Specified by:
removeCookie
in interfaceCrowdRememberMeService
- Parameters:
request
- the requestresponse
- the response
-
clearAllTokensForSeries
Description copied from interface:CrowdRememberMeService
Clears all remember me tokens for the user with given series- Specified by:
clearAllTokensForSeries
in interfaceCrowdRememberMeService
-
clearAllTokensForUserInDirectory
Description copied from interface:CrowdRememberMeService
Clears all remember me tokens for the user with given username, and directory id- Specified by:
clearAllTokensForUserInDirectory
in interfaceCrowdRememberMeService
-
clearAllTokens
public void clearAllTokens()Description copied from interface:CrowdRememberMeService
Clears all remember me tokens for all the users- Specified by:
clearAllTokens
in interfaceCrowdRememberMeService
-
clearAllExpiredTokens
public void clearAllExpiredTokens()Description copied from interface:CrowdRememberMeService
Clears all expired remember me tokens- Specified by:
clearAllExpiredTokens
in interfaceCrowdRememberMeService
-
clearAllTokensForDirectory
Description copied from interface:CrowdRememberMeService
Clears all remember me tokens for the users belonging to the given directoryId- Specified by:
clearAllTokensForDirectory
in interfaceCrowdRememberMeService
-
saveConfiguration
Description copied from interface:CrowdRememberMeService
Validates and stores passed configuration, ifCrowdSpecificRememberMeSettings.isEnabled()
happens to befalse
all existing tokens will be expired immediately- Specified by:
saveConfiguration
in interfaceCrowdRememberMeService
- Parameters:
configuration
- new configuration
-
getConfiguration
Description copied from interface:CrowdRememberMeService
Retrieves current configuration- Specified by:
getConfiguration
in interfaceCrowdRememberMeService
- Returns:
- configuration
-
extractToken
-
claimSingleUseToken
public io.atlassian.fugue.Pair<InternalCrowdRememberMeToken,InternalCrowdRememberMeToken> claimSingleUseToken(InternalCrowdRememberMeToken token) -
getRemoteAddress
-
now
-