List of usage examples for com.amazonaws.services.ec2.model IpPermission setUserIdGroupPairs
public void setUserIdGroupPairs(java.util.Collection<UserIdGroupPair> userIdGroupPairs)
The security group and AWS account ID pairs.
From source file:com.norbl.cbp.ppe.SecurityGroupFactory.java
License:Open Source License
private IpPermission createIPPermissionGroup(String protocol, int fromPort, int toPort, String group) { IpPermission ipp = new IpPermission(); ipp.setIpProtocol(protocol);// w w w .ja va 2 s .c om ipp.setFromPort(fromPort); ipp.setToPort(toPort); List<UserIdGroupPair> gps = new ArrayList<UserIdGroupPair>(); UserIdGroupPair gp = new UserIdGroupPair(); gp.setGroupName(group); gp.setUserId(params.getAWSUserID()); gps.add(gp); ipp.setUserIdGroupPairs(gps); return (ipp); }
From source file:jp.primecloud.auto.aws.typica.converter.IpPermissionConverter.java
License:Open Source License
@Override protected IpPermission convertObject(com.xerox.amazonws.ec2.GroupDescription.IpPermission from) { IpPermission to = new IpPermission(); to.setIpProtocol(from.getProtocol()); to.setFromPort(from.getFromPort());// www . jav a 2 s .com to.setToPort(from.getToPort()); to.setUserIdGroupPairs(new UserIdGroupPairConverter().convert(from.getUidGroupPairs())); to.setIpRanges(from.getIpRanges()); return to; }
From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java
License:Apache License
public void authorizeGroup(String securityGroupName, String sourceGroupName, String sourceGroupOwner, Integer fromPort, Integer toPort, String protocol) { try {//w ww . j a va 2 s . c o m AuthorizeSecurityGroupIngressRequest request = new AuthorizeSecurityGroupIngressRequest(); // if(this.cloudType == InstanceService.CLOUD_TYPE_EUCALYPTUS) { /* request.setFromPort(fromPort); request.setToPort(toPort); request.setSourceSecurityGroupName(sourceGroupName); request.setSourceSecurityGroupOwnerId(sourceGroupOwner); request.setIpProtocol(protocol); */ // } else { UserIdGroupPair pair = new UserIdGroupPair(); pair.setGroupName(sourceGroupName); pair.setUserId(sourceGroupOwner); List<UserIdGroupPair> idList = new ArrayList<UserIdGroupPair>(); idList.add(pair); IpPermission perm = new IpPermission(); perm.setUserIdGroupPairs(idList); perm.setFromPort(fromPort); perm.setToPort(toPort); perm.setIpProtocol(protocol); List<IpPermission> permList = new ArrayList<IpPermission>(); permList.add(perm); request.setIpPermissions(permList); // } request.setGroupName(securityGroupName); ec2.authorizeSecurityGroupIngress(request); } catch (Exception e) { String message = e.getMessage(); LOG.error("Could not set authorized IP:s to security group: " + message); ExceptionUtil.throwSystemException(message, e); } }
From source file:org.openinfinity.cloud.service.administrator.EC2Wrapper.java
License:Apache License
public void revokeGroup(String securityGroupName, String sourceGroupName, String sourceGroupOwner, Integer fromPort, Integer toPort, String protocol) { try {/* w w w. j av a2 s . c om*/ RevokeSecurityGroupIngressRequest request = new RevokeSecurityGroupIngressRequest(); UserIdGroupPair pair = new UserIdGroupPair(); pair.setGroupName(sourceGroupName); pair.setUserId(sourceGroupOwner); List<UserIdGroupPair> idList = new ArrayList<UserIdGroupPair>(); idList.add(pair); IpPermission perm = new IpPermission(); perm.setUserIdGroupPairs(idList); perm.setFromPort(fromPort); perm.setToPort(toPort); perm.setIpProtocol(protocol); List<IpPermission> permList = new ArrayList<IpPermission>(); permList.add(perm); request.setIpPermissions(permList); request.setGroupName(securityGroupName); ec2.revokeSecurityGroupIngress(request); } catch (Exception e) { String message = e.getMessage(); LOG.error("Could not set authorized IP:s to security group: " + message); ExceptionUtil.throwSystemException(message, e); } }