Package org.apache.accumulo.core.security

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


     * @throws IllegalArgumentException if no table present or table not found.
     */
    public <C> List<CellGroup<C>> read(Parameters params, CellTransformer<Map.Entry<Key, Value>, C> transformer) {
        AccumuloParameters parameters = AccumuloParameterOps.checkParamType(params);
        Connector connector = AccumuloParameterOps.getConnectorFromParameters(instance, parameters);
        Authorizations auths = AccumuloParameterOps.getAuthsFromConnector(connector);
        if(log.isDebugEnabled())
            log.info("Create auths and connector for " + parameters.getUser());
        Scan scan = parameters.hasKey(AccumuloParameters.MULTI_RANGE) ?
                new MultiRangeScan(connector, auths, parameters) :
                new SingleRangeScan(connector, auths, parameters);
View Full Code Here


        }
    }

    public void setAuthorizations(String user, String... auths) {
        try {
            connector.securityOperations().changeUserAuthorizations(user, new Authorizations(auths));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

                LOGGER.debug("got lock to add authorization [%s] for secure graph user", auth);
                if (graph instanceof AccumuloGraph) {
                    try {
                        AccumuloGraph accumuloGraph = (AccumuloGraph) graph;
                        String principal = accumuloGraph.getConnector().whoami();
                        Authorizations currentAuthorizations = accumuloGraph.getConnector().securityOperations().getUserAuthorizations(principal);
                        if (currentAuthorizations.contains(auth)) {
                            return;
                        }
                        List<byte[]> newAuthorizationsArray = new ArrayList<byte[]>();
                        for (byte[] currentAuth : currentAuthorizations) {
                            newAuthorizationsArray.add(currentAuth);
                        }
                        newAuthorizationsArray.add(auth.getBytes(Constants.UTF8));
                        Authorizations newAuthorizations = new Authorizations(newAuthorizationsArray);
                        accumuloGraph.getConnector().securityOperations().changeUserAuthorizations(principal, newAuthorizations);
                    } catch (Exception ex) {
                        throw new RuntimeException("Could not update authorizations in accumulo", ex);
                    }
                } else {
View Full Code Here

                LOGGER.debug("got lock removing authorization to graph user %s", auth);
                if (graph instanceof AccumuloGraph) {
                    try {
                        AccumuloGraph accumuloGraph = (AccumuloGraph) graph;
                        String principal = accumuloGraph.getConnector().whoami();
                        Authorizations currentAuthorizations = accumuloGraph.getConnector().securityOperations().getUserAuthorizations(principal);
                        if (!currentAuthorizations.toString().contains(auth)) {
                            return;
                        }
                        byte[] authBytes = auth.getBytes(Constants.UTF8);
                        List<byte[]> newAuthorizationsArray = new ArrayList<byte[]>();
                        for (byte[] currentAuth : currentAuthorizations) {
                            if (Arrays.equals(currentAuth, authBytes)) {
                                continue;
                            }
                            newAuthorizationsArray.add(currentAuth);
                        }
                        Authorizations newAuthorizations = new Authorizations(newAuthorizationsArray);
                        accumuloGraph.getConnector().securityOperations().changeUserAuthorizations(principal, newAuthorizations);
                    } catch (Exception ex) {
                        throw new RuntimeException("Could not update authorizations in accumulo", ex);
                    }
                } else {
View Full Code Here

    public List<String> getGraphAuthorizations() {
        if (graph instanceof AccumuloGraph) {
            try {
                AccumuloGraph accumuloGraph = (AccumuloGraph) graph;
                String principal = accumuloGraph.getConnector().whoami();
                Authorizations currentAuthorizations = accumuloGraph.getConnector().securityOperations().getUserAuthorizations(principal);
                ArrayList<String> auths = new ArrayList<String>();
                for (byte[] currentAuth : currentAuthorizations) {
                    auths.add(new String(currentAuth));
                }
                return auths;
View Full Code Here

        return getModelUserContext(auths.toArray(new String[auths.size()]));
    }

    public ModelUserContext getModelUserContext(String... authorizations) {
        // TODO: figure out a better way to create this without requiring accumulo
        return new AccumuloUserContext(new Authorizations(authorizations));
    }
View Full Code Here

      org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
    try {
      Connector connector = getConnector(login);
      Text startText = ByteBufferUtil.toText(startRow);
      Text endText = ByteBufferUtil.toText(endRow);
      Authorizations auth;
      if (auths != null) {
        auth = getAuthorizations(auths);
      } else {
        auth = connector.securityOperations().getUserAuthorizations(connector.whoami());
      }
View Full Code Here

    try {
      Set<String> auths = new HashSet<String>();
      for (ByteBuffer auth : authorizations) {
        auths.add(ByteBufferUtil.toString(auth));
      }
      getConnector(login).securityOperations().changeUserAuthorizations(user, new Authorizations(auths.toArray(new String[0])));
    } catch (Exception e) {
      handleException(e);
    }
  }
View Full Code Here

 
  @Override
  public void createLocalUser(ByteBuffer login, String user, ByteBuffer password) throws org.apache.accumulo.proxy.thrift.AccumuloException,
      org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
    try {
      getConnector(login).securityOperations().createUser(user, ByteBufferUtil.toBytes(password), new Authorizations());
    } catch (Exception e) {
      handleException(e);
    }
  }
View Full Code Here

  private Authorizations getAuthorizations(Set<ByteBuffer> authorizations) {
    List<String> auths = new ArrayList<String>();
    for (ByteBuffer bbauth : authorizations) {
      auths.add(ByteBufferUtil.toString(bbauth));
    }
    return new Authorizations(auths.toArray(new String[0]));
  }
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.