Package org.apache.accumulo.core.security

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


  private void authenticate(TCredentials credentials) throws ThriftSecurityException {
    if (!credentials.getInstanceId().equals(HdfsZooInstance.getInstance().getInstanceID()))
      throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.INVALID_INSTANCEID);

    Credentials creds = Credentials.fromThrift(credentials);
    if (isSystemUser(credentials)) {
      if (!(SystemCredentials.get().equals(creds))) {
        throw new ThriftSecurityException(creds.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
      }
    } else {
      try {
        if (!authenticator.authenticateUser(creds.getPrincipal(), creds.getToken())) {
          throw new ThriftSecurityException(creds.getPrincipal(), SecurityErrorCode.BAD_CREDENTIALS);
        }
      } catch (AccumuloSecurityException e) {
        log.debug(e);
        throw e.asThriftException();
      }
View Full Code Here


    canAskAboutUser(credentials, toAuth.getPrincipal());
    // User is already authenticated from canAskAboutUser
    if (credentials.equals(toAuth))
      return true;
    try {
      Credentials toCreds = Credentials.fromThrift(toAuth);
      return authenticator.authenticateUser(toCreds.getPrincipal(), toCreds.getToken());
    } catch (AccumuloSecurityException e) {
      throw e.asThriftException();
    }
  }
View Full Code Here

    return (int) ServerConfiguration.getSiteConfiguration().getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT);
  }

  @Override
  public Connector getConnector(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
    return new ConnectorImpl(this, new Credentials(principal, token));
  }
View Full Code Here

      } else if (cl.getParsedCommand().equals("ping")) {
        if (ping(instance, principal, token, pingCommand.args) != 0)
          rc = 4;
      } else if (cl.getParsedCommand().equals("checkTablets")) {
        System.out.println("\n*** Looking for offline tablets ***\n");
        if (FindOfflineTablets.findOffline(instance, new Credentials(principal, token), checkTabletsCommand.table) != 0)
          rc = 5;
        System.out.println("\n*** Looking for missing files ***\n");
        if (checkTabletsCommand.table == null) {
          if (RemoveEntriesForMissingFiles.checkAllTables(instance, principal, token, checkTabletsCommand.fixFiles) != 0)
            rc = 6;
        } else {
          if (RemoveEntriesForMissingFiles.checkTable(instance, principal, token, checkTabletsCommand.table, checkTabletsCommand.fixFiles) != 0)
            rc = 6;
        }

      } else if (cl.getParsedCommand().equals("stop")) {
        stopTabletServer(instance, new Credentials(principal, token), stopOpts.args, opts.force);
      } else if (cl.getParsedCommand().equals("dumpConfig")) {
        printConfig(instance, principal, token, dumpConfigCommand);
      } else if (cl.getParsedCommand().equals("volumes")) {
        ListVolumesUsed.listVolumes(instance, principal, token);
      } else {
        everything = cl.getParsedCommand().equals("stopAll");

        if (everything)
          flushAll(instance, principal, token);

        stopServer(instance, new Credentials(principal, token), everything);
      }

      if (rc != 0)
        System.exit(rc);
    } catch (AccumuloException e) {
View Full Code Here

    try {
      TabletClientService.Iface client = ThriftUtil.getTServerClient(opts.location, conf.getConfiguration());
     
      Mutation mutation = new Mutation(new Text("row_0003750001"));
      mutation.putDelete(new Text("colf"), new Text("colq"));
      client.update(Tracer.traceInfo(), new Credentials(opts.principal, opts.getToken()).toThrift(opts.getInstance()), new KeyExtent(new Text("!!"), null,
          new Text("row_0003750000")).toThrift(), mutation.toThrift());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

public class ScannerImplTest {

  @Test
  public void testValidReadaheadValues() {
    MockInstance instance = new MockInstance();
    Scanner s = new ScannerImpl(instance, new Credentials("root", new PasswordToken("")), "foo", new Authorizations());
    s.setReadaheadThreshold(0);
    s.setReadaheadThreshold(10);
    s.setReadaheadThreshold(Long.MAX_VALUE);
   
    Assert.assertEquals(Long.MAX_VALUE, s.getReadaheadThreshold());
View Full Code Here

  }
 
  @Test(expected = IllegalArgumentException.class)
  public void testInValidReadaheadValues() {
    MockInstance instance = new MockInstance();
    Scanner s = new ScannerImpl(instance, new Credentials("root", new PasswordToken("")), "foo", new Authorizations());
    s.setReadaheadThreshold(-1);
  }
View Full Code Here

    }
    bw.close();

    File tf = folder.newFile("root_test.pw");
    PrintStream out = new PrintStream(tf);
    String outString = new Credentials("root", new PasswordToken("")).serialize();
    out.println(outString);
    out.close();

    MRTokenFileTester.main(new String[] {"root", tf.getAbsolutePath(), TEST_TABLE_1, TEST_TABLE_2});
    assertNull(e1);
View Full Code Here

      authToken = state.getToken();
    }
    Connector conn = state.getInstance().getConnector(authPrincipal, authToken);
   
    boolean exists = WalkingSecurity.get(state).userExists(target);
    boolean hasPermission = WalkingSecurity.get(state).canChangeAuthorizations(new Credentials(authPrincipal, authToken).toThrift(state.getInstance()), target);
   
    Authorizations auths;
    if (authsString.equals("_random")) {
      String[] possibleAuths = WalkingSecurity.get(state).getAuthsArray();
     
View Full Code Here

    }
    bw.close();

    File tf = folder.newFile("root_test.pw");
    PrintStream out = new PrintStream(tf);
    String outString = new Credentials("root", new PasswordToken("")).serialize();
    out.println(outString);
    out.close();

    MRTokenFileTester.main(new String[] {"root", tf.getAbsolutePath(), TEST_TABLE_1, TEST_TABLE_2});
    assertNull(e1);
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.