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


Java Authenticator类代码示例

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


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

示例1: generateToken

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public static synchronized Token generateToken(String srvUrl, String princ,
                                               String passwd) {
    AuthenticatedURL.Token newToken = new AuthenticatedURL.Token();
    Authenticator authenticator = new PseudoAuthenticator(princ);
    try {
        String spec = MessageFormat.format(
                "/webhdfs/v1/?op=GETHOMEDIRECTORY&user.name={0}", princ);
        HttpURLConnection conn = new AuthenticatedURL(authenticator)
                .openConnection(new URL(new URL(srvUrl), spec), newToken);

        conn.connect();
        conn.disconnect();
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        logger.error("[" + princ + ":" + passwd + "]@" + srvUrl, ex);
    }

    return newToken;
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:20,代码来源:PseudoWebHDFSConnection.java

示例2: generateToken

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public static synchronized Token generateToken(String srvUrl, String princ,
		String passwd) {
	AuthenticatedURL.Token newToken = new AuthenticatedURL.Token();
	Authenticator authenticator = new PseudoAuthenticator2(princ);
	try {

		String spec = MessageFormat.format(
				"/webhdfs/v1/?op=GETHOMEDIRECTORY&user.name={0}", princ);
		HttpURLConnection conn = new AuthenticatedURL(authenticator)
				.openConnection(new URL(new URL(srvUrl), spec), newToken);

		conn.connect();

		conn.disconnect();

	} catch (Exception ex) {
		logger.error(ex.getMessage());
		logger.error("[" + princ + ":" + passwd + "]@" + srvUrl, ex);
		// WARN
		// throws MalformedURLException, IOException,
		// AuthenticationException, InterruptedException
	}

	return newToken;
}
 
开发者ID:BT-OpenSource,项目名称:Skool,代码行数:26,代码来源:PseudoHTTPFSConnection.java

示例3: getConnection

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
/**
 * Convenience method that creates a <code>HttpURLConnection</code> for the specified URL.
 * <p/>
 * This methods performs and injects any needed authentication credentials.
 *
 * @param url url to connect to.
 * @param method the HTTP method.
 *
 * @return a <code>HttpURLConnection</code> for the HttpFSServer server, authenticated and ready to use for
 *         the specified path and file system operation.
 *
 * @throws IOException thrown if an IO error occurrs.
 */
private HttpURLConnection getConnection(URL url, String method) throws IOException {
  Class<? extends Authenticator> klass =
    getConf().getClass("httpfs.authenticator.class",
                       HttpFSKerberosAuthenticator.class, Authenticator.class);
  Authenticator authenticator = ReflectionUtils.newInstance(klass, getConf());
  try {
    HttpURLConnection conn = new AuthenticatedURL(authenticator).openConnection(url, authToken);
    conn.setRequestMethod(method);
    if (method.equals(HTTP_POST) || method.equals(HTTP_PUT)) {
      conn.setDoOutput(true);
    }
    return conn;
  } catch (Exception ex) {
    throw new IOException(ex);
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:30,代码来源:HttpFSFileSystem.java

示例4: getConnection

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
/**
 * Convenience method that creates a <code>HttpURLConnection</code> for the
 * specified URL.
 * <p/>
 * This methods performs and injects any needed authentication credentials.
 *
 * @param url
 *     url to connect to.
 * @param method
 *     the HTTP method.
 * @return a <code>HttpURLConnection</code> for the HttpFSServer server,
 * authenticated and ready to use for
 * the specified path and file system operation.
 * @throws IOException
 *     thrown if an IO error occurrs.
 */
private HttpURLConnection getConnection(URL url, String method)
    throws IOException {
  Class<? extends Authenticator> klass = getConf()
      .getClass("httpfs.authenticator.class",
          HttpFSKerberosAuthenticator.class, Authenticator.class);
  Authenticator authenticator = ReflectionUtils.newInstance(klass, getConf());
  try {
    HttpURLConnection conn =
        new AuthenticatedURL(authenticator).openConnection(url, authToken);
    conn.setRequestMethod(method);
    if (method.equals(HTTP_POST) || method.equals(HTTP_PUT)) {
      conn.setDoOutput(true);
    }
    return conn;
  } catch (Exception ex) {
    throw new IOException(ex);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:35,代码来源:HttpFSFileSystem.java

示例5: KerberosDelegationTokenAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:KerberosDelegationTokenAuthenticator.java

示例6: getFallBackAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
@Override
protected Authenticator getFallBackAuthenticator() {
  return new PseudoAuthenticator() {
    @Override
    protected String getUserName() {
      try {
        return UserGroupInformation.getLoginUser().getUserName();
      } catch (IOException e) {
        throw new SecurityException("Failed to obtain current username", e);
      }
    }
  };
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:KerberosUgiAuthenticator.java

示例7: generateToken

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public static synchronized Token generateToken(String srvUrl, String princ, String passwd,
                                               AuthenticationType authenticationType) {
    AuthenticatedURL.Token newToken = new AuthenticatedURL.Token();

    Authenticator authenticator = null;
    String spec;
    if (authenticationType == AuthenticationType.KERBEROS) {
        authenticator = new KerberosAuthenticator2(princ,passwd);
        spec = "/webhdfs/v1/?op=GETHOMEDIRECTORY";
    } else {
        authenticator = new PseudoAuthenticator2(princ);
        spec = MessageFormat.format("/webhdfs/v1/?op=GETHOMEDIRECTORY&user.name={0}", princ);
    }
    try {
        HttpURLConnection conn = new AuthenticatedURL(authenticator).openConnection(new URL(new URL(srvUrl), spec), newToken);
        conn.connect();
        conn.disconnect();
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        logger.error("[" + princ + ":" + passwd + "]@" + srvUrl, ex);
        // WARN
        // throws  IOException,
        // AuthenticationException, InterruptedException
    }

    return newToken;
}
 
开发者ID:sivasamyk,项目名称:graylog-plugin-output-webhdfs,代码行数:28,代码来源:WebHDFSConnection.java

示例8: getTokenAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
private static Authenticator getTokenAuthenticator() throws TezException {
  String authenticatorClazzName;

  if (UserGroupInformation.isSecurityEnabled()) {
    authenticatorClazzName = KERBEROS_DELEGATION_TOKEN_AUTHENTICATOR_CLAZZ_NAME;
  } else {
    authenticatorClazzName = PSEUDO_DELEGATION_TOKEN_AUTHENTICATOR_CLAZZ_NAME;
  }

  return ReflectionUtils.createClazzInstance(authenticatorClazzName);
}
 
开发者ID:apache,项目名称:tez,代码行数:12,代码来源:TimelineReaderFactory.java

示例9: TokenAuthenticatedURLConnectionFactory

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public TokenAuthenticatedURLConnectionFactory(ConnectionConfigurator connConfigurator,
                                              Authenticator authenticator,
                                              UserGroupInformation authUgi,
                                              String doAsUser) throws TezException {
  this.connConfigurator = connConfigurator;
  this.authenticator = authenticator;
  this.authUgi = authUgi;
  this.doAsUser = doAsUser;
  this.token = ReflectionUtils.createClazzInstance(
      DELEGATION_TOKEN_AUTHENTICATED_URL_TOKEN_CLASS_NAME, null, null);
}
 
开发者ID:apache,项目名称:tez,代码行数:12,代码来源:TimelineReaderFactory.java

示例10: DelegationTokenAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:DelegationTokenAuthenticator.java

示例11: getFallBackAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
/**
 * If the specified URL does not support SPNEGO authentication, a fallback
 * {@link Authenticator} will be used.
 * <p/>
 * This implementation returns a {@link PseudoAuthenticator}.
 *
 * @return the fallback {@link Authenticator}.
 */
protected Authenticator getFallBackAuthenticator() {
    return new PseudoAuthenticator();
}
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:12,代码来源:KerberosAuthenticator2.java

示例12: getFallBackAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
/**
 * If the specified URL does not support SPNEGO authentication, a fallback
 * {@link Authenticator} will be used.
 * <p/>
 * This implementation returns a {@link PseudoAuthenticator}.
 * 
 * @return the fallback {@link Authenticator}.
 */
protected Authenticator getFallBackAuthenticator() {
	return new PseudoAuthenticator();
}
 
开发者ID:BT-OpenSource,项目名称:Skool,代码行数:12,代码来源:KerberosAuthenticator2.java

示例13: getFallBackAuthenticator

import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
/**
 * Returns the fallback authenticator if the server does not use
 * Kerberos SPNEGO HTTP authentication.
 *
 * @return a {@link HttpFSPseudoAuthenticator} instance.
 */
@Override
protected Authenticator getFallBackAuthenticator() {
  return new HttpFSPseudoAuthenticator();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:11,代码来源:HttpFSKerberosAuthenticator.java


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