本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例5: KerberosDelegationTokenAuthenticator
import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public KerberosDelegationTokenAuthenticator() {
super(new KerberosAuthenticator() {
@Override
protected Authenticator getFallBackAuthenticator() {
return new PseudoDelegationTokenAuthenticator();
}
});
}
示例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);
}
}
};
}
示例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;
}
示例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);
}
示例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);
}
示例10: DelegationTokenAuthenticator
import org.apache.hadoop.security.authentication.client.Authenticator; //导入依赖的package包/类
public DelegationTokenAuthenticator(Authenticator authenticator) {
this.authenticator = authenticator;
}
示例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();
}
示例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();
}
示例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();
}