Class HasPrivilegesResponse


  • public final class HasPrivilegesResponse
    extends java.lang.Object
    Response when checking whether the current user has a defined set of privileges.
    • Constructor Summary

      Constructors 
      Constructor Description
      HasPrivilegesResponse​(java.lang.String username, boolean hasAllRequested, java.util.Map<java.lang.String,​java.lang.Boolean> clusterPrivileges, java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>> indexPrivileges, java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>>> applicationPrivileges)  
    • Method Summary

      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      static HasPrivilegesResponse fromXContent​(XContentParser parser)  
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>>> getApplicationPrivileges()
      A Map from application-name + resource-name + privilege-name to access.
      java.util.Map<java.lang.String,​java.lang.Boolean> getClusterPrivileges()
      A Map from cluster-privilege-name to access.
      java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>> getIndexPrivileges()
      A Map from index-name + privilege-name to access.
      java.lang.String getUsername()
      The username (principal) of the user for which the privileges check was executed.
      boolean hasAllRequested()
      true if the user has every privilege that was checked.
      boolean hasApplicationPrivilege​(java.lang.String applicationName, java.lang.String resourceName, java.lang.String privilegeName)  
      boolean hasClusterPrivilege​(java.lang.String clusterPrivilegeName)  
      int hashCode()  
      boolean hasIndexPrivilege​(java.lang.String indexName, java.lang.String privilegeName)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HasPrivilegesResponse

        public HasPrivilegesResponse​(java.lang.String username,
                                     boolean hasAllRequested,
                                     java.util.Map<java.lang.String,​java.lang.Boolean> clusterPrivileges,
                                     java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>> indexPrivileges,
                                     java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>>> applicationPrivileges)
    • Method Detail

      • getUsername

        public java.lang.String getUsername()
        The username (principal) of the user for which the privileges check was executed.
      • hasAllRequested

        public boolean hasAllRequested()
        true if the user has every privilege that was checked. Otherwise false.
      • hasClusterPrivilege

        public boolean hasClusterPrivilege​(java.lang.String clusterPrivilegeName)
                                    throws java.lang.IllegalArgumentException
        Parameters:
        clusterPrivilegeName - The name of a cluster privilege. This privilege must have been specified (verbatim) in the cluster privileges of the request.
        Returns:
        true if the user has the specified cluster privilege. false if the privilege was checked but it has not been granted to the user.
        Throws:
        java.lang.IllegalArgumentException - if the response did not include a value for the specified privilege name. The response only includes values for privileges that were included in the request.
      • hasIndexPrivilege

        public boolean hasIndexPrivilege​(java.lang.String indexName,
                                         java.lang.String privilegeName)
        Parameters:
        indexName - The name of the index to check. This index must have been specified (verbatim) in the requested index privileges.
        privilegeName - The name of the index privilege to check. This privilege must have been specified (verbatim), for the given index, in the requested index privileges.
        Returns:
        true if the user has the specified privilege on the specified index. false if the privilege was checked for that index and was not granted to the user.
        Throws:
        java.lang.IllegalArgumentException - if the response did not include a value for the specified index and privilege name pair. The response only includes values for indices and privileges that were included in the request.
      • hasApplicationPrivilege

        public boolean hasApplicationPrivilege​(java.lang.String applicationName,
                                               java.lang.String resourceName,
                                               java.lang.String privilegeName)
        Parameters:
        applicationName - The name of the application to check. This application must have been specified (verbatim) in the requested application privileges.
        resourceName - The name of the resource to check. This resource must have been specified (verbatim), for the given application in the requested application privileges.
        privilegeName - The name of the privilege to check. This privilege must have been specified (verbatim), for the given application and resource, in the requested application privileges.
        Returns:
        true if the user has the specified privilege on the specified resource in the specified application. false if the privilege was checked for that application and resource, but was not granted to the user.
        Throws:
        java.lang.IllegalArgumentException - if the response did not include a value for the specified application, resource and privilege triplet. The response only includes values for applications, resources and privileges that were included in the request.
      • getClusterPrivileges

        public java.util.Map<java.lang.String,​java.lang.Boolean> getClusterPrivileges()
        A Map from cluster-privilege-name to access. Each requested privilege is included as a key in the map, and the associated value indicates whether the user was granted that privilege.

        The hasClusterPrivilege(java.lang.String) method should be used in preference to directly accessing this map.

      • getIndexPrivileges

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>> getIndexPrivileges()
        A Map from index-name + privilege-name to access. Each requested index is a key in the outer map. Each requested privilege is a key in the inner map. The inner most Boolean value indicates whether the user was granted that privilege on that index.

        The hasIndexPrivilege(java.lang.String, java.lang.String) method should be used in preference to directly accessing this map.

      • getApplicationPrivileges

        public java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.Boolean>>> getApplicationPrivileges()
        A Map from application-name + resource-name + privilege-name to access. Each requested application is a key in the outer-most map. Each requested resource is a key in the next-level map. The requested privileges form the keys in the inner-most map. The Boolean value indicates whether the user was granted that privilege on that resource within that application.

        The hasApplicationPrivilege(java.lang.String, java.lang.String, java.lang.String) method should be used in preference to directly accessing this map.

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object