protected Grantee createGrantee(final String value) { if (StringUtils.isEmpty(value)) { return null; } if (value.contains("@")) { return new EmailAddressGrantee(value); } else { return new CanonicalGrantee(value); } }
/** * Returns an XML fragment representing the specified canonical grantee. * * @param grantee * The canonical grantee to convert to an XML representation that * can be sent to Amazon S3 as part of request. * @param xml * The XmlWriter to which to concatenate this node to. * * @return The given XmlWriter containing the specified canonical grantee. */ protected XmlWriter convertToXml(CanonicalGrantee grantee, XmlWriter xml) { xml.start("Grantee", new String[] {"xmlns:xsi" , "xsi:type"}, new String[] {"http://www.w3.org/2001/XMLSchema-instance", "CanonicalUser"}); xml.start("ID").value(grantee.getIdentifier()).end(); xml.end(); return xml; }
.setDisplayName(getText());
/** * Constructs a new {@link CanonicalGrantee} object * with the given canonical ID. * * @param identifier */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
/** * Constructs a new {@link CanonicalGrantee} object with the given canonical * ID. * * @param identifier */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
/** * Constructs a new {@link CanonicalGrantee} object * with the given canonical ID. * * @param identifier */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
/** * Returns an XML fragment representing the specified canonical grantee. * * @param grantee The canonical grantee to convert to an XML representation * that can be sent to Amazon S3 as part of request. * @param xml The XmlWriter to which to concatenate this node to. * @return The given XmlWriter containing the specified canonical grantee. */ protected XmlWriter convertToXml(CanonicalGrantee grantee, XmlWriter xml) { xml.start("Grantee", new String[] { "xmlns:xsi", "xsi:type" }, new String[] { "http://www.w3.org/2001/XMLSchema-instance", "CanonicalUser" }); xml.start("ID").value(grantee.getIdentifier()).end(); xml.end(); return xml; }
.setDisplayName(getText());
@Override protected void doStartElement( String uri, String name, String qName, Attributes attrs) { if (in("AccessControlPolicy")) { if (name.equals("Owner")) { accessControlList.setOwner(new Owner()); } } else if (in("AccessControlPolicy", "AccessControlList", "Grant")) { if (name.equals("Grantee")) { String type = XmlResponsesSaxParser .findAttributeValue( "xsi:type", attrs ); if ("AmazonCustomerByEmail".equals(type)) { currentGrantee = new EmailAddressGrantee(null); } else if ("CanonicalUser".equals(type)) { currentGrantee = new CanonicalGrantee(null); } else if ("Group".equals(type)) { /* * Nothing to do for GroupGrantees here since we * can't construct an empty enum value early. */ } } } }
/** * Constructs a new {@link CanonicalGrantee} object with the given canonical * ID. * * @param identifier */ public CanonicalGrantee(String identifier) { this.setIdentifier(identifier); }
/** * Returns an XML fragment representing the specified canonical grantee. * * @param grantee * The canonical grantee to convert to an XML representation that * can be sent to Amazon S3 as part of request. * @param xml * The XmlWriter to which to concatenate this node to. * * @return The given XmlWriter containing the specified canonical grantee. */ protected XmlWriter convertToXml(CanonicalGrantee grantee, XmlWriter xml) { xml.start("Grantee", new String[] {"xmlns:xsi" , "xsi:type"}, new String[] {"http://www.w3.org/2001/XMLSchema-instance", "CanonicalUser"}); xml.start("ID").value(grantee.getIdentifier()).end(); xml.end(); return xml; }
@Override protected void doStartElement( String uri, String name, String qName, Attributes attrs) { if (in("AccessControlPolicy")) { if (name.equals("Owner")) { accessControlList.setOwner(new Owner()); } } else if (in("AccessControlPolicy", "AccessControlList", "Grant")) { if (name.equals("Grantee")) { final String type = XmlResponsesSaxParser .findAttributeValue("xsi:type", attrs); if ("AmazonCustomerByEmail".equals(type)) { currentGrantee = new EmailAddressGrantee(null); } else if ("CanonicalUser".equals(type)) { currentGrantee = new CanonicalGrantee(null); } else if ("Group".equals(type)) { /* * Nothing to do for GroupGrantees here since we can't * construct an empty enum value early. */ } } } }
/** * Returns an XML fragment representing the specified canonical grantee. * * @param grantee The canonical grantee to convert to an XML representation * that can be sent to Amazon S3 as part of request. * @param xml The XmlWriter to which to concatenate this node to. * @return The given XmlWriter containing the specified canonical grantee. */ protected XmlWriter convertToXml(CanonicalGrantee grantee, XmlWriter xml) { xml.start("Grantee", new String[] { "xmlns:xsi", "xsi:type" }, new String[] { "http://www.w3.org/2001/XMLSchema-instance", "CanonicalUser" }); xml.start("ID").value(grantee.getIdentifier()).end(); xml.end(); return xml; }
.setDisplayName(getText());
protected Grantee createGrantee(final String value) { if (StringUtils.isEmpty(value)) { return null; } if (value.contains("@")) { return new EmailAddressGrantee(value); } else { return new CanonicalGrantee(value); } }
static AccessControlList grantFullControlToBucketOwner(ServerSideEncryptingAmazonS3 s3Client, String bucket) { final AccessControlList acl = s3Client.getBucketAcl(bucket); acl.grantAllPermissions(new Grant(new CanonicalGrantee(acl.getOwner().getId()), Permission.FullControl)); return acl; }
@Override protected void doStartElement( String uri, String name, String qName, Attributes attrs) { if (in("AccessControlPolicy")) { if (name.equals("Owner")) { accessControlList.setOwner(new Owner()); } } else if (in("AccessControlPolicy", "AccessControlList", "Grant")) { if (name.equals("Grantee")) { String type = XmlResponsesSaxParser .findAttributeValue( "xsi:type", attrs ); if ("AmazonCustomerByEmail".equals(type)) { currentGrantee = new EmailAddressGrantee(null); } else if ("CanonicalUser".equals(type)) { currentGrantee = new CanonicalGrantee(null); } else if ("Group".equals(type)) { /* * Nothing to do for GroupGrantees here since we * can't construct an empty enum value early. */ } } } }
@Override protected void doStartElement( String uri, String name, String qName, Attributes attrs) { if (in("AccessControlPolicy")) { if (name.equals("Owner")) { accessControlList.setOwner(new Owner()); } } else if (in("AccessControlPolicy", "AccessControlList", "Grant")) { if (name.equals("Grantee")) { final String type = XmlResponsesSaxParser .findAttributeValue("xsi:type", attrs); if ("AmazonCustomerByEmail".equals(type)) { currentGrantee = new EmailAddressGrantee(null); } else if ("CanonicalUser".equals(type)) { currentGrantee = new CanonicalGrantee(null); } else if ("Group".equals(type)) { /* * Nothing to do for GroupGrantees here since we can't * construct an empty enum value early. */ } } } }