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


Java AuthMethod.SIMPLE属性代码示例

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


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

示例1: getUserInfoPB

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();
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:18,代码来源:HBaseClient.java

示例2: SecureConnection

public SecureConnection(ConnectionId remoteId) throws IOException {
  super(remoteId);
  this.server = remoteId.getAddress();

  User ticket = remoteId.getTicket();
  Class<?> protocol = remoteId.getProtocol();
  this.useSasl = userProvider.isHBaseSecurityEnabled();
  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.getUGI().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;
  }

  header = new SecureConnectionHeader(
      protocol == null ? null : protocol.getName(), ticket, authMethod);

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

  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:52,代码来源:SecureClient.java

示例3: setupIOstreams

@Override
protected synchronized void setupIOstreams()
    throws IOException, InterruptedException {
  if (socket != null || shouldCloseConnection.get()) {
    return;
  }

  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Connecting to "+server);
    }
    short numRetries = 0;
    final short MAX_RETRIES = 5;
    Random rand = null;
    while (true) {
      setupConnection();
      InputStream inStream = NetUtils.getInputStream(socket);
      OutputStream outStream = NetUtils.getOutputStream(socket, pingInterval);
      writeRpcHeader(outStream);
      if (useSasl) {
        final InputStream in2 = inStream;
        final OutputStream out2 = outStream;
        User ticket = remoteId.getTicket();
        if (authMethod == AuthMethod.KERBEROS) {
          UserGroupInformation ugi = ticket.getUGI();
          if (ugi != null && ugi.getRealUser() != null) {
            ticket = userProvider.create(ugi.getRealUser());
          }
        }
        boolean continueSasl = false;
        try {
          continueSasl =
            ticket.runAs(new PrivilegedExceptionAction<Boolean>() {
              @Override
              public Boolean run() throws IOException {
                return setupSaslConnection(in2, out2);
              }
            });
        } catch (Exception ex) {
          if (rand == null) {
            rand = new Random();
          }
          handleSaslConnectionFailure(numRetries++, MAX_RETRIES, ex, rand,
               ticket);
          continue;
        }
        if (continueSasl) {
          // Sasl connect is successful. Let's set up Sasl i/o streams.
          inStream = saslRpcClient.getInputStream(inStream);
          outStream = saslRpcClient.getOutputStream(outStream);
        } else {
          // fall back to simple auth because server told us so.
          authMethod = AuthMethod.SIMPLE;
          header = new SecureConnectionHeader(header.getProtocol(),
              header.getUser(), authMethod);
          useSasl = false;
        }
      }
      this.in = new DataInputStream(new BufferedInputStream
          (new PingInputStream(inStream)));
      this.out = new DataOutputStream
      (new BufferedOutputStream(outStream));
      writeHeader();

      // update last activity time
      touch();

      // start the receiver thread after the socket connection has been set up
      start();
      return;
    }
  } catch (IOException e) {
    markClosed(e);
    close();

    throw e;
  }
}
 
开发者ID:wanhao,项目名称:IRIndex,代码行数:78,代码来源:SecureClient.java

示例4: SecureConnection

public SecureConnection(ConnectionId remoteId) throws IOException {
  super(remoteId);
  this.server = remoteId.getAddress();

  User ticket = remoteId.getTicket();
  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.getUGI().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;
  }

  header = new SecureConnectionHeader(
      protocol == null ? null : protocol.getName(), ticket, authMethod);

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

  reloginMaxBackoff = conf.getInt("hbase.security.relogin.maxbackoff", 5000);
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:52,代码来源:SecureClient.java

示例5: setupIOstreams

@Override
protected synchronized void setupIOstreams()
    throws IOException, InterruptedException {
  if (socket != null || shouldCloseConnection.get()) {
    return;
  }

  try {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Connecting to "+server);
    }
    short numRetries = 0;
    final short MAX_RETRIES = 5;
    Random rand = null;
    while (true) {
      setupConnection();
      InputStream inStream = NetUtils.getInputStream(socket);
      OutputStream outStream = NetUtils.getOutputStream(socket);
      writeRpcHeader(outStream);
      if (useSasl) {
        final InputStream in2 = inStream;
        final OutputStream out2 = outStream;
        User ticket = remoteId.getTicket();
        if (authMethod == AuthMethod.KERBEROS) {
          UserGroupInformation ugi = ticket.getUGI();
          if (ugi != null && ugi.getRealUser() != null) {
            ticket = User.create(ugi.getRealUser());
          }
        }
        boolean continueSasl = false;
        try {
          continueSasl =
            ticket.runAs(new PrivilegedExceptionAction<Boolean>() {
              @Override
              public Boolean run() throws IOException {
                return setupSaslConnection(in2, out2);
              }
            });
        } catch (Exception ex) {
          if (rand == null) {
            rand = new Random();
          }
          handleSaslConnectionFailure(numRetries++, MAX_RETRIES, ex, rand,
               ticket);
          continue;
        }
        if (continueSasl) {
          // Sasl connect is successful. Let's set up Sasl i/o streams.
          inStream = saslRpcClient.getInputStream(inStream);
          outStream = saslRpcClient.getOutputStream(outStream);
        } else {
          // fall back to simple auth because server told us so.
          authMethod = AuthMethod.SIMPLE;
          header = new SecureConnectionHeader(header.getProtocol(),
              header.getUser(), authMethod);
          useSasl = false;
        }
      }
      this.in = new DataInputStream(new BufferedInputStream
          (new PingInputStream(inStream)));
      this.out = new DataOutputStream
      (new BufferedOutputStream(outStream));
      writeHeader();

      // update last activity time
      touch();

      // start the receiver thread after the socket connection has been set up
      start();
      return;
    }
  } catch (IOException e) {
    markClosed(e);
    close();

    throw e;
  }
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:78,代码来源:SecureClient.java

示例6: Connection

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);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:67,代码来源:HBaseClient.java


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