@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getGroupName() == null) ? 0 : getGroupName().hashCode()); hashCode = prime * hashCode + ((getGroupId() == null) ? 0 : getGroupId().hashCode()); return hashCode; }
public GroupIdentifier unmarshall(StaxUnmarshallerContext context) throws Exception { GroupIdentifier groupIdentifier = new GroupIdentifier(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return groupIdentifier; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("groupName", targetDepth)) { groupIdentifier.setGroupName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("groupId", targetDepth)) { groupIdentifier.setGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return groupIdentifier; } } } }
private boolean verifySecurityGroups(Instance instance) { boolean result = false; List<String> expectedIds = new ArrayList<String>(); for (SecurityGroupRefTask group : getSecurityGroupRefs()) { expectedIds.add(group.fetchSecurityGroup().getId()); } List<String> foundIds = new ArrayList<String>(); List<GroupIdentifier> gids = instance.getSecurityGroups(); if (gids != null && !gids.isEmpty()) { for (GroupIdentifier gid : gids) { foundIds.add(gid.getGroupId()); } } return result; }
public static List<GroupIdentifier> getSecurityGroupsByInstanceId(String instanceId, String esUrl) throws Exception { List<GroupIdentifier> list = new ArrayList<>(); JsonParser jsonParser = new JsonParser(); Map<String, Object> mustFilter = new HashMap<>(); Map<String, Object> mustNotFilter = new HashMap<>(); HashMultimap<String, Object> shouldFilter = HashMultimap.create(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.INSTANCEID), instanceId); JsonObject resultJson = RulesElasticSearchRepositoryUtil.getQueryDetailsFromES(esUrl, mustFilter, mustNotFilter, shouldFilter, null, 0, mustTermsFilter, null); if (resultJson != null && resultJson.has(PacmanRuleConstants.HITS)) { JsonObject hitsJson = (JsonObject) jsonParser.parse(resultJson.get(PacmanRuleConstants.HITS).toString()); JsonArray hitsArray = hitsJson.getAsJsonArray(PacmanRuleConstants.HITS); for (int i = 0; i < hitsArray.size(); i++) { JsonObject source = hitsArray.get(i).getAsJsonObject().get(PacmanRuleConstants.SOURCE) .getAsJsonObject(); String securitygroupid = source.get(PacmanRuleConstants.EC2_WITH_SECURITYGROUP_ID).getAsString(); GroupIdentifier groupIdentifier = new GroupIdentifier(); if (!com.amazonaws.util.StringUtils.isNullOrEmpty(securitygroupid)) { groupIdentifier.setGroupId(securitygroupid); list.add(groupIdentifier); } } } return list; }
private void populateReservationSecurityGroupNames(Reservation reservation) { List<String> groupNames = new ArrayList<String>(); for (GroupIdentifier group : reservation.getGroups()) { groupNames.add(group.getGroupName()); } reservation.setGroupNames(groupNames); }
@Override public DescribeInstanceAttributeResult describeInstanceAttribute(AmazonEC2Client ec2Client, DescribeInstanceAttributeRequest describeInstanceAttributeRequest) { InstanceAttribute instanceAttribute = new InstanceAttribute(); instanceAttribute.withGroups(new GroupIdentifier().withGroupId("A_TEST_SECURITY_GROUP")); return new DescribeInstanceAttributeResult().withInstanceAttribute(instanceAttribute); }
/** * <p> * The ID of the security group. * </p> * * @param groupId * The ID of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupId(String groupId) { setGroupId(groupId); return this; }
/** * <p> * The name of the security group. * </p> * * @param groupName * The name of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupName(String groupName) { setGroupName(groupName); return this; }
StringBuilder requestBody = new StringBuilder( "{\"query\":{\"bool\":{\"must\":[{\"term\":{\"groupid.keyword\":{\"value\":\"" + securityGrp.getGroupId() + "\"}}},{\"term\":{\"cidrip.keyword\":{\"value\":\"" + cidrIp JsonArray hitsArray = hitsJson.getAsJsonArray("hits"); logger.info(sgRulesUrl); logger.info(securityGrp.getGroupId()); logger.info(portToCheck); for (int i = 0; i < hitsArray.size(); i++) {
Annotation annotation = null; Set<GroupIdentifier> securityGroupsSet = new HashSet<>(); GroupIdentifier groupIdentifier = new GroupIdentifier(); List<GroupIdentifier> list = new ArrayList<>(); String securityGroupId = ruleParam.get(PacmanSdkConstants.RESOURCE_ID); groupIdentifier.setGroupId(securityGroupId); list.add(groupIdentifier); securityGroupsSet.addAll(list);
private void populateLaunchSpecificationSecurityGroupNames(LaunchSpecification launchSpecification) { List<String> groupNames = new ArrayList<String>(); for (GroupIdentifier group : launchSpecification.getAllSecurityGroups()) { groupNames.add(group.getGroupName()); } launchSpecification.setSecurityGroups(groupNames); } }
/** * <p> * The ID of the security group. * </p> * * @param groupId * The ID of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupId(String groupId) { setGroupId(groupId); return this; }
/** * <p> * The name of the security group. * </p> * * @param groupName * The name of the security group. * @return Returns a reference to this object so that method calls can be chained together. */ public GroupIdentifier withGroupName(String groupName) { setGroupName(groupName); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GroupIdentifier == false) return false; GroupIdentifier other = (GroupIdentifier) obj; if (other.getGroupName() == null ^ this.getGroupName() == null) return false; if (other.getGroupName() != null && other.getGroupName().equals(this.getGroupName()) == false) return false; if (other.getGroupId() == null ^ this.getGroupId() == null) return false; if (other.getGroupId() != null && other.getGroupId().equals(this.getGroupId()) == false) return false; return true; }
HashMultimap<String, Object> shouldFilter = HashMultimap.create(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.GROUP_ID), securityGrp.getGroupId()); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.CIDRIP), cidrIp); mustFilter.put(convertAttributetoKeyword(PacmanSdkConstants.TYPE), PacmanRuleConstants.INBOUND);
Annotation annotation = null; Set<GroupIdentifier> securityGroupsSet = new HashSet<>(); GroupIdentifier groupIdentifier = new GroupIdentifier(); List<GroupIdentifier> list = new ArrayList<>(); String securityGroupId = ruleParam.get(PacmanSdkConstants.RESOURCE_ID); groupIdentifier.setGroupId(securityGroupId); list.add(groupIdentifier); securityGroupsSet.addAll(list);
public GroupIdentifier unmarshall(StaxUnmarshallerContext context) throws Exception { GroupIdentifier groupIdentifier = new GroupIdentifier(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) return groupIdentifier; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("groupName", targetDepth)) { groupIdentifier.setGroupName(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } if (context.testExpression("groupId", targetDepth)) { groupIdentifier.setGroupId(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { return groupIdentifier; } } } }
private void populateReservationSecurityGroupNames(Reservation reservation) { List<String> groupNames = new ArrayList<String>(); for (GroupIdentifier group : reservation.getGroups()) { groupNames.add(group.getGroupName()); } reservation.setGroupNames(groupNames); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getGroupName() != null) sb.append("GroupName: ").append(getGroupName()).append(","); if (getGroupId() != null) sb.append("GroupId: ").append(getGroupId()); sb.append("}"); return sb.toString(); }
HashMultimap<String, Object> shouldFilter = HashMultimap.create(); Map<String, Object> mustTermsFilter = new HashMap<>(); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.GROUP_ID), securityGrp.getGroupId()); mustFilter.put(convertAttributetoKeyword(PacmanRuleConstants.CIDRIP), cidrIp); mustFilter.put(convertAttributetoKeyword(PacmanSdkConstants.TYPE), PacmanRuleConstants.INBOUND); JsonArray hitsArray = hitsJson.getAsJsonArray(PacmanRuleConstants.HITS); logger.info(sgRulesUrl); logger.info(securityGrp.getGroupId()); logger.info(portToCheck); for (int i = 0; i < hitsArray.size(); i++) {