Package org.apache.accumulo.core.security

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


      expectations.put(Maps.immutableEntry("foo", "col2"), "val2");
      expectations.put(Maps.immutableEntry("bar", "col1"), "val1");
      expectations.put(Maps.immutableEntry("bar", "col2"), "val2");

      for (String table : Arrays.asList(newTable1, newTable2)) {
        Scanner s = connector.createScanner(table, new Authorizations());
        s.setRange(new Range());
        Map<Entry<String,String>,String> actual = new HashMap<Entry<String,String>,String>();
        for (Entry<Key,Value> entry : s) {
          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
        }
View Full Code Here


      expectations.put(Maps.immutableEntry("foo", "col2"), "val2");
      expectations.put(Maps.immutableEntry("bar", "col1"), "val1");
      expectations.put(Maps.immutableEntry("bar", "col2"), "val2");

      for (String table : Arrays.asList(newTable1, newTable2)) {
        Scanner s = connector.createScanner(table, new Authorizations());
        s.setRange(new Range());
        Map<Entry<String,String>,String> actual = new HashMap<Entry<String,String>,String>();
        for (Entry<Key,Value> entry : s) {
          actual.put(Maps.immutableEntry(entry.getKey().getRow().toString(), entry.getKey().getColumnFamily().toString()), entry.getValue().toString());
        }
View Full Code Here

    return false;
  }
 
  @Override
  public void initUser(String user) throws AccumuloSecurityException {
    changeAuthorizations(user, new Authorizations());
  }
View Full Code Here

   * @since 1.5.0
   * @see #setScanAuthorizations(Class, Configuration, Authorizations)
   */
  public static Authorizations getScanAuthorizations(Class<?> implementingClass, Configuration conf) {
    String authString = conf.get(enumToConfKey(implementingClass, ScanOpts.AUTHORIZATIONS));
    return authString == null ? Constants.NO_AUTHS : new Authorizations(authString.getBytes(Constants.UTF8));
  }
View Full Code Here

     
      fetchedColumns = InputFormatBase.deserializeFetchedColumns(columns);
    }
   
    if (in.readBoolean()) {
      auths = new Authorizations(StringUtils.split(in.readUTF()));
    }
   
    if (in.readBoolean()) {
      username = in.readUTF();
    }
View Full Code Here

    insertList(bw, row2);
    insertList(bw, row3);
    bw.close();
   
    JobContext job = ContextFactory.createJobContext();
    AccumuloRowInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "test", new Authorizations());
    AccumuloRowInputFormat.setMockInstance(job.getConfiguration(), "instance1");
    AccumuloRowInputFormat crif = new AccumuloRowInputFormat();
    RangeInputSplit ris = new RangeInputSplit();
    TaskAttemptContext tac = ContextFactory.createTaskAttemptContext(job);
    RecordReader<Text,PeekingIterator<Entry<Key,Value>>> rr = crif.createRecordReader(ris, tac);
View Full Code Here

    job.setMapperClass(TestMapper.class);
    job.setOutputFormatClass(AccumuloOutputFormat.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Mutation.class);
    job.setNumReduceTasks(0);
    AccumuloInputFormat.setInputInfo(job.getConfiguration(), "root", "".getBytes(), "testtable1", new Authorizations());
    AccumuloInputFormat.setMockInstance(job.getConfiguration(), "testmrinstance");
    AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), "root", "".getBytes(), false, "testtable2");
    AccumuloOutputFormat.setMockInstance(job.getConfiguration(), "testmrinstance");

    AccumuloInputFormat input = new AccumuloInputFormat();
    List<InputSplit> splits = input.getSplits(job);
    assertEquals(splits.size(), 1);

    AccumuloOutputFormat output = new AccumuloOutputFormat();

    TestMapper mapper = (TestMapper) job.getMapperClass().newInstance();
    for (InputSplit split : splits) {
      TaskAttemptContext tac = ContextFactory.createTaskAttemptContext(job);
      RecordReader<Key,Value> reader = input.createRecordReader(split, tac);
      RecordWriter<Text,Mutation> writer = output.getRecordWriter(tac);
      Mapper<Key,Value,Text,Mutation>.Context context = ContextFactory.createMapContext(mapper, tac, reader, writer, split);
      reader.initialize(split, context);
      mapper.run(context);
      writer.close(context);
    }

    Scanner scanner = c.createScanner("testtable2", new Authorizations());
    Iterator<Entry<Key,Value>> iter = scanner.iterator();
    assertTrue(iter.hasNext());
    Entry<Key,Value> entry = iter.next();
    assertEquals(Integer.parseInt(new String(entry.getValue().get())), 100);
    assertFalse(iter.hasNext());
View Full Code Here

    Set<Pair<Text,Text>> fetchedColumns = new HashSet<Pair<Text,Text>>();
   
    fetchedColumns.add(new Pair<Text,Text>(new Text("colf1"), new Text("colq1")));
    fetchedColumns.add(new Pair<Text,Text>(new Text("colf2"), new Text("colq2")));
   
    split.setAuths(new Authorizations("foo"));
    split.setOffline(true);
    split.setIsolatedScan(true);
    split.setUsesLocalIterators(true);
    split.setMaxVersions(5);
    split.setRowRegex("row");
View Full Code Here

    ColumnVisibility le1 = new ColumnVisibility("L1");
    ColumnVisibility le2 = new ColumnVisibility("L0&OFFICIAL");
    ColumnVisibility le3 = new ColumnVisibility("L1&L2");
    ColumnVisibility le4 = new ColumnVisibility("L1&L2&G1");
    ColumnVisibility[] lea = {le1, le2, le3, le4};
    Authorizations auths = new Authorizations("L1", "L2", "L0", "OFFICIAL");
    VisibilityFilter a = new VisibilityFilter(auths, le2.getExpression());
    f.add(a);
   
    for (int i = 0; i < 1000; i++) {
      Key k = new Key(new Text(String.format("%03d", i)), new Text("a"), new Text("b"), new Text(lea[i % 4].getExpression()));
View Full Code Here

   
    String tableName = state.getString("secTableName");
   
    switch (tp) {
      case READ:
        Authorizations auths = SecurityHelper.getUserAuths(state, SecurityHelper.getTabUserName(state));
        boolean canRead = SecurityHelper.getTabPerm(state, SecurityHelper.getTabUserName(state), TablePermission.READ);
        boolean ambiguousAuths = SecurityHelper.ambiguousAuthorizations(state, SecurityHelper.getTabUserName(state));
        try {
          Scanner scan = conn.createScanner(tableName, conn.securityOperations().getUserAuthorizations(SecurityHelper.getTabUserName(state)));
          int seen = 0;
          Iterator<Entry<Key,Value>> iter = scan.iterator();
          while (iter.hasNext()) {
            Entry<Key,Value> entry = iter.next();
            Key k = entry.getKey();
            seen++;
            if (!auths.contains(k.getColumnVisibilityData()) && !ambiguousAuths)
              throw new AccumuloException("Got data I should not be capable of seeing: " + k + " table " + tableName);
          }
          if (!canRead)
            throw new AccumuloException("Was able to read when I shouldn't have had the perm with connection user " + conn.whoami() + " table " + tableName);
          for (Entry<String,Integer> entry : SecurityHelper.getAuthsMap(state).entrySet()) {
            if (auths.contains(entry.getKey().getBytes()))
              seen = seen - entry.getValue();
          }
          if (seen != 0 && !ambiguousAuths)
            throw new AccumuloException("Got mismatched amounts of data");
        } catch (TableNotFoundException tnfe) {
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.