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 forUserDetails
lookup.
-
-
Constructor Summary
Constructors Constructor Description UserDetailsCache()
Constructor intended to be instantiated by Jenkins only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UserDetailsCache
get()
The singleton instance registered in Jenkins.org.springframework.security.core.userdetails.UserDetails
getCached(String idOrFullName)
Gets the cached UserDetails for the given username.void
invalidate(String idOrFullName)
Discards any cached value for key.void
invalidateAll()
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)
.
-
-
-
Method Detail
-
get
public static UserDetailsCache 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
public void invalidate(String idOrFullName)
Discards any cached value for key.- Parameters:
idOrFullName
- the key
-
-