当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationFilter类代码示例

本文整理汇总了Java中org.apache.hadoop.security.authentication.server.AuthenticationFilter的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationFilter类的具体用法?Java AuthenticationFilter怎么用?Java AuthenticationFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationFilter类属于org.apache.hadoop.security.authentication.server包,在下文中一共展示了AuthenticationFilter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initSpnego

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
private void initSpnego(Configuration conf, String hostName,
    String usernameConfKey, String keytabConfKey) throws IOException {
  Map<String, String> params = new HashMap<>();
  String principalInConf = conf.get(usernameConfKey);
  if (principalInConf != null && !principalInConf.isEmpty()) {
    params.put("kerberos.principal", SecurityUtil.getServerPrincipal(
        principalInConf, hostName));
  }
  String httpKeytab = conf.get(keytabConfKey);
  if (httpKeytab != null && !httpKeytab.isEmpty()) {
    params.put("kerberos.keytab", httpKeytab);
  }
  params.put(AuthenticationFilter.AUTH_TYPE, "kerberos");

  defineFilter(webAppContext, SPNEGO_FILTER,
               AuthenticationFilter.class.getName(), params, null);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:HttpServer2.java

示例2: getConfiguration

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
@Override
protected Properties getConfiguration(String configPrefix,
    FilterConfig filterConfig) throws ServletException {
  Properties props = new Properties();
  Enumeration<?> names = filterConfig.getInitParameterNames();
  while (names.hasMoreElements()) {
    String name = (String) names.nextElement();
    if (name.startsWith(configPrefix)) {
      String value = filterConfig.getInitParameter(name);
      props.put(name.substring(configPrefix.length()), value);
    }
  }
  props.put(AuthenticationFilter.AUTH_TYPE, "simple");
  props.put(PseudoAuthenticationHandler.ANONYMOUS_ALLOWED, "false");
  return props;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestRMWebServicesAppsModification.java

示例3: getFilterConfigMap

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
public static Map<String, String> getFilterConfigMap(Configuration conf,
    String prefix) {
  Map<String, String> filterConfig = new HashMap<String, String>();

  //setting the cookie path to root '/' so it is used for all resources.
  filterConfig.put(AuthenticationFilter.COOKIE_PATH, "/");

  for (Map.Entry<String, String> entry : conf) {
    String name = entry.getKey();
    if (name.startsWith(prefix)) {
      String value = conf.get(name);
      name = name.substring(prefix.length());
      filterConfig.put(name, value);
    }
  }

  //Resolve _HOST into bind address
  String bindAddress = conf.get(HttpServer2.BIND_ADDRESS);
  String principal = filterConfig.get(KerberosAuthenticationHandler.PRINCIPAL);
  if (principal != null) {
    try {
      principal = SecurityUtil.getServerPrincipal(principal, bindAddress);
    }
    catch (IOException ex) {
      throw new RuntimeException("Could not resolve Kerberos principal name: " + ex.toString(), ex);
    }
    filterConfig.put(KerberosAuthenticationHandler.PRINCIPAL, principal);
  }
  return filterConfig;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:31,代码来源:AuthenticationFilterInitializer.java

示例4: initSpnego

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
protected void initSpnego(Configuration conf,
    String usernameConfKey, String keytabConfKey) throws IOException {
  Map<String, String> params = new HashMap<String, String>();
  String principalInConf = conf.get(usernameConfKey);
  if (principalInConf != null && !principalInConf.isEmpty()) {
    params.put("kerberos.principal",
               SecurityUtil.getServerPrincipal(principalInConf, listener.getHost()));
  }
  String httpKeytab = conf.get(keytabConfKey);
  if (httpKeytab != null && !httpKeytab.isEmpty()) {
    params.put("kerberos.keytab", httpKeytab);
  }
  params.put(AuthenticationFilter.AUTH_TYPE, "kerberos");

  defineFilter(webAppContext, SPNEGO_FILTER,
               AuthenticationFilter.class.getName(), params, null);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:HttpServer.java

示例5: testGetSecrets

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
@Test
public void testGetSecrets() throws Exception {
  File testDir = new File(System.getProperty("test.build.data",
      "target/test-dir"));
  testDir.mkdirs();
  String secretValue = "hadoop";
  File secretFile = new File(testDir, "http-secret.txt");
  Writer writer = new FileWriter(secretFile);
  writer.write(secretValue);
  writer.close();

  FileSignerSecretProvider secretProvider
          = new FileSignerSecretProvider();
  Properties secretProviderProps = new Properties();
  secretProviderProps.setProperty(
          AuthenticationFilter.SIGNATURE_SECRET_FILE,
      secretFile.getAbsolutePath());
  secretProvider.init(secretProviderProps, null, -1);
  Assert.assertArrayEquals(secretValue.getBytes(),
      secretProvider.getCurrentSecret());
  byte[][] allSecrets = secretProvider.getAllSecrets();
  Assert.assertEquals(1, allSecrets.length);
  Assert.assertArrayEquals(secretValue.getBytes(), allSecrets[0]);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestFileSignerSecretProvider.java

示例6: initSpnego

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
private void initSpnego(Configuration conf, String hostName,
    String usernameConfKey, String keytabConfKey) throws IOException {
  Map<String, String> params = new HashMap<String, String>();
  String principalInConf = conf.get(usernameConfKey);
  if (principalInConf != null && !principalInConf.isEmpty()) {
    params.put("kerberos.principal", SecurityUtil.getServerPrincipal(
        principalInConf, hostName));
  }
  String httpKeytab = conf.get(keytabConfKey);
  if (httpKeytab != null && !httpKeytab.isEmpty()) {
    params.put("kerberos.keytab", httpKeytab);
  }
  params.put(AuthenticationFilter.AUTH_TYPE, "kerberos");

  defineFilter(webAppContext, SPNEGO_FILTER,
               AuthenticationFilter.class.getName(), params, null);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:HttpServer.java

示例7: initializeSecretProvider

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
@Override
public void initializeSecretProvider(FilterConfig filterConfig)
        throws ServletException {
    LOG.debug("AtlasAuthenticationFilter :: initializeSecretProvider {}", filterConfig);
    secretProvider = (SignerSecretProvider) filterConfig.getServletContext().
            getAttribute(AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE);
    if (secretProvider == null) {
        // As tomcat cannot specify the provider object in the configuration.
        // It'll go into this path
        String configPrefix = filterConfig.getInitParameter(CONFIG_PREFIX);
        configPrefix = (configPrefix != null) ? configPrefix + "." : "";
        try {
            secretProvider = AuthenticationFilter.constructSecretProvider(
                    filterConfig.getServletContext(),
                    super.getConfiguration(configPrefix, filterConfig), false);
            this.isInitializedByTomcat = true;
        } catch (Exception ex) {
            throw new ServletException(ex);
        }
    }
    signer = new Signer(secretProvider);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:23,代码来源:AtlasAuthenticationFilter.java

示例8: initFilter

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
/**
 * Initializes Alfredo AuthenticationFilter.
 * <p/>
 * Propagates to Alfredo AuthenticationFilter configuration all Hadoop
 * configuration properties prefixed with "hadoop.http.authentication."
 *
 * @param container The filter container
 * @param conf Configuration for run-time parameters
 */
@Override
public void initFilter(FilterContainer container, Configuration conf) {
  Map<String, String> filterConfig = new HashMap<String, String>();

  //setting the cookie path to root '/' so it is used for all resources.
  filterConfig.put(AuthenticationFilter.COOKIE_PATH, "/");

  for (Map.Entry<String, String> entry : conf) {
    String name = entry.getKey();
    if (name.startsWith(PREFIX)) {
      String value = conf.get(name);
      name = name.substring(PREFIX.length());
      filterConfig.put(name, value);
    }
  }

  container.addFilter("authentication",
                      AuthenticationFilter.class.getName(),
                      filterConfig);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:30,代码来源:AuthenticationFilterInitializer.java

示例9: loadWebAuthenticationConf

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
private static Map<String, String> loadWebAuthenticationConf(Configuration conf) {
  Map<String,String> prop = new HashMap<String, String>();
  prop.put(AuthenticationFilter.CONFIG_PREFIX, ServerConfig.SENTRY_WEB_SECURITY_PREFIX);
  String allowUsers = conf.get(ServerConfig.SENTRY_WEB_SECURITY_ALLOW_CONNECT_USERS);
  if (allowUsers == null || allowUsers.equals("")) {
    allowUsers = conf.get(ServerConfig.ALLOW_CONNECT);
    conf.set(ServerConfig.SENTRY_WEB_SECURITY_ALLOW_CONNECT_USERS, allowUsers);
  }
  validateConf(conf);
  for (Map.Entry<String, String> entry : conf) {
    String name = entry.getKey();
    if (name.startsWith(ServerConfig.SENTRY_WEB_SECURITY_PREFIX)) {
      String value = conf.get(name);
      prop.put(name, value);
    }
  }
  return prop;
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:19,代码来源:SentryWebServer.java

示例10: constructSecretProvider

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
private static SignerSecretProvider constructSecretProvider(final Builder b,
    ServletContext ctx)
    throws Exception {
  final Configuration conf = b.conf;
  Properties config = getFilterProperties(conf,
                                          b.authFilterConfigurationPrefix);
  return AuthenticationFilter.constructSecretProvider(
      ctx, config, b.disallowFallbackToRandomSignerSecretProvider);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:HttpServer2.java

示例11: doFilter

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response,
                     FilterChain chain) throws IOException,
                                               ServletException {
  HttpServletResponse resp = (HttpServletResponse) response;
  AuthenticationFilter.createAuthCookie(resp, "token", null, null, expires,
          isCookiePersistent, true);
  chain.doFilter(request, resp);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:TestAuthenticationSessionCookie.java

示例12: doFilter

import org.apache.hadoop.security.authentication.server.AuthenticationFilter; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response,
                     FilterChain chain) throws IOException,
                                               ServletException {
  HttpServletResponse resp = (HttpServletResponse) response;
  boolean isHttps = "https".equals(request.getScheme());
  AuthenticationFilter.createAuthCookie(resp, "token", null, null, -1,
          true, isHttps);
  chain.doFilter(request, resp);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:11,代码来源:TestHttpCookieFlag.java


注:本文中的org.apache.hadoop.security.authentication.server.AuthenticationFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。