All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clouway.oauth2.jwt.Jwt Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package com.clouway.oauth2.jwt;

import com.google.common.base.MoreObjects;

/**
 * Jwt stands for JSON Web Token and is the entry point of the JWT package.
 *
 * @author Miroslav Genov ([email protected])
 */
public final class Jwt {

  /**
   * JSON object represented by the JOSE Header describe the cryptographic operations applied to the JWT
   * and optionally, additional properties of the JWT.
   *
   * @author Miroslav Genov ([email protected])
   * @see Jose Header
   */
  public static class Header {

    public final String alg;

    public Header(String alg) {
      this.alg = alg;
    }
  }

  /**
   * ClaimSet contains information about JWT signature including the permissions being requested (scopes), the target of
   * the token, the issuer, the time token was issued and lifetime of the token.
   *
   * @author Miroslav Genov ([email protected])
   * @see Registered Claim Names
   */
  public static final class ClaimSet {
    /**
     * Email address of the client_id of the application making access token request.
     */
    public final String iss;
    /**
     * Space delimited list of permissions of application requests
     */
    public final String scope;

    /**
     * Descriptor of the intended target of the assertion (Optional)
     */
    public final String aud;

    /**
     * The expiration time of assertion
     */
    public final Long exp;

    /**
     * The time assertion was issued
     */
    public final Long iat;

    /**
     * Token Type (Optional)
     */
    public final String typ;

    /**
     * Email for which the application is requested delegated access (Optional)
     */
    public final String sub;

    /**
     * Prn is an old name of sub. Keep setting it to be compatible with legacy OAuth2 clients
     */
    public final String prn;

    public ClaimSet(String iss, String scope, String aud, Long exp, Long iat, String typ, String sub) {
      this.iss = iss;
      this.scope = scope;
      this.aud = aud;
      this.exp = exp;
      this.iat = iat;
      this.typ = typ;
      this.sub = sub;
      this.prn = sub;

    }

    @Override
    public String toString() {
      return MoreObjects.toStringHelper(this).add("iss", iss).add("scope", scope).add("aud", aud).add("exp", exp).add("iat", iat).add("typ", typ).toString();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy