title: Check if bearer token is jwt or not
body: <p>I have two types of tokens coming in for a http request. One has a JWT token in the authorization header and other has a fixed length oauth token.
  Based on the type of token, I want to perform some action. How do I differentiate them?</p>
  <p>I have tried</p>
  <pre><code>import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  public class Main
  {
      public static void main(String[] args) {
  
        String pattern=&quot;^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.^[A-Za-z0-9-_.+/=]*$&quot;;
        String line=&quot;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1MTYyMzkwMjJ9tbD.epxpstvGdW8TC3G8zg4B6rUYAOvfzdceoH48wgRQ&quot;;
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(line);
        if (m.find( )) {  //is jwt
           System.out.println(&quot;jwt token&quot;);
        }else {
           System.out.println(&quot;NOt jwt&quot;);
        }
      }
  }
  
  </code></pre>
  <p>but this is not working as expected. Is there any library which does this? Or can we modify the above regex?</p>