Class BaseAuthConfigFactory

  • Direct Known Subclasses:
    AuthConfigFileFactory, GFAuthConfigFactory

    public abstract class BaseAuthConfigFactory
    extends jakarta.security.auth.message.config.AuthConfigFactory
    This class implements methods in the abstract class AuthConfigFactory.
    Author:
    Shing Wai Chan
    • Nested Class Summary

      • Nested classes/interfaces inherited from class jakarta.security.auth.message.config.AuthConfigFactory

        jakarta.security.auth.message.config.AuthConfigFactory.RegistrationContext
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static String CONF_FILE_NAME  
      static Lock readLock  
      static Lock writeLock  
      • Fields inherited from class jakarta.security.auth.message.config.AuthConfigFactory

        DEFAULT_FACTORY_SECURITY_PROPERTY, GET_FACTORY_PERMISSION_NAME, getFactorySecurityPermission, PROVIDER_REGISTRATION_PERMISSION_NAME, providerRegistrationSecurityPermission, SET_FACTORY_PERMISSION_NAME, setFactorySecurityPermission
    • Field Detail

      • readLock

        public static final Lock readLock
      • writeLock

        public static final Lock writeLock
    • Constructor Detail

      • BaseAuthConfigFactory

        public BaseAuthConfigFactory()
    • Method Detail

      • getConfigProvider

        public jakarta.security.auth.message.config.AuthConfigProvider getConfigProvider​(String layer,
                                                                                         String appContext,
                                                                                         jakarta.security.auth.message.config.RegistrationListener listener)
        Get a registered AuthConfigProvider from the factory. Get the provider of ServerAuthConfig and/or ClientAuthConfig objects registered for the identified message layer and application context.

        All factories shall employ the following precedence rules to select the registered AuthConfigProvider that matches (via matchConstructors) the layer and appContext arguments:

        • The provider that is specifically registered for both the corresponding message layer and appContext shall be selected.
        • if no provider is selected according to the preceding rule, the provider specifically registered for the corresponding appContext and for all message layers shall be selected.
        • if no provider is selected according to the preceding rules, the provider specifically registered for the corresponding message layer and for all appContexts shall be selected.
        • if no provider is selected according to the preceding rules, the provider registered for all message layers and for all appContexts shall be selected.
        • if no provider is selected according to the preceding rules, the factory shall terminate its search for a registered provider.
        Specified by:
        getConfigProvider in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        layer - a String identifying the message layer for which the registered AuthConfigProvider is to be returned. This argument may be null.
        appContext - a String that identifies the application messaging context for which the registered AuthConfigProvider is to be returned. This argument may be null.
        listener - the RegistrationListener whose notify method is to be invoked if the corresponding registration is unregistered or replaced. The value of this argument may be null.
        Returns:
        the implementation of the AuthConfigProvider interface registered at the factory for the layer and appContext or null if no AuthConfigProvider is selected.
      • registerConfigProvider

        public String registerConfigProvider​(String className,
                                             Map properties,
                                             String layer,
                                             String appContext,
                                             String description)
        Registers within the factory, a provider of ServerAuthConfig and/or ClientAuthConfig objects for a message layer and application context identifier.

        At most one registration may exist within the factory for a given combination of message layer and appContext. Any pre-existing registration with identical values for layer and appContext is replaced by a subsequent registration. When replacement occurs, the registration identifier, layer, and appContext identifier remain unchanged, and the AuthConfigProvider (with initialization properties) and description are replaced.

        Within the lifetime of its Java process, a factory must assign unique registration identifiers to registrations, and must never assign a previously used registration identifier to a registration whose message layer and or appContext identifier differ from the previous use.

        Programmatic registrations performed via this method must update (according to the replacement rules described above), the persistent declarative representation of provider registrations employed by the factory constructor.

        Specified by:
        registerConfigProvider in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        className - the fully qualified name of an AuthConfigProvider implementation class. This argument must not be null.
        properties - a Map object containing the initialization properties to be passed to the provider constructor. This argument may be null. When this argument is not null, all the values and keys occuring in the Map must be of type String.
        layer - a String identifying the message layer for which the provider will be registered at the factory. A null value may be passed as an argument for this parameter, in which case, the provider is registered at all layers.
        appContext - a String value that may be used by a runtime to request a configuration object from this provider. A null value may be passed as an argument for this parameter, in which case, the provider is registered for all configuration ids (at the indicated layers).
        description - a text String describing the provider. this value may be null.
        Returns:
        a String identifier assigned by the factory to the provider registration, and that may be used to remove the registration from the provider.
        Throws:
        SecurityException - if the caller does not have permission to register a provider at the factory.
        jakarta.security.auth.message.AuthException - if the provider construction or registration fails.
      • registerConfigProvider

        public String registerConfigProvider​(jakarta.security.auth.message.config.AuthConfigProvider provider,
                                             String layer,
                                             String appContext,
                                             String description)
        Specified by:
        registerConfigProvider in class jakarta.security.auth.message.config.AuthConfigFactory
      • removeRegistration

        public boolean removeRegistration​(String registrationID)
        Remove the identified provider registration from the factory and invoke any listeners associated with the removed registration.
        Specified by:
        removeRegistration in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        registrationID - a String that identifies a provider registration at the factory
        Returns:
        true if there was a registration with the specified identifier and it was removed. Return false if the registraionID was invalid.
        Throws:
        SecurityException - if the caller does not have permission to unregister the provider at the factory.
      • detachListener

        public String[] detachListener​(jakarta.security.auth.message.config.RegistrationListener listener,
                                       String layer,
                                       String appContext)
        Disassociate the listener from all the provider registrations whose layer and appContext values are matched by the corresponding arguments to this method.
        Specified by:
        detachListener in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        listener - the RegistrationListener to be detached.
        layer - a String identifying the message layer or null.
        appContext - a String value identifying the application context or null.
        Returns:
        an array of String values where each value identifies a provider registration from which the listener was removed. This method never returns null; it returns an empty array if the listener was not removed from any registrations.
        Throws:
        SecurityException - if the caller does not have permission to detach the listener from the factory.
      • getRegistrationIDs

        public String[] getRegistrationIDs​(jakarta.security.auth.message.config.AuthConfigProvider provider)
        Get the registration identifiers for all registrations of the provider instance at the factory.
        Specified by:
        getRegistrationIDs in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        provider - the AuthConfigurationProvider whose registration identifiers are to be returned. This argument may be null, in which case, it indicates that the the id's of all active registration within the factory are returned.
        Returns:
        an array of String values where each value identifies a provider registration at the factory. This method never returns null; it returns an empty array when their are no registrations at the factory for the identified provider.
      • getRegistrationContext

        public jakarta.security.auth.message.config.AuthConfigFactory.RegistrationContext getRegistrationContext​(String registrationID)
        Get the the registration context for the identified registration.
        Specified by:
        getRegistrationContext in class jakarta.security.auth.message.config.AuthConfigFactory
        Parameters:
        registrationID - a String that identifies a provider registration at the factory
        Returns:
        a RegistrationContext or null. When a Non-null value is returned, it is a copy of the registration context corresponding to the registration. Null is returned when the registration identifier does not correspond to an active registration
      • refresh

        public void refresh()
        Cause the factory to reprocess its persistent declarative representation of provider registrations.

        A factory should only replace an existing registration when a change of provider implementation class or initialization properties has occurred.

        Specified by:
        refresh in class jakarta.security.auth.message.config.AuthConfigFactory
        Throws:
        jakarta.security.auth.message.AuthException - if an error occurred during the reinitialization.
        SecurityException - if the caller does not have permission to refresh the factory.
      • _loadFactory

        protected void _loadFactory()
      • doReadLocked

        protected <T> T doReadLocked​(Supplier<T> supplier)
      • doWriteLocked

        protected <T> T doWriteLocked​(Supplier<T> supplier)
      • doWriteLocked

        protected void doWriteLocked​(Runnable runnable)
      • registerServerAuthModule

        public String registerServerAuthModule​(jakarta.security.auth.message.module.ServerAuthModule sam,
                                               Object context)
        Specified by:
        registerServerAuthModule in class jakarta.security.auth.message.config.AuthConfigFactory
      • removeServerAuthModule

        public void removeServerAuthModule​(Object context)
        Specified by:
        removeServerAuthModule in class jakarta.security.auth.message.config.AuthConfigFactory