<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="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Courier New";
        panose-1:2 7 3 9 2 2 5 2 4 4;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@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:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 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:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:Calibri;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:93207627;
        mso-list-type:hybrid;
        mso-list-template-ids:-986833530 989071042 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;
        mso-fareast-font-family:Calibri;
        mso-bidi-font-family:"Times New Roman";}
@list l0:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l0:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l0:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1
        {mso-list-id:1882980452;
        mso-list-type:hybrid;
        mso-list-template-ids:804834320 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l1:level1
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level3
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1:level4
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l1:level5
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level6
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
@list l1:level7
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Symbol;}
@list l1:level8
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Courier New";}
@list l1:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:Wingdings;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">&#43;1 for not trusting the algorithm in the JWT header to avoid these attacks:&nbsp;
<a href="https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/">
https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/</a>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">Should do more than just signature validation though to be secure:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p>&nbsp;</o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:Calibri">Expiration check<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:Calibri">Audience check<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt &quot;Times New Roman&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:Calibri">Subject check<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">This is a pretty good overview of the mechanics:&nbsp;
<a href="http://www.cloudidentity.com/blog/2014/03/03/principles-of-token-validation/">
http://www.cloudidentity.com/blog/2014/03/03/principles-of-token-validation/</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri">-Jason<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Calibri"><o:p>&nbsp;</o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-family:Calibri;color:black">From: </span>
</b><span style="font-family:Calibri;color:black">&lt;keycloak-user-bounces@lists.jboss.org&gt; on behalf of Stian Thorgersen &lt;sthorger@redhat.com&gt;<br>
<b>Reply-To: </b>&quot;stian@redhat.com&quot; &lt;stian@redhat.com&gt;<br>
<b>Date: </b>Wednesday, May 18, 2016 at 10:01 PM<br>
<b>To: </b>Josh Cain &lt;josh.cain@redhat.com&gt;<br>
<b>Cc: </b>Aikeaguinea &lt;aikeaguinea@xsmail.com&gt;, &quot;keycloak-user@lists.jboss.org&quot; &lt;keycloak-user@lists.jboss.org&gt;<br>
<b>Subject: </b>Re: [keycloak-user] Validating JWT tokens<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">You can also use&nbsp;<a href="https://github.com/keycloak/keycloak/blob/master/core/src/main/java/org/keycloak/RSATokenVerifier.java">https://github.com/keycloak/keycloak/blob/master/core/src/main/java/org/keycloak/RSATokenVerifier.java</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On 11 May 2016 at 15:50, Josh Cain &lt;<a href="mailto:josh.cain@redhat.com" target="_blank">josh.cain@redhat.com</a>&gt; wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">I recently put together a quick test for this as well using jjwt:
<a href="https://github.com/cainj13/jwtExamples/blob/master/src/test/java/jcain/example/TokenParseTest.java" target="_blank">
https://github.com/cainj13/jwtExamples/blob/master/src/test/java/jcain/example/TokenParseTest.java</a><o:p></o:p></p>
</div>
<p class="MsoNormal">Pretty similar to the gist that Thomas mentioned above.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><br clear="all">
</span><span class="hoenzb"><span style="color:#888888"><o:p></o:p></span></span></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="color:#888888">Josh Cain | Software Applications Engineer</span><o:p></o:p></p>
</div>
<p class="MsoNormal"><i><span style="color:#888888">Identity and Access Management</span></i><span style="color:#888888"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><b><span style="color:#888888">Red Hat</span></b><span style="color:#888888"><br>
<a href="tel:%2B1%20843-737-1735" target="_blank">&#43;1 843-737-1735</a><o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">On Wed, May 11, 2016 at 4:09 AM, Thomas Darimont &lt;<a href="mailto:thomas.darimont@googlemail.com" target="_blank">thomas.darimont@googlemail.com</a>&gt; wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal">Hello, <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">another example for (Parsing) &amp; Validating a Keycloak JWT was posted on the ML a few months ago:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://lists.jboss.org/pipermail/keycloak-user/2016-March/005325.html" target="_blank">http://lists.jboss.org/pipermail/keycloak-user/2016-March/005325.html</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">In the example the token is only successfully parsed when the token is valid.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Cheers,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thomas<o:p></o:p></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class="MsoNormal">2016-05-11 10:45 GMT&#43;02:00 Gerard Laissard &lt;<a href="mailto:glaissard@axway.com" target="_blank">glaissard@axway.com</a>&gt;:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">My 2 cents:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">There is an openSSL example to verify a jwt:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D"><a href="https://gist.github.com/rolandyoung/176dd310a6948e094be6" target="_blank">https://gist.github.com/rolandyoung/176dd310a6948e094be6</a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">By using jose4j</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // be sure you do not have any EOL at the end of the token</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">String accesToken = …;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">accesToken = accesToken.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;\r\n&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">accesToken = accesToken.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;\n&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">JsonWebSignature
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">jws</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> JsonWebSignature();</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">jws</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.setCompactSerialization(accesToken);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">jws</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.setKey(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">publicKey</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">boolean signatureVerified = jws.verifySignature();</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">To get a PublicKey : if you put the content of the realm public you get from keycloak admin
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">public</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> PublicKey
<span style="background:silver">getPublicKey</span>(String </span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">fileName</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">File </span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">f</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> File(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">fileName</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in;text-autospace:none">
<b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">try</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> (FileInputStream
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">fis</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> FileInputStream(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">f</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:.5in;text-indent:.5in;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">DataInputStream
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">dis</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> DataInputStream(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">fis</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);)
 {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">byte</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">[]
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">keyBytes</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">byte</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">[(</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">int</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">)
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">f</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.length()];</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">dis</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.readFully(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">keyBytes</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">dis</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.close();</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // convert to der format</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String pem = new String(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">keyBytes</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;-----BEGIN (.*)-----&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;-----END (.*)----&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;\r\n&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">pem</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.replaceAll(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;\n&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] der = Base64.getDecoder().decode(pem); // java 8</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">X509EncodedKeySpec
</span><span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">spec</span><span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span><b><span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> X509EncodedKeySpec(der);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span lang="FR" style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">KeyFactory
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">kf</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> = KeyFactory.<i>getInstance</i>(</span><b><i><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#0000C0">RSA</span></i></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">return</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">kf</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">.generatePublic(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">spec</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } </span>
<b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">catch</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> (IOException | InvalidKeySpecException | NoSuchAlgorithmException
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">throw</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">
</span><b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#7F0055">new</span></b><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> RuntimeException(</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;Failed
 to load public key from file '&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> &#43;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">fileName</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black"> &#43;
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#2A00FF">&quot;'&quot;</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">,
</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:#6A3E3E">e</span><span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:&quot;Courier New&quot;;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">With Java 8, it is quite simple too</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">String[]&nbsp; tokenParts</span><span style="font-size:8.0pt;font-family:Calibri;color:#1F497D"> &nbsp;=
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">accessToken.split(&quot;\\.&quot;);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-indent:.5in">
<span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">// detect algo from tokenParts[0] or put &quot;SHA256withRSA” (for “RS256”)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:8.0pt;font-family:Calibri;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">String jwtSignAlgo = &quot;SHA256withRSA&quot;;
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String jwtInputString = tokenParts[0] &#43; “.” &#43; tokenParts[1];</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String jwtDecodedSign = new String(Base64.getUrlDecoder().decode(tokenParts[2]);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
<span lang="FR" style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">Signature verifier = Signature.getInstance(jwtSignAlgo);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span lang="FR" style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">verifier</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.initVerify(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">publicKey</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">verifier</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.update(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">jwtInputString</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.getBytes(&quot;UTF-8&quot;));</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:8.0pt;font-family:Consolas;color:black">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boolean </span>
<span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">signatureVerified</span><span style="font-size:8.0pt;font-family:Consolas;color:black"> =
</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">verifier</span><span style="font-size:8.0pt;font-family:Consolas;color:black">.verify(</span><span style="font-size:8.0pt;font-family:Consolas;color:#6A3E3E">jwtDecodedSign</span><span style="font-size:8.0pt;font-family:Consolas;color:black">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">gerard</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:Calibri;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span style="font-size:10.0pt;font-family:Tahoma">From:</span></b><span style="font-size:10.0pt;font-family:Tahoma">
<a href="mailto:keycloak-user-bounces@lists.jboss.org" target="_blank">keycloak-user-bounces@lists.jboss.org</a> [mailto:<a href="mailto:keycloak-user-bounces@lists.jboss.org" target="_blank">keycloak-user-bounces@lists.jboss.org</a>]
<b>On Behalf Of </b>Stian Thorgersen<br>
<b>Sent:</b> vendredi 6 mai 2016 07:33<br>
<b>To:</b> Aikeaguinea<br>
<b>Cc:</b> keycloak-user<br>
<b>Subject:</b> Re: [keycloak-user] Validating JWT tokens</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On 4 May 2016 at 18:37, Aikeaguinea &lt;<a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a>&gt; wrote:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Figured it out, kinda. I have to use the Realm public key, and at least<br>
in <a href="http://jwt.io" target="_blank">jwt.io</a> it has to begin with &quot;-----BEGIN PUBLIC KEY-----&quot; and end with<br>
&quot;-----END PUBLIC KEY-----&quot; -- these can't be omitted.<br>
<br>
If I try using the Realm certificate, it won't work, however, whether or<br>
not I use &quot;-----BEGIN CERTIFICATE-----&quot;/&quot;-----END CERTIFICATE-----&quot;.<br>
<br>
If I use the validator at <a href="http://kjur.github.io/jsjws/tool_jwt.html" target="_blank">
http://kjur.github.io/jsjws/tool_jwt.html</a> and<br>
select &quot;default X509 Certificate (RSA z4) it tells me &quot;Error: malformed<br>
X.509 certificate PEM (code:003)&quot;<br>
<br>
I can use the Realm public key for validating the JWT, but shouldn't the<br>
certificate work as well?<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">The certificate is only used by SAML, so no you can't verify the JWT with the certificate only the public key.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
On Wed, May 4, 2016, at 12:00 PM, Aikeaguinea wrote:<br>
&gt; I have a client with a service account and credentials using Signed Jwt.<br>
&gt; Authentication works fine. The service uses<br>
&gt; org.keycloak.adapters.authentication.ClientCredentialsProviderUtils#setClientCredentials<br>
&gt; to create the JWT token and set the headers, and I get back a JWT<br>
&gt; containing an access token from Keycloak.<br>
&gt;<br>
&gt; However, when I use <a href="http://jwt.io" target="_blank">jwt.io</a> to look at the access token, I can't validate<br>
&gt; the signature. This is true whether I use the client Certificate (from<br>
&gt; the client's Credentials tab), the Realm public key, or the Realm<br>
&gt; Certificate. In addition, I have generated the client's public key from<br>
&gt; the certificate using<br>
&gt;<br>
&gt; keytool -exportcert -alias x -keypass y -storepass z -rfc -keystore<br>
&gt; client-keystore.jks | openssl x509 -inform pem -pubkey<br>
&gt;<br>
&gt; on the jks file supplied when I generated the client credentials, and<br>
&gt; that doesn't work either.<br>
&gt;<br>
&gt; We've also been having trouble validating the signature programmatically<br>
&gt; using Java.<br>
&gt;<br>
&gt; Any idea why I might be seeing this?<br>
&gt;<br>
&gt; --<br>
&gt; <a href="http://www.fastmail.com" target="_blank">http://www.fastmail.com</a> - Or how I learned to stop worrying and<br>
&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;love email again<br>
&gt;<br>
<br>
<br>
<span style="color:#888888">--<br>
&nbsp; Aikeaguinea<br>
&nbsp; <a href="mailto:aikeaguinea@xsmail.com" target="_blank">aikeaguinea@xsmail.com</a><br>
<br>
--<br>
<a href="http://www.fastmail.com" target="_blank">http://www.fastmail.com</a> - Send your email first class</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">&nbsp;<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
keycloak-user mailing list<br>
<a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>