Java 类org.apache.hadoop.hbase.protobuf.generated.RPCProtos.UserInformation 实例源码

项目:ditb    文件:RpcServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:ditb    文件:RpcClientImpl.java   
private synchronized UserInformation getUserInfo(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:pbase    文件:RpcServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:pbase    文件:RpcClientImpl.java   
private UserInformation getUserInfo(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:HIndex    文件:RpcServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:HIndex    文件:RpcClient.java   
private UserInformation getUserInfo(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:PyroDB    文件:RpcServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:PyroDB    文件:RpcClient.java   
private UserInformation getUserInfo(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:c5    文件:RpcServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:c5    文件:RpcClient.java   
private UserInformation getUserInfo(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:DominoHBase    文件:HBaseClient.java   
private UserInformation getUserInfoPB(UserGroupInformation ugi) {
  if (ugi == null || authMethod == AuthMethod.DIGEST) {
    // Don't send user for token auth
    return null;
  }
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  if (authMethod == AuthMethod.KERBEROS) {
    // Send effective user for Kerberos auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
  } else if (authMethod == AuthMethod.SIMPLE) {
    //Send both effective user and real user for simple auth
    userInfoPB.setEffectiveUser(ugi.getUserName());
    if (ugi.getRealUser() != null) {
      userInfoPB.setRealUser(ugi.getRealUser().getUserName());
    }
  }
  return userInfoPB.build();
}
项目:DominoHBase    文件:HBaseServer.java   
private UserGroupInformation createUser(ConnectionHeader head) {
  UserGroupInformation ugi = null;

  if (!head.hasUserInfo()) {
    return null;
  }
  UserInformation userInfoProto = head.getUserInfo();
  String effectiveUser = null;
  if (userInfoProto.hasEffectiveUser()) {
    effectiveUser = userInfoProto.getEffectiveUser();
  }
  String realUser = null;
  if (userInfoProto.hasRealUser()) {
    realUser = userInfoProto.getRealUser();
  }
  if (effectiveUser != null) {
    if (realUser != null) {
      UserGroupInformation realUserUgi =
          UserGroupInformation.createRemoteUser(realUser);
      ugi = UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    } else {
      ugi = UserGroupInformation.createRemoteUser(effectiveUser);
    }
  }
  return ugi;
}
项目:ditb    文件:MasterProcedureUtil.java   
public static UserInformation toProtoUserInfo(UserGroupInformation ugi) {
  UserInformation.Builder userInfoPB = UserInformation.newBuilder();
  userInfoPB.setEffectiveUser(ugi.getUserName());
  if (ugi.getRealUser() != null) {
    userInfoPB.setRealUser(ugi.getRealUser().getUserName());
  }
  return userInfoPB.build();
}
项目:ditb    文件:MasterProcedureUtil.java   
public static UserGroupInformation toUserInfo(UserInformation userInfoProto) {
  if (userInfoProto.hasEffectiveUser()) {
    String effectiveUser = userInfoProto.getEffectiveUser();
    if (userInfoProto.hasRealUser()) {
      String realUser = userInfoProto.getRealUser();
      UserGroupInformation realUserUgi = UserGroupInformation.createRemoteUser(realUser);
      return UserGroupInformation.createProxyUser(effectiveUser, realUserUgi);
    }
    return UserGroupInformation.createRemoteUser(effectiveUser);
  }
  return null;
}
项目:ditb    文件:RpcClientImpl.java   
Connection(ConnectionId remoteId, final Codec codec, final CompressionCodec compressor)
throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " + remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();
  this.codec = codec;
  this.compressor = compressor;

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  SecurityInfo securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  if (useSasl && securityInfo != null) {
    AuthenticationProtos.TokenIdentifier.Kind tokenKind = securityInfo.getTokenKind();
    if (tokenKind != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenKind);
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenKind);
      }
    }
    String serverKey = securityInfo.getServerPrincipal();
    if (serverKey == null) {
      throw new IOException(
          "Can't obtain server Kerberos config key from SecurityInfo");
    }
    serverPrincipal = SecurityUtil.getServerPrincipal(
        conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
    if (LOG.isDebugEnabled()) {
      LOG.debug("RPC Server Kerberos principal name for service="
          + remoteId.getServiceName() + " is " + serverPrincipal);
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Use " + authMethod + " authentication for service " + remoteId.serviceName +
      ", sasl=" + useSasl);
  }
  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setServiceName(remoteId.getServiceName());
  UserInformation userInfoPB = getUserInfo(ticket);
  if (userInfoPB != null) {
    builder.setUserInfo(userInfoPB);
  }
  if (this.codec != null) {
    builder.setCellBlockCodecClass(this.codec.getClass().getCanonicalName());
  }
  if (this.compressor != null) {
    builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
  }
  builder.setVersionInfo(ProtobufUtil.getVersionInfo());
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from "
    + ticket.getUserName())));
  this.setDaemon(true);

  if (conf.getBoolean(SPECIFIC_WRITE_THREAD, false)) {
    callSender = new CallSender(getName(), conf);
    callSender.start();
  } else {
    callSender = null;
  }
}
项目:pbase    文件:RpcClientImpl.java   
Connection(ConnectionId remoteId, final Codec codec, final CompressionCodec compressor)
throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " + remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();
  this.codec = codec;
  this.compressor = compressor;

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  SecurityInfo securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  if (useSasl && securityInfo != null) {
    AuthenticationProtos.TokenIdentifier.Kind tokenKind = securityInfo.getTokenKind();
    if (tokenKind != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenKind);
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenKind);
      }
    }
    String serverKey = securityInfo.getServerPrincipal();
    if (serverKey == null) {
      throw new IOException(
          "Can't obtain server Kerberos config key from SecurityInfo");
    }
    serverPrincipal = SecurityUtil.getServerPrincipal(
        conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
    if (LOG.isDebugEnabled()) {
      LOG.debug("RPC Server Kerberos principal name for service="
          + remoteId.getServiceName() + " is " + serverPrincipal);
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Use " + authMethod + " authentication for service " + remoteId.serviceName +
      ", sasl=" + useSasl);
  }
  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setServiceName(remoteId.getServiceName());
  UserInformation userInfoPB = getUserInfo(ticket);
  if (userInfoPB != null) {
    builder.setUserInfo(userInfoPB);
  }
  if (this.codec != null) {
    builder.setCellBlockCodecClass(this.codec.getClass().getCanonicalName());
  }
  if (this.compressor != null) {
    builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
  }
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from "
    + ticket.getUserName())));
  this.setDaemon(true);

  if (conf.getBoolean(SPECIFIC_WRITE_THREAD, false)) {
    callSender = new CallSender(getName(), conf);
    callSender.start();
  } else {
    callSender = null;
  }
}
项目:HIndex    文件:RpcClient.java   
Connection(ConnectionId remoteId, final Codec codec, final CompressionCodec compressor)
throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " + remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();
  this.codec = codec;
  this.compressor = compressor;

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  SecurityInfo securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  if (useSasl && securityInfo != null) {
    AuthenticationProtos.TokenIdentifier.Kind tokenKind = securityInfo.getTokenKind();
    if (tokenKind != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenKind);
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenKind);
      }
    }
    String serverKey = securityInfo.getServerPrincipal();
    if (serverKey == null) {
      throw new IOException(
          "Can't obtain server Kerberos config key from SecurityInfo");
    }
    serverPrincipal = SecurityUtil.getServerPrincipal(
        conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
    if (LOG.isDebugEnabled()) {
      LOG.debug("RPC Server Kerberos principal name for service="
          + remoteId.getServiceName() + " is " + serverPrincipal);
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Use " + authMethod + " authentication for service " + remoteId.serviceName +
      ", sasl=" + useSasl);
  }
  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setServiceName(remoteId.getServiceName());
  UserInformation userInfoPB;
  if ((userInfoPB = getUserInfo(ticket)) != null) {
    builder.setUserInfo(userInfoPB);
  }
  if (this.codec != null) {
    builder.setCellBlockCodecClass(this.codec.getClass().getCanonicalName());
  }
  if (this.compressor != null) {
    builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
  }
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from "
    + ticket.getUserName())));
  this.setDaemon(true);
}
项目:PyroDB    文件:RpcClient.java   
Connection(ConnectionId remoteId, final Codec codec, final CompressionCodec compressor)
throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " + remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();
  this.codec = codec;
  this.compressor = compressor;

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  SecurityInfo securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  if (useSasl && securityInfo != null) {
    AuthenticationProtos.TokenIdentifier.Kind tokenKind = securityInfo.getTokenKind();
    if (tokenKind != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenKind);
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenKind);
      }
    }
    String serverKey = securityInfo.getServerPrincipal();
    if (serverKey == null) {
      throw new IOException(
          "Can't obtain server Kerberos config key from SecurityInfo");
    }
    serverPrincipal = SecurityUtil.getServerPrincipal(
        conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
    if (LOG.isDebugEnabled()) {
      LOG.debug("RPC Server Kerberos principal name for service="
          + remoteId.getServiceName() + " is " + serverPrincipal);
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Use " + authMethod + " authentication for service " + remoteId.serviceName +
      ", sasl=" + useSasl);
  }
  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setServiceName(remoteId.getServiceName());
  UserInformation userInfoPB;
  if ((userInfoPB = getUserInfo(ticket)) != null) {
    builder.setUserInfo(userInfoPB);
  }
  if (this.codec != null) {
    builder.setCellBlockCodecClass(this.codec.getClass().getCanonicalName());
  }
  if (this.compressor != null) {
    builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
  }
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from "
    + ticket.getUserName())));
  this.setDaemon(true);

  if (conf.getBoolean(ALLOWS_INTERRUPTS, false)) {
    callSender = new CallSender(getName(), conf);
    callSender.start();
  } else {
    callSender = null;
  }
}
项目:c5    文件:RpcClient.java   
Connection(ConnectionId remoteId, final Codec codec, final CompressionCodec compressor)
throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " + remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();
  this.codec = codec;
  this.compressor = compressor;

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  SecurityInfo securityInfo = SecurityInfo.getInfo(remoteId.getServiceName());
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  if (useSasl && securityInfo != null) {
    AuthenticationProtos.TokenIdentifier.Kind tokenKind = securityInfo.getTokenKind();
    if (tokenKind != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenKind);
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenKind);
      }
    }
    String serverKey = securityInfo.getServerPrincipal();
    if (serverKey == null) {
      throw new IOException(
          "Can't obtain server Kerberos config key from SecurityInfo");
    }
    serverPrincipal = SecurityUtil.getServerPrincipal(
        conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
    if (LOG.isDebugEnabled()) {
      LOG.debug("RPC Server Kerberos principal name for service="
          + remoteId.getServiceName() + " is " + serverPrincipal);
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled()) {
    LOG.debug("Use " + authMethod + " authentication for service " + remoteId.serviceName +
      ", sasl=" + useSasl);
  }
  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setServiceName(remoteId.getServiceName());
  UserInformation userInfoPB;
  if ((userInfoPB = getUserInfo(ticket)) != null) {
    builder.setUserInfo(userInfoPB);
  }
  if (this.codec != null) {
    builder.setCellBlockCodecClass(this.codec.getClass().getCanonicalName());
  }
  if (this.compressor != null) {
    builder.setCellBlockCompressorClass(this.compressor.getClass().getCanonicalName());
  }
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from "
    + ticket.getUserName())));
  this.setDaemon(true);
}
项目:DominoHBase    文件:HBaseClient.java   
Connection(ConnectionId remoteId) throws IOException {
  if (remoteId.getAddress().isUnresolved()) {
    throw new UnknownHostException("unknown host: " +
                                   remoteId.getAddress().getHostName());
  }
  this.server = remoteId.getAddress();

  UserGroupInformation ticket = remoteId.getTicket().getUGI();
  Class<?> protocol = remoteId.getProtocol();
  this.useSasl = User.isHBaseSecurityEnabled(conf);
  if (useSasl && protocol != null) {
    TokenInfo tokenInfo = protocol.getAnnotation(TokenInfo.class);
    if (tokenInfo != null) {
      TokenSelector<? extends TokenIdentifier> tokenSelector =
          tokenHandlers.get(tokenInfo.value());
      if (tokenSelector != null) {
        token = tokenSelector.selectToken(new Text(clusterId),
            ticket.getTokens());
      } else if (LOG.isDebugEnabled()) {
        LOG.debug("No token selector found for type "+tokenInfo.value());
      }
    }
    KerberosInfo krbInfo = protocol.getAnnotation(KerberosInfo.class);
    if (krbInfo != null) {
      String serverKey = krbInfo.serverPrincipal();
      if (serverKey == null) {
        throw new IOException(
            "Can't obtain server Kerberos config key from KerberosInfo");
      }
      serverPrincipal = SecurityUtil.getServerPrincipal(
          conf.get(serverKey), server.getAddress().getCanonicalHostName().toLowerCase());
      if (LOG.isDebugEnabled()) {
        LOG.debug("RPC Server Kerberos principal name for protocol="
            + protocol.getCanonicalName() + " is " + serverPrincipal);
      }
    }
  }

  if (!useSasl) {
    authMethod = AuthMethod.SIMPLE;
  } else if (token != null) {
    authMethod = AuthMethod.DIGEST;
  } else {
    authMethod = AuthMethod.KERBEROS;
  }

  if (LOG.isDebugEnabled())
    LOG.debug("Use " + authMethod + " authentication for protocol "
        + protocol.getSimpleName());

  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
  this.remoteId = remoteId;

  ConnectionHeader.Builder builder = ConnectionHeader.newBuilder();
  builder.setProtocol(protocol == null ? "" : protocol.getName());
  UserInformation userInfoPB;
  if ((userInfoPB = getUserInfoPB(ticket)) != null) {
    builder.setUserInfo(userInfoPB);
  }
  this.header = builder.build();

  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
    remoteId.getAddress().toString() +
    ((ticket==null)?" from an unknown user": (" from " 
    + ticket.getUserName())));
  this.setDaemon(true);
}