Class AbstractApiAction

    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.elasticsearch.rest.BaseRestHandler

        org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer, org.elasticsearch.rest.BaseRestHandler.Wrapper
      • Nested classes/interfaces inherited from interface org.elasticsearch.rest.RestHandler

        org.elasticsearch.rest.RestHandler.Route
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Boolean acceptInvalidLicense  
      protected com.floragunn.searchguard.auditlog.AuditLog auditLog  
      protected com.floragunn.searchguard.configuration.ConfigurationRepository cl  
      protected org.elasticsearch.cluster.service.ClusterService cs  
      protected org.apache.logging.log4j.Logger log  
      protected org.elasticsearch.common.settings.Settings settings  
      protected com.floragunn.searchguard.sgconf.StaticSgConfig staticSgConfig  
      • Fields inherited from class org.elasticsearch.rest.BaseRestHandler

        DEFAULT_INCLUDE_TYPE_NAME_POLICY, INCLUDE_TYPE_NAME_PARAMETER, logger, MULTI_ALLOW_EXPLICIT_INDEX
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractApiAction​(org.elasticsearch.common.settings.Settings settings, Path configPath, org.elasticsearch.rest.RestController controller, org.elasticsearch.client.Client client, com.floragunn.searchguard.configuration.AdminDNs adminDNs, com.floragunn.searchguard.configuration.ConfigurationRepository cl, com.floragunn.searchguard.sgconf.StaticSgConfig staticSgConfig, org.elasticsearch.cluster.service.ClusterService cs, com.floragunn.searchguard.ssl.transport.PrincipalExtractor principalExtractor, com.floragunn.searchguard.privileges.PrivilegesEvaluator evaluator, com.floragunn.searchguard.privileges.SpecialPrivilegesEvaluationContextProviderRegistry specialPrivilegesEvaluationContextProviderRegistry, org.elasticsearch.threadpool.ThreadPool threadPool, com.floragunn.searchguard.auditlog.AuditLog auditLog)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void badRequestResponse​(org.elasticsearch.rest.RestChannel channel, AbstractConfigurationValidator validator)  
      protected void badRequestResponse​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected boolean checkConfigUpdateResponse​(com.floragunn.searchguard.action.configupdate.ConfigUpdateResponse response)  
      protected void consumeParameters​(org.elasticsearch.rest.RestRequest request)
      Consume all defined parameters for the request.
      protected static org.elasticsearch.xcontent.XContentBuilder convertToJson​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.xcontent.ToXContent toxContent)  
      protected void createdResponse​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected boolean ensureIndexExists()  
      protected void filter​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> builder)  
      protected void forbidden​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected abstract com.floragunn.searchguard.sgconf.impl.CType getConfigName()  
      protected abstract Endpoint getEndpoint()  
      String getName()  
      protected abstract String getResourceName()  
      protected abstract AbstractConfigurationValidator getValidator​(org.elasticsearch.rest.RestRequest request, org.elasticsearch.common.bytes.BytesReference ref, Object... params)  
      protected void handleApiRequest​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client)  
      protected void handleDelete​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client, com.fasterxml.jackson.databind.JsonNode content)  
      protected void handleGet​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client, com.fasterxml.jackson.databind.JsonNode content)  
      protected void handlePost​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client, com.fasterxml.jackson.databind.JsonNode content)  
      protected void handlePut​(String name, org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client, com.fasterxml.jackson.databind.JsonNode content)  
      protected void handlePut​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.Client client, com.fasterxml.jackson.databind.JsonNode content)  
      protected void internalErrorResponse​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected boolean isHidden​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration, String resourceName)  
      protected boolean isReserved​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration, String resourceName)  
      protected boolean isStatic​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration, String resourceName)  
      protected com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> load​(com.floragunn.searchguard.sgconf.impl.CType config, boolean logComplianceEvent)  
      protected void notFound​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected void notImplemented​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestRequest.Method method)  
      protected org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer prepareRequest​(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.node.NodeClient client)  
      protected void response​(org.elasticsearch.rest.RestChannel channel, org.elasticsearch.rest.RestStatus status, String message)  
      protected void saveAnUpdateConfigs​(org.elasticsearch.client.Client client, org.elasticsearch.rest.RestRequest request, com.floragunn.searchguard.sgconf.impl.CType cType, com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration, com.floragunn.searchguard.dlic.rest.api.AbstractApiAction.OnSucessActionListener<org.elasticsearch.action.index.IndexResponse> actionListener)  
      protected void successResponse​(org.elasticsearch.rest.RestChannel channel, com.floragunn.searchguard.action.licenseinfo.LicenseInfoResponse ur)  
      protected void successResponse​(org.elasticsearch.rest.RestChannel channel, com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> response)  
      protected void successResponse​(org.elasticsearch.rest.RestChannel channel, String message)  
      protected void unprocessable​(org.elasticsearch.rest.RestChannel channel, String message)  
      • Methods inherited from class org.elasticsearch.rest.BaseRestHandler

        getUsageCount, handleRequest, responseParams, routes, unrecognized
      • Methods inherited from interface org.elasticsearch.rest.RestHandler

        allowsUnsafeBuffers, allowSystemIndexAccessByDefault, canTripCircuitBreaker, getConcreteRestHandler, supportsContentStream
    • Field Detail

      • log

        protected final org.apache.logging.log4j.Logger log
      • cl

        protected final com.floragunn.searchguard.configuration.ConfigurationRepository cl
      • cs

        protected final org.elasticsearch.cluster.service.ClusterService cs
      • acceptInvalidLicense

        protected final Boolean acceptInvalidLicense
      • auditLog

        protected final com.floragunn.searchguard.auditlog.AuditLog auditLog
      • settings

        protected final org.elasticsearch.common.settings.Settings settings
      • staticSgConfig

        protected final com.floragunn.searchguard.sgconf.StaticSgConfig staticSgConfig
    • Constructor Detail

      • AbstractApiAction

        protected AbstractApiAction​(org.elasticsearch.common.settings.Settings settings,
                                    Path configPath,
                                    org.elasticsearch.rest.RestController controller,
                                    org.elasticsearch.client.Client client,
                                    com.floragunn.searchguard.configuration.AdminDNs adminDNs,
                                    com.floragunn.searchguard.configuration.ConfigurationRepository cl,
                                    com.floragunn.searchguard.sgconf.StaticSgConfig staticSgConfig,
                                    org.elasticsearch.cluster.service.ClusterService cs,
                                    com.floragunn.searchguard.ssl.transport.PrincipalExtractor principalExtractor,
                                    com.floragunn.searchguard.privileges.PrivilegesEvaluator evaluator,
                                    com.floragunn.searchguard.privileges.SpecialPrivilegesEvaluationContextProviderRegistry specialPrivilegesEvaluationContextProviderRegistry,
                                    org.elasticsearch.threadpool.ThreadPool threadPool,
                                    com.floragunn.searchguard.auditlog.AuditLog auditLog)
    • Method Detail

      • getValidator

        protected abstract AbstractConfigurationValidator getValidator​(org.elasticsearch.rest.RestRequest request,
                                                                       org.elasticsearch.common.bytes.BytesReference ref,
                                                                       Object... params)
      • getResourceName

        protected abstract String getResourceName()
      • getConfigName

        protected abstract com.floragunn.searchguard.sgconf.impl.CType getConfigName()
      • handleApiRequest

        protected void handleApiRequest​(org.elasticsearch.rest.RestChannel channel,
                                        org.elasticsearch.rest.RestRequest request,
                                        org.elasticsearch.client.Client client)
                                 throws IOException
        Throws:
        IOException
      • handleDelete

        protected void handleDelete​(org.elasticsearch.rest.RestChannel channel,
                                    org.elasticsearch.rest.RestRequest request,
                                    org.elasticsearch.client.Client client,
                                    com.fasterxml.jackson.databind.JsonNode content)
                             throws IOException
        Throws:
        IOException
      • handlePut

        protected void handlePut​(String name,
                                 org.elasticsearch.rest.RestChannel channel,
                                 org.elasticsearch.rest.RestRequest request,
                                 org.elasticsearch.client.Client client,
                                 com.fasterxml.jackson.databind.JsonNode content)
                          throws IOException
        Throws:
        IOException
      • handlePut

        protected void handlePut​(org.elasticsearch.rest.RestChannel channel,
                                 org.elasticsearch.rest.RestRequest request,
                                 org.elasticsearch.client.Client client,
                                 com.fasterxml.jackson.databind.JsonNode content)
                          throws IOException
        Throws:
        IOException
      • handlePost

        protected void handlePost​(org.elasticsearch.rest.RestChannel channel,
                                  org.elasticsearch.rest.RestRequest request,
                                  org.elasticsearch.client.Client client,
                                  com.fasterxml.jackson.databind.JsonNode content)
                           throws IOException
        Throws:
        IOException
      • handleGet

        protected void handleGet​(org.elasticsearch.rest.RestChannel channel,
                                 org.elasticsearch.rest.RestRequest request,
                                 org.elasticsearch.client.Client client,
                                 com.fasterxml.jackson.databind.JsonNode content)
                          throws IOException
        Throws:
        IOException
      • load

        protected final com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> load​(com.floragunn.searchguard.sgconf.impl.CType config,
                                                                                             boolean logComplianceEvent)
      • ensureIndexExists

        protected boolean ensureIndexExists()
      • filter

        protected void filter​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> builder)
      • saveAnUpdateConfigs

        protected void saveAnUpdateConfigs​(org.elasticsearch.client.Client client,
                                           org.elasticsearch.rest.RestRequest request,
                                           com.floragunn.searchguard.sgconf.impl.CType cType,
                                           com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration,
                                           com.floragunn.searchguard.dlic.rest.api.AbstractApiAction.OnSucessActionListener<org.elasticsearch.action.index.IndexResponse> actionListener)
      • prepareRequest

        protected final org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer prepareRequest​(org.elasticsearch.rest.RestRequest request,
                                                                                                  org.elasticsearch.client.node.NodeClient client)
                                                                                           throws IOException
        Specified by:
        prepareRequest in class org.elasticsearch.rest.BaseRestHandler
        Throws:
        IOException
      • checkConfigUpdateResponse

        protected boolean checkConfigUpdateResponse​(com.floragunn.searchguard.action.configupdate.ConfigUpdateResponse response)
      • convertToJson

        protected static org.elasticsearch.xcontent.XContentBuilder convertToJson​(org.elasticsearch.rest.RestChannel channel,
                                                                                  org.elasticsearch.xcontent.ToXContent toxContent)
      • response

        protected void response​(org.elasticsearch.rest.RestChannel channel,
                                org.elasticsearch.rest.RestStatus status,
                                String message)
      • successResponse

        protected void successResponse​(org.elasticsearch.rest.RestChannel channel,
                                       com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> response)
      • successResponse

        protected void successResponse​(org.elasticsearch.rest.RestChannel channel,
                                       com.floragunn.searchguard.action.licenseinfo.LicenseInfoResponse ur)
      • successResponse

        protected void successResponse​(org.elasticsearch.rest.RestChannel channel,
                                       String message)
      • createdResponse

        protected void createdResponse​(org.elasticsearch.rest.RestChannel channel,
                                       String message)
      • badRequestResponse

        protected void badRequestResponse​(org.elasticsearch.rest.RestChannel channel,
                                          String message)
      • notFound

        protected void notFound​(org.elasticsearch.rest.RestChannel channel,
                                String message)
      • forbidden

        protected void forbidden​(org.elasticsearch.rest.RestChannel channel,
                                 String message)
      • internalErrorResponse

        protected void internalErrorResponse​(org.elasticsearch.rest.RestChannel channel,
                                             String message)
      • unprocessable

        protected void unprocessable​(org.elasticsearch.rest.RestChannel channel,
                                     String message)
      • notImplemented

        protected void notImplemented​(org.elasticsearch.rest.RestChannel channel,
                                      org.elasticsearch.rest.RestRequest.Method method)
      • isReserved

        protected final boolean isReserved​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration,
                                           String resourceName)
      • isHidden

        protected final boolean isHidden​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration,
                                         String resourceName)
      • isStatic

        protected final boolean isStatic​(com.floragunn.searchguard.sgconf.impl.SgDynamicConfiguration<?> configuration,
                                         String resourceName)
      • consumeParameters

        protected void consumeParameters​(org.elasticsearch.rest.RestRequest request)
        Consume all defined parameters for the request. Before we handle the request in subclasses where we actually need the parameter, some global checks are performed, e.g. check whether the SG index exists. Thus, the parameter(s) have not been consumed, and ES will always return a 400 with an internal error message.
        Parameters:
        request -
      • getName

        public String getName()
        Specified by:
        getName in class org.elasticsearch.rest.BaseRestHandler
      • getEndpoint

        protected abstract Endpoint getEndpoint()