Dexter meyers' approach should work just fine, provided that:
- your application uses a single
ServerAuthModule
(SAM),
- no AS-wide -i.e. having been registered with the
AuthConfigFactory
with null appContext
and "HttpServlet"
or null layer
arguments- AuthConfigProvider
has been established,
- you do not provide your own
AuthConfigProvider
, ServerAuthConfig
and ServerAuthContext
implementations, and
- your sole concern is to receive a runtime confirmation that the SAM has been "activated" for your application.
Otherwise, a non-null
return from AuthConfigFactory#getConfigProvider(String, String, RegistrationListener)
might be misleading, in the sense that it does not necessarily assert that your application uses a SAM, only that an AuthConfigProvider
has been put into place at a compatible layer and could serve your application's authentication needs if the rest of the required components (ServerAuthConfig
et al.) are registered as well.
If you additionally need to know which SAMs exactly your application has been configured to use, there is, afaik, no standard way to do so, as, first and foremost, ServerAuthContext
does not expose its encapsulated SAMs (and its very acquisition via ServerAuthConfig#getAuthContext(String, Subject, Map)
is not straightforward anyway, since JASPIC's Servlet Profile leaves authContextIDs arbitrary). Which basically means you will either need to implement your own ServerAuthContext
(along with the 2 further indirections) to get that functionality, or alternatively attach an identifier to represent the SAM to the HttpServletRequest
or HttpSession
, if it suffices for you to know which SAMs got triggered for individual requests. Note that in case you prefer to use the javax.servlet.http.authType MessageInfo
callback property to set the value returned by HttpServletRequest#getAuthType()
instead, it will only work when authentication succeeds, that is, when your SAM's validateRequest(...)
establishes a non-null
caller Principal
and/or at least a single AS group Principal
and returns AuthStatus.SUCCESS
; otherwise you will get a null
despite having set the callback property.