Package org.apache.sentry.provider.db

Examples of org.apache.sentry.provider.db.SentryInvalidInputException


    String uri = privilege.getURI();
    String action = safeTrimLower(privilege.getAction());
    PrivilegeScope scope;

    if (serverName == null) {
      throw new SentryInvalidInputException("Server name is null");
    }

    if (AccessConstants.SELECT.equalsIgnoreCase(action) ||
        AccessConstants.INSERT.equalsIgnoreCase(action)) {
      if (Strings.nullToEmpty(tableName).trim().isEmpty()
          &&Strings.nullToEmpty(dbName).trim().isEmpty()) {
        throw new SentryInvalidInputException("Either Table name or Db name must be NON-NULL for SELECT/INSERT privilege");
      }
    }
    if (action == null) {
      action = AccessConstants.ALL;
    }

    // Validate privilege scope
    try {
      scope = Enum.valueOf(PrivilegeScope.class, privilege.getPrivilegeScope().toUpperCase());
    } catch (IllegalArgumentException e) {
      throw new SentryInvalidInputException("Invalid Privilege scope: " +
          privilege.getPrivilegeScope());
    }
    if (PrivilegeScope.SERVER.equals(scope)) {
      if (StringUtils.isNotEmpty(dbName) || StringUtils.isNotEmpty(tableName)) {
        throw new SentryInvalidInputException("DB and TABLE names should not be "
            + "set for SERVER scope");
      }
    } else if (PrivilegeScope.DATABASE.equals(scope)) {
      if (StringUtils.isEmpty(dbName)) {
        throw new SentryInvalidInputException("DB name not set for DB scope");
      }
      if (StringUtils.isNotEmpty(tableName)) {
        StringUtils.isNotEmpty("TABLE names should not be set for DB scope");
      }
    } else if (PrivilegeScope.TABLE.equals(scope)) {
      if (StringUtils.isEmpty(dbName) || StringUtils.isEmpty(tableName)) {
        throw new SentryInvalidInputException("TABLE or DB name not set for TABLE scope");
      }
    } else if (PrivilegeScope.URI.equals(scope)){
      if (StringUtils.isEmpty(uri)) {
        throw new SentryInvalidInputException("URI path not set for URI scope");
      }
      if (StringUtils.isNotEmpty(tableName)) {
        throw new SentryInvalidInputException("TABLE should not be set for URI scope");
      }
    } else {
      throw new SentryInvalidInputException("Unsupported operation scope: " + scope);
    }

    if (uri == null || uri.equals("")) {
      privilegeName.append(serverName);
      privilegeName.append("+");
View Full Code Here


   * @throws SentryNoSuchObjectException
   */

  public Set<TSentryPrivilege> getTSentryPrivileges(Set<String> roleNames, TSentryAuthorizable authHierarchy) throws SentryInvalidInputException {
    if (authHierarchy.getServer() == null) {
      throw new SentryInvalidInputException("serverName cannot be null !!");
    }
    if ((authHierarchy.getTable() != null) && (authHierarchy.getDb() == null)) {
      throw new SentryInvalidInputException("dbName cannot be null when tableName is present !!");
    }
    if ((authHierarchy.getUri() == null) && (authHierarchy.getDb() == null)) {
      throw new SentryInvalidInputException("One of uri or dbName must not be null !!");
    }
    return convertToTSentryPrivileges(getMSentryPrivileges(roleNames, authHierarchy));
  }
View Full Code Here

        dropPrivilegeForAllRoles(pm, new TSentryPrivilege(tPrivilege));
      }
      rollbackTransaction = false;
      commitTransaction(pm);
    } catch (JDODataStoreException e) {
      throw new SentryInvalidInputException("Failed to get privileges: "
          + e.getMessage());
    } finally {
      if (rollbackTransaction) {
        rollbackTransaction(pm);
      }
View Full Code Here

        renamePrivilegeForAllRoles(pm, tPrivilege, newPrivilege);
      }
      rollbackTransaction = false;
      commitTransaction(pm);
    } catch (JDODataStoreException e) {
      throw new SentryInvalidInputException("Failed to get privileges: "
          + e.getMessage());
    } finally {
      if (rollbackTransaction) {
        rollbackTransaction(pm);
      }
View Full Code Here

TOP

Related Classes of org.apache.sentry.provider.db.SentryInvalidInputException

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.