Class JwtUtil
java.lang.Object
energy.eddie.regionconnector.shared.security.JwtUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates a new signed JWT and adds the suppliedpermissionIdto the map of permitted permissions.getPermissions(String jwtString) Returns a map of the permissions contained in the supplied JWT grouped by region connector ID.
-
Field Details
-
JWT_PERMISSIONS_CLAIM
- See Also:
-
JWS_ALGORITHM
public static final com.nimbusds.jose.JWSAlgorithm JWS_ALGORITHM
-
-
Constructor Details
-
JwtUtil
- Parameters:
jwtHmacSecret- Base64 encoded secret that should be used as secret key for calculating and validating the HMAC signatures.
-
-
Method Details
-
getPermissions
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 suppliedpermissionIdto 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.
-