Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-15912

Access KeycloakSecurityContext in tomcat servlet without reflection

    XMLWordPrintable

Details

    • Feature Request
    • Status: Closed
    • Minor
    • Resolution: Incomplete Description
    • 11.0.2
    • None
    • Adapter - JEE
    • NEW
    • NEW
    • ---
    • ---

    Description

      KeycloakSecurityContext keycloakSecurityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());

      Can get context, but cannot cast to KeycloakSecurityContext, because tomcat adapter and servlet was loaded in different classloaders.

      java.lang.ClassCastException: class org.keycloak.adapters.RefreshableKeycloakSecurityContext cannot be cast to class org.keycloak.KeycloakSecurityContext
      (org.keycloak.adapters.RefreshableKeycloakSecurityContext is in unnamed module of loader java.net.URLClassLoader @77f99a05;
      org.keycloak.KeycloakSecurityContext is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @4ce7c8e5)

      Attachments

        Activity

          People

            psilva@redhat.com Pedro Igor Craveiro
            tnikolay Nicolai Timofeev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: