title: How to create a authentication token using Java
body: <p>On my Java EE6, REST service, I want to use authentication tokens for login from mobile devices, User will send their username, password and server will send back a token, which will be used to authorize the user on their further requests for a given time.</p>
  <p>Can I simply create a token myself like this?(I guess I do not need to encrypt this since I will use HTTPS.)</p>
  <pre><code>String token = UUID.randomUUID().toString().toUpperCase() 
              + &quot;|&quot; + &quot;userid&quot; + &quot;|&quot;
              + cal.getTimeInMillis();
  </code></pre>
  <p>Or there is a more standard way to create these tokens? maybe it exists in one of the API`s?</p>