static String writeRoleGrantsInfo(List<RolePrincipalGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (RolePrincipalGrant roleGrant : roleGrants) { appendNonNull(builder, roleGrant.getRoleName(), true); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); appendNonNull(builder, roleGrant.getGrantorName()); } return builder.toString(); }
static String writeRoleGrantsInfo(List<RolePrincipalGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (RolePrincipalGrant roleGrant : roleGrants) { appendNonNull(builder, roleGrant.getRoleName(), true); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); appendNonNull(builder, roleGrant.getGrantorName()); } return builder.toString(); }
public Object getFieldValue(_Fields field) { switch (field) { case ROLE_NAME: return getRoleName(); case PRINCIPAL_NAME: return getPrincipalName(); case PRINCIPAL_TYPE: return getPrincipalType(); case GRANT_OPTION: return isGrantOption(); case GRANT_TIME: return getGrantTime(); case GRANTOR_NAME: return getGrantorName(); case GRANTOR_PRINCIPAL_TYPE: return getGrantorPrincipalType(); } throw new IllegalStateException(); }
public HiveRoleGrant(RolePrincipalGrant thriftRoleGrant) { this.roleName = thriftRoleGrant.getRoleName(); this.principalName = thriftRoleGrant.getPrincipalName(); this.principalType = thriftRoleGrant.getPrincipalType().name(); this.grantOption = thriftRoleGrant.isGrantOption(); this.grantTime = thriftRoleGrant.getGrantTime(); this.grantor = thriftRoleGrant.getGrantorName(); this.grantorType = thriftRoleGrant.getGrantorPrincipalType() == null ? null : thriftRoleGrant.getGrantorPrincipalType().name(); }
public HiveRoleGrant(RolePrincipalGrant thriftRoleGrant) { this.roleName = thriftRoleGrant.getRoleName(); this.principalName = thriftRoleGrant.getPrincipalName(); this.principalType = thriftRoleGrant.getPrincipalType().name(); this.grantOption = thriftRoleGrant.isGrantOption(); this.grantTime = thriftRoleGrant.getGrantTime(); this.grantor = thriftRoleGrant.getGrantorName(); this.grantorType = thriftRoleGrant.getGrantorPrincipalType() == null ? null : thriftRoleGrant.getGrantorPrincipalType().name(); }
@Override public void grantRole(String role, String granteeName, PrincipalType granteeType, String grantorName, PrincipalType grantorType, boolean grantOption) throws TException { List<RolePrincipalGrant> grants = listRoleGrants(granteeName, granteeType); for (RolePrincipalGrant grant : grants) { if (grant.getRoleName().equals(role)) { if (grant.isGrantOption() == grantOption) { return; } if (!grant.isGrantOption() && grantOption) { revokeRole(role, granteeName, granteeType, false); break; } } } createGrant(role, granteeName, granteeType, grantorName, grantorType, grantOption); }
@Override public void revokeRole(String role, String granteeName, PrincipalType granteeType, boolean grantOption) throws TException { List<RolePrincipalGrant> grants = listRoleGrants(granteeName, granteeType); RolePrincipalGrant currentGrant = null; for (RolePrincipalGrant grant : grants) { if (grant.getRoleName().equals(role)) { currentGrant = grant; break; } } if (currentGrant == null) { return; } if (!currentGrant.isGrantOption() && grantOption) { return; } removeGrant(role, granteeName, granteeType, grantOption); }
static String writeRoleGrantsInfo(List<RolePrincipalGrant> roleGrants, boolean testMode) { if (roleGrants == null || roleGrants.isEmpty()) { return ""; } StringBuilder builder = new StringBuilder(); //sort the list to get sorted (deterministic) output (for ease of testing) Collections.sort(roleGrants); for (RolePrincipalGrant roleGrant : roleGrants) { appendNonNull(builder, roleGrant.getRoleName(), true); appendNonNull(builder, roleGrant.isGrantOption()); appendNonNull(builder, testMode ? -1 : roleGrant.getGrantTime() * 1000L); appendNonNull(builder, roleGrant.getGrantorName()); } return builder.toString(); }
public Object getFieldValue(_Fields field) { switch (field) { case ROLE_NAME: return getRoleName(); case PRINCIPAL_NAME: return getPrincipalName(); case PRINCIPAL_TYPE: return getPrincipalType(); case GRANT_OPTION: return Boolean.valueOf(isGrantOption()); case GRANT_TIME: return Integer.valueOf(getGrantTime()); case GRANTOR_NAME: return getGrantorName(); case GRANTOR_PRINCIPAL_TYPE: return getGrantorPrincipalType(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case ROLE_NAME: return getRoleName(); case PRINCIPAL_NAME: return getPrincipalName(); case PRINCIPAL_TYPE: return getPrincipalType(); case GRANT_OPTION: return Boolean.valueOf(isGrantOption()); case GRANT_TIME: return Integer.valueOf(getGrantTime()); case GRANTOR_NAME: return getGrantorName(); case GRANTOR_PRINCIPAL_TYPE: return getGrantorPrincipalType(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case ROLE_NAME: return getRoleName(); case PRINCIPAL_NAME: return getPrincipalName(); case PRINCIPAL_TYPE: return getPrincipalType(); case GRANT_OPTION: return isGrantOption(); case GRANT_TIME: return getGrantTime(); case GRANTOR_NAME: return getGrantorName(); case GRANTOR_PRINCIPAL_TYPE: return getGrantorPrincipalType(); } throw new IllegalStateException(); }
public static RoleGrant fromRolePrincipalGrant(RolePrincipalGrant grant) { return new RoleGrant( new PrestoPrincipal(fromMetastoreApiPrincipalType(grant.getPrincipalType()), grant.getPrincipalName()), grant.getRoleName(), grant.isGrantOption()); }
public HiveRoleGrant(RolePrincipalGrant thriftRoleGrant) { this.roleName = thriftRoleGrant.getRoleName(); this.principalName = thriftRoleGrant.getPrincipalName(); this.principalType = thriftRoleGrant.getPrincipalType().name(); this.grantOption = thriftRoleGrant.isGrantOption(); this.grantTime = thriftRoleGrant.getGrantTime(); this.grantor = thriftRoleGrant.getGrantorName(); this.grantorType = thriftRoleGrant.getGrantorPrincipalType() == null ? null : thriftRoleGrant.getGrantorPrincipalType().name(); }