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 class  AuthUtil.AuthenticationFailure
    An unchecked exception representing failure to authenticate a token or gain necessary permission for a given user.
    static class  AuthUtil.AuthenticationRejected
    An 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 ByteBuffer makeTokenBuffer​(com.fishlib.auth.AuthToken token)
    Serialize an AuthToken into a ByteBuffer.
    static com.fishlib.auth.AuthToken readAuthToken​(ByteBuffer buffer)
    Reconstitute an AuthToken from the given ByteBuffer.
    static void verifyToken​(com.fishlib.io.logger.Logger log, com.fishlib.auth.AuthToken authToken, String serviceName)
    Ensure that the AuthToken is valid.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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, an AuthUtil.AuthenticationFailure or AuthException is thrown.
      Parameters:
      authToken - token containing an effective user to be verified
      serviceName - the name of the service verifying the token
      Throws:
      AuthUtil.AuthenticationFailure - if the token fails verification
      com.fishlib.auth.AuthException - may be thrown from WAuthenticationClientManager.verifyToken(java.lang.String, com.fishlib.auth.AuthToken)
    • readAuthToken

      public static com.fishlib.auth.AuthToken readAuthToken​(ByteBuffer buffer)
      Reconstitute an AuthToken from the given ByteBuffer.
      Parameters:
      buffer - ByteBuffer to read from
      Returns:
      a new AuthToken
    • makeTokenBuffer

      public static ByteBuffer makeTokenBuffer​(@NotNull com.fishlib.auth.AuthToken token)
      Serialize an AuthToken into a ByteBuffer.
      Parameters:
      token - serialize this token
      Returns:
      a new ByteBuffer containing the token