Search in sources :

Example 1 with AuthenticationFilter

use of org.apache.hadoop.security.authentication.server.AuthenticationFilter in project hive by apache.

the class HttpServer method setupSpnegoFilter.

/**
   * Secure the web server with kerberos (AuthenticationFilter).
   */
void setupSpnegoFilter(Builder b) throws IOException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("kerberos.principal", SecurityUtil.getServerPrincipal(b.spnegoPrincipal, b.host));
    params.put("kerberos.keytab", b.spnegoKeytab);
    params.put(AuthenticationFilter.AUTH_TYPE, "kerberos");
    FilterHolder holder = new FilterHolder();
    holder.setClassName(AuthenticationFilter.class.getName());
    holder.setInitParameters(params);
    ServletHandler handler = webAppContext.getServletHandler();
    handler.addFilterWithMapping(holder, "/*", FilterMapping.ALL);
}
Also used : ServletHandler(org.eclipse.jetty.servlet.ServletHandler) FilterHolder(org.eclipse.jetty.servlet.FilterHolder) HashMap(java.util.HashMap) AuthenticationFilter(org.apache.hadoop.security.authentication.server.AuthenticationFilter)

Example 2 with AuthenticationFilter

use of org.apache.hadoop.security.authentication.server.AuthenticationFilter in project lucene-solr by apache.

the class HadoopAuthPlugin method init.

@Override
public void init(Map<String, Object> pluginConfig) {
    try {
        String delegationTokenEnabled = (String) pluginConfig.getOrDefault(DELEGATION_TOKEN_ENABLED_PROPERTY, "false");
        authFilter = (Boolean.parseBoolean(delegationTokenEnabled)) ? new HadoopAuthFilter() : new AuthenticationFilter();
        // Initialize kerberos before initializing curator instance.
        boolean initKerberosZk = Boolean.parseBoolean((String) pluginConfig.getOrDefault(INIT_KERBEROS_ZK, "false"));
        if (initKerberosZk) {
            (new Krb5HttpClientBuilder()).getBuilder();
        }
        FilterConfig conf = getInitFilterConfig(pluginConfig);
        authFilter.init(conf);
    } catch (ServletException e) {
        throw new SolrException(ErrorCode.SERVER_ERROR, "Error initializing " + getClass().getName() + ": " + e);
    }
}
Also used : ServletException(javax.servlet.ServletException) AuthenticationFilter(org.apache.hadoop.security.authentication.server.AuthenticationFilter) FilterConfig(javax.servlet.FilterConfig) SolrException(org.apache.solr.common.SolrException) Krb5HttpClientBuilder(org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder)

Aggregations

AuthenticationFilter (org.apache.hadoop.security.authentication.server.AuthenticationFilter)2 HashMap (java.util.HashMap)1 FilterConfig (javax.servlet.FilterConfig)1 ServletException (javax.servlet.ServletException)1 Krb5HttpClientBuilder (org.apache.solr.client.solrj.impl.Krb5HttpClientBuilder)1 SolrException (org.apache.solr.common.SolrException)1 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)1 ServletHandler (org.eclipse.jetty.servlet.ServletHandler)1