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
ConstructorsConstructorDescriptionTransactionalRememberMeService(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(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Attempts to authenticate a request using the remember-me cookie provided on the request.io.atlassian.fugue.Pair<InternalCrowdRememberMeToken, InternalCrowdRememberMeToken> voidClears all expired remember me tokensvoidClears all remember me tokens for all the usersvoidclearAllTokensForDirectory(Long directoryId) Clears all remember me tokens for the users belonging to the given directoryIdvoidclearAllTokensForSeries(String series) Clears all remember me tokens for the user with given seriesvoidclearAllTokensForUserInDirectory(String username, Long directoryId) Clears all remember me tokens for the user with given username, and directory idvoidcreateCookie(User user, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Generates and saves a new remember-me token for the user.protected InternalCrowdRememberMeTokenextractToken(jakarta.servlet.http.Cookie cookie) Retrieves current configurationprotected StringgetRemoteAddress(jakarta.servlet.http.HttpServletRequest request) now()voidremoveCookie(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Clears the remember-me cookie and removes all remember-me tokens for the corresponding seriesvoidsaveConfiguration(CrowdSpecificRememberMeSettings configuration) Validates and stores passed configuration, ifCrowdSpecificRememberMeSettings.isEnabled()happens to befalseall 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 jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeServiceAttempts 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:
authenticatein interfaceCrowdRememberMeService- Parameters:
request- the requestresponse- the response- Returns:
- the authenticated user, or
Optional.empty()if authentication failed.
-
createCookie
public void createCookie(@Nonnull User user, @Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeServiceGenerates and saves a new remember-me token for the user. Sets the corresponding cookie on the response. If a remember-me cookie is already present in the response it will be overwritten.- Specified by:
createCookiein interfaceCrowdRememberMeService- Parameters:
user- the authenticating userrequest- the requestresponse- the response
-
removeCookie
public void removeCookie(@Nonnull jakarta.servlet.http.HttpServletRequest request, @Nonnull jakarta.servlet.http.HttpServletResponse response) Description copied from interface:CrowdRememberMeServiceClears the remember-me cookie and removes all remember-me tokens for the corresponding series- Specified by:
removeCookiein interfaceCrowdRememberMeService- Parameters:
request- the requestresponse- the response
-
clearAllTokensForSeries
Description copied from interface:CrowdRememberMeServiceClears all remember me tokens for the user with given series- Specified by:
clearAllTokensForSeriesin interfaceCrowdRememberMeService
-
clearAllTokensForUserInDirectory
Description copied from interface:CrowdRememberMeServiceClears all remember me tokens for the user with given username, and directory id- Specified by:
clearAllTokensForUserInDirectoryin interfaceCrowdRememberMeService
-
clearAllTokens
public void clearAllTokens()Description copied from interface:CrowdRememberMeServiceClears all remember me tokens for all the users- Specified by:
clearAllTokensin interfaceCrowdRememberMeService
-
clearAllExpiredTokens
public void clearAllExpiredTokens()Description copied from interface:CrowdRememberMeServiceClears all expired remember me tokens- Specified by:
clearAllExpiredTokensin interfaceCrowdRememberMeService
-
clearAllTokensForDirectory
Description copied from interface:CrowdRememberMeServiceClears all remember me tokens for the users belonging to the given directoryId- Specified by:
clearAllTokensForDirectoryin interfaceCrowdRememberMeService
-
saveConfiguration
Description copied from interface:CrowdRememberMeServiceValidates and stores passed configuration, ifCrowdSpecificRememberMeSettings.isEnabled()happens to befalseall existing tokens will be expired immediately- Specified by:
saveConfigurationin interfaceCrowdRememberMeService- Parameters:
configuration- new configuration
-
getConfiguration
Description copied from interface:CrowdRememberMeServiceRetrieves current configuration- Specified by:
getConfigurationin interfaceCrowdRememberMeService- Returns:
- configuration
-
extractToken
-
claimSingleUseToken
public io.atlassian.fugue.Pair<InternalCrowdRememberMeToken,InternalCrowdRememberMeToken> claimSingleUseToken(InternalCrowdRememberMeToken token) -
getRemoteAddress
-
now
-