public void endElement(String uri, String name, String qName) { if (qName.equals("TargetBucket")) { this.targetBucket = currentOrNull(currentText); } else if (qName.equals("TargetPrefix")) { this.targetPrefix = currentOrNull(currentText); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { targetGrants.add(new Grant(currentGrantee, currentPermission)); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
ImmutableSet.<Grant> of(new Grant(new EmailAddressGrantee(TEST_ACL_EMAIL), FULL_CONTROL)));
ImmutableSet.<Grant> of(new Grant(new EmailAddressGrantee(StubS3AsyncClient.TEST_ACL_EMAIL), Permission.FULL_CONTROL)));
public void endElement(String uri, String name, String qName) { if (qName.equals("Owner")) { CanonicalUser owner = new CanonicalUser(currentId); owner.setDisplayName(currentDisplayName); acl.setOwner(owner); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { acl.addPermission(currentGrantee, currentPermission); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
public void endElement(String uri, String name, String qName) { if (qName.equals("TargetBucket")) { this.targetBucket = currentOrNull(currentText); } else if (qName.equals("TargetPrefix")) { this.targetPrefix = currentOrNull(currentText); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { targetGrants.add(new Grant(currentGrantee, currentPermission)); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
public void endElement(String uri, String name, String qName) { if (qName.equals("TargetBucket")) { this.targetBucket = currentOrNull(currentText); } else if (qName.equals("TargetPrefix")) { this.targetPrefix = currentOrNull(currentText); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { targetGrants.add(new Grant(currentGrantee, currentPermission)); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText = new StringBuilder(); }
public void endElement(String uri, String name, String qName) { if (qName.equals("Owner")) { CanonicalUser owner = new CanonicalUser(currentId); owner.setDisplayName(currentDisplayName); acl.setOwner(owner); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { acl.addPermission(currentGrantee, currentPermission); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
public void endElement(String uri, String name, String qName) { if (qName.equals("TargetBucket")) { this.targetBucket = currentOrNull(currentText); } else if (qName.equals("TargetPrefix")) { this.targetPrefix = currentOrNull(currentText); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { targetGrants.add(new Grant(currentGrantee, currentPermission)); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
public void endElement(String uri, String name, String qName) { if (qName.equals("Owner")) { CanonicalUser owner = new CanonicalUser(currentId); owner.setDisplayName(currentDisplayName); acl.setOwner(owner); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { acl.addPermission(currentGrantee, currentPermission); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText = new StringBuilder(); }
public void endElement(String uri, String name, String qName) { if (qName.equals("Owner")) { CanonicalUser owner = new CanonicalUser(currentId); owner.setDisplayName(currentDisplayName); acl.setOwner(owner); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { acl.addPermission(currentGrantee, currentPermission); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText.setLength(0); }
public void endElement(String uri, String name, String qName) { if (qName.equals("TargetBucket")) { this.targetBucket = currentOrNull(currentText); } else if (qName.equals("TargetPrefix")) { this.targetPrefix = currentOrNull(currentText); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { targetGrants.add(new Grant(currentGrantee, currentPermission)); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText = new StringBuilder(); }
public void endElement(String uri, String name, String qName) { if (qName.equals("Owner")) { CanonicalUser owner = new CanonicalUser(currentId); owner.setDisplayName(currentDisplayName); acl.setOwner(owner); } else if (qName.equals("Grantee")) { if ("AmazonCustomerByEmail".equals(currentGranteeType)) { currentGrantee = new EmailAddressGrantee(currentId); } else if ("CanonicalUser".equals(currentGranteeType)) { currentGrantee = new CanonicalUserGrantee(currentId, currentDisplayName); } else if ("Group".equals(currentGranteeType)) { currentGrantee = new GroupGrantee(URI.create(currentId)); } } else if (qName.equals("Grant")) { acl.addPermission(currentGrantee, currentPermission); } else if (qName.equals("ID") || qName.equals("EmailAddress") || qName.equals("URI")) { currentId = currentOrNull(currentText); } else if (qName.equals("DisplayName")) { currentDisplayName = currentOrNull(currentText); } else if (qName.equals("Permission")) { currentPermission = currentOrNull(currentText); } currentText = new StringBuilder(); }
/** * Replace any AmazonCustomerByEmail grantees with a somewhat-arbitrary canonical user grantee, * to match S3 which substitutes each email address grantee with that user's corresponding ID. In * short, although you can PUT email address grantees, these are actually subsequently returned * by S3 as canonical user grantees. * * @param acl * @return */ protected AccessControlList sanitizeUploadedACL(AccessControlList acl) { // Replace any email address grantees with canonical user grantees, using // the acl's owner ID as the surrogate replacement. for (Grant grant : acl.getGrants()) { if (grant.getGrantee() instanceof EmailAddressGrantee) { EmailAddressGrantee emailGrantee = (EmailAddressGrantee) grant.getGrantee(); String id = emailGrantee.getEmailAddress().equals(TEST_ACL_EMAIL) ? TEST_ACL_ID : acl.getOwner().getId(); grant.setGrantee(new CanonicalUserGrantee(id, acl.getOwner().getDisplayName())); } } return acl; }
public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(S3Client.class, "enableBucketLogging", String.class, BucketLogging.class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/bucket_logging.xml")), "text/xml", false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); assertFallbackClassEquals(method, null); checkFilters(request); }
public void testApplyInputStream() throws IOException { BucketLogging bucketLogging = new BucketLogging("mylogs", "access_log-", ImmutableSet .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream( "/bucket_logging.xml")); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build(); BindBucketLoggingToXmlPayload binder = injector .getInstance(BindBucketLoggingToXmlPayload.class); binder.bindToRequest(request, bucketLogging); assertEquals(request.getPayload().getContentMetadata().getContentType(), "text/xml"); assertEquals(request.getPayload().getRawContent(), expected); } }
public String getEmailAddress() { return getIdentifier(); } }
public String getEmailAddress() { return getIdentifier(); } }
public void testApplyInputStream() throws IOException { BucketLogging bucketLogging = new BucketLogging("mylogs", "access_log-", ImmutableSet .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))); String expected = Strings2.toStringAndClose(getClass().getResourceAsStream( "/bucket_logging.xml")); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build(); BindBucketLoggingToXmlPayload binder = injector .getInstance(BindBucketLoggingToXmlPayload.class); binder.bindToRequest(request, bucketLogging); assertEquals(request.getPayload().getContentMetadata().getContentType(), "text/xml"); assertEquals(request.getPayload().getRawContent(), expected); } }
public String getEmailAddress() { return getIdentifier(); } }
public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(S3AsyncClient.class, "enableBucketLogging", String.class, BucketLogging.class); GeneratedHttpRequest request = processor .createRequest(method, ImmutableList.<Object> of("bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet .<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))))); assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/bucket_logging.xml")), "text/xml", false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); assertFallbackClassEquals(method, null); checkFilters(request); }