Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TimeZone tz = TimeZone.getTimeZone("UTC");
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
- df.setTimeZone(tz);
- String nowAsISO = df.format(new Date());
- HashMap<String, String> keyValues = new HashMap<String, String>();
- keyValues.put("consumerKey", this.annotatorKey);
- keyValues.put("userId", this.userId);
- keyValues.put("issuedAt", nowAsISO);
- keyValues.put("ttl", "60000");
- JWTUtils jwtutil = new JWTUtils(this.userId, this.annotatorKey, this.annotatorSecret);
- String signedToken = "";
- try {
- JsonToken token = jwtutil.createToken(keyValues);
- signedToken = token.serializeAndSign();
- } catch (InvalidKeyException e) {
- e.printStackTrace();
- } catch (SignatureException e) {
- e.printStackTrace();
- }
- resp.setContentType("text/plain");
- PrintWriter out = resp.getWriter();
- out.println(signedToken);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement