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 Details

  • Constructor Details

    • 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

      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

      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

      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 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

      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:
    • 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