<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.lit
        {mso-style-name:lit;}
span.pln
        {mso-style-name:pln;}
span.typ
        {mso-style-name:typ;}
span.pun
        {mso-style-name:pun;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hello, I am trying to retrieve information about the User logged into the webapp via keycloak. I have seen around information on using the following;</p><p class=MsoNormal><o:p> </o:p></p><pre><b><i><span style='color:#44546A'>@SecurityDomain("keycloak")</span></i></b><span style='color:#44546A'><o:p></o:p></span></pre><p class=MsoNormal><o:p> </o:p></p><div><pre style='background:#EEEEEE'><span class=lit><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'>@Context</span></i></b></span><span class=pln><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'><o:p></o:p></span></i></b></span></pre><pre style='background:#EEEEEE'><span class=typ><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'>SecurityContext</span></i></b></span><span class=pln><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'> sc</span></i></b></span><span class=pun><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'>;</span></i></b></span><b><i><span style='font-family:Consolas;color:#44546A;border:none windowtext 1.0pt;padding:0in;background:#EEEEEE'><o:p></o:p></span></i></b></pre></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>And </p><pre><b><i><span style='color:#44546A'>KeycloakPrincipal principal = (KeycloakPrincipal) sc.getUserPrincipal();<o:p></o:p></span></i></b></pre><pre><b><i><span style='color:#44546A'><o:p> </o:p></span></i></b></pre><pre><b><i><span style='color:#44546A'><o:p> </o:p></span></i></b></pre><pre><b><i><span style='color:#44546A'><o:p> </o:p></span></i></b></pre><p class=MsoNormal><b>But the above line is returning a NullPointerException</b><b><span style='font-size:12.0pt'>.<o:p></o:p></span></b></p><pre><b><i><span style='color:black'><o:p> </o:p></span></i></b></pre><p><span style='font-family:"Calibri",sans-serif;color:black'>I must say, I have already done the required configuration; as in </span>enabling the Keycloak Subsystem within my app server's server configuration:<span class=apple-converted-space> </span><code><span style='font-size:11.0pt'>standalone.xml</span></code>.<span style='font-size:10.0pt'><o:p></o:p></span></p><p class=MsoNormal>Please any lead on how to retrieve the logged in User via KeyCloak?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p></div></body></html>