title: Java REST split part of token body, and return it
body: <p>I have a Java token, that is used for authentication between the client and the server, and as of now I get it in this format:</p>
  
  <pre><code>bearer{token}
  </code></pre>
  
  <p>now I want to crop out bearer so I only have the value of the token:</p>
  
  <p>so far i have made this method:</p>
  
  <pre><code>    public static String cropToken(String token){
      token = token.replace("bearer{", "");
      token = token.replace("}", "");
      return token;
  }
  </code></pre>
  
  <p>then i assign the new token back to the original refrence in the resource:</p>
  
  <pre><code>    public Response create(@HeaderParam("Authorization")String token, String content) throws IOException, AuthenticationException
      {
      TokenAuthenticator authenticator = new TokenAuthenticator(() -&gt; new 
  JpaUserRepository(JpaConnection.create()));
      token =TokenSplitter.cropToken(token);
      AuthenticationContext  authenticationContext = 
  authenticator.authenticate(token);
  </code></pre>
  
  <p>is this a best practice or is there a better way to do this?</p>