Class AuthenticationContext

  • All Implemented Interfaces:
    org.wildfly.common.context.Contextual<AuthenticationContext>

    public final class AuthenticationContext
    extends Object
    implements org.wildfly.common.context.Contextual<AuthenticationContext>
    A set of rules and authentication configurations to use with a client for establishing a connection.
    Author:
    David M. Lloyd
    • Method Detail

      • empty

        public static AuthenticationContext empty()
        Get a new, empty authentication context.
        Returns:
        the new authentication context
      • captureCurrent

        public static AuthenticationContext captureCurrent()
        Get the current thread's captured authentication context.
        Returns:
        the current thread's captured authentication context
      • with

        public AuthenticationContext with​(MatchRule rule,
                                          AuthenticationConfiguration configuration)
        Get a new authentication context which is the same as this one, but which includes the given rule and configuration at the end of its list.
        Parameters:
        rule - the rule to match
        configuration - the configuration to select when the rule matches
        Returns:
        the combined authentication context
      • withSsl

        public AuthenticationContext withSsl​(MatchRule rule,
                                             SecurityFactory<SSLContext> sslContext)
        Get a new authentication context which is the same as this one, but which includes the given rule and SSL context at the end of its SSL context list.
        Parameters:
        rule - the rule to match
        sslContext - the SSL context to select when the rule matches
        Returns:
        the combined authentication context
      • with

        public AuthenticationContext with​(AuthenticationContext other)
        Get a new authentication context which is the same as this one, but which includes the rules, configurations and SSL contexts of the given context at the end of its list.
        Parameters:
        other - the other authentication context
        Returns:
        the combined authentication context
      • with

        public AuthenticationContext with​(int idx,
                                          MatchRule rule,
                                          AuthenticationConfiguration configuration)
                                   throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but which includes the given rule and configuration inserted at the position of its list indicated by the idx parameter.
        Parameters:
        idx - the index at which insertion should be done
        rule - the rule to match
        configuration - the configuration to select when the rule matches
        Returns:
        the combined authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • withSsl

        public AuthenticationContext withSsl​(int idx,
                                             MatchRule rule,
                                             SecurityFactory<SSLContext> sslContext)
                                      throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but which includes the given rule and SSL context inserted at the position of its list indicated by the idx parameter.
        Parameters:
        idx - the index at which insertion should be done
        rule - the rule to match
        sslContext - the SSL context to select when the rule matches
        Returns:
        the combined authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • replacing

        public AuthenticationContext replacing​(int idx,
                                               MatchRule rule,
                                               AuthenticationConfiguration configuration)
                                        throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but which replaces the rule and configuration at the given index with the given rule and configuration.
        Parameters:
        idx - the index at which insertion should be done
        rule - the rule to match
        configuration - the configuration to select when the rule matches
        Returns:
        the combined authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • replacingSslContext

        public AuthenticationContext replacingSslContext​(int idx,
                                                         MatchRule rule,
                                                         SecurityFactory<SSLContext> sslContext)
                                                  throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but which replaces the rule and SSL context at the given index with the given rule and SSL context.
        Parameters:
        idx - the index at which insertion should be done
        rule - the rule to match
        sslContext - the SSL context to select when the rule matches
        Returns:
        the combined authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • without

        public AuthenticationContext without​(int idx)
                                      throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by the idx parameter.
        Parameters:
        idx - the index at which removal should be done
        Returns:
        the modified authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • withoutSsl

        public AuthenticationContext withoutSsl​(int idx)
                                         throws IndexOutOfBoundsException
        Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by the idx parameter.
        Parameters:
        idx - the index at which removal should be done
        Returns:
        the modified authentication context
        Throws:
        IndexOutOfBoundsException - if the index is out of bounds
      • run

        public <T> T run​(PrivilegedAction<T> action)
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        Parameters:
        action - the action to run under association
        Returns:
        the action return value
      • run

        public <T> T run​(PrivilegedExceptionAction<T> action)
                  throws PrivilegedActionException
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        Parameters:
        action - the action to run under association
        Returns:
        the action return value
        Throws:
        PrivilegedActionException - if the action throws an exception
      • run

        public <T,​P> T run​(P parameter,
                                 ParametricPrivilegedAction<T,​P> action)
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        P - the action parameter type
        Parameters:
        parameter - the parameter to pass to the action
        action - the action to run under association
        Returns:
        the action return value
      • run

        public <T,​P> T run​(P parameter,
                                 ParametricPrivilegedExceptionAction<T,​P> action)
                          throws PrivilegedActionException
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        P - the action parameter type
        Parameters:
        parameter - the parameter to pass to the action
        action - the action to run under association
        Returns:
        the action return value
        Throws:
        PrivilegedActionException - if the action throws an exception
      • runAsObjIntConsumer

        public <T> void runAsObjIntConsumer​(ObjIntConsumer<T> action,
                                            T parameter1,
                                            int parameter2)
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action first parameter type
        Parameters:
        parameter1 - the first parameter to pass to the action
        parameter2 - the second parameter to pass to the action
        action - the action to run
      • runAsSupplier

        public <T> T runAsSupplier​(Supplier<T> action)
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        Parameters:
        action - the action to run
        Returns:
        the action result (may be null)
      • runAsObjIntConsumerEx

        public <T,​E extends Exception> void runAsObjIntConsumerEx​(org.wildfly.common.function.ExceptionObjIntConsumer<T,​E> action,
                                                                        T parameter1,
                                                                        int parameter2)
                                                                 throws E extends Exception
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action first parameter type
        E - the action exception type
        Parameters:
        parameter1 - the first parameter to pass to the action
        parameter2 - the second parameter to pass to the action
        action - the action to run
        Throws:
        E - if the action throws this exception
        E extends Exception
      • runAsSupplierEx

        public <T,​E extends Exception> T runAsSupplierEx​(org.wildfly.common.function.ExceptionSupplier<T,​E> action)
                                                        throws E extends Exception
        Run a privileged action with this authentication context associated for the duration of the task.
        Type Parameters:
        T - the action return type
        E - the action exception type
        Parameters:
        action - the action to run
        Returns:
        the action result (may be null)
        Throws:
        E - if the action throws this exception
        E extends Exception
      • getInstanceContextManager

        public org.wildfly.common.context.ContextManager<AuthenticationContext> getInstanceContextManager()
        Specified by:
        getInstanceContextManager in interface org.wildfly.common.context.Contextual<AuthenticationContext>
      • getContextManager

        public static org.wildfly.common.context.ContextManager<AuthenticationContext> getContextManager()
        Get the context manager for authentication contexts.
        Returns:
        the context manager for authentication contexts (not null)