Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1592

JaccAuthorizationRealm always returns false on subsequent requests

XMLWordPrintable

      After the initial login, the JaccAuthorizationRealm always returns false because the PolicyContext handler for the Subject is not yet initialized when the realm is called. To figure out the root of the problem, an understanding of the calling order is necessary.

      The standard pipeline is composed of the following valves, in this order:

      • JaccContextValve
      • FormAuthenticator (the authenticator valve in my case)
      • SecurityAssociationValve
      • CustomPrincipalValve
      • StandardContextValve

      The SecurityAssociationValve is added to the pipeline after the authenticator valve due to the ordering of the code in the TomcatDeployer.performDeployInternal method. The SecurityAssociationValve is added after the init call to the server. The init call results in the authenticator valve being added to the pipeline.

      When a request is received by an authenticated user, the authenticator valve obtains control before the SecurityAssociationValve. The authenticator valve calls the JaccAuthorizationRealm for the authorization check. Part of the check is as follows:

      Subject caller = null;
      try
      {
      caller = (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
      }
      catch (PolicyContextException e)
      {
      if( trace )
      log.trace("Failed to get subject from PolicyContext", e);
      }
      if( caller == null ) //*** is always true!
      {
      if( trace )
      log.trace("Denied, no active subject found in PolicyContext");
      return false;
      }

      The realm expects to have an initialized caller (Subject), but the caller is always null because it wasn't initialized yet since the SecurityAssociationValve that initializes the caller (Subject) doesn't receive control until after the authenticator valve is finished.

              starksm64 Scott Stark (Inactive)
              skinser_jira Stephen Kinser (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Estimated:
                  Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 1 day
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified