Package org.apache.accumulo.core.security

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


    more.removeAll(perms);
    more.remove(SystemPermission.GRANT);
   
    if (rand.nextBoolean() && more.size() > 0) {
      List<SystemPermission> moreList = new ArrayList<SystemPermission>(more);
      SystemPermission choice = moreList.get(rand.nextInt(moreList.size()));
      log.debug("adding permission " + choice);
      conn.securityOperations().grantSystemPermission(userName, choice);
    } else {
      if (perms.size() > 0) {
        List<SystemPermission> permList = new ArrayList<SystemPermission>(perms);
        SystemPermission choice = permList.get(rand.nextInt(permList.size()));
        log.debug("removing permission " + choice);
        conn.securityOperations().revokeSystemPermission(userName, choice);
      }
    }
  }
View Full Code Here


    String action = props.getProperty("task", "toggle");
    String perm = props.getProperty("perm", "random");
   
    String targetUser = WalkingSecurity.get(state).getSysUserName();
   
    SystemPermission sysPerm;
    if (perm.equals("random")) {
      Random r = new Random();
      int i = r.nextInt(SystemPermission.values().length);
      sysPerm = SystemPermission.values()[i];
    } else
      sysPerm = SystemPermission.valueOf(perm);
   
    boolean hasPerm = ws.hasSystemPermission(targetUser, sysPerm);
   
    // toggle
    if (!"take".equals(action) && !"give".equals(action)) {
      if (hasPerm != conn.securityOperations().hasSystemPermission(targetUser, sysPerm))
        throw new AccumuloException("Test framework and accumulo are out of sync!");
      if (hasPerm)
        action = "take";
      else
        action = "give";
    }
   
    if ("take".equals(action)) {
      try {
        conn.securityOperations().revokeSystemPermission(targetUser, sysPerm);
      } catch (AccumuloSecurityException ae) {
        switch (ae.getSecurityErrorCode()) {
          case GRANT_INVALID:
            if (sysPerm.equals(SystemPermission.GRANT))
              return;
            throw new AccumuloException("Got GRANT_INVALID when not dealing with GRANT", ae);
          case PERMISSION_DENIED:
            throw new AccumuloException("Test user doesn't have root", ae);
          case USER_DOESNT_EXIST:
            throw new AccumuloException("System user doesn't exist and they SHOULD.", ae);
          default:
            throw new AccumuloException("Got unexpected exception", ae);
        }
      }
      ws.revokeSystemPermission(targetUser, sysPerm);
    } else if ("give".equals(action)) {
      try {
        conn.securityOperations().grantSystemPermission(targetUser, sysPerm);
      } catch (AccumuloSecurityException ae) {
        switch (ae.getSecurityErrorCode()) {
          case GRANT_INVALID:
            if (sysPerm.equals(SystemPermission.GRANT))
              return;
          case PERMISSION_DENIED:
            throw new AccumuloException("Test user doesn't have root", ae);
          case USER_DOESNT_EXIST:
            throw new AccumuloException("System user doesn't exist and they SHOULD.", ae);
View Full Code Here

    String action = props.getProperty("task", "toggle");
    String perm = props.getProperty("perm", "random");
   
    String targetUser = SecurityHelper.getSysUserName(state);
   
    SystemPermission sysPerm;
    if (perm.equals("random")) {
      Random r = new Random();
      int i = r.nextInt(SystemPermission.values().length);
      sysPerm = SystemPermission.values()[i];
    } else
      sysPerm = SystemPermission.valueOf(perm);
   
    boolean hasPerm = SecurityHelper.getSysPerm(state, SecurityHelper.getSysUserName(state), sysPerm);
   
    // toggle
    if (!"take".equals(action) && !"give".equals(action)) {
      if (hasPerm != conn.securityOperations().hasSystemPermission(targetUser, sysPerm))
        throw new AccumuloException("Test framework and accumulo are out of sync!");
      if (hasPerm)
        action = "take";
      else
        action = "give";
    }
   
    if ("take".equals(action)) {
      try {
        conn.securityOperations().revokeSystemPermission(targetUser, sysPerm);
      } catch (AccumuloSecurityException ae) {
        switch (ae.getErrorCode()) {
          case GRANT_INVALID:
            if (sysPerm.equals(SystemPermission.GRANT))
              return;
          case PERMISSION_DENIED:
            throw new AccumuloException("Test user doesn't have root", ae);
          case USER_DOESNT_EXIST:
            throw new AccumuloException("System user doesn't exist and they SHOULD.", ae);
          default:
            throw new AccumuloException("Got unexpected exception", ae);
        }
      }
      SecurityHelper.setSysPerm(state, SecurityHelper.getSysUserName(state), sysPerm, false);
    } else if ("give".equals(action)) {
      try {
        conn.securityOperations().grantSystemPermission(targetUser, sysPerm);
      } catch (AccumuloSecurityException ae) {
        switch (ae.getErrorCode()) {
          case GRANT_INVALID:
            if (sysPerm.equals(SystemPermission.GRANT))
              return;
          case PERMISSION_DENIED:
            throw new AccumuloException("Test user doesn't have root", ae);
          case USER_DOESNT_EXIST:
            throw new AccumuloException("System user doesn't exist and they SHOULD.", ae);
View Full Code Here

    more.removeAll(perms);
    more.remove(SystemPermission.GRANT);
   
    if (rand.nextBoolean() && more.size() > 0) {
      List<SystemPermission> moreList = new ArrayList<SystemPermission>(more);
      SystemPermission choice = moreList.get(rand.nextInt(moreList.size()));
      log.debug("adding permission " + choice);
      conn.securityOperations().grantSystemPermission(userName, choice);
    } else {
      if (perms.size() > 0) {
        List<SystemPermission> permList = new ArrayList<SystemPermission>(perms);
        SystemPermission choice = permList.get(rand.nextInt(permList.size()));
        log.debug("removing permission " + choice);
        conn.securityOperations().revokeSystemPermission(userName, choice);
      }
    }
  }
View Full Code Here

    more.removeAll(perms);
    more.remove(SystemPermission.GRANT);
   
    if (rand.nextBoolean() && more.size() > 0) {
      List<SystemPermission> moreList = new ArrayList<SystemPermission>(more);
      SystemPermission choice = moreList.get(rand.nextInt(moreList.size()));
      log.debug("adding permission " + choice);
      conn.securityOperations().grantSystemPermission(userName, choice);
    } else {
      if (perms.size() > 0) {
        List<SystemPermission> permList = new ArrayList<SystemPermission>(perms);
        SystemPermission choice = permList.get(rand.nextInt(permList.size()));
        log.debug("removing permission " + choice);
        conn.securityOperations().revokeSystemPermission(userName, choice);
      }
    }
  }
View Full Code Here

TOP

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

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.