Package org.apache.accumulo.core.security

Examples of org.apache.accumulo.core.security.Authorizations


      bw.addMutation(m);
    }
    bw.close();
   
    JobContext job = ContextFactory.createJobContext();
    ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D"));
    ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance1");
    ChunkInputFormat cif = new ChunkInputFormat();
    RangeInputSplit ris = new RangeInputSplit();
    TaskAttemptContext tac = ContextFactory.createTaskAttemptContext(job.getConfiguration());
    RecordReader<List<Entry<Key,Value>>,InputStream> rr = cif.createRecordReader(ris, tac);
View Full Code Here


      bw.addMutation(m);
    }
    bw.close();
   
    JobContext job = ContextFactory.createJobContext();
    ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D"));
    ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance2");
    ChunkInputFormat cif = new ChunkInputFormat();
    RangeInputSplit ris = new RangeInputSplit();
    TaskAttemptContext tac = ContextFactory.createTaskAttemptContext(job.getConfiguration());
    RecordReader<List<Entry<Key,Value>>,InputStream> crr = cif.createRecordReader(ris, tac);
View Full Code Here

      bw.addMutation(m);
    }
    bw.close();
   
    JobContext job = ContextFactory.createJobContext();
    ChunkInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations("A", "B", "C", "D"));
    ChunkInputFormat.setMockInstance(job.getConfiguration(), "instance3");
    ChunkInputFormat cif = new ChunkInputFormat();
    RangeInputSplit ris = new RangeInputSplit();
    TaskAttemptContext tac = ContextFactory.createTaskAttemptContext(job.getConfiguration());
    RecordReader<List<Entry<Key,Value>>,InputStream> crr = cif.createRecordReader(ris, tac);
View Full Code Here

    else {
      shellState.checkTableState();
      tableName = shellState.getTableName();
    }
   
    Authorizations auths = cl.hasOption(selectrowOptAuths.getOpt()) ? CreateUserCommand.parseAuthorizations(cl.getOptionValue(selectrowOptAuths.getOpt()))
        : Constants.NO_AUTHS;
    Scanner scanner = shellState.getConnector().createScanner(tableName.toString(), auths);
    scanner.setRange(new Range(new Text(cl.getArgs()[0])));
   
    // output the records
View Full Code Here

    @Override
    public InitialScan startScan(TInfo tinfo, AuthInfo credentials, TKeyExtent textent, TRange range, List<TColumn> columns, int batchSize,
        List<IterInfo> ssiList, Map<String,Map<String,String>> ssio, List<ByteBuffer> authorizations, boolean waitForWrites, boolean isolated)
        throws NotServingTabletException, ThriftSecurityException, org.apache.accumulo.core.tabletserver.thrift.TooManyFilesException {

      Authorizations userauths = null;

      try {
        if (!authenticator.hasTablePermission(credentials, credentials.user, new String(textent.getTable()), TablePermission.READ))
          throw new ThriftSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED);

        userauths = authenticator.getUserAuthorizations(credentials, credentials.user);
        for (ByteBuffer auth : authorizations)
          if (!userauths.contains(ByteBufferUtil.toBytes(auth)))
            throw new ThriftSecurityException(credentials.user, SecurityErrorCode.BAD_AUTHORIZATIONS);
      } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
      }

      scanCount.addAndGet(1);

      KeyExtent extent = new KeyExtent(textent);

      // wait for any writes that are in flight.. this done to ensure
      // consistency across client restarts... assume a client writes
      // to accumulo and dies while waiting for a confirmation from
      // accumulo... the client process restarts and tries to read
      // data from accumulo making the assumption that it will get
      // any writes previously made... however if the server side thread
      // processing the write from the dead client is still in progress,
      // the restarted client may not see the write unless we wait here.
      // this behavior is very important when the client is reading the
      // !METADATA table
      if (waitForWrites)
        writeTracker.waitForWrites(TabletType.type(extent));

      Tablet tablet = onlineTablets.get(extent);
      if (tablet == null)
        throw new NotServingTabletException(textent);

      ScanSession scanSession = new ScanSession();
      scanSession.user = credentials.user;
      scanSession.extent = new KeyExtent(extent);
      scanSession.columnSet = new HashSet<Column>();
      scanSession.ssiList = ssiList;
      scanSession.ssio = ssio;
      scanSession.interruptFlag = new AtomicBoolean();

      for (TColumn tcolumn : columns) {
        scanSession.columnSet.add(new Column(tcolumn));
      }

      scanSession.scanner = tablet.createScanner(new Range(range), batchSize, scanSession.columnSet, new Authorizations(authorizations), ssiList, ssio,
          isolated, scanSession.interruptFlag);

      long sid = sessionManager.createSession(scanSession, true);

      ScanResult scanResult;
View Full Code Here

      for (TKeyExtent keyExtent : tbatch.keySet()) {
        tables.add(new String(keyExtent.getTable()));
      }

      // check if user has permission to the tables
      Authorizations userauths = null;
      try {
        for (String table : tables)
          if (!authenticator.hasTablePermission(credentials, credentials.user, table, TablePermission.READ))
            throw new ThriftSecurityException(credentials.user, SecurityErrorCode.PERMISSION_DENIED);

        userauths = authenticator.getUserAuthorizations(credentials, credentials.user);
        for (ByteBuffer auth : authorizations)
          if (!userauths.contains(ByteBufferUtil.toBytes(auth)))
            throw new ThriftSecurityException(credentials.user, SecurityErrorCode.BAD_AUTHORIZATIONS);
      } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
      }

      KeyExtent threadPoolExtent = null;

      Map<KeyExtent,List<Range>> batch = Translator.translate(tbatch, Translators.TKET, new Translator.ListTranslator<TRange,Range>(Translators.TRT));

      for (KeyExtent keyExtent : batch.keySet()) {
        if (threadPoolExtent == null) {
          threadPoolExtent = keyExtent;
        } else if (keyExtent.equals(Constants.ROOT_TABLET_EXTENT)) {
          throw new IllegalArgumentException("Cannot batch query root tablet with other tablets " + threadPoolExtent + " " + keyExtent);
        } else if (keyExtent.getTableId().toString().equals(Constants.METADATA_TABLE_ID)
            && !threadPoolExtent.getTableId().toString().equals(Constants.METADATA_TABLE_ID)) {
          throw new IllegalArgumentException("Cannot batch query !METADATA and non !METADATA tablets " + threadPoolExtent + " " + keyExtent);
        }

      }

      if (waitForWrites)
        writeTracker.waitForWrites(TabletType.type(batch.keySet()));

      MultiScanSession mss = new MultiScanSession();
      mss.user = credentials.user;
      mss.queries = batch;
      mss.columnSet = new HashSet<Column>(tcolumns.size());
      mss.ssiList = ssiList;
      mss.ssio = ssio;
      mss.auths = new Authorizations(authorizations);

      mss.numTablets = batch.size();
      for (List<Range> ranges : batch.values()) {
        mss.numRanges += ranges.size();
      }
View Full Code Here

      tableName = shellState.getTableName();
    }
   
    // handle first argument, if present, the authorizations list to
    // scan with
    Authorizations auths = getAuths(cl, shellState);
    Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
   
    // handle session-specific scan iterators
    addScanIterators(shellState, scanner, tableName);
   
View Full Code Here

    }
  }
 
  protected Authorizations getAuths(CommandLine cl, Shell shellState) throws AccumuloSecurityException, AccumuloException {
    String user = shellState.getConnector().whoami();
    Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
    if (cl.hasOption(scanOptAuths.getOpt())) {
      auths = CreateUserCommand.parseAuthorizations(cl.getOptionValue(scanOptAuths.getOpt()));
    }
    return auths;
  }
View Full Code Here

    else {
      shellState.checkTableState();
      tableName = shellState.getTableName();
    }
   
    Authorizations authorizations = cl.hasOption(selectOptAuths.getOpt()) ? CreateUserCommand.parseAuthorizations(cl.getOptionValue(selectOptAuths.getOpt()))
        : Constants.NO_AUTHS;
    Scanner scanner = shellState.getConnector().createScanner(tableName.toString(), authorizations);
   
    Key key = new Key(new Text(cl.getArgs()[0]), new Text(cl.getArgs()[1]), new Text(cl.getArgs()[2]));
    scanner.setRange(new Range(key, key.followingKey(PartialKey.ROW_COLFAM_COLQUAL)));
View Full Code Here

    // Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
    // logger.setLevel(Level.TRACE);
   
    ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers);
    Connector connector = instance.getConnector(user, pass);
    BatchScanner tsbr = connector.createBatchScanner(table, new Authorizations(auths.split(",")), numThreads);
   
    Random r;
    if (seed == null)
      r = new Random();
    else
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.security.Authorizations

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.