java.lang.Object
energy.eddie.regionconnector.shared.security.JwtUtil

public class JwtUtil extends Object
  • Field Details

    • JWT_PERMISSIONS_CLAIM

      public static final String JWT_PERMISSIONS_CLAIM
      See Also:
    • JWS_ALGORITHM

      public static final com.nimbusds.jose.JWSAlgorithm JWS_ALGORITHM
  • Constructor Details

    • JwtUtil

      public JwtUtil(String jwtHmacSecret, int timeoutDuration)
      Parameters:
      jwtHmacSecret - Base64 encoded secret that should be used as secret key for calculating and validating the HMAC signatures.
  • Method Details

    • getPermissions

      public Map<String,List<String>> getPermissions(@Nullable String jwtString)
      Returns a map of the permissions contained in the supplied JWT grouped by region connector ID.
      Returns:
      Map of the permissions grouped by region connector ID. It is never null, but may be empty.
    • createJwt

      public String createJwt(String regionConnectorId, String permissionId) throws JwtCreationFailedException
      Creates a new signed JWT and adds the supplied permissionId to the map of permitted permissions. The returned JWT is to be included by the region connector element to make requests that update the permission.
      Parameters:
      regionConnectorId - ID of the region connector that created the new permission.
      permissionId - ID of the newly created permission.
      Returns:
      Serialized JWT.
      Throws:
      JwtCreationFailedException - If for any reason, the creation of the JWT failed.