Java 类org.apache.hadoop.security.authentication.client.Authenticator 实例源码

项目:Transwarp-Sample-Code    文件:PseudoWebHDFSConnection.java   
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;
}
项目:Skool    文件:PseudoHTTPFSConnection.java   
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;
}
项目:hadoop-plus    文件:HttpFSFileSystem.java   
/**
 * 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);
  }
}
项目:hops    文件:HttpFSFileSystem.java   
/**
 * 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);
  }
}
项目:hadoop-TCP    文件:HttpFSFileSystem.java   
/**
 * 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);
  }
}
项目:hardfs    文件:HttpFSFileSystem.java   
/**
 * 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);
  }
}
项目:hadoop-on-lustre2    文件:HttpFSFileSystem.java   
/**
 * 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);
  }
}
项目:hadoop-oss    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:hadoop    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hadoop    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:aliyun-oss-hadoop-fs    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:aliyun-oss-hadoop-fs    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:big-c    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:big-c    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:hadoop-2.6.0-cdh5.4.3    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hadoop-2.6.0-cdh5.4.3    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:graylog-plugin-output-webhdfs    文件:WebHDFSConnection.java   
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;
}
项目:hadoop-plus    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:FlexMap    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hops    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hops    文件:KerberosDelegationTokenAuthenticator.java   
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
项目:hadoop-TCP    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hadoop-on-lustre    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hardfs    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hadoop-on-lustre2    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:tez    文件:TimelineReaderFactory.java   
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);
}
项目:tez    文件:TimelineReaderFactory.java   
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);
}
项目:hortonworks-extension    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hortonworks-extension    文件:KerberosUgiAuthenticator.java   
@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);
      }
    }
  };
}
项目:hadoop-oss    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:hadoop    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:aliyun-oss-hadoop-fs    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:big-c    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:hops    文件:DelegationTokenAuthenticator.java   
public DelegationTokenAuthenticator(Authenticator authenticator) {
  this.authenticator = authenticator;
}
项目:Transwarp-Sample-Code    文件:KerberosAuthenticator2.java   
/**
 * 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();
}
项目:Skool    文件:KerberosAuthenticator2.java   
/**
 * 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();
}
项目:hadoop-plus    文件:HttpFSKerberosAuthenticator.java   
/**
 * 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();
}
项目:hops    文件:HttpFSKerberosAuthenticator.java   
/**
 * 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();
}
项目:hadoop-TCP    文件:HttpFSKerberosAuthenticator.java   
/**
 * 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();
}