title: Trying to get a public key from a jwk in Java
body: <p>I'm trying to verify the signature on a JWT from AzureAD in my API. The endpoint where I retrieve the public key is here: <a href="https://login.microsoftonline.com/common/discovery/keys" rel="nofollow noreferrer">https://login.microsoftonline.com/common/discovery/keys</a></p>
  
  <p>So far I've tried using the Auth0 library (<a href="https://github.com/auth0/java-jwt)and" rel="nofollow noreferrer">https://github.com/auth0/java-jwt)and</a> the Nimbusds library (<a href="https://connect2id.com/products/nimbus-jose-jwt/download" rel="nofollow noreferrer">https://connect2id.com/products/nimbus-jose-jwt/download</a>) but I don't see how to actually convert the JWK in the form it's in (a string) to an object that can be operated on.</p>
  
  <p>Nimubs seems to the the more promising option as it has a method which I can use to extract the public key from a JWK...</p>
  
  <pre><code>List&lt;JWK&gt; matches = new JWKSelector(
          new JWKMatcher.Builder()
              .keyType(KeyType.RSA)
              .keyID("123456")
              .build()
          ).select(jwkSet);
  </code></pre>
  
  <p>This looks more or less like what I need but I'm not sure how to set my list of JWK objects from the string provided.</p>
  
  <p>Thanks.</p>