Class PasswordHashProviderRegistry

java.lang.Object
com.svenruppert.jsentinel.credential.password.provider.PasswordHashProviderRegistry

public final class PasswordHashProviderRegistry extends Object
Lookup of PasswordHashProviders by stored envelope metadata.

The registry resolves providers by the providerId that is embedded in the envelope — not by the active policy. That way a stored hash always finds the implementation that produced it, regardless of policy churn (CWE-693).

Construction takes a defensive copy. Duplicate providerId values are rejected at construction time so that misconfiguration surfaces fast (CWE-755).

  • Constructor Details

  • Method Details

    • resolve

      public Optional<PasswordHashProvider> resolve(String providerId, String algorithm)
      Resolves the provider associated with the given envelope metadata.
      Returns:
      the matching provider, or Optional.empty() when no provider with that providerId is registered, or the registered provider declines to supports(...) the requested algorithm
    • knownProviderIds

      public Set<String> knownProviderIds()
      Returns the provider identifiers known to this registry, in registration order.
    • providers

      public Collection<PasswordHashProvider> providers()
      Returns the providers registered with this instance.
    • fromServiceLoader

      public static PasswordHashProviderRegistry fromServiceLoader()
      Builds a registry from every PasswordHashProvider discovered through ServiceLoader on the current thread's context class loader.

      The global JCA provider order is not modified by this call. Providers are only registered with this registry instance; the caller decides where to hand the registry next.