* The SOAP equivalent of this function appears to allow multiple permissions per request, yet
* in the REST API documentation only one permission is allowed.
*/
private void revokeSecurityGroupIngress( HttpServletRequest request, HttpServletResponse response )
throws ADBException, XMLStreamException, IOException {
EC2AuthorizeRevokeSecurityGroup EC2request = new EC2AuthorizeRevokeSecurityGroup();
String[] groupName = request.getParameterValues( "GroupName" );
if ( null != groupName && 0 < groupName.length )
EC2request.setName( groupName[0] );
else { response.sendError(530, "Missing GroupName parameter" ); return; }
EC2IpPermission perm = new EC2IpPermission();
String[] protocol = request.getParameterValues( "IpProtocol" );
if ( null != protocol && 0 < protocol.length )
perm.setProtocol( protocol[0] );
else { response.sendError(530, "Missing IpProtocol parameter" ); return; }
String[] fromPort = request.getParameterValues( "FromPort" );
if ( null != fromPort && 0 < fromPort.length )
perm.setProtocol( fromPort[0] );
else { response.sendError(530, "Missing FromPort parameter" ); return; }
String[] toPort = request.getParameterValues( "ToPort" );
if ( null != toPort && 0 < toPort.length )
perm.setProtocol( toPort[0] );
else { response.sendError(530, "Missing ToPort parameter" ); return; }
String[] ranges = request.getParameterValues( "CidrIp" );
if ( null != ranges && 0 < ranges.length)
perm.addIpRange( ranges[0] );
else { response.sendError(530, "Missing CidrIp parameter" ); return; }
String[] user = request.getParameterValues( "SourceSecurityGroupOwnerId" );
if ( null == user || 0 == user.length) {
response.sendError(530, "Missing SourceSecurityGroupOwnerId parameter" );
return;
}
String[] name = request.getParameterValues( "SourceSecurityGroupName" );
if ( null == name || 0 == name.length) {
response.sendError(530, "Missing SourceSecurityGroupName parameter" );
return;
}
EC2SecurityGroup group = new EC2SecurityGroup();
group.setAccount( user[0] );
group.setName( name[0] );
perm.addUser( group );
EC2request.addIpPermission( perm );
// -> execute the request
RevokeSecurityGroupIngressResponse EC2response = EC2SoapServiceImpl.toRevokeSecurityGroupIngressResponse(
ServiceProvider.getInstance().getEC2Engine().revokeSecurityGroup( EC2request ));
serializeResponse(response, EC2response);