Tabnine Logo
PrivilegeValidatorContext
Code IndexAdd Tabnine to your IDE (free)

How to use
PrivilegeValidatorContext
in
org.apache.sentry.policy.common

Best Java code snippets using org.apache.sentry.policy.common.PrivilegeValidatorContext (Showing top 11 results out of 315)

origin: apache/incubator-sentry

@Override
public void validate(PrivilegeValidatorContext context)
  throws ConfigurationException {
 Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege());
 boolean match = false;
 for (SqoopAuthorizable authorizable : authorizables) {
  if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) {
   match = true;
   break;
  }
 }
 if (!match) {
  String msg = "server=[name] in " + context.getPrivilege()
    + " is required. The name is expected " + sqoopServerName;
  throw new ConfigurationException(msg);
 }
}
origin: apache/incubator-sentry

 private static void validatePrivilegeHierarchy(String privilegeStr) throws Exception {
  List<PrivilegeValidator> validators = SimpleSearchPolicyEngine.createPrivilegeValidators();
  PrivilegeValidatorContext context = new PrivilegeValidatorContext(null, privilegeStr);
  for (PrivilegeValidator validator : validators) {
   try {
    validator.validate(context);
   } catch (ConfigurationException e) {
    throw new IllegalArgumentException(e);
   }
  }
 }
}
origin: apache/incubator-sentry

 @Override
 public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
  String database = context.getDatabase();
  String privilege = context.getPrivilege();
  /*
   *  Rule only applies to rules in per database policy file
   */
  if(database != null) {
   Iterable<DBModelAuthorizable> authorizables = parsePrivilege(privilege);
   for(DBModelAuthorizable authorizable : authorizables) {
    if(authorizable instanceof Database &&
      !database.equalsIgnoreCase(authorizable.getName())) {
     String msg = "Privilege " + privilege + " references db " +
       authorizable.getName() + ", but is only allowed to reference "
       + database;
     throw new ConfigurationException(msg);
    }
   }
  }
 }
}
origin: apache/incubator-sentry

 @Override
 public void validate(PrivilegeValidatorContext context) throws SentryConfigurationException {
  String privilege = context.getPrivilege();
  Iterable<IndexerModelAuthorizable> authorizables = parsePrivilege(privilege);
  boolean foundIndexerInAuthorizables = false;

  for(IndexerModelAuthorizable authorizable : authorizables) {
   if(authorizable instanceof Indexer) {
    foundIndexerInAuthorizables = true;
    break;
   }
  }
  if(!foundIndexerInAuthorizables) {
   String msg = "Missing indexer object in " + privilege;
   throw new SentryConfigurationException(msg);
  }
 }
}
origin: apache/incubator-sentry

@Override
public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
 String database = context.getDatabase();
 String privilege = context.getPrivilege();
origin: apache/incubator-sentry

for(String privilege : privileges) {
 for(PrivilegeValidator validator : validators) {
  validator.validate(new PrivilegeValidatorContext(database, privilege.trim()));
origin: apache/incubator-sentry

 @Override
 public void validate(PrivilegeValidatorContext context) throws SentryConfigurationException {
  String privilege = context.getPrivilege();
  Iterable<SearchModelAuthorizable> authorizables = parsePrivilege(privilege);
  boolean foundCollectionInAuthorizables = false;

  for(SearchModelAuthorizable authorizable : authorizables) {
   if(authorizable instanceof Collection) {
    foundCollectionInAuthorizables = true;
    break;
   }
  }
  if(!foundCollectionInAuthorizables) {
   String msg = "Missing collection object in " + privilege;
   throw new SentryConfigurationException(msg);
  }
 }
}
origin: apache/incubator-sentry

@Override
public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
 String privilege = context.getPrivilege();
 Iterable<DBModelAuthorizable> authorizables = parsePrivilege(privilege);
 for(DBModelAuthorizable authorizable : authorizables) {
  if(authorizable instanceof Server && !serverName.equalsIgnoreCase(authorizable.getName())) {
   String msg = "Server name " + authorizable.getName() + " in "
     + privilege + " is invalid. Expected " + serverName;
   throw new ConfigurationException(msg);
  }
 }
}
origin: co.cask.cdap/cdap-sentry-policy

@Override
public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
 Deque<String> privileges = Lists.newLinkedList(PolicyConstants.AUTHORIZABLE_SPLITTER.split(context.getPrivilege()));
 // Check privilege splits length is at least 2 the smallest privilege possible with action. Example:
 // smallest privilege of size 2 : instance=instance1->action=read
 if (privileges.size() < 2) {
  throw new ConfigurationException("Invalid Privilege Exception: Privilege can be given to an " +
                    "instance or " +
                    "instance -> namespace or " +
                    "instance -> namespace -> (artifact|applications|stream|dataset) or " +
                    "instance -> namespace -> application -> program");
 }
 // Check the last part is a valid action
 if (!isAction(privileges.removeLast())) {
  throw new ConfigurationException("CDAP privilege must end with a valid action.\n");
 }
 // the first valid authorizable type is instance since all privilege string should start with it
 Set<Authorizable.AuthorizableType> validTypes = EnumSet.of(Authorizable.AuthorizableType.INSTANCE);
 while (!privileges.isEmpty()) {
  Authorizable authorizable = ModelAuthorizables.from(privileges.removeFirst());
  // if we were expecting no validTypes for this authorizable type that means the privilege string has more
  // authorizable when we were expecting it to end
  if (validTypes.isEmpty()) {
   throw new ConfigurationException(String.format("Was expecting end of Authorizables. Found unexpected " +
                            "authorizable %s of type %s",
                           authorizable, authorizable.getAuthzType()));
  }
  validTypes = validatePrivilege(authorizable.getAuthzType(), validTypes);
 }
}
origin: apache/incubator-sentry

@Override
public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
 String privilege = context.getPrivilege();
 Iterable<DBModelAuthorizable> authorizables = parsePrivilege(privilege);
 for(DBModelAuthorizable authorizable : authorizables) {
  if(authorizable instanceof Server &&
    authorizable.getName().equals(Server.ALL.getName())) {
   String msg = "Invalid value for " + authorizable.getAuthzType() + " in " + privilege;
   throw new ConfigurationException(msg);
  }
 }
}
origin: apache/incubator-sentry

@Override
public void validate(PrivilegeValidatorContext context) throws ConfigurationException {
 List<String> splits = Lists.newArrayList();
 for (String section : AUTHORIZABLE_SPLITTER.split(context.getPrivilege())) {
  splits.add(section);
org.apache.sentry.policy.commonPrivilegeValidatorContext

Most used methods

  • getPrivilege
  • <init>
  • getDatabase

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Reference (javax.naming)
  • JButton (javax.swing)
  • Join (org.hibernate.mapping)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now