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

项目: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;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目: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;
}
项目:DominoHBase    文件:HBaseServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException when the client isn't authorized to talk the protocol
 */
public void authorize(UserGroupInformation user,
                      ConnectionHeader connection,
                      InetAddress addr
                      ) throws AuthorizationException {
  if (authorize) {
    Class<?> protocol = null;
    try {
      protocol = getProtocolClass(connection.getProtocol(), getConf());
    } catch (ClassNotFoundException cfne) {
      throw new AuthorizationException("Unknown protocol: " +
                                       connection.getProtocol());
    }
    authManager.authorize(user != null ? user : null,
      protocol, getConf(), addr);
  }
}
项目:pbase    文件:RpcServer.java   
private void processConnectionHeader(byte[] buf) throws IOException {
  this.connectionHeader = ConnectionHeader.parseFrom(buf);
  String serviceName = connectionHeader.getServiceName();
  if (serviceName == null) throw new EmptyServiceNameException();
  this.service = getService(services, serviceName);
  if (this.service == null) throw new UnknownServiceException(serviceName);
  setupCellBlockCodecs(this.connectionHeader);
  UserGroupInformation protocolUser = createUser(connectionHeader);
  if (!useSasl) {
    user = protocolUser;
    if (user != null) {
      user.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessDeniedException("Authenticated user (" + user
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        user.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
}
项目:HIndex    文件:RpcServer.java   
private void processConnectionHeader(byte[] buf) throws IOException {
  this.connectionHeader = ConnectionHeader.parseFrom(buf);
  String serviceName = connectionHeader.getServiceName();
  if (serviceName == null) throw new EmptyServiceNameException();
  this.service = getService(services, serviceName);
  if (this.service == null) throw new UnknownServiceException(serviceName);
  setupCellBlockCodecs(this.connectionHeader);
  UserGroupInformation protocolUser = createUser(connectionHeader);
  if (!useSasl) {
    user = protocolUser;
    if (user != null) {
      user.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessControlException("Authenticated user (" + user
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        user.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
}
项目:HIndex    文件:RpcServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException when the client isn't authorized to talk the protocol
 */
@SuppressWarnings("static-access")
public void authorize(UserGroupInformation user, ConnectionHeader connection, InetAddress addr)
throws AuthorizationException {
  if (authorize) {
    Class<?> c = getServiceInterface(services, connection.getServiceName());
    this.authManager.authorize(user != null ? user : null, c, getConf(), addr);
  }
}
项目:PyroDB    文件:RpcServer.java   
private void processConnectionHeader(byte[] buf) throws IOException {
  this.connectionHeader = ConnectionHeader.parseFrom(buf);
  String serviceName = connectionHeader.getServiceName();
  if (serviceName == null) throw new EmptyServiceNameException();
  this.service = getService(services, serviceName);
  if (this.service == null) throw new UnknownServiceException(serviceName);
  setupCellBlockCodecs(this.connectionHeader);
  UserGroupInformation protocolUser = createUser(connectionHeader);
  if (!useSasl) {
    user = protocolUser;
    if (user != null) {
      user.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessControlException("Authenticated user (" + user
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        user.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
}
项目:c5    文件:RpcServer.java   
private void processConnectionHeader(byte[] buf) throws IOException {
  this.connectionHeader = ConnectionHeader.parseFrom(buf);
  String serviceName = connectionHeader.getServiceName();
  if (serviceName == null) throw new EmptyServiceNameException();
  this.service = getService(services, serviceName);
  if (this.service == null) throw new UnknownServiceException(serviceName);
  setupCellBlockCodecs(this.connectionHeader);
  UserGroupInformation protocolUser = createUser(connectionHeader);
  if (!useSasl) {
    user = protocolUser;
    if (user != null) {
      user.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessControlException("Authenticated user (" + user
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        user.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
}
项目:c5    文件:RpcServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException when the client isn't authorized to talk the protocol
 */
@SuppressWarnings("static-access")
public void authorize(UserGroupInformation user, ConnectionHeader connection, InetAddress addr)
throws AuthorizationException {
  if (authorize) {
    Class<?> c = getServiceInterface(services, connection.getServiceName());
    this.authManager.authorize(user != null ? user : null, c, getConf(), addr);
  }
}
项目:ditb    文件:RpcServer.java   
private void processConnectionHeader(byte[] buf) throws IOException {
  this.connectionHeader = ConnectionHeader.parseFrom(buf);
  String serviceName = connectionHeader.getServiceName();
  if (serviceName == null) throw new EmptyServiceNameException();
  this.service = getService(services, serviceName);
  if (this.service == null) throw new UnknownServiceException(serviceName);
  setupCellBlockCodecs(this.connectionHeader);
  UserGroupInformation protocolUser = createUser(connectionHeader);
  if (!useSasl) {
    ugi = protocolUser;
    if (ugi != null) {
      ugi.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
    // audit logging for SASL authenticated users happens in saslReadAndProcess()
    if (authenticatedWithFallback) {
      LOG.warn("Allowed fallback to SIMPLE auth for " + ugi
          + " connecting from " + getHostAddress());
    }
    AUDITLOG.info(AUTH_SUCCESSFUL_FOR + ugi);
  } else {
    // user is authenticated
    ugi.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(ugi.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessDeniedException("Authenticated user (" + ugi
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = ugi;
        ugi = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        ugi.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
  if (connectionHeader.hasVersionInfo()) {
    // see if this connection will support RetryImmediatelyException
    retryImmediatelySupported = VersionInfoUtil.hasMinimumVersion(getVersionInfo(), 1, 2);

    AUDITLOG.info("Connection from " + this.hostAddress + " port: " + this.remotePort
        + " with version info: "
        + TextFormat.shortDebugString(connectionHeader.getVersionInfo()));
  } else {
    AUDITLOG.info("Connection from " + this.hostAddress + " port: " + this.remotePort
        + " with unknown version info");
  }


}
项目: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);
}
项目:DominoHBase    文件:HBaseServer.java   
private void processHeader(byte[] buf) throws IOException {
  DataInputStream in =
    new DataInputStream(new ByteArrayInputStream(buf));
  header = ConnectionHeader.parseFrom(in);
  try {
    String protocolClassName = header.getProtocol();
    if (protocolClassName != null) {
      protocol = getProtocolClass(header.getProtocol(), conf);
    }
  } catch (ClassNotFoundException cnfe) {
    throw new IOException("Unknown protocol: " + header.getProtocol());
  }

  UserGroupInformation protocolUser = createUser(header);
  if (!useSasl) {
    user = protocolUser;
    if (user != null) {
      user.setAuthenticationMethod(AuthMethod.SIMPLE.authenticationMethod);
    }
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod.authenticationMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However,
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.DIGEST) {
        // Not allowed to doAs if token authentication is used
        throw new AccessControlException("Authenticated user (" + user
            + ") doesn't match what the client claims to be ("
            + protocolUser + ")");
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
        // Now the user is a proxy user, set Authentication method Proxy.
        user.setAuthenticationMethod(AuthenticationMethod.PROXY);
      }
    }
  }
}
项目:ditb    文件:RpcServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException
 *         when the client isn't authorized to talk the protocol
 */
public synchronized void authorize(UserGroupInformation user, ConnectionHeader connection,
    InetAddress addr)
throws AuthorizationException {
  if (authorize) {
    Class<?> c = getServiceInterface(services, connection.getServiceName());
    this.authManager.authorize(user != null ? user : null, c, getConf(), addr);
  }
}
项目:pbase    文件:RpcServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException when the client isn't authorized to talk the protocol
 */
public void authorize(UserGroupInformation user, ConnectionHeader connection, InetAddress addr)
throws AuthorizationException {
  if (authorize) {
    Class<?> c = getServiceInterface(services, connection.getServiceName());
    this.authManager.authorize(user != null ? user : null, c, getConf(), addr);
  }
}
项目:PyroDB    文件:RpcServer.java   
/**
 * Authorize the incoming client connection.
 *
 * @param user client user
 * @param connection incoming connection
 * @param addr InetAddress of incoming connection
 * @throws org.apache.hadoop.security.authorize.AuthorizationException when the client isn't authorized to talk the protocol
 */
public void authorize(UserGroupInformation user, ConnectionHeader connection, InetAddress addr)
throws AuthorizationException {
  if (authorize) {
    Class<?> c = getServiceInterface(services, connection.getServiceName());
    this.authManager.authorize(user != null ? user : null, c, getConf(), addr);
  }
}