Class SessionAuthentication

java.lang.Object
com.appliedolap.essbase.impl.SessionAuthentication
All Implemented Interfaces:
EssAuthentication

public class SessionAuthentication extends Object implements EssAuthentication
Username and password until the server hands back a session, then the session from then on.

This is what the library has always done outside "stateless" mode, and it is worth keeping rather than always sending Basic: Essbase creates a server-side session per authenticated request, so re-presenting the password on every call leaves a trail of sessions behind.

  • Constructor Details

    • SessionAuthentication

      public SessionAuthentication(String username, String password)
  • Method Details

    • username

      public Optional<String> username()
      Description copied from interface: EssAuthentication
      The user being authenticated as, where this strategy knows it.

      Empty for a strategy that only carries a session or a token: those identify a user to the server without the client necessarily knowing who it is. A caller that needs the name regardless has to ask the server - but should prefer this, because asking is a round trip and, on Essbase 26.1, GET /session answers 500.

      Specified by:
      username in interface EssAuthentication
    • authorizationHeader

      public String authorizationHeader()
      Description copied from interface: EssAuthentication
      The value for the Authorization header, or null to send none. Null is meaningful rather than a degenerate case - a cookie-borne session needs no Authorization header.
      Specified by:
      authorizationHeader in interface EssAuthentication
    • cookieHeader

      public String cookieHeader()
      Description copied from interface: EssAuthentication
      The value for the Cookie header, or null to send none.
      Specified by:
      cookieHeader in interface EssAuthentication
    • observeSetCookies

      public void observeSetCookies(List<String> setCookieHeaders)
      Description copied from interface: EssAuthentication
      Offers the Set-Cookie headers from a response, so an implementation that establishes a session as it goes can pick one up. Called for every response; most implementations ignore it.

      Takes the raw header values rather than the response so that the decision this makes - which is the subtle part - can be tested without a server or an HttpResponse.

      Specified by:
      observeSetCookies in interface EssAuthentication
      Parameters:
      setCookieHeaders - every Set-Cookie header value on the response, possibly empty
    • sessionExpiry

      public Optional<Instant> sessionExpiry()
      Description copied from interface: EssAuthentication
      When the current session expires, if that is known. Essbase reports it in a sessionExpiry cookie alongside the session itself, so it is only ever known for a session this library established.
      Specified by:
      sessionExpiry in interface EssAuthentication
    • sessionEnded

      public void sessionEnded()
      Forgets the session, falling back to the username and password. The next request authenticates with them and the server issues a fresh session, so signing off and carrying on works rather than leaving the client wedged presenting a session the server has already discarded.
      Specified by:
      sessionEnded in interface EssAuthentication
    • getSessionId

      public String getSessionId()
      The session this has established, or null if it is still authenticating with a password.
    • getWeblogicAuthCookie

      public String getWeblogicAuthCookie()
      The WebLogic authentication cookie for the established session, or null.

      Exposed alongside getSessionId() so a session established here can be handed to EssAuthentication.sessionCookie(java.lang.String, java.lang.String) - the same handoff a caller performs when the session came from somewhere else entirely, such as a browser sign-in.