Package org.apache.accumulo.core.client.security.tokens

Examples of org.apache.accumulo.core.client.security.tokens.AuthenticationToken


    table = conf.get(Property.TRACE_TABLE);
    Connector connector = null;
    while (true) {
      try {
        String principal = conf.get(Property.TRACE_USER);
        AuthenticationToken at;
        Map<String,String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
        if (loginMap.isEmpty()) {
          Property p = Property.TRACE_PASSWORD;
          at = new PasswordToken(conf.get(p).getBytes(Constants.UTF8));
        } else {
          Properties props = new Properties();
          AuthenticationToken token = AccumuloVFSClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class)
              .newInstance();

          int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length();
          for (Entry<String,String> entry : loginMap.entrySet()) {
            props.put(entry.getKey().substring(prefixLength), entry.getValue());
          }

          token.init(props);

          at = token;
        }

        connector = serverConfiguration.getInstance().getConnector(principal, at);
View Full Code Here


          throw new IOException(e);
        }
      }

      try {
        AuthenticationToken token =  new PasswordToken(password);
        if (mock == null || !mock.equals("true")) {
          String instance = DataStoreFactory.findProperty(properties, this, INSTANCE_NAME_PROPERTY, null);
          String zookeepers = DataStoreFactory.findProperty(properties, this, ZOOKEEPERS_NAME_PROPERTY, null);
          credentials = new TCredentials(user,
              "org.apache.accumulo.core.client.security.tokens.PasswordToken",
View Full Code Here

  }
 
  protected Scanner getScanner(StringBuilder sb) throws AccumuloException, AccumuloSecurityException {
    AccumuloConfiguration conf = Monitor.getSystemConfiguration();
    String principal = conf.get(Property.TRACE_USER);
    AuthenticationToken at;
    Map<String,String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
    if (loginMap.isEmpty()) {
      Property p = Property.TRACE_PASSWORD;
      at = new PasswordToken(conf.get(p).getBytes());
    } else {
      Properties props = new Properties();
      int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length() + 1;
      for (Entry<String,String> entry : loginMap.entrySet()) {
        props.put(entry.getKey().substring(prefixLength), entry.getValue());
      }
     
      AuthenticationToken token;
      try {
        token = AccumuloClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class).newInstance();
      } catch (Exception e) {
        throw new AccumuloException(e);
      }
     
      token.init(props);
      at = token;
    }
   
    String table = conf.get(Property.TRACE_TABLE);
    try {
View Full Code Here

    Authorizations auths = getScanAuthorizations(job);
    String principal = getPrincipal(job);
    String tokenClass = getTokenClass(job);
    byte[] tokenBytes = getToken(job);

    AuthenticationToken token;
    try {
      token = CredentialHelper.extractToken(tokenClass, tokenBytes);
    } catch (AccumuloSecurityException e) {
      throw new IOException(e);
    }
View Full Code Here

    Authorizations auths = getScanAuthorizations(context);
    String principal = getPrincipal(context);
    String tokenClass = getTokenClass(context);
    byte[] tokenBytes = getToken(context);

    AuthenticationToken token;
    try {
      token = CredentialHelper.extractToken(tokenClass, tokenBytes);
    } catch (AccumuloSecurityException e) {
      throw new IOException(e);
    }
View Full Code Here

      String principal = split.getPrincipal();
      if (null == principal) {
        principal = getPrincipal(job);
      }

      AuthenticationToken token = split.getToken();
      if (null == token) {
        String tokenClass = getTokenClass(job);
        byte[] tokenBytes = getToken(job);
        try {
          token = CredentialHelper.extractToken(tokenClass, tokenBytes);
        } catch (AccumuloSecurityException e) {
          throw new IOException(e);
        }
      }

      Authorizations authorizations = split.getAuths();
      if (null == authorizations) {
        authorizations = getScanAuthorizations(job);
      }

      String table = split.getTable();
      if (null == table) {
        table = getInputTableName(job);
      }

      Boolean isOffline = split.isOffline();
      if (null == isOffline) {
        isOffline = isOfflineScan(job);
      }

      Boolean isIsolated = split.isIsolatedScan();
      if (null == isIsolated) {
        isIsolated = isIsolated(job);
      }

      Boolean usesLocalIterators = split.usesLocalIterators();
      if (null == usesLocalIterators) {
        usesLocalIterators = usesLocalIterators(job);
      }

      List<IteratorSetting> iterators = split.getIterators();
      if (null == iterators) {
        iterators = getIterators(job);
      }

      Set<Pair<Text,Text>> columns = split.getFetchedColumns();
      if (null == columns) {
        columns = getFetchedColumns(job);
      }

      try {
        log.debug("Creating connector with user: " + principal);
        Connector conn = instance.getConnector(principal, token);
        log.debug("Creating scanner for table: " + table);
        log.debug("Authorizations are: " + authorizations);
        if (isOffline) {
          String tokenClass = token.getClass().getCanonicalName();
          ByteBuffer tokenBuffer = ByteBuffer.wrap(CredentialHelper.toBytes(token));
          scanner = new OfflineScanner(instance, new TCredentials(principal, tokenClass, tokenBuffer, instance.getInstanceID()), Tables.getTableId(instance,
              table), authorizations);
        } else {
          scanner = conn.createScanner(table, authorizations);
View Full Code Here

    else if (credentials.getPrincipal().equals(SecurityConstants.SYSTEM_PRINCIPAL)) {
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
    }

    try {
      AuthenticationToken token = reassembleToken(credentials);
      if (!authenticator.authenticateUser(credentials.getPrincipal(), token)) {
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
      }
    } catch (AccumuloSecurityException e) {
      log.debug(e);
View Full Code Here

    canAskAboutUser(credentials, toAuth.getPrincipal());
    // User is already authenticated from canAskAboutUser, this gets around issues with !SYSTEM user
    if (credentials.equals(toAuth))
      return true;
    try {
      AuthenticationToken token = reassembleToken(toAuth);
      return authenticator.authenticateUser(toAuth.getPrincipal(), token);
    } catch (AccumuloSecurityException e) {
      throw e.asThriftException();
    }
  }
View Full Code Here

  public void changePassword(TCredentials credentials, TCredentials toChange) throws ThriftSecurityException {
    if (!canChangePassword(credentials, toChange.getPrincipal()))
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
      AuthenticationToken token = reassembleToken(toChange);
      authenticator.changePassword(toChange.getPrincipal(), token);
      log.info("Changed password for user " + toChange.getPrincipal() + " at the request of user " + credentials.getPrincipal());
    } catch (AccumuloSecurityException e) {
      throw e.asThriftException();
    }
View Full Code Here

  public void createUser(TCredentials credentials, TCredentials newUser, Authorizations authorizations) throws ThriftSecurityException {
    if (!canCreateUser(credentials, newUser.getPrincipal()))
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
      AuthenticationToken token = reassembleToken(newUser);
      authenticator.createUser(newUser.getPrincipal(), token);
      authorizor.initUser(newUser.getPrincipal());
      permHandle.initUser(newUser.getPrincipal());
      log.info("Created user " + newUser.getPrincipal() + " at the request of user " + credentials.getPrincipal());
      if (canChangeAuthorizations(credentials, newUser.getPrincipal()))
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.security.tokens.AuthenticationToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.