Package com.auth0.jwt

Examples of com.auth0.jwt.JwtSigner


    try {
   
      JwtSigner jwtSigner = new JwtSigner();
      payload = new  ObjectMapper().writeValueAsString(object);

        ClaimSet claimSet = new ClaimSet();
        claimSet.setExp(expiration); // expire in 1 year
       
        token = jwtSigner.encode(Algorithm.HS256, payload, "payload", new String(Base64.decodeBase64(clientSecret)), claimSet);
   
    } catch (JsonProcessingException e) {
      throw new Auth0RuntimeException(e);
View Full Code Here


    }
    if (securedRoute == null) {
      throw new RuntimeException(
          "You must set which route pattern is used to check for users so that they must be authenticated");
    }
    jwtVerifier = new JWTVerifier(clientSecret, clientId);
  }
View Full Code Here

  }

  @Override
  public Object decodeToken(String token) {

    JWTVerifier jwtVerifier = new JWTVerifier(clientSecret, clientId);

   
    Map<String, Object> verify;
    try {

      verify = jwtVerifier.verify(token);
      String payload = (String) verify.get("$");
      @SuppressWarnings("unchecked")
      Map<String, String> map = new ObjectMapper().readValue(payload, Map.class);
      return map;
View Full Code Here

   * Verify a JSON web token and return the object serialized in the JSON payload
   */
  public Object decode(Algorithm algorithm, String token, String secret)
      throws Exception {
   
    JWTVerifier jwtVerifier = new JWTVerifier(Base64.encodeBase64String(secret.getBytes()));
    Map<String, Object> verify = jwtVerifier.verify(token);
    String payload = (String) verify.get(PAYLOAD_ID);
   
    return getPayloadHandler().decoding(payload);
  }
View Full Code Here

  public String generateToken(Object object, int expiration) {

    String payload, token;
    try {
   
      JwtSigner jwtSigner = new JwtSigner();
      payload = new  ObjectMapper().writeValueAsString(object);

        ClaimSet claimSet = new ClaimSet();
        claimSet.setExp(expiration); // expire in 1 year
       
        token = jwtSigner.encode(Algorithm.HS256, payload, "payload", new String(Base64.decodeBase64(clientSecret)), claimSet);
   
    } catch (JsonProcessingException e) {
      throw new Auth0RuntimeException(e);
    } catch (Exception e) {
      throw new Auth0RuntimeException(e);
View Full Code Here

   * Create a JSON web token by serializing a java object
   */
  public String encode(Algorithm algorithm, Object obj, String secret,
      ClaimSet claimSet) throws Exception {
   
    JwtSigner jwtSigner = new JwtSigner();
    String payload = getPayloadHandler().encoding(obj);
   
    return jwtSigner.encode(algorithm, payload, PAYLOAD_ID, secret, claimSet);
  }
View Full Code Here

TOP

Related Classes of com.auth0.jwt.JwtSigner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.