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

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


   
    String tableUserName = WalkingSecurity.get(state).getTabUserName();
   
    boolean exists = WalkingSecurity.get(state).userExists(tableUserName);
    boolean hasPermission = WalkingSecurity.get(state).canCreateUser(WalkingSecurity.get(state).getSysCredentials(), tableUserName);
    PasswordToken tabUserPass = new PasswordToken("Super Sekret Table User Password");
    try {
      conn.securityOperations().createLocalUser(tableUserName, tabUserPass);
    } catch (AccumuloSecurityException ae) {
      switch (ae.getSecurityErrorCode()) {
        case PERMISSION_DENIED:
View Full Code Here


    return userList;
  }
 
  @Override
  public boolean authenticateUser(String principal, AuthenticationToken token) {
    PasswordToken pass = (PasswordToken) state.get(principal + userPass);
    boolean ret = pass.equals(token);
    return ret;
  }
View Full Code Here

  public TCredentials getTabCredentials() {
    return CredentialHelper.createSquelchError(getTabUserName(), getTabToken(), state.getInstance().getInstanceID());
  }
 
  public AuthenticationToken getSysToken() {
    return new PasswordToken(getSysPassword());
  }
View Full Code Here

  public AuthenticationToken getSysToken() {
    return new PasswordToken(getSysPassword());
  }
 
  public AuthenticationToken getTabToken() {
    return new PasswordToken(getTabPassword());
  }
View Full Code Here

    @Parameter(names = "--opt", required = true, description = "the options for test")
    String opt = null;
  }
 
  public static void main(String[] args) throws Exception {
    CredentialHelper.create("", new PasswordToken(new byte[0]), "");
    Opts opts = new Opts();
    opts.parseArgs(FunctionalTest.class.getName(), args);
   
    Class<? extends FunctionalTest> testClass = AccumuloVFSClassLoader.loadClass(opts.classname, FunctionalTest.class);
    FunctionalTest fTest = testClass.newInstance();
View Full Code Here

    if (oldPassword == null) {
      shellState.getReader().printNewline();
      return 0;
    } // user canceled
   
    if (!shellState.getConnector().securityOperations().authenticateUser(currentUser, new PasswordToken(oldPassword)))
      throw new AccumuloSecurityException(user, SecurityErrorCode.BAD_CREDENTIALS);
   
    password = shellState.readMaskedLine("Enter new password for '" + user + "': ", '*');
    if (password == null) {
      shellState.getReader().printNewline();
      return 0;
    } // user canceled
    passwordConfirm = shellState.readMaskedLine("Please confirm new password for '" + user + "': ", '*');
    if (passwordConfirm == null) {
      shellState.getReader().printNewline();
      return 0;
    } // user canceled
   
    if (!password.equals(passwordConfirm)) {
      throw new IllegalArgumentException("Passwords do not match");
    }
    byte[] pass = password.getBytes();
    shellState.getConnector().securityOperations().changeLocalUserPassword(user, new PasswordToken(pass));
    // update the current credentials if the password changed was for
    // the current user
    if (shellState.getConnector().whoami().equals(user)) {
      shellState.updateUser(user, new PasswordToken(pass));
    }
    Shell.log.debug("Changed password for user " + user);
    return 0;
  }
View Full Code Here

          }
          break;
        case CREATE_USER:
          user = "__CREATE_USER_WITHOUT_PERM_TEST__";
          try {
            test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
            throw new IllegalStateException("Should NOT be able to create a user");
          } catch (AccumuloSecurityException e) {
            if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
                || root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
              throw e;
          }
          break;
        case DROP_USER:
          user = "__DROP_USER_WITHOUT_PERM_TEST__";
          root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
          try {
            test_user_conn.securityOperations().dropLocalUser(user);
            throw new IllegalStateException("Should NOT be able to delete a user");
          } catch (AccumuloSecurityException e) {
            if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED
                || !root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
              throw e;
          }
          break;
        case ALTER_USER:
          user = "__ALTER_USER_WITHOUT_PERM_TEST__";
          root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
          try {
            test_user_conn.securityOperations().changeUserAuthorizations(user, new Authorizations("A", "B"));
            throw new IllegalStateException("Should NOT be able to alter a user");
          } catch (AccumuloSecurityException e) {
            if (e.getSecurityErrorCode() != SecurityErrorCode.PERMISSION_DENIED || !root_conn.securityOperations().getUserAuthorizations(user).isEmpty())
View Full Code Here

          if (root_conn.tableOperations().list().contains(tableName) || !root_conn.tableOperations().list().contains(table2))
            throw new IllegalStateException("Should be able to rename a table");
          break;
        case CREATE_USER:
          user = "__CREATE_USER_WITH_PERM_TEST__";
          test_user_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
          if (!root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
            throw new IllegalStateException("Should be able to create a user");
          break;
        case DROP_USER:
          user = "__DROP_USER_WITH_PERM_TEST__";
          root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
          test_user_conn.securityOperations().dropLocalUser(user);
          if (root_conn.securityOperations().authenticateUser(user, new PasswordToken(password)))
            throw new IllegalStateException("Should be able to delete a user");
          break;
        case ALTER_USER:
          user = "__ALTER_USER_WITH_PERM_TEST__";
          root_conn.securityOperations().createLocalUser(user, new PasswordToken(password));
          test_user_conn.securityOperations().changeUserAuthorizations(user, new Authorizations("A", "B"));
          if (root_conn.securityOperations().getUserAuthorizations(user).isEmpty())
            throw new IllegalStateException("Should be able to alter a user");
          break;
        case SYSTEM:
View Full Code Here

  }
 
  @Test
  public void testMap() throws Exception {
    MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
    Connector c = mockInstance.getConnector("root", new PasswordToken(""));
    c.tableOperations().create(TEST_TABLE_1);
    BatchWriter bw = c.createBatchWriter(TEST_TABLE_1, new BatchWriterConfig());
    for (int i = 0; i < 100; i++) {
      Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
      m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
View Full Code Here

public class TestBatchScanner821 {
 
  @Test
  public void test() throws Exception {
    MockInstance inst = new MockInstance();
    Connector conn = inst.getConnector("root", new PasswordToken(""));
    conn.tableOperations().create("test");
    BatchWriter bw = conn.createBatchWriter("test", new BatchWriterConfig());
    for (String row : "A,B,C,D".split(",")) {
      Mutation m = new Mutation(row);
      m.put("cf", "cq", "");
View Full Code Here

TOP

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

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.