public SecurityGroup build() { return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); }
public SecurityGroup build() { return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); }
public SecurityGroup build() { return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); }
public SecurityGroup build() { return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); }
public SecurityGroup build() { return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); }
public boolean commit() throws LoginException { // some validation code here Set<Principal> principals = subject.getPrincipals(); // ensure principals contains (CallerPrincipal and UserRoles) createRolesGroup(principals); return true; } private void createRolesGroup(Set<Principal> principals) { // Thee java.security.acl.Group implementation SecurityGroup rolesGroup = new SecurityGroup("Roles"); Iterator<Principal> iter = principals.iterator(); while(iter.hasNext()) { Object principal = iter.next(); if(!(principal instanceof Group)){ rolesGroup.addMember((Principal)principal); } principals.add(rolesGroup); }
public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml"); Set<SecurityGroup> expected = ImmutableSet.of( new SecurityGroup(defaultRegion, null, "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", ImmutableSet.of(new IpPermission(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")))), new SecurityGroup(defaultRegion, null, "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A", ImmutableSet.of(new IpPermission(IpProtocol.TCP, 6000, 7000, ImmutableMultimap .<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of())))); DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); addDefaultRegionToHandler(handler); Set<SecurityGroup> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); }
public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml"); Set<SecurityGroup> expected = ImmutableSet.of( new SecurityGroup(defaultRegion, "sg-3c6ef654", "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", ImmutableSet.of(new IpPermission(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0"), ImmutableSet.<String> of()))), new SecurityGroup(defaultRegion, "sg-867309ab", "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A", ImmutableSet.of(new IpPermission(IpProtocol.TCP, 6000, 7000, ImmutableMultimap .<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of())))); DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); addDefaultRegionToHandler(handler); Set<SecurityGroup> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); }
public void testApplyInputStreamWithEmptyFields() { InputStream is = getClass().getResourceAsStream("/describe_securitygroups_empty.xml"); Multimap<String, String> userIdGroupPairs = LinkedHashMultimap.create(); userIdGroupPairs.put("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "jclouds#cluster#world"); Set<SecurityGroup> expected = ImmutableSet.of( new SecurityGroup(defaultRegion, null, "jclouds#cluster#world", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Cluster", ImmutableSet.of( new IpPermission(IpProtocol.TCP, 22, 22, ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")), new IpPermission(IpProtocol.ALL, -1, -1, userIdGroupPairs, ImmutableSet.<String> of(), ImmutableSet.<String> of())))); DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); addDefaultRegionToHandler(handler); Set<SecurityGroup> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); }
public void testApplyInputStreamWithEmptyFields() { InputStream is = getClass().getResourceAsStream("/describe_securitygroups_empty.xml"); Multimap<String, String> userIdGroupPairs = LinkedHashMultimap.create(); userIdGroupPairs.put("UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "jclouds#cluster#world"); Set<SecurityGroup> expected = ImmutableSet.of( new SecurityGroup(defaultRegion, "sg-3c6ef654", "jclouds#cluster#world", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Cluster", ImmutableSet.of( new IpPermission(IpProtocol.TCP, 22, 22, ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0"), ImmutableSet.<String> of()), new IpPermission(IpProtocol.ALL, -1, -1, userIdGroupPairs, ImmutableSet.<String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of())))); DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class); addDefaultRegionToHandler(handler); Set<SecurityGroup> result = factory.create(handler).parse(is); assertEquals(result.toString(), expected.toString()); }