Class JwtValve

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.valves.ValveBase
org.exoplatform.addons.jwt.JwtValve
All Implemented Interfaces:
MBeanRegistration, org.apache.catalina.Contained, org.apache.catalina.JmxEnabled, org.apache.catalina.Lifecycle, org.apache.catalina.Valve

public class JwtValve extends org.apache.catalina.valves.ValveBase
Authenticates the incoming request from a JWT token, then lets the request flow through the regular filter chain. This is deliberately a Tomcat Valve and not a servlet Filter. A Filter contributed to ExtensibleFilter is reached through GenericFilter, which is mapped *after* SetCurrentIdentityFilter in the portal web.xml. By the time such a filter authenticates the user, SetCurrentIdentityFilter has already read a null getRemoteUser() and installed an anonymous ConversationState on the thread, so the REST services downstream see __anonim for the whole request. Valves run in the Context pipeline, before any filter, so the principal is in place when SetCurrentIdentityFilter builds the ConversationState. The actual token validation stays in JwtLoginModule: this valve only reads the sub claim to know which user to log in, and delegates to request.login(...), which triggers the JAAS realm.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

    org.apache.catalina.Lifecycle.SingleUse
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.exoplatform.services.log.Log
     

    Fields inherited from class org.apache.catalina.valves.ValveBase

    asyncSupported, container, containerLog, next, sm

    Fields inherited from interface org.apache.catalina.Lifecycle

    AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response)
     

    Methods inherited from class org.apache.catalina.valves.ValveBase

    backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, startInternal, stopInternal, toString

    Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

    destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister

    Methods inherited from class org.apache.catalina.util.LifecycleBase

    addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • LOG

      protected final org.exoplatform.services.log.Log LOG
  • Constructor Details

    • JwtValve

      public JwtValve()
  • Method Details

    • invoke

      public void invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response) throws IOException, jakarta.servlet.ServletException
      Throws:
      IOException
      jakarta.servlet.ServletException