public TSentryRole deepCopy() { return new TSentryRole(this); }
public Object getFieldValue(_Fields field) { switch (field) { case ROLE_NAME: return getRoleName(); case GROUPS: return getGroups(); } throw new IllegalStateException(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof TSentryRole) return this.equals((TSentryRole)that); return false; }
/** * Performs a deep copy on <i>other</i>. */ public TSentryRole(TSentryRole other) { if (other.isSetRoleName()) { this.roleName = other.roleName; } if (other.isSetGroups()) { Set<String> __this__groups = new HashSet<String>(other.groups); this.groups = __this__groups; } }
public void setFieldValue(_Fields field, Object value) { switch (field) { case ROLE_NAME: if (value == null) { unsetRoleName(); } else { setRoleName((String)value); } break; case GROUPS: if (value == null) { unsetGroups(); } else { setGroups((Set<String>)value); } break; } }
for (int _i34 = 0; _i34 < _set32.size; ++_i34) _elem33 = new TSentryRole(); _elem33.read(iprot); struct.roles.add(_elem33);
@Override public void runTestAsSubject() throws Exception { String requestorUserName = ADMIN_USER; Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP); String roleName = "admin_r"; setLocalGroupMapping(requestorUserName, requestorUserGroupNames); writePolicyFile(); client.dropRoleIfExists(requestorUserName, roleName, SOLR); client.createRole(requestorUserName, roleName, SOLR); client.grantRoleToGroups(requestorUserName, roleName, SOLR, Sets.newHashSet(requestorUserGroupNames)); Set<TSentryRole> roles = client.listUserRoles(requestorUserName,SOLR); assertEquals("Incorrect number of roles", 1, roles.size()); for (TSentryRole role:roles) { assertTrue(role.getRoleName(), role.getRoleName().equalsIgnoreCase(roleName)); } client.dropRole(requestorUserName, roleName, SOLR); }}); }
public void validate() throws org.apache.thrift.TException { // check for required fields if (!isSetRoleName()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'roleName' is unset! Struct:" + toString()); } if (!isSetGroups()) { throw new org.apache.thrift.protocol.TProtocolException("Required field 'groups' is unset! Struct:" + toString()); } // check for sub-struct validity }
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.roleName = iprot.readString(); struct.setRoleNameIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); struct.setGroupsIsSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); struct.validate();
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TSentryRole struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.roleName = iprot.readString(); struct.setRoleNameIsSet(true); { org.apache.thrift.protocol.TSet _set29 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); struct.groups = new HashSet<String>(2*_set29.size); String _elem30; for (int _i31 = 0; _i31 < _set29.size; ++_i31) { _elem30 = iprot.readString(); struct.groups.add(_elem30); } } struct.setGroupsIsSet(true); } }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, TListSentryRolesResponse struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.status = new org.apache.sentry.service.thrift.TSentryResponseStatus(); struct.status.read(iprot); struct.setStatusIsSet(true); BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { { org.apache.thrift.protocol.TSet _set37 = new org.apache.thrift.protocol.TSet(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.roles = new HashSet<TSentryRole>(2*_set37.size); TSentryRole _elem38; for (int _i39 = 0; _i39 < _set37.size; ++_i39) { _elem38 = new TSentryRole(); _elem38.read(iprot); struct.roles.add(_elem38); } } struct.setRolesIsSet(true); } } }
@Override public void runTestAsSubject() throws Exception { Set<TSentryRole> tRoles = client.listAllRoles(SentryServiceIntegrationBase.ADMIN_USER, COMPONENT); for (TSentryRole tRole : tRoles) { client.dropRole(SentryServiceIntegrationBase.ADMIN_USER, tRole.getRoleName(), COMPONENT); } if (client != null) { client.close(); } } });
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case ROLE_NAME: return isSetRoleName(); case GROUPS: return isSetGroups(); } throw new IllegalStateException(); }
/** * Build cache replica with latest values * * @return cache replica with latest values */ private Table<String, String, Set<String>> loadFromRemote() throws Exception { Table<String, String, Set<String>> tempCache = HashBasedTable.create(); String requestor; requestor = UserGroupInformation.getLoginUser().getShortUserName(); try(SentryGenericServiceClient client = getClient()) { Set<TSentryRole> tSentryRoles = client.listAllRoles(requestor, componentType); for (TSentryRole tSentryRole : tSentryRoles) { final String roleName = tSentryRole.getRoleName(); final Set<TSentryPrivilege> tSentryPrivileges = client.listAllPrivilegesByRoleName(requestor, roleName, componentType, serviceName); for (String group : tSentryRole.getGroups()) { Set<String> currentPrivileges = tempCache.get(group, roleName); if (currentPrivileges == null) { currentPrivileges = new HashSet<>(); tempCache.put(group, roleName, currentPrivileges); } for (TSentryPrivilege tSentryPrivilege : tSentryPrivileges) { currentPrivileges.add(tSentryPrivilegeConverter.toString(tSentryPrivilege)); } } } return tempCache; } }
/** * Performs a deep copy on <i>other</i>. */ public TListSentryRolesResponse(TListSentryRolesResponse other) { if (other.isSetStatus()) { this.status = other.status; } if (other.isSetRoles()) { Set<TSentryRole> __this__roles = new HashSet<TSentryRole>(other.roles.size()); for (TSentryRole other_element : other.roles) { __this__roles.add(new TSentryRole(other_element)); } this.roles = __this__roles; } }
@Override public void runTestAsSubject() throws Exception { Set<TSentryRole> tRoles = client.listAllRoles(ADMIN_USER, SOLR); for (TSentryRole tRole : tRoles) { client.dropRole(ADMIN_USER, tRole.getRoleName(), SOLR); } if(client != null) { client.close(); } } });
public boolean equals(TSentryRole that) { if (that == null) return false; boolean this_present_roleName = true && this.isSetRoleName(); boolean that_present_roleName = true && that.isSetRoleName(); if (this_present_roleName || that_present_roleName) { if (!(this_present_roleName && that_present_roleName)) return false; if (!this.roleName.equals(that.roleName)) return false; } boolean this_present_groups = true && this.isSetGroups(); boolean that_present_groups = true && that.isSetGroups(); if (this_present_groups || that_present_groups) { if (!(this_present_groups && that_present_groups)) return false; if (!this.groups.equals(that.groups)) return false; } return true; }
@Override public void runTestAsSubject() throws Exception { String requestorUserName = ADMIN_USER; Set<String> requestorUserGroupNames = Sets.newHashSet(ADMIN_GROUP); String roleName = "admin_r1"; String groupName = "group1"; setLocalGroupMapping(requestorUserName, requestorUserGroupNames); setLocalGroupMapping(requestorUserName, Sets.newHashSet(groupName)); writePolicyFile(); client.dropRoleIfExists(requestorUserName, roleName, SOLR); client.createRole(requestorUserName, roleName, SOLR); client.grantRoleToGroups(requestorUserName, roleName, SOLR, Sets.newHashSet(groupName)); Set<TSentryRole> groupRoles = client.listRolesByGroupName(requestorUserName, groupName,SOLR); assertTrue(groupRoles.size() == 1); for (TSentryRole role:groupRoles) { assertTrue(role.getRoleName(), role.getRoleName().equalsIgnoreCase(roleName)); assertTrue(role.getGroups().size() == 1); for (String group :role.getGroups()) { assertEquals(groupName, group); } } client.dropRole(requestorUserName, roleName, SOLR); }}); }
public Set<TSentryRole> execute(PersistenceManager pm) throws Exception { Set<TSentryRole> tRoles = Sets.newHashSet(); pm.setDetachAllOnCommit(false); // No need to detach objects Set<MSentryRole> mSentryRoles = Sets.newHashSet(); if(groups.contains(null)) { mSentryRoles.addAll(delegate.getAllRoles(pm)); } else { mSentryRoles = delegate.getRolesForGroups(pm, groups); } for(MSentryRole mSentryRole: mSentryRoles) { String roleName = mSentryRole.getRoleName().intern(); Set<String> groupNames = Sets.newHashSet(); Set<MSentryGroup> mSentryGroups = mSentryRole.getGroups(); for(MSentryGroup mSentryGroup: mSentryGroups) { groupNames.add(mSentryGroup.getGroupName()); } tRoles.add(new TSentryRole(roleName, groupNames)); } return tRoles; } });