Package com.illumon.util
Class AuthUtil
java.lang.Object
com.illumon.util.AuthUtil
public class AuthUtil extends Object
Helper methods for handling Authentication and AuthTokens
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuthUtil.AuthenticationFailureAn unchecked exception representing failure to authenticate a token or gain necessary permission for a given user.static classAuthUtil.AuthenticationRejectedAn unchecked exception representing authentication rejection of a token for the requested purpose. -
Constructor Summary
Constructors Constructor Description AuthUtil() -
Method Summary
Modifier and Type Method Description static ByteBuffermakeTokenBuffer(com.fishlib.auth.AuthToken token)Serialize an AuthToken into a ByteBuffer.static com.fishlib.auth.AuthTokenreadAuthToken(ByteBuffer buffer)Reconstitute an AuthToken from the given ByteBuffer.static voidverifyToken(com.fishlib.io.logger.Logger log, com.fishlib.auth.AuthToken authToken, String serviceName)Ensure that the AuthToken is valid.
-
Constructor Details
-
AuthUtil
public AuthUtil()
-
-
Method Details
-
verifyToken
public static void verifyToken(com.fishlib.io.logger.Logger log, com.fishlib.auth.AuthToken authToken, String serviceName)Ensure that the AuthToken is valid. If it is not, anAuthUtil.AuthenticationFailureorAuthExceptionis thrown.- Parameters:
authToken- token containing an effective user to be verifiedserviceName- the name of the service verifying the token- Throws:
AuthUtil.AuthenticationFailure- if the token fails verificationcom.fishlib.auth.AuthException- may be thrown fromWAuthenticationClientManager.verifyToken(java.lang.String, com.fishlib.auth.AuthToken)
-
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
-