Class Credentials
- java.lang.Object
-
- org.apache.accumulo.core.clientImpl.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 aAccumuloClientcan be destroyed, invalidating future RPC operations from thatAccumuloClient.See ACCUMULO-1312
- Since:
- 1.6.0
-
-
Constructor Summary
Constructors Constructor Description Credentials(String principal, AuthenticationToken token)Creates a new credentials object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Credentialsdeserialize(String serializedForm)Converts the serialized form to an instance ofCredentials.booleanequals(Object obj)static CredentialsfromThrift(TCredentials serialized)Converts a given thrift object to our internal Credentials representation.StringgetPrincipal()Gets the principal.AuthenticationTokengetToken()Gets the authentication token.inthashCode()Stringserialize()Converts the current object to a serialized form.StringtoString()TCredentialstoThrift(String instanceID)Converts the current object to the relevant thrift type.
-
-
-
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 credentialstoken- 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 theAuthenticationToken, 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 theAuthenticationToken, 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 ofCredentials. The original serialized form will not be affected.- Parameters:
serializedForm- serialized form of credentials- Returns:
- deserialized credentials
-
-