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 AuthToken
deserializeTokenFromBytes
(byte[] bytes) static String
getAlgorithmFromKey
(Key publicKey) Given a PublicKey, determine which signature algorithm we should use.static String
getProviderForKey
(Key publicKey) Given a PublicKey, determine which signature algorithm provider we should use.static ByteBuffer
makeTokenBuffer
(AuthToken token) Serialize an AuthToken into a ByteBuffer.static AuthToken
readAuthToken
(ByteBuffer buffer) Reconstitute an AuthToken from the given ByteBuffer.static AuthToken
static void
serializeTokenToBuffer
(AuthToken token, DataOutputStream out) static byte[]
serializeTokenToBytes
(AuthToken token) static byte[]
sign
(PrivateKey privateKey, byte[] data) static boolean
verifySignature
(PublicKey publicKey, byte[] signedData, byte[] data) static void
verifyToken
(com.fishlib.io.logger.Logger log, String service, AuthToken authToken) Verify that the AuthToken is valid, using the default authentication client.static void
verifyToken
(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, anAuthenticationFailure
orAuthException
is 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
-