title: How to get user data when using KeyCloak when using Java Servlet Filter Adapter
body: <p>I am trying to use KeyCloak for developing a Service Provider and authenticating against an OpenAM IDP.</p>
  
  <p>I followed these instructions:
  <a href="http://keycloak.github.io/docs/userguide/saml-client-adapter/html/ch07.html" rel="nofollow noreferrer">http://keycloak.github.io/docs/userguide/saml-client-adapter/html/ch07.html</a></p>
  
  <p>My problem now is that after being authenticated I cannot get the user data (such as email, username, roles...)</p>
  
  <p>The userPrinciple seems to be of type SamlPrinciple, not KeycloakPrinciple.</p>
  
  <p>both attributes and friendly attributes are empty.</p>
  
  <pre><code>import org.keycloak.adapters.saml.SamlPrincipal;
  import org.keycloak.KeycloakPrincipal;
  
  @Path("/user")
  public class User {
  
      @GET
      @Path("/")
      @Produces({ MediaType.APPLICATION_JSON })
      @Consumes({ MediaType.APPLICATION_JSON })
      public Object info(@Context SecurityContext context) {
  
          SamlPrincipal userPrincipal = (SamlPrincipal) context
                  .getUserPrincipal();
  
          Set&lt;String&gt; attributeNames = userPrincipal.getAttributeNames();
          Set&lt;String&gt; friendlyNames = userPrincipal.getFriendlyNames();
          ...
      }
  </code></pre>
  
  <p>Both attributeNames and friendlyNames are empty sets (size=0).</p>
  
  <p>When I look to the communication between the KeyCloak SP and the OpenAP IDP I see a request-response that sends user data:</p>
  
  <p><a href="https://i.stack.imgur.com/bcCB7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bcCB7.png" alt="OpenAM --&gt; KeyCloak user information"></a></p>
  
  <p>How/where can I get this user information from the SamlPrinciple object?</p>