Package jenkins.security
Class UserDetailsCache
java.lang.Object
jenkins.security.UserDetailsCache
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
@Extension
public final class UserDetailsCache
extends Object
Cache layer for
UserDetails
lookup.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic UserDetailsCache
get()
The singleton instance registered in Jenkins.org.springframework.security.core.userdetails.UserDetails
Gets the cached UserDetails for the given username.void
invalidate
(String idOrFullName) Discards any cached value for key.void
Discards all entries in the cache.org.springframework.security.core.userdetails.UserDetails
loadUserByUsername
(String idOrFullName) Locates the user based on the username, by first looking in the cache and then delegate toSecurityRealm.loadUserByUsername2(String)
.
-
Constructor Details
-
UserDetailsCache
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public UserDetailsCache()Constructor intended to be instantiated by Jenkins only.
-
-
Method Details
-
get
The singleton instance registered in Jenkins.- Returns:
- the cache
-
getCached
@CheckForNull public org.springframework.security.core.userdetails.UserDetails getCached(String idOrFullName) throws org.springframework.security.core.userdetails.UsernameNotFoundException Gets the cached UserDetails for the given username. Similar toloadUserByUsername(String)
except it doesn't perform the actual lookup if there is a cache miss.- Parameters:
idOrFullName
- the username- Returns:
null
if the cache doesn't contain any data for the key or the user details cached for the key.- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
- if a previous lookup resulted in the same
-
loadUserByUsername
@NonNull public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String idOrFullName) throws org.springframework.security.core.userdetails.UsernameNotFoundException, ExecutionException Locates the user based on the username, by first looking in the cache and then delegate toSecurityRealm.loadUserByUsername2(String)
.- Parameters:
idOrFullName
- the username- Returns:
- the details
- Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException
- (normally aUserMayOrMayNotExistException2
) if the user could not be found or the user has no GrantedAuthorityExecutionException
- if anything else went wrong in the cache lookup/retrieval
-
invalidateAll
public void invalidateAll()Discards all entries in the cache. -
invalidate
Discards any cached value for key.- Parameters:
idOrFullName
- the key
-