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 Details

    • UserDetailsCache

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public UserDetailsCache()
      Constructor intended to be instantiated by Jenkins only.
  • Method Details

    • 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 to loadUserByUsername(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 to SecurityRealm.loadUserByUsername2(String).
      Parameters:
      idOrFullName - the username
      Returns:
      the details
      Throws:
      org.springframework.security.core.userdetails.UsernameNotFoundException - (normally a UserMayOrMayNotExistException2) if the user could not be found or the user has no GrantedAuthority
      ExecutionException - 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