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


Java KerberosName.getShortName方法代码示例

本文整理汇总了Java中org.apache.hadoop.security.authentication.util.KerberosName.getShortName方法的典型用法代码示例。如果您正苦于以下问题:Java KerberosName.getShortName方法的具体用法?Java KerberosName.getShortName怎么用?Java KerberosName.getShortName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.security.authentication.util.KerberosName的用法示例。


在下文中一共展示了KerberosName.getShortName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkUsername

import org.apache.hadoop.security.authentication.util.KerberosName; //导入方法依赖的package包/类
/**
 * Expected user name should be a short name.
 */
public static void checkUsername(final String expected, final String name
    ) throws IOException {
  if (expected == null && name != null) {
    throw new IOException("Usernames not matched: expecting null but name="
        + name);
  }
  if (name == null) { //name is optional, null is okay
    return;
  }
  KerberosName u = new KerberosName(name);
  String shortName = u.getShortName();
  if (!shortName.equals(expected)) {
    throw new IOException("Usernames not matched: name=" + shortName
        + " != expected=" + expected);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:JspHelper.java

示例2: checkUsername

import org.apache.hadoop.security.authentication.util.KerberosName; //导入方法依赖的package包/类
/**
 * Expected user name should be a short name.
 */
private static void checkUsername(final String expected, final String name
    ) throws IOException {
  if (expected == null && name != null) {
    throw new IOException("Usernames not matched: expecting null but name="
        + name);
  }
  if (name == null) { //name is optional, null is okay
    return;
  }
  KerberosName u = new KerberosName(name);
  String shortName = u.getShortName();
  if (!shortName.equals(expected)) {
    throw new IOException("Usernames not matched: name=" + shortName
        + " != expected=" + expected);
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:20,代码来源:JspHelper.java

示例3: checkUsername

import org.apache.hadoop.security.authentication.util.KerberosName; //导入方法依赖的package包/类
/**
 * Expected user name should be a short name.
 */
private static void checkUsername(final String expected, final String name)
    throws IOException {
  if (expected == null && name != null) {
    throw new IOException(
        "Usernames not matched: expecting null but name=" + name);
  }
  if (name == null) { //name is optional, null is okay
    return;
  }
  KerberosName u = new KerberosName(name);
  String shortName = u.getShortName();
  if (!shortName.equals(expected)) {
    throw new IOException(
        "Usernames not matched: name=" + shortName + " != expected=" +
            expected);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:21,代码来源:JspHelper.java

示例4: runWithPrincipal

import org.apache.hadoop.security.authentication.util.KerberosName; //导入方法依赖的package包/类
private AuthenticationToken runWithPrincipal(String serverPrincipal,
    byte[] clientToken, Base64 base64, HttpServletResponse response) throws
    IOException, AuthenticationException, ClassNotFoundException,
    GSSException, IllegalAccessException, NoSuchFieldException {
  GSSContext gssContext = null;
  GSSCredential gssCreds = null;
  AuthenticationToken token = null;
  try {
    LOG.trace("SPNEGO initiated with server principal [{}]", serverPrincipal);
    gssCreds = this.gssManager.createCredential(
        this.gssManager.createName(serverPrincipal,
            KerberosUtil.getOidInstance("NT_GSS_KRB5_PRINCIPAL")),
        GSSCredential.INDEFINITE_LIFETIME,
        new Oid[]{
            KerberosUtil.getOidInstance("GSS_SPNEGO_MECH_OID"),
            KerberosUtil.getOidInstance("GSS_KRB5_MECH_OID")},
        GSSCredential.ACCEPT_ONLY);
    gssContext = this.gssManager.createContext(gssCreds);
    byte[] serverToken = gssContext.acceptSecContext(clientToken, 0,
        clientToken.length);
    if (serverToken != null && serverToken.length > 0) {
      String authenticate = base64.encodeToString(serverToken);
      response.setHeader(KerberosAuthenticator.WWW_AUTHENTICATE,
                         KerberosAuthenticator.NEGOTIATE + " " +
                         authenticate);
    }
    if (!gssContext.isEstablished()) {
      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      LOG.trace("SPNEGO in progress");
    } else {
      String clientPrincipal = gssContext.getSrcName().toString();
      KerberosName kerberosName = new KerberosName(clientPrincipal);
      String userName = kerberosName.getShortName();
      token = new AuthenticationToken(userName, clientPrincipal, getType());
      response.setStatus(HttpServletResponse.SC_OK);
      LOG.trace("SPNEGO completed for client principal [{}]",
          clientPrincipal);
    }
  } finally {
    if (gssContext != null) {
      gssContext.dispose();
    }
    if (gssCreds != null) {
      gssCreds.dispose();
    }
  }
  return token;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:49,代码来源:KerberosAuthenticationHandler.java


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