Package org.apache.accumulo.core.security

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


    }
    return connector;
  }

  public Credentials getCredentials() {
    return new Credentials(getUserName(), getToken());
  }
View Full Code Here


          log.error("Failed to add log recovery watcher back", e);
        }
      }
    });

    Credentials systemCreds = SystemCredentials.get();
    watchers.add(new TabletGroupWatcher(this, new MetaDataStateStore(instance, systemCreds, this), null));
    watchers.add(new TabletGroupWatcher(this, new RootTabletStateStore(instance, systemCreds, this), watchers.get(0)));
    watchers.add(new TabletGroupWatcher(this, new ZooTabletStateStore(new ZooStore(zroot)), watchers.get(1)));
    for (TabletGroupWatcher watcher : watchers) {
      watcher.start();
View Full Code Here

    assertEquals(0, exec(SystemCredentialsIT.class, "good", getCluster().getZooKeepers()).waitFor());
    assertEquals(FAIL_CODE, exec(SystemCredentialsIT.class, "bad", getCluster().getZooKeepers()).waitFor());
  }

  public static void main(final String[] args) throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
    Credentials creds = null;
    if (args.length < 2)
      throw new RuntimeException("Incorrect usage; expected to be run by test only");
    if (args[0].equals("bad")) {
      creds = new SystemCredentials(new Instance() {

        @Deprecated
        @Override
        public void setConfiguration(AccumuloConfiguration conf) {
          throw new UnsupportedOperationException();
        }

        @Override
        public int getZooKeepersSessionTimeOut() {
          throw new UnsupportedOperationException();
        }

        @Override
        public String getZooKeepers() {
          throw new UnsupportedOperationException();
        }

        @Override
        public String getRootTabletLocation() {
          throw new UnsupportedOperationException();
        }

        @Override
        public List<String> getMasterLocations() {
          throw new UnsupportedOperationException();
        }

        @Override
        public String getInstanceName() {
          throw new UnsupportedOperationException();
        }

        @Override
        public String getInstanceID() {
          return SystemCredentials.class.getName();
        }

        @Override
        public Connector getConnector(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
          throw new UnsupportedOperationException();
        }

        @Deprecated
        @Override
        public Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException {
          throw new UnsupportedOperationException();
        }

        @Deprecated
        @Override
        public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException {
          throw new UnsupportedOperationException();
        }

        @Deprecated
        @Override
        public Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException {
          throw new UnsupportedOperationException();
        }

        @Deprecated
        @Override
        public AccumuloConfiguration getConfiguration() {
          throw new UnsupportedOperationException();
        }
      });
    } else if (args[0].equals("good")) {
      creds = SystemCredentials.get();
    }
    Instance instance = HdfsZooInstance.getInstance();
    Connector conn = instance.getConnector(creds.getPrincipal(), creds.getToken());
    try {
      Scanner scan = conn.createScanner(RootTable.NAME, Authorizations.EMPTY);
      for (Entry<Key,Value> e : scan) {
        e.hashCode();
      }
View Full Code Here

      throw new IllegalArgumentException("Couldn't open password file called \"" + tokenFile + "\".");
    }
    java.util.Scanner fileScanner = new java.util.Scanner(in);
    try {
      while (fileScanner.hasNextLine()) {
        Credentials creds = Credentials.deserialize(fileScanner.nextLine());
        if (principal.equals(creds.getPrincipal())) {
          return creds.getToken();
        }
      }
      throw new IllegalArgumentException("Couldn't find token for user \"" + principal + "\" in file \"" + tokenFile + "\"");
    } finally {
      if (fileScanner != null && fileScanner.ioException() == null)
View Full Code Here

   
    UtilWaitThread.sleep(30 * 1000);
   
    while (true) {
      MasterMonitorInfo stats = null;
      Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
      Client client = null;
      try {
        client = MasterClient.getConnectionWithRetry(c.getInstance());
        stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
      } finally {
        if (client != null)
          MasterClient.close(client);
      }
      int tablets = 0;
View Full Code Here

    TestIngest.Opts opts = new TestIngest.Opts();
    opts.rows = 200000;
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    c.tableOperations().flush("test_ingest", null, null, false);
    UtilWaitThread.sleep(15 * 1000);
    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
   
    MasterClientService.Iface client = null;
    MasterMonitorInfo stats = null;
    try {
      client = MasterClient.getConnectionWithRetry(c.getInstance());
      stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
    } finally {
      if (client != null)
        MasterClient.close(client);
    }
    List<Integer> counts = new ArrayList<Integer>();
View Full Code Here

    TestIngest.ingest(c, opts, BWOPTS);
    c.tableOperations().flush("test_ingest", null, null, true);
    for (int i = 1; i < TABLES; i++)
      c.tableOperations().clone("test_ingest", "test_ingest" + i, true, null, null);
    UtilWaitThread.sleep(11 * 1000); // time between checks of the thread pool sizes
    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
    for (int i = 1; i < TABLES; i++)
      c.tableOperations().compact("test_ingest" + i, null, null, true, false);
    for (int i = 0; i < 30; i++) {
      int count = 0;
      MasterClientService.Iface client = null;
      MasterMonitorInfo stats = null;
      try {
        client = MasterClient.getConnectionWithRetry(c.getInstance());
        stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
      } finally {
        if (client != null)
          MasterClient.close(client);
      }
      for (TabletServerStatus server : stats.tServerInfo) {
View Full Code Here

    UtilWaitThread.sleep(10 * 1000);
    checkBalance(c);
  }

  private void checkBalance(Connector c) throws Exception {
    Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
   
    MasterClientService.Iface client = null;
    MasterMonitorInfo stats = null;
    try {
      client = MasterClient.getConnectionWithRetry(c.getInstance());
      stats = client.getMasterStats(Tracer.traceInfo(), creds.toThrift(c.getInstance()));
    } finally {
      if (client != null)
        MasterClient.close(client);
    }
    List<Integer> counts = new ArrayList<Integer>();
View Full Code Here

      if (extent.isRootTablet()) {
        throw new IllegalArgumentException("Can not import files to root tablet");
      }

      synchronized (bulkFileImportLock) {
        Credentials creds = SystemCredentials.get();
        Connector conn;
        try {
          conn = HdfsZooInstance.getInstance().getConnector(creds.getPrincipal(), creds.getToken());
        } catch (Exception ex) {
          throw new IOException(ex);
        }
        // Remove any bulk files we've previously loaded and compacted away
        List<FileRef> files = MetadataTableUtil.getBulkFilesLoaded(conn, extent, tid);
View Full Code Here

  }

  @Override
  public boolean authenticateUser(final String principal, final AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
    ArgumentChecker.notNull(principal, token);
    final Credentials toAuth = new Credentials(principal, token);
    return execute(new ClientExecReturn<Boolean,ClientService.Client>() {
      @Override
      public Boolean execute(ClientService.Client client) throws Exception {
        return client.authenticateUser(Tracer.traceInfo(), credentials.toThrift(instance), toAuth.toThrift(instance));
      }
    });
  }
View Full Code Here

TOP

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

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.