org.apache.accumulo.core.security
Class Credentials

java.lang.Object
  extended by org.apache.accumulo.core.security.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 Connector can be destroyed, invalidating future RPC operations from that Connector.

See ACCUMULO-1312

Since:
1.6.0

Constructor Summary
Credentials(String principal, AuthenticationToken token)
          Creates a new credentials object.
 
Method Summary
static Credentials deserialize(String serializedForm)
          Converts the serialized form to an instance of Credentials.
 boolean equals(Object obj)
           
static Credentials fromThrift(TCredentials serialized)
          Converts a given thrift object to our internal Credentials representation.
 String getPrincipal()
          Gets the principal.
 AuthenticationToken getToken()
          Gets the authentication token.
 int hashCode()
           
 String serialize()
          Converts the current object to a serialized form.
 String toString()
           
 TCredentials toThrift(Instance instance)
          Converts the current object to the relevant thrift type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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(Instance instance)
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:
instance - client instance
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

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Apache Accumulo Project. All rights reserved.