Package io.deephaven.enterprise.auth
Class AuthUtil
java.lang.Object
io.deephaven.enterprise.auth.AuthUtil
Helper methods for handling Authentication and AuthTokens
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AuthTokendeserializeTokenFromBytes(byte[] bytes) static StringgetAlgorithmFromKey(Key publicKey) Given a PublicKey, determine which signature algorithm we should use.static StringgetProviderForKey(Key publicKey) Given a PublicKey, determine which signature algorithm provider we should use.static ByteBuffermakeTokenBuffer(AuthToken token) Serialize an AuthToken into a ByteBuffer.static AuthTokenreadAuthToken(ByteBuffer buffer) Reconstitute an AuthToken from the given ByteBuffer.static AuthTokenstatic voidserializeTokenToBuffer(AuthToken token, DataOutputStream out) static byte[]serializeTokenToBytes(AuthToken token) static byte[]sign(PrivateKey privateKey, byte[] data) static booleanverifySignature(PublicKey publicKey, byte[] signedData, byte[] data) static voidverifyToken(com.fishlib.io.logger.Logger log, String service, AuthToken authToken) Verify that the AuthToken is valid, using the default authentication client.static voidverifyToken(com.fishlib.io.logger.Logger log, String service, AuthToken authToken, TokenVerificationClient tokenVerificationClient) Ensure that the AuthToken is valid.
-
Constructor Details
-
AuthUtil
public AuthUtil()
-
-
Method Details
-
verifyToken
public static void verifyToken(com.fishlib.io.logger.Logger log, String service, AuthToken authToken, TokenVerificationClient tokenVerificationClient) Ensure that the AuthToken is valid. If it is not, anAuthenticationFailureorAuthExceptionis thrown.- Parameters:
authToken- token containing an effective user to be verifiedservice- the name of the service verifying the token
-
verifyToken
public static void verifyToken(com.fishlib.io.logger.Logger log, String service, AuthToken authToken) Verify that the AuthToken is valid, using the default authentication client. If it is not, an AuthenticationFailure exception is thrown.- Parameters:
authToken- token containing an effective user, will be verified and used to check table permissions.
-
readAuthToken
Reconstitute an AuthToken from the given ByteBuffer.- Parameters:
buffer- ByteBuffer to read from- Returns:
- a new AuthToken
-
makeTokenBuffer
Serialize an AuthToken into a ByteBuffer.- Parameters:
token- serialize this token- Returns:
- a new ByteBuffer containing the token
-
serializeTokenToBuffer
public static void serializeTokenToBuffer(@NotNull AuthToken token, @NotNull DataOutputStream out) throws IOException - Throws:
IOException
-
readTokenFromBuffer
- Throws:
IOException
-
serializeTokenToBytes
-
deserializeTokenFromBytes
- Throws:
IOException
-
verifySignature
public static boolean verifySignature(PublicKey publicKey, byte[] signedData, byte[] data) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException -
getAlgorithmFromKey
Given a PublicKey, determine which signature algorithm we should use.- Parameters:
publicKey- the public key for which we are going to verify a signature- Returns:
- the signature algorithm
-
getProviderForKey
Given a PublicKey, determine which signature algorithm provider we should use.- Parameters:
publicKey- the public key for which we are going to verify a signature- Returns:
- the signature algorithm provider
-
sign
public static byte[] sign(PrivateKey privateKey, byte[] data) throws SignatureException, InvalidKeyException, NoSuchAlgorithmException, NoSuchProviderException
-