Class Credentials


  • public class Credentials
    extends Object
    A wrapper for internal use. This class carries the instance, principal, and authentication token for use in the public API, in a non-serialized form. This is important, so that the authentication token carried in a AccumuloClient can be destroyed, invalidating future RPC operations from that AccumuloClient.

    See ACCUMULO-1312

    Since:
    1.6.0
    • Constructor Detail

      • Credentials

        public Credentials​(String principal,
                           AuthenticationToken token)
        Creates a new credentials object.
        Parameters:
        principal - unique identifier for the entity (e.g. a user or service) authorized for these credentials
        token - authentication token used to prove that the principal for these credentials has been properly verified
    • Method Detail

      • getPrincipal

        public String getPrincipal()
        Gets the principal.
        Returns:
        unique identifier for the entity (e.g. a user or service) authorized for these credentials
      • getToken

        public AuthenticationToken getToken()
        Gets the authentication token.
        Returns:
        authentication token used to prove that the principal for these credentials has been properly verified
      • toThrift

        public TCredentials toThrift​(String instanceID)
        Converts the current object to the relevant thrift type. The object returned from this contains a non-destroyable version of the AuthenticationToken, so this should be used just before placing on the wire, and references to it should be tightly controlled.
        Parameters:
        instanceID - Accumulo instance ID
        Returns:
        Thrift credentials
        Throws:
        RuntimeException - if the authentication token has been destroyed (expired)
      • fromThrift

        public static Credentials fromThrift​(TCredentials serialized)
        Converts a given thrift object to our internal Credentials representation.
        Parameters:
        serialized - a Thrift encoded set of credentials
        Returns:
        a new Credentials instance; destroy the token when you're done.
      • serialize

        public final String serialize()
        Converts the current object to a serialized form. The object returned from this contains a non-destroyable version of the AuthenticationToken, so references to it should be tightly controlled.
        Returns:
        serialized form of these credentials
      • deserialize

        public static final Credentials deserialize​(String serializedForm)
        Converts the serialized form to an instance of Credentials. The original serialized form will not be affected.
        Parameters:
        serializedForm - serialized form of credentials
        Returns:
        deserialized credentials
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object