Class AuthUtil
java.lang.Object
com.inductiveautomation.ignition.gateway.auth.util.AuthUtil
Utility methods useful for Auth
- 
Method SummaryModifier and TypeMethodDescriptionstatic org.jose4j.jwt.JwtClaimsdeserializeJwt(String jwt) De-serialize from a compact and URL-safe JWTStringto aJwtClaimsobject.static StringgenerateRandomBase64String(int entropyCountInBytes) Generates a random Base64-encoded String of "entropyCountInBytes" number of bytes.static StringserializeJwt(org.jose4j.jwt.JwtClaims jwtClaims) Secure an arbitrary set of claims with a message authentication code (MAC) and return the data wrapped in JSON Web Token (JWT).
- 
Method Details- 
generateRandomBase64StringGenerates a random Base64-encoded String of "entropyCountInBytes" number of bytes. Delegates toSecureRandomProviderfor generating a secure random byte array. This Base64 encoded string is safe for use in URLs.- Parameters:
- entropyCountInBytes- Number of bytes of randomness to generate (must be greater than 0)
- Returns:
- The random Base64-encoded String of bytes
- See Also:
 
- 
serializeJwtpublic static String serializeJwt(org.jose4j.jwt.JwtClaims jwtClaims) throws org.jose4j.lang.JoseException Secure an arbitrary set of claims with a message authentication code (MAC) and return the data wrapped in JSON Web Token (JWT). The resulting JWT will be serialized in its compact URL-safe form. Note: secret keys will vary each time the server is restarted. The JWT may be verified using deserializeJwt(String).- Parameters:
- jwtClaims- the arbitrary- JwtClaimsto include in the JWT
- Returns:
- the JWT with the claims included in compact URL-safe form
- Throws:
- org.jose4j.lang.JoseException- if there is an unexpected problem serializing the JWT
 
- 
deserializeJwtpublic static org.jose4j.jwt.JwtClaims deserializeJwt(String jwt) throws org.jose4j.jwt.consumer.InvalidJwtException De-serialize from a compact and URL-safe JWTStringto aJwtClaimsobject. Throws anInvalidJwtExceptionif the JWT fails MAC verification against the secret key.- Parameters:
- jwt- the JWT to de-serialize and verify
- Returns:
- the de-serialized JwtClaimswhich may be trusted since MAC verification was performed and it was determined that the payload was generated from this server (authenticated) and was not tampered with (integrity protection)
- Throws:
- org.jose4j.jwt.consumer.InvalidJwtException- if the JWT fails MAC verification against the secret key
 
 
-