@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getPolicyName() == null) ? 0 : getPolicyName().hashCode()); hashCode = prime * hashCode + ((getPolicyId() == null) ? 0 : getPolicyId().hashCode()); hashCode = prime * hashCode + ((getArn() == null) ? 0 : getArn().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getDefaultVersionId() == null) ? 0 : getDefaultVersionId().hashCode()); hashCode = prime * hashCode + ((getAttachmentCount() == null) ? 0 : getAttachmentCount().hashCode()); hashCode = prime * hashCode + ((getPermissionsBoundaryUsageCount() == null) ? 0 : getPermissionsBoundaryUsageCount().hashCode()); hashCode = prime * hashCode + ((getIsAttachable() == null) ? 0 : getIsAttachable().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode()); hashCode = prime * hashCode + ((getUpdateDate() == null) ? 0 : getUpdateDate().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetPolicyResult == false) return false; GetPolicyResult other = (GetPolicyResult) obj; if (other.getPolicy() == null ^ this.getPolicy() == null) return false; if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == false) return false; return true; }
public Policy unmarshall(StaxUnmarshallerContext context) throws Exception { Policy policy = new Policy(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; policy.setPolicyName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPolicyId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPath(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setDefaultVersionId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setAttachmentCount(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPermissionsBoundaryUsageCount(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setIsAttachable(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context));
.withVersionId(getResult.getPolicy().getDefaultVersionId())) .getPolicyVersion(); .withPolicyName(policyName)); log_.debug("Created policy " + result.getPolicy().getArn());
if ((awsManagedPolicy = policy.getArn().startsWith("arn:aws:iam::aws:policy")) && policy.getAttachmentCount() != null && policy.getAttachmentCount() == 0) { neo4j.execCypher(cypher, "a", policy.getArn(), "p", n).forEach(gc.MERGE_ACTION::accept); incrementEntityCount(); linkToAccount(policy.getArn());
private void updateAttachedEntities(AmazonIdentityManagementClient iam, Policy policy) { ListEntitiesForPolicyRequest request = new ListEntitiesForPolicyRequest() .withPolicyArn(policy.getArn()); List<String> attachedRoles = new ArrayList<>(); List<String> attachedUsers = new ArrayList<>(); while (true) { ListEntitiesForPolicyResult attachedEntities = iam.listEntitiesForPolicy(request); attachedRoles.addAll(attachedEntities.getPolicyRoles().stream() .map(rp -> createIamArn("role", rp.getRoleName())).collect(Collectors.toList())); attachedUsers.addAll(attachedEntities.getPolicyUsers().stream() .map(ur -> createIamArn("user", ur.getUserName())).collect(Collectors.toList())); // TODO - group if (!attachedEntities.isTruncated()) { break; } request.setMarker(attachedEntities.getMarker()); } if (!attachedRoles.isEmpty()) { newLinkageHelper().withLinkLabel("ATTACHED_TO").withFromArn(policy.getArn()) .withTargetLabel("AwsIamRole").withTargetValues(attachedRoles).execute(); } if (!attachedUsers.isEmpty()) { newLinkageHelper().withLinkLabel("ATTACHED_TO").withFromArn(policy.getArn()) .withTargetLabel("AwsIamUser").withTargetValues(attachedUsers).execute(); } }
versionRequest.setVersionId(p.getDefaultVersionId()); GetPolicyVersionResult versionResult = iamClient .getPolicyVersion(versionRequest);
public Policy unmarshall(StaxUnmarshallerContext context) throws Exception { Policy policy = new Policy(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; policy.setPolicyName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPolicyId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPath(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setDefaultVersionId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setAttachmentCount(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setPermissionsBoundaryUsageCount(IntegerStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setIsAttachable(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; policy.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context));
return false; Policy other = (Policy) obj; if (other.getPolicyName() == null ^ this.getPolicyName() == null) return false; if (other.getPolicyName() != null && other.getPolicyName().equals(this.getPolicyName()) == false) return false; if (other.getPolicyId() == null ^ this.getPolicyId() == null) return false; if (other.getPolicyId() != null && other.getPolicyId().equals(this.getPolicyId()) == 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.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getDefaultVersionId() == null ^ this.getDefaultVersionId() == null) return false; if (other.getDefaultVersionId() != null && other.getDefaultVersionId().equals(this.getDefaultVersionId()) == false) return false; if (other.getAttachmentCount() == null ^ this.getAttachmentCount() == null) return false; if (other.getAttachmentCount() != null && other.getAttachmentCount().equals(this.getAttachmentCount()) == false) return false; if (other.getPermissionsBoundaryUsageCount() == null ^ this.getPermissionsBoundaryUsageCount() == null) return false; if (other.getPermissionsBoundaryUsageCount() != null
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreatePolicyResult == false) return false; CreatePolicyResult other = (CreatePolicyResult) obj; if (other.getPolicy() == null ^ this.getPolicy() == null) return false; if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == false) return false; return true; }
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getPolicyName() != null) sb.append("PolicyName: ").append(getPolicyName()).append(","); if (getPolicyId() != null) sb.append("PolicyId: ").append(getPolicyId()).append(","); if (getArn() != null) sb.append("Arn: ").append(getArn()).append(","); if (getPath() != null) sb.append("Path: ").append(getPath()).append(","); if (getDefaultVersionId() != null) sb.append("DefaultVersionId: ").append(getDefaultVersionId()).append(","); if (getAttachmentCount() != null) sb.append("AttachmentCount: ").append(getAttachmentCount()).append(","); if (getPermissionsBoundaryUsageCount() != null) sb.append("PermissionsBoundaryUsageCount: ").append(getPermissionsBoundaryUsageCount()).append(","); if (getIsAttachable() != null) sb.append("IsAttachable: ").append(getIsAttachable()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getCreateDate() != null) sb.append("CreateDate: ").append(getCreateDate()).append(","); if (getUpdateDate() != null) sb.append("UpdateDate: ").append(getUpdateDate()); sb.append("}"); return sb.toString();
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GetPolicyResult == false) return false; GetPolicyResult other = (GetPolicyResult) obj; if (other.getPolicy() == null ^ this.getPolicy() == null) return false; if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == false) return false; return true; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getPolicyName() == null) ? 0 : getPolicyName().hashCode()); hashCode = prime * hashCode + ((getPolicyId() == null) ? 0 : getPolicyId().hashCode()); hashCode = prime * hashCode + ((getArn() == null) ? 0 : getArn().hashCode()); hashCode = prime * hashCode + ((getPath() == null) ? 0 : getPath().hashCode()); hashCode = prime * hashCode + ((getDefaultVersionId() == null) ? 0 : getDefaultVersionId().hashCode()); hashCode = prime * hashCode + ((getAttachmentCount() == null) ? 0 : getAttachmentCount().hashCode()); hashCode = prime * hashCode + ((getPermissionsBoundaryUsageCount() == null) ? 0 : getPermissionsBoundaryUsageCount().hashCode()); hashCode = prime * hashCode + ((getIsAttachable() == null) ? 0 : getIsAttachable().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode()); hashCode = prime * hashCode + ((getUpdateDate() == null) ? 0 : getUpdateDate().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreatePolicyResult == false) return false; CreatePolicyResult other = (CreatePolicyResult) obj; if (other.getPolicy() == null ^ this.getPolicy() == null) return false; if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == false) return false; return true; }
return false; Policy other = (Policy) obj; if (other.getPolicyName() == null ^ this.getPolicyName() == null) return false; if (other.getPolicyName() != null && other.getPolicyName().equals(this.getPolicyName()) == false) return false; if (other.getPolicyId() == null ^ this.getPolicyId() == null) return false; if (other.getPolicyId() != null && other.getPolicyId().equals(this.getPolicyId()) == 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.getPath() == null ^ this.getPath() == null) return false; if (other.getPath() != null && other.getPath().equals(this.getPath()) == false) return false; if (other.getDefaultVersionId() == null ^ this.getDefaultVersionId() == null) return false; if (other.getDefaultVersionId() != null && other.getDefaultVersionId().equals(this.getDefaultVersionId()) == false) return false; if (other.getAttachmentCount() == null ^ this.getAttachmentCount() == null) return false; if (other.getAttachmentCount() != null && other.getAttachmentCount().equals(this.getAttachmentCount()) == false) return false; if (other.getPermissionsBoundaryUsageCount() == null ^ this.getPermissionsBoundaryUsageCount() == null) return false; if (other.getPermissionsBoundaryUsageCount() != null
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getPolicyName() != null) sb.append("PolicyName: ").append(getPolicyName()).append(","); if (getPolicyId() != null) sb.append("PolicyId: ").append(getPolicyId()).append(","); if (getArn() != null) sb.append("Arn: ").append(getArn()).append(","); if (getPath() != null) sb.append("Path: ").append(getPath()).append(","); if (getDefaultVersionId() != null) sb.append("DefaultVersionId: ").append(getDefaultVersionId()).append(","); if (getAttachmentCount() != null) sb.append("AttachmentCount: ").append(getAttachmentCount()).append(","); if (getPermissionsBoundaryUsageCount() != null) sb.append("PermissionsBoundaryUsageCount: ").append(getPermissionsBoundaryUsageCount()).append(","); if (getIsAttachable() != null) sb.append("IsAttachable: ").append(getIsAttachable()).append(","); if (getDescription() != null) sb.append("Description: ").append(getDescription()).append(","); if (getCreateDate() != null) sb.append("CreateDate: ").append(getCreateDate()).append(","); if (getUpdateDate() != null) sb.append("UpdateDate: ").append(getUpdateDate()); sb.append("}"); return sb.toString();