@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getRoleName() == null) ? 0 : getRoleName().hashCode()); hashCode = prime * hashCode + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); hashCode = prime * hashCode + ((getArn() == null) ? 0 : getArn().hashCode()); hashCode = prime * hashCode + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode()); hashCode = prime * hashCode + ((getAssumeRolePolicyDocument() == null) ? 0 : getAssumeRolePolicyDocument().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getMaxSessionDuration() == null) ? 0 : getMaxSessionDuration().hashCode()); hashCode = prime * hashCode + ((getPermissionsBoundary() == null) ? 0 : getPermissionsBoundary().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); return hashCode; }
public Role unmarshall(StaxUnmarshallerContext context) throws Exception { Role role = new Role(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; role.setPath(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setRoleName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setRoleId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setCreateDate(DateStaxUnmarshallerFactory.getInstance("iso8601").unmarshall(context)); continue; role.setAssumeRolePolicyDocument(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setMaxSessionDuration(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setPermissionsBoundary(AttachedPermissionsBoundaryStaxUnmarshaller.getInstance().unmarshall(context));
final String assumeRolePolicyDocument = role.getAssumeRolePolicyDocument(); account, ImmutableMap.of( "role_arn", role.getArn(), "role_name", role.getRoleName(), "grantees", crossAccountArns), role.getRoleId() );
try { ObjectNode n = convertAwsObject(role, null); n.put("aws_assumeRolePolicyDocument", urlDecode(role.getAssumeRolePolicyDocument())); neo4j.execCypher(cypher, "a", role.getArn(), "p", n).forEach(it -> { gc.MERGE_ACTION.accept(it); }); .listRolePolicies(new ListRolePoliciesRequest().withRoleName(role.getRoleName())); long timestamp = System.currentTimeMillis(); for (String policyName : rolePolicies.getPolicyNames()) { GetRolePolicyResult rolePolicy = iam.getRolePolicy( new GetRolePolicyRequest().withRoleName(role.getRoleName()).withPolicyName(policyName)); String policyCypher = "match (n:AwsIamRole { aws_arn: {a} })" + "merge (n)-[r:CONTAINS]->(p:AwsInlinePolicy { aws_owner_arn: {a}, aws_policyName: {n} })" + " set p :AwsIamPolicy, p.aws_policyDocument = {d}, r.updateTs = {t}"; neo4j.execCypher(policyCypher, "a", role.getArn(), "n", policyName, "d", urlDecode(rolePolicy.getPolicyDocument()), "t", timestamp); neo4j.execCypher(removePolicyCypher, "a", role.getArn(), "t", timestamp); linkToAccount(role.getArn());
private Set<String> loadRoles() { Set<String> result = new TreeSet<String>(); boolean done = false; String marker = null; do { final ListRolesRequest listRolesRequest = new ListRolesRequest(); listRolesRequest.setMarker(marker); final ListRolesResult listRolesResult = iam.listRoles(listRolesRequest); for (Role r : listRolesResult.getRoles()) { result.add(r.getArn()); } done = (!listRolesResult.isTruncated()); marker = listRolesResult.getMarker(); } while (!done); return result; }
@Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } }
long companyId= _X_; //Perhaps CompanyThreadLocal.getCompanyId() if you don't have it anywhere else? Role role=RoleLocalServiceUtil.getRole(companyId, "Example Role"); Group group=GroupLocalServiceUtil.getGroup(companyId, "Example Community"); List<UserGroupRole> userGroupRoles = UserGroupRoleLocalServiceUtil. getUserGroupRolesByGroupAndRole(groupId, role.getRoleId()); for(UserGroupRole userGroupRole:userGroupRoles){ User oneUser=userGroupRole.getUser(); }
Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER); List<ResourcePermission> roleResourcePermissions = ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(role.getRoleId()); for(ResourcePermission permission : roleResourcePermissions ) ResourcePermissionLocalServiceUtil.reassignPermissions(permission.getResourcePermissionId(),role.getRoleId());
return false; Role other = (Role) obj; if (other.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getRoleName() == null ^ this.getRoleName() == null) return false; if (other.getRoleName() != null && other.getRoleName().equals(this.getRoleName()) == false) return false; if (other.getRoleId() == null ^ this.getRoleId() == null) return false; if (other.getRoleId() != null && other.getRoleId().equals(this.getRoleId()) == false) return false; if (other.getArn() == null ^ this.getArn() == null) return false; if (other.getArn() != null && other.getArn().equals(this.getArn()) == false) return false; if (other.getCreateDate() == null ^ this.getCreateDate() == null) return false; if (other.getCreateDate() != null && other.getCreateDate().equals(this.getCreateDate()) == false) return false; if (other.getAssumeRolePolicyDocument() == null ^ this.getAssumeRolePolicyDocument() == null) return false; if (other.getAssumeRolePolicyDocument() != null && other.getAssumeRolePolicyDocument().equals(this.getAssumeRolePolicyDocument()) == false) return false; if (other.getDescription() == null ^ this.getDescription() == null) return false; if (other.getDescription() != null && other.getDescription().equals(this.getDescription()) == false)
.withAssumeRolePolicyDocument(assumeRolePolicyDocument); createRole = iam.createRole(request); getLogger().info("Create Role requested: {}", createRole.getRole().getArn()); policyArns.stream().forEach(policyArn -> { iam.attachRolePolicy(new AttachRolePolicyRequest()
public Role unmarshall(StaxUnmarshallerContext context) throws Exception { Role role = new Role(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; role.setPath(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setRoleName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setRoleId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setCreateDate(DateStaxUnmarshallerFactory.getInstance("iso8601").unmarshall(context)); continue; role.setAssumeRolePolicyDocument(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setMaxSessionDuration(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; role.setPermissionsBoundary(AttachedPermissionsBoundaryStaxUnmarshaller.getInstance().unmarshall(context));
String[] usery = (String[])user.getExpandoBridge().getAttribute("Type"); Role role = RoleLocalServiceUtil.getRole(company.getCompanyId(), usery[0]); UserLocalServiceUtil.addRoleUser(role.getRoleId(), user.getUserId()); UserLocalServiceUtil.updateUser(user);
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getPath() != null) sb.append("Path: ").append(getPath()).append(","); if (getRoleName() != null) sb.append("RoleName: ").append(getRoleName()).append(","); if (getRoleId() != null) sb.append("RoleId: ").append(getRoleId()).append(","); if (getArn() != null) sb.append("Arn: ").append(getArn()).append(","); if (getCreateDate() != null) sb.append("CreateDate: ").append(getCreateDate()).append(","); if (getAssumeRolePolicyDocument() != null) sb.append("AssumeRolePolicyDocument: ").append(getAssumeRolePolicyDocument()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getMaxSessionDuration() != null) sb.append("MaxSessionDuration: ").append(getMaxSessionDuration()).append(","); if (getPermissionsBoundary() != null) sb.append("PermissionsBoundary: ").append(getPermissionsBoundary()).append(","); if (getTags() != null) sb.append("Tags: ").append(getTags()); sb.append("}"); return sb.toString();
private CreateStackTask readyStackTask() { CreateStackTask stackTask = new CreateStackTask(); stackTask.setProject(project); stackTask.setName("AntTaskTestStack"); stackTask.setRegion("us-east-1"); stackTask .setDefaultInstanceProfileArn(iamClient .getInstanceProfile( new GetInstanceProfileRequest() .withInstanceProfileName("aws-opsworks-ec2-role")) .getInstanceProfile().getArn()); stackTask.setServiceRoleArn(iamClient .getRole( new GetRoleRequest() .withRoleName("aws-opsworks-service-role")) .getRole().getArn()); return stackTask; }
Role userRole = RoleLocalServiceUtil.getRole(companyId, "POWER USER"); ResourcePermissionServiceUtil.setIndividualResourcePermissions(themeDisplay.getScopeGroupId(), themeDisplay.getCompanyId(), Layout.class.getName(), "primKey", userRole.getRoleId(), new String[] { ActionKeys.VIEW });
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getRoleName() == null) ? 0 : getRoleName().hashCode()); hashCode = prime * hashCode + ((getRoleId() == null) ? 0 : getRoleId().hashCode()); hashCode = prime * hashCode + ((getArn() == null) ? 0 : getArn().hashCode()); hashCode = prime * hashCode + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode()); hashCode = prime * hashCode + ((getAssumeRolePolicyDocument() == null) ? 0 : getAssumeRolePolicyDocument().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getMaxSessionDuration() == null) ? 0 : getMaxSessionDuration().hashCode()); hashCode = prime * hashCode + ((getPermissionsBoundary() == null) ? 0 : getPermissionsBoundary().hashCode()); hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode()); return hashCode; }
/** * Sets the "instanceProfile" and "serviceRole" properties according to the * set parameters. */ public void execute() { checkParams(); AmazonIdentityManagementClient iamClient = getOrCreateClient(AmazonIdentityManagementClient.class); getProject() .setProperty( "instanceProfileArn", iamClient .getInstanceProfile( new GetInstanceProfileRequest() .withInstanceProfileName(instanceProfile)) .getInstanceProfile().getArn()); getProject() .setProperty( "serviceRoleArn", iamClient .getRole( new GetRoleRequest() .withRoleName(serviceRole)) .getRole().getArn()); } }
List<Layout> tempPages = LayoutLocalServiceUtil.getLayouts( 0, LayoutLocalServiceUtil.getLayoutsCount() ); List<Role> allAvailRoles = RoleLocalServiceUtil.getRoles( 0, RoleLocalServiceUtil.getRolesCount() ); for ( Layout page : tempPages ) { List<Role> mappedRoles = new ArrayList<Role>(); for ( Role role : allAvailRoles ) { boolean hasRolePermission = PermissionLocalServiceUtil.hasRolePermission( role.getRoleId(), page.getCompanyId(), Layout.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf( page.getPrimaryKey() ), "VIEW" ); if ( hasRolePermission ) { mappedRoles.add( role ); } } pages.add( new LayoutRoleModel( page, mappedRoles ) ); }