Class SaslRoleTokenSigner

java.lang.Object
org.apache.pulsar.broker.authentication.SaslRoleTokenSigner

public class SaslRoleTokenSigner extends Object
  • Constructor Details

    • SaslRoleTokenSigner

      public SaslRoleTokenSigner(byte[] secret)
      Creates a SaslRoleTokenSigner instance using the specified secret.
      Parameters:
      secret - secret to use for creating the digest.
  • Method Details

    • sign

      public String sign(String str)
      Returns a signed string.

      The signature '&s=SIGNATURE' is appended at the end of the string.

      Parameters:
      str - string to sign.
      Returns:
      the signed string.
    • verifyAndExtract

      public String verifyAndExtract(String signedStr) throws AuthenticationException
      Verifies a signed string and extracts the original string.
      Parameters:
      signedStr - the signed string to verify and extract.
      Returns:
      the extracted original string.
      Throws:
      AuthenticationException - thrown if the given string is not a signed string or if the signature is invalid.
    • computeSignature

      protected String computeSignature(String str)
      Returns the signature of a string.
      Parameters:
      str - string to sign.
      Returns:
      the signature for the string.