/** * Constructs a new principal with the specified AWS web service which * is being allowed or denied access to a resource through an access control * policy. * * @param service * An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
/** * Construct the Services object from a string representing the service id. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }
/** * Constructs a new principal with the specified AWS web service which is * being allowed or denied access to a resource through an access control * policy. * * @param service An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
/** * Construct the Services object from a string representing the service * id. * @param serviceId the service ID. * @return the Services object. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }
/** * Construct the Services object from a string representing the service * id. * @param serviceId the service ID. * @return the Services object. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }
/** * Constructs a new principal with the specified AWS web service which * is being allowed or denied access to a resource through an access control * policy. * * @param service * An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
/** * Constructs a new principal with the specified AWS web service which is * being allowed or denied access to a resource through an access control * policy. * * @param service An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
/** * Construct the Services object from a string representing the service id. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }
/** * Constructs a new principal with the specified AWS web service which is * being allowed or denied access to a resource through an access control * policy. * * @param service An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
assertEquals(2, statements.get(0).getPrincipals().size()); assertEquals("Service", statements.get(0).getPrincipals().get(0).getProvider()); assertEquals(Services.AmazonEC2.getServiceId(), statements.get(0).getPrincipals().get(0) .getId()); assertEquals("Service", statements.get(0).getPrincipals().get(1).getProvider()); assertEquals(Services.AmazonElasticTranscoder.getServiceId(), statements.get(0) .getPrincipals().get(1).getId());
@Test public void testCloudHSMServicePrincipal() { String jsonString = "{" + "\"Version\":\"2008-10-17\"," + "\"Statement\":[" + "{\"Sid\":\"\"," + "\"Effect\":\"Allow\"," + "\"Principal\":{\"Service\":\"cloudhsm.amazonaws.com\"}," + "\"Action\":\"sts:AssumeRole\"}" + "]" + "}"; Policy policy = Policy.fromJson(jsonString); assertEquals(POLICY_VERSION, policy.getVersion()); List<Statement> statements = new LinkedList<Statement>(policy.getStatements()); assertEquals(1, statements.size()); assertEquals(1, statements.get(0).getActions().size()); assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals("sts:AssumeRole", statements.get(0).getActions().get(0).getActionName()); assertEquals(0, statements.get(0).getConditions().size()); assertEquals(1, statements.get(0).getPrincipals().size()); assertEquals(Services.AWSCloudHSM.getServiceId(), statements.get(0).getPrincipals().get(0) .getId()); assertEquals("Service", statements.get(0).getPrincipals().get(0).getProvider()); }
/** * Construct the Services object from a string representing the service * id. * @param serviceId the service ID. * @return the Services object. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }
/** * Constructs a new principal with the specified AWS web service which * is being allowed or denied access to a resource through an access control * policy. * * @param service * An AWS service. */ public Principal(Services service) { if (service == null) { throw new IllegalArgumentException("Null AWS service name specified"); } id = service.getServiceId(); provider = "Service"; }
/** * Construct the Services object from a string representing the service id. */ public static Services fromString(String serviceId) { if (serviceId != null) { for (Services s : Services.values()) { if (s.getServiceId().equalsIgnoreCase(serviceId)) { return s; } } } return null; }