Class OpenAMAuthHandler

  • All Implemented Interfaces:
    AccessRequestHandler

    public class OpenAMAuthHandler
    extends Object
    implements AccessRequestHandler
    This RADIUS handler authenticates against an authentication realm and chain specified via configuration. It uses OpenAM's AuthContext object. This flow proceeds as follows. It is also important to note that challenge answers are passed in the RADIUS packet via the password field as per the RFC 2865 specification. In the diagram below are shown the RADIUS CLIENT and the OPENAM instance acting as a radius server. Time generally increases as we move from the top of the diagram to the bottom. However, the while and for loops violate that aspect. Vertical bars imply where processing or user input is currently proceeding. Periods imply an idle or waiting system.
    
     RADIUS CLIENT                            OPENAM
          |                                      .
          | AccessRequest                        .
          | [username + password]                .
          + -----------------------------------> +
          .                                      | ac = new AuthContext(realm)
          .                                      | ac.login(VIA_CHAIN, chain)
          .                                      |
          .   at a minimum the auth chain used   | ac.hasMoreRequirements()
          .   must have a first module that      | callback[] cbs = ac.getRequirements(true)
          .   accepts username and password -->  | find nameCallback and inject username
          .                                      | find passwordCallback and inject password
          . AccessReject                         |
          + <----------------------------------- + if unable to find name/password callbacks or inject values
          .                                      |
          .                                      +-- while ac.hasMoreRequirements()
          .                                      .    | callback[] cbs = ac.getRequirements(true)
          .                                      .    |
          .                                      .    +-- for n=0 to cbs.length-1 for each cbs that accepts user input
          .                                      .    .   | issue challenge, gather response, and inject into the
     callback
          . AccessChallenge                      .    .   |
          . [message + state(n)]                 .    .   |
          + <---------------------------------------------+
          |                                      .    .   .
          | AccessRequest                        .    .   .
          | [username + answer + state(n)]       .    .   .
          + --------------------------------------------->+
          .                                      .    .   | inject value into cbs(n)
          .                                      .    +---+
          .                                      .    |
          .                                      .    | ac.submit(cbs)
          .                                      +----+
          .                                      |
          . AccessAccept                         | s = ac.getStatus()
          + <----------------------------------- + if s == SUCCESS
          .                                      |
          . AccessReject                         |
          + <----------------------------------- + all else
          |                                      .
          |                                      .
     

    Of special note to authentication module implementors is what modules are allowed in the chain used by a radius client. If an authentication module uses HttpServletRequest or HttpServletResponse they generally won't work for radius clients without modification. For non-http clients the HttpServletRequest and HttpServletResponse objects will be null typically leading to a NullPointerException. Looking for a value of null is how such modules can tell if they are dealing with a non-http client and adjust their behavior accordingly.

    This may include having different sets of callbacks for http clients than for radius clients. For example, a module may support a checkbox causing a cookie to be set in the user's browser to remember that module's use for a period of time and not require that the user leverage its unique authentication mechanism until that cookie has expired. Such a feature won't work for radius clients since they have no such persistent client-side mechanism. Hence for non-http clients a different callback set would most likely be needed that didn't include that checkbox and its label.

    • Constructor Detail

      • OpenAMAuthHandler

        @Inject
        public OpenAMAuthHandler​(OpenAMAuthFactory amAuthFactory,
                                 ContextHolderCache contextHolderCache,
                                 @Named("RadiusEventBus")
                                 com.google.common.eventbus.EventBus eventBus)
        Constructor.
        Parameters:
        amAuthFactory - - a factory that provides OpenAM auth entities such as AuthContexts.
        contextHolderCache - - the cache to be used to hold ContextHolder objects that persist state in the server (here) when control is with the client, e.g. when the client is providing user input to meet a challenge request.
        eventBus - - the Radius event bus that will be used to notify interested parties of org.forgerock.openam.radius.server.events as they occur.
    • Method Detail

      • init

        public void init​(Properties config)
        Description copied from interface: AccessRequestHandler
        Passes to the handler configuration parameters declared in OpenAM's admin console for the client's declared handler class.
        Specified by:
        init in interface AccessRequestHandler
        Parameters:
        config - - the handler configuration parameters.
      • handle

        public void handle​(RadiusRequest request,
                           RadiusResponse response,
                           RadiusRequestContext context)
                    throws RadiusProcessingException
        Handles the request in potentially two distinct ways depending on whether a state attribute is found in the request or not. When no state field is found this is an initial request starting the authentication process and the request will have username and password embedded and ready for consumption by the first module in the chain. Any request with a state attribute is a user response to a previous challenge response that we sent back to them in a previously started authentication process. The number of challenge responses that are sent and their corresponding replies is dependent upon the number of modules in the chain and the number of callback fields in each set of callbacks. A set of callbacks represents one grouping of data needed by a module to complete its next step in the authentication process that it implements. This grouping in a web environment constitutes a single page into which a number of fields can receive data. However, to gather additional feedback from a user the radius protocol only supports a challenge response with a text message and state and radius clients typically present that message and a single text input field with a label like, "Answer", and submit and cancel buttons. This means that we only get a single answer per radius challenge response. Therefore, for some callback groupings we will need to return multiple challenge responses before we can submit the callback set's user response values back to the module to take the next step in authentication.
        Specified by:
        handle in interface AccessRequestHandler
        Parameters:
        request - the access request
        response - - the response to be sent to the client.
        context - - provides methods that the handler can use to obtain information about the context in which the request was made, for example the name and IP address of the client from which the request was received.
        Throws:
        RadiusProcessingException - - when the response can not be sent.