org.apache.accumulo.core.security
Class Authorizations

java.lang.Object
  extended by org.apache.accumulo.core.security.Authorizations
All Implemented Interfaces:
Serializable, Iterable<byte[]>, AuthorizationContainer

public class Authorizations
extends Object
implements Iterable<byte[]>, Serializable, AuthorizationContainer

A collection of authorization strings.

See Also:
Serialized Form

Field Summary
static Authorizations EMPTY
          An empty set of authorizations.
static String HEADER
          A special header string used when serializing instances of this class.
 
Constructor Summary
Authorizations()
          Constructs an empty set of authorizations.
Authorizations(byte[] authorizations)
          Constructs an authorizations object from a serialized form.
Authorizations(Collection<byte[]> authorizations)
          Constructs an authorization object from a collection of string authorizations that have each already been encoded as UTF-8 bytes.
Authorizations(List<ByteBuffer> authorizations)
          Constructs an authorization object from a list of string authorizations that have each already been encoded as UTF-8 bytes.
Authorizations(String... authorizations)
          Constructs an authorizations object from a set of human-readable authorizations.
 
Method Summary
 boolean contains(byte[] auth)
          Checks whether this object contains the given authorization.
 boolean contains(ByteSequence auth)
          Checks whether this object contains the given authorization.
 boolean contains(String auth)
          Checks whether this object contains the given authorization.
 boolean equals(Object o)
           
 List<byte[]> getAuthorizations()
          Gets the authorizations in sorted order.
 byte[] getAuthorizationsArray()
          Returns a serialized form of these authorizations.
 List<ByteBuffer> getAuthorizationsBB()
          Gets the authorizations in sorted order.
 int hashCode()
           
 boolean isEmpty()
          Checks if this collection of authorizations is empty.
 Iterator<byte[]> iterator()
           
 String serialize()
          Returns a serialized form of these authorizations.
 int size()
          Gets the size of this collection of authorizations.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Authorizations EMPTY
An empty set of authorizations.


HEADER

public static final String HEADER
A special header string used when serializing instances of this class.

See Also:
serialize(), Constant Field Values
Constructor Detail

Authorizations

public Authorizations(Collection<byte[]> authorizations)
Constructs an authorization object from a collection of string authorizations that have each already been encoded as UTF-8 bytes. Warning: This method does not verify that each encoded string is valid UTF-8.

Parameters:
authorizations - collection of authorizations, as strings encoded in UTF-8
Throws:
IllegalArgumentException - if authorizations is null
See Also:
Authorizations(String...)

Authorizations

public Authorizations(List<ByteBuffer> authorizations)
Constructs an authorization object from a list of string authorizations that have each already been encoded as UTF-8 bytes. Warning: This method does not verify that each encoded string is valid UTF-8.

Parameters:
authorizations - list of authorizations, as strings encoded in UTF-8 and placed in buffers
Throws:
IllegalArgumentException - if authorizations is null
See Also:
Authorizations(String...)

Authorizations

public Authorizations(byte[] authorizations)
Constructs an authorizations object from a serialized form. This is NOT a constructor for a set of authorizations of size one. Warning: This method does not verify that the encoded serialized form is valid UTF-8.

Parameters:
authorizations - a serialized authorizations string produced by getAuthorizationsArray() or serialize(), converted to UTF-8 bytes
Throws:
IllegalArgumentException - if authorizations is null

Authorizations

public Authorizations()
Constructs an empty set of authorizations.

See Also:
Authorizations(String...)

Authorizations

public Authorizations(String... authorizations)
Constructs an authorizations object from a set of human-readable authorizations.

Parameters:
authorizations - array of authorizations
Throws:
IllegalArgumentException - if authorizations is null
Method Detail

getAuthorizationsArray

public byte[] getAuthorizationsArray()
Returns a serialized form of these authorizations.

Returns:
serialized form of these authorizations, as a string encoded in UTF-8
See Also:
serialize()

getAuthorizations

public List<byte[]> getAuthorizations()
Gets the authorizations in sorted order. The returned list is not modifiable.

Returns:
authorizations, each as a string encoded in UTF-8
See Also:
Authorizations(Collection)

getAuthorizationsBB

public List<ByteBuffer> getAuthorizationsBB()
Gets the authorizations in sorted order. The returned list is not modifiable.

Returns:
authorizations, each as a string encoded in UTF-8 and within a buffer

toString

public String toString()
Overrides:
toString in class Object

contains

public boolean contains(byte[] auth)
Checks whether this object contains the given authorization.

Parameters:
auth - authorization, as a string encoded in UTF-8
Returns:
true if authorization is in this collection

contains

public boolean contains(ByteSequence auth)
Checks whether this object contains the given authorization. Warning: This method does not verify that the encoded string is valid UTF-8.

Specified by:
contains in interface AuthorizationContainer
Parameters:
auth - authorization, as a string encoded in UTF-8
Returns:
true if authorization is in this collection

contains

public boolean contains(String auth)
Checks whether this object contains the given authorization.

Parameters:
auth - authorization
Returns:
true if authorization is in this collection

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

size

public int size()
Gets the size of this collection of authorizations.

Returns:
collection size

isEmpty

public boolean isEmpty()
Checks if this collection of authorizations is empty.

Returns:
true if this collection contains no authorizations

iterator

public Iterator<byte[]> iterator()
Specified by:
iterator in interface Iterable<byte[]>

serialize

public String serialize()
Returns a serialized form of these authorizations. Convert the returned string to UTF-8 bytes to deserialize with Authorizations(byte[]).

Returns:
serialized form of authorizations


Copyright © 2015 Apache Accumulo Project. All rights reserved.