Class 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.
      the cache
    • getCached

      @CheckForNull public getCached(String idOrFullName) throws
      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.
      idOrFullName - the username
      null if the cache doesn't contain any data for the key or the user details cached for the key.
      Throws: - if a previous lookup resulted in the same
    • loadUserByUsername

      @NonNull public loadUserByUsername(String idOrFullName) throws, ExecutionException
      Locates the user based on the username, by first looking in the cache and then delegate to SecurityRealm.loadUserByUsername2(String).
      idOrFullName - the username
      the details
      Throws: - (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.
      idOrFullName - the key