本文整理汇总了Java中org.jclouds.net.domain.IpPermission类的典型用法代码示例。如果您正苦于以下问题:Java IpPermission类的具体用法?Java IpPermission怎么用?Java IpPermission使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IpPermission类属于org.jclouds.net.domain包,在下文中一共展示了IpPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addIpPermissionCidrFromIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void addIpPermissionCidrFromIpPermission() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/describe_securitygroups_extension_cidr.xml");
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
SecurityGroup newGroup = extension().addIpPermission(permByCidrBlock, group);
assertEquals(1, newGroup.getIpPermissions().size());
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
assertEquals(newPerm, permByCidrBlock);
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION,
"Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=40&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupId.1=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
}
示例2: addIpPermissionCidrFromParams
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void addIpPermissionCidrFromParams() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/describe_securitygroups_extension_cidr.xml");
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
SecurityGroup newGroup = extension()
.addIpPermission(permByCidrBlock.getIpProtocol(), permByCidrBlock.getFromPort(),
permByCidrBlock.getToPort(), permByCidrBlock.getTenantIdGroupNamePairs(),
permByCidrBlock.getCidrBlocks(), permByCidrBlock.getGroupIds(), group);
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
assertEquals(newPerm, permByCidrBlock);
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION,
"Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=40&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupId.1=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
}
示例3: addIpPermissionGroupFromIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void addIpPermissionGroupFromIpPermission() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/describe_securitygroups_extension_group.xml");
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
SecurityGroup newGroup = extension().addIpPermission(permByGroup, group);
assertEquals(1, newGroup.getIpPermissions().size());
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
assertEquals(newPerm, permByGroup);
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION,
"Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=40&IpPermissions.0.Groups.0.UserId=993194456877&IpPermissions.0.Groups.0.GroupId=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupId.1=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
}
示例4: addIpPermissionGroupFromParams
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void addIpPermissionGroupFromParams() throws Exception {
enqueueRegions(DEFAULT_REGION);
enqueueXml(DEFAULT_REGION, "/authorize_securitygroup_ingress_response.xml");
enqueueXml(DEFAULT_REGION, "/describe_securitygroups_extension_group.xml");
enqueueXml(DEFAULT_REGION, "/availabilityZones.xml");
SecurityGroup newGroup = extension()
.addIpPermission(permByGroup.getIpProtocol(), permByGroup.getFromPort(), permByGroup.getToPort(),
permByGroup.getTenantIdGroupNamePairs(), permByGroup.getCidrBlocks(), permByGroup.getGroupIds(),
group);
IpPermission newPerm = Iterables.getOnlyElement(newGroup.getIpPermissions());
assertEquals(newPerm, permByGroup);
assertPosted(DEFAULT_REGION, "Action=DescribeRegions");
assertPosted(DEFAULT_REGION,
"Action=AuthorizeSecurityGroupIngress&GroupId=sg-3c6ef654&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=22&IpPermissions.0.ToPort=40&IpPermissions.0.Groups.0.UserId=993194456877&IpPermissions.0.Groups.0.GroupId=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeSecurityGroups&GroupId.1=sg-3c6ef654");
assertPosted(DEFAULT_REGION, "Action=DescribeAvailabilityZones");
}
示例5: testApply
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Test
public void testApply() {
IpPermissions authorization = IpPermissions.permitAnyProtocol();
org.jclouds.ec2.domain.SecurityGroup origGroup = org.jclouds.ec2.domain.SecurityGroup.builder()
.region("us-east-1")
.id("some-id")
.name("some-group")
.ownerId("some-owner")
.description("some-description")
.ipPermission(authorization)
.build();
AWSEC2SecurityGroupToSecurityGroup parser = createGroupParser(ImmutableSet.of(provider));
SecurityGroup group = parser.apply(origGroup);
assertEquals(group.getLocation(), provider);
assertEquals(group.getId(), provider.getId() + "/" + origGroup.getId());
assertEquals(group.getProviderId(), origGroup.getId());
assertEquals(group.getName(), origGroup.getName());
assertEquals(group.getIpPermissions(), (Set<IpPermission>)origGroup);
assertEquals(group.getOwnerId(), origGroup.getOwnerId());
}
示例6: testAuthorizeSecurityGroupIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void testAuthorizeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
String.class, String.class, IpPermission.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
示例7: testAuthorizeSecurityGroupIpPermissions
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void testAuthorizeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion",
String.class, String.class, Iterable.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
.originatingFromSecurityGroupId("groupId"))));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
示例8: testRevokeSecurityGroupIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void testRevokeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
String.class, IpPermission.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", IpPermissions.permitAnyProtocol()));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0/0",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
示例9: testRevokeSecurityGroupIpPermissions
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public void testRevokeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
Invokable<?, ?> method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class,
String.class, Iterable.class);
GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "group", ImmutableSet.<IpPermission> of(IpPermissions
.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
.originatingFromSecurityGroupId("groupId"))));
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
assertPayloadEquals(
request,
"Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1/32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
"application/x-www-form-urlencoded", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, null);
checkFilters(request);
}
示例10: expected
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
public Set<SecurityGroup> expected() {
return ImmutableSet.of(SecurityGroup.builder()
.region(defaultRegion)
.ownerId("123123123123")
.id("sg-11111111")
.name("default")
.description("default VPC security group")
// .vpcId("vpc-99999999")
.ipPermission(IpPermission.builder()
.ipProtocol(IpProtocol.ALL)
.tenantIdGroupNamePair("123123123123", "sg-11111111").build())
// .ipPermissionEgress(IpPermission.builder()
// .ipProtocol(IpProtocol.ALL)
// .ipRange("0.0.0.0/0").build())
.build());
}
示例11: addRule
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Override
public SecurityGroup addRule(SecurityGroupRule rule, String securityGroupId) {
checkNotNull(rule, "rule is null");
checkNotNull(securityGroupId, "securityGroupId is null");
checkArgument(!securityGroupId.isEmpty(), "securityGroupId is empty");
org.jclouds.net.domain.IpProtocol ipProtocol;
switch (rule.ipProtocol()) {
case ALL:
ipProtocol = org.jclouds.net.domain.IpProtocol.ALL;
break;
case ICMP:
ipProtocol = org.jclouds.net.domain.IpProtocol.ICMP;
break;
case TCP:
ipProtocol = org.jclouds.net.domain.IpProtocol.TCP;
break;
case UDP:
ipProtocol = org.jclouds.net.domain.IpProtocol.UDP;
break;
default:
throw new AssertionError("unknown ipProtocol" + rule.ipProtocol());
}
org.jclouds.compute.domain.SecurityGroup jcloudsSecurityGroup =
securityGroupExtension.getSecurityGroupById(securityGroupId);
IpPermission ipPermission =
new IpPermission.Builder().cidrBlock(rule.cidr().toString()).fromPort(rule.fromPort())
.toPort(rule.toPort()).ipProtocol(ipProtocol).build();
return securityGroupConverter
.apply(securityGroupExtension.addIpPermission(ipPermission, jcloudsSecurityGroup));
}
示例12: JCloudsSecurityGroupToSecurityGroup
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Inject
public JCloudsSecurityGroupToSecurityGroup(
OneWayConverter<org.jclouds.domain.Location, Location> locationConverter,
OneWayConverter<IpPermission, SecurityGroupRule> securityGroupRuleConverter) {
checkNotNull(securityGroupRuleConverter);
this.securityGroupRuleConverter = securityGroupRuleConverter;
checkNotNull(locationConverter);
this.locationConverter = locationConverter;
}
示例13: apply
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Override
public SecurityGroupRule apply(IpPermission ipPermission) {
SecurityGroupRuleBuilder securityGroupRuleBuilder = SecurityGroupRuleBuilder.newBuilder()
.ipProtocol(ipProtocolConverter.apply(ipPermission.getIpProtocol()))
.fromPort(ipPermission.getFromPort()).toPort(ipPermission.getToPort());
//todo: we only want to support cidr, can we ensure this?
checkState(ipPermission.getCidrBlocks().size() == 1);
securityGroupRuleBuilder.cidr(CidrImpl.of(ipPermission.getCidrBlocks().iterator().next()));
checkState(ipPermission.getExclusionCidrBlocks().size() == 0);
return securityGroupRuleBuilder.build();
}
示例14: addIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Override
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
String id = group.getProviderId();
client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, id, ipPermission);
return getSecurityGroupById(group.getId());
}
示例15: removeIpPermission
import org.jclouds.net.domain.IpPermission; //导入依赖的package包/类
@Override
public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation());
String id = group.getProviderId();
client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, id, ipPermission);
return getSecurityGroupById(group.getId());
}