public static SqoopAuthorizable from(String keyValue) { return from(new KeyValue(keyValue)); }
/** * Gets a {@link Authorizable} from the given key and value * * @param key the {@link AuthorizableType type} of the authorizable * @param value the {@link Authorizable name} of the authorizable * @return the created {@link Authorizable} with the given name if {@link AuthorizableType} given was valid * @throws NoSuchElementException if the given {@link AuthorizableType} was not valid */ public static Authorizable from(String key, String value) { return from(new KeyValue(key, value)); }
/** * Gets a {@link Authorizable} from the given {@link KeyValue} * * @param keyValue {@link KeyValue} containing the {@link AuthorizableType} and name of the {@link Authorizable} * to be crearted * @return the created {@link Authorizable} with the given name if {@link AuthorizableType} given was valid * @throws NoSuchElementException if the given {@link AuthorizableType} was not valid */ static Authorizable from(String keyValue) { return from(new KeyValue(keyValue)); }
public WildcardPrivilege(String permission) { if (Strings.isNullOrEmpty(permission)) { throw new IllegalArgumentException("Permission string cannot be null or empty."); } List<KeyValue> parts = new ArrayList<>(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split(permission)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + permission + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } Preconditions.checkState(!parts.isEmpty(), "Failed to split the permission string %s into a list of Authorizables" + " separated by %s", permission, PolicyConstants.AUTHORIZABLE_SPLITTER); this.privilegeParts = Collections.unmodifiableList(parts); }
public SqoopWildcardPrivilege(String permission) { if (Strings.isNullOrEmpty(permission)) { throw new IllegalArgumentException("permission string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); for (String authorizable : AUTHORIZABLE_SPLITTER.trimResults().split(permission.trim())) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + permission + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + permission); } this.parts = ImmutableList.copyOf(parts); }
public static KafkaAuthorizable from(String keyValue) throws ConfigurationException { return from(new KeyValue(keyValue)); }
public static IndexerModelAuthorizable from(String s) { return from(new KeyValue(s)); }
public KafkaWildcardPrivilege(String permission) { if (Strings.isNullOrEmpty(permission)) { throw new IllegalArgumentException("Permission string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); for (String authorizable : AUTHORIZABLE_SPLITTER.trimResults().split(permission.trim())) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + permission + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Privilege, " + permission + ", did not consist of any valid authorizable."); } this.parts = ImmutableList.copyOf(parts); }
public static SearchModelAuthorizable from(String s) { return from(new KeyValue(s)); }
public static DBModelAuthorizable from(String s) { return from(new KeyValue(s)); }
public SearchWildcardPrivilege(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
public IndexerWildcardPrivilege(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
public DBWildcardPrivilege(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); } List<KeyValue>parts = Lists.newArrayList(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.trimResults().split( wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
private List<? extends Authorizable> toAuthorizables(String privilegeStr) { List<Authorizable> authorizables = Lists.newArrayList(); if (privilegeStr == null) { return authorizables; } for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue tempKV = new KeyValue(authorizable); final String key = tempKV.getKey(); final String value = tempKV.getValue(); authorizables.add(new Authorizable() { @Override public String getTypeName() { return key; } @Override public String getName() { return value; } }); } return authorizables; }
public static TSentryPrivilege convertToTSentryPrivilege(String privilegeStr) { TSentryPrivilege tSentryPrivilege = new TSentryPrivilege(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue tempKV = new KeyValue(authorizable); String key = tempKV.getKey(); String value = tempKV.getValue(); if (PolicyFileConstants.PRIVILEGE_SERVER_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setServerName(value); } else if (PolicyFileConstants.PRIVILEGE_DATABASE_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setDbName(value); } else if (PolicyFileConstants.PRIVILEGE_TABLE_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setTableName(value); } else if (PolicyFileConstants.PRIVILEGE_COLUMN_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setColumnName(value); } else if (PolicyFileConstants.PRIVILEGE_URI_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setURI(value); } else if (PolicyFileConstants.PRIVILEGE_ACTION_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setAction(value); } else if (PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME.equalsIgnoreCase(key)) { TSentryGrantOption grantOption = "true".equalsIgnoreCase(value) ? TSentryGrantOption.TRUE : TSentryGrantOption.FALSE; tSentryPrivilege.setGrantOption(grantOption); } } tSentryPrivilege.setPrivilegeScope(getPrivilegeScope(tSentryPrivilege)); return tSentryPrivilege; }
public static TSentryPrivilege convertToTSentryPrivilege(String privilegeStr) throws Exception { TSentryPrivilege tSentryPrivilege = new TSentryPrivilege(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue tempKV = new KeyValue(authorizable); String key = tempKV.getKey(); String value = tempKV.getValue(); if (PolicyFileConstants.PRIVILEGE_SERVER_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setServerName(value); } else if (PolicyFileConstants.PRIVILEGE_DATABASE_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setDbName(value); } else if (PolicyFileConstants.PRIVILEGE_TABLE_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setTableName(value); } else if (PolicyFileConstants.PRIVILEGE_COLUMN_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setColumnName(value); } else if (PolicyFileConstants.PRIVILEGE_URI_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setURI(value); } else if (PolicyFileConstants.PRIVILEGE_ACTION_NAME.equalsIgnoreCase(key)) { tSentryPrivilege.setAction(value); } else if (PolicyFileConstants.PRIVILEGE_GRANT_OPTION_NAME.equalsIgnoreCase(key)) { TSentryGrantOption grantOption = "true".equalsIgnoreCase(value) ? TSentryGrantOption.TRUE : TSentryGrantOption.FALSE; tSentryPrivilege.setGrantOption(grantOption); } } tSentryPrivilege.setPrivilegeScope(getPrivilegeScope(tSentryPrivilege)); validatePrivilegeHierarchy(tSentryPrivilege); return tSentryPrivilege; }
List<TAuthorizable> authorizables = new LinkedList<TAuthorizable>(); for (String authorizable : PolicyConstants.AUTHORIZABLE_SPLITTER.split(privilegeStr)) { KeyValue keyValue = new KeyValue(authorizable); String key = keyValue.getKey(); String value = keyValue.getValue();