Class Authorizations
java.lang.Object
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AuthorizationsAn empty set of authorizations.static final StringA special header string used when serializing instances of this class. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty set of authorizations.Authorizations(byte[] authorizations) Constructs an authorizations object from a serialized form.Authorizations(String... authorizations) Constructs an authorizations object from a set of human-readable authorizations.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. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(byte[] auth) Checks whether this object contains the given authorization.booleanChecks whether this object contains the given authorization.booleancontains(ByteSequence auth) Checks whether this object contains the given authorization.booleanList<byte[]>Gets the authorizations in sorted order.byte[]Returns a serialized form of these authorizations.Gets the authorizations in sorted order.inthashCode()booleanisEmpty()Checks if this collection of authorizations is empty.Iterator<byte[]>iterator()Returns a serialized form of these authorizations.intsize()Gets the size of this collection of authorizations.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY
An empty set of authorizations. -
HEADER
A special header string used when serializing instances of this class.- See Also:
-
-
Constructor Details
-
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
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
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 bygetAuthorizationsArray()orserialize(), converted to UTF-8 bytes- Throws:
IllegalArgumentException- if authorizations is null
-
Authorizations
public Authorizations()Constructs an empty set of authorizations.- See Also:
-
Authorizations
Constructs an authorizations object from a set of human-readable authorizations.- Parameters:
authorizations- array of authorizations- Throws:
IllegalArgumentException- if authorizations is null
-
-
Method Details
-
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:
-
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:
-
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
-
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
Checks whether this object contains the given authorization. Warning: This method does not verify that the encoded string is valid UTF-8.- Specified by:
containsin interfaceAuthorizationContainer- Parameters:
auth- authorization, as a string encoded in UTF-8- Returns:
- true if authorization is in this collection
-
contains
Checks whether this object contains the given authorization.- Parameters:
auth- authorization- Returns:
- true if authorization is in this collection
-
equals
-
hashCode
public int hashCode() -
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
-
serialize
Returns a serialized form of these authorizations. Convert the returned string to UTF-8 bytes to deserialize withAuthorizations(byte[]).- Returns:
- serialized form of authorizations
-