Search in sources :

Example 1 with AuthFilter

use of org.apache.hadoop.hbase.rest.filter.AuthFilter in project hbase by apache.

the class RESTServer method loginServerPrincipal.

// login the server principal (if using secure Hadoop)
private static Pair<FilterHolder, Class<? extends ServletContainer>> loginServerPrincipal(UserProvider userProvider, Configuration conf) throws Exception {
    Class<? extends ServletContainer> containerClass = ServletContainer.class;
    if (userProvider.isHadoopSecurityEnabled() && userProvider.isHBaseSecurityEnabled()) {
        String machineName = Strings.domainNamePointerToHostName(DNS.getDefaultHost(conf.get(REST_DNS_INTERFACE, "default"), conf.get(REST_DNS_NAMESERVER, "default")));
        String keytabFilename = conf.get(REST_KEYTAB_FILE);
        Preconditions.checkArgument(keytabFilename != null && !keytabFilename.isEmpty(), REST_KEYTAB_FILE + " should be set if security is enabled");
        String principalConfig = conf.get(REST_KERBEROS_PRINCIPAL);
        Preconditions.checkArgument(principalConfig != null && !principalConfig.isEmpty(), REST_KERBEROS_PRINCIPAL + " should be set if security is enabled");
        userProvider.login(REST_KEYTAB_FILE, REST_KERBEROS_PRINCIPAL, machineName);
        if (conf.get(REST_AUTHENTICATION_TYPE) != null) {
            containerClass = RESTServletContainer.class;
            FilterHolder authFilter = new FilterHolder();
            authFilter.setClassName(AuthFilter.class.getName());
            authFilter.setName("AuthenticationFilter");
            return new Pair<>(authFilter, containerClass);
        }
    }
    return new Pair<>(null, containerClass);
}
Also used : FilterHolder(org.eclipse.jetty.servlet.FilterHolder) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) AuthFilter(org.apache.hadoop.hbase.rest.filter.AuthFilter) Pair(org.apache.hadoop.hbase.util.Pair)

Aggregations

AuthFilter (org.apache.hadoop.hbase.rest.filter.AuthFilter)1 Pair (org.apache.hadoop.hbase.util.Pair)1 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)1 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)1