本文整理汇总了Java中org.jets3t.service.acl.Permission类的典型用法代码示例。如果您正苦于以下问题:Java Permission类的具体用法?Java Permission怎么用?Java Permission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Permission类属于org.jets3t.service.acl包,在下文中一共展示了Permission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAvailableAclRoles
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Override
public List<Acl.Role> getAvailableAclRoles(final List<Path> files) {
final List<Acl.Role> roles = new ArrayList<Acl.Role>(Arrays.asList(
new Acl.Role(org.jets3t.service.acl.Permission.PERMISSION_FULL_CONTROL.toString()),
new Acl.Role(org.jets3t.service.acl.Permission.PERMISSION_READ.toString()))
);
for(Path file : files) {
if(file.isVolume()) {
// When applied to a bucket, this permission lets a user create objects, overwrite objects, and
// delete objects in a bucket. This permission also lets a user list the contents of a bucket.
// You cannot apply this permission to objects because bucket ACLs control who can upload,
// overwrite, and delete objects. Also, you must grant READ permission if you grant WRITE permission.
roles.add(new Acl.Role(org.jets3t.service.acl.Permission.PERMISSION_WRITE.toString()));
break;
}
}
return roles;
}
示例2: setConfiguration
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Override
public void setConfiguration(final Path container, final LoggingConfiguration configuration) throws BackgroundException {
try {
// Logging target bucket
final GSBucketLoggingStatus status = new GSBucketLoggingStatus(
StringUtils.isNotBlank(configuration.getLoggingTarget()) ? configuration.getLoggingTarget() : container.getName(), null);
if(configuration.isEnabled()) {
status.setLogfilePrefix(PreferencesFactory.get().getProperty("google.logging.prefix"));
}
// Grant write for Google to logging target bucket
final AccessControlList acl = session.getClient().getBucketAcl(container.getName());
final GroupByEmailAddressGrantee grantee = new GroupByEmailAddressGrantee(
"[email protected]");
if(!acl.getPermissionsForGrantee(grantee).contains(Permission.PERMISSION_WRITE)) {
acl.grantPermission(grantee, Permission.PERMISSION_WRITE);
session.getClient().putBucketAcl(container.getName(), acl);
}
session.getClient().setBucketLoggingStatusImpl(container.getName(), status);
}
catch(ServiceException e) {
throw new S3ExceptionMappingService().map("Failure to write attributes of {0}", e);
}
}
示例3: GranteeTable
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public GranteeTable(GranteeTableModel granteeTableModel) {
super();
sorter = new TableSorter(granteeTableModel);
this.setModel(sorter);
sorter.setTableHeader(this.getTableHeader());
getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
getSelectionModel().addListSelectionListener(this);
DefaultCellEditor groupCellEditor = new DefaultCellEditor(groupGranteeComboBox);
groupCellEditor.setClickCountToStart(2);
setDefaultEditor(GroupGrantee.class, groupCellEditor);
setDefaultRenderer(GroupGrantee.class, new DefaultTableCellRenderer() {
private static final long serialVersionUID = 4938391147702620699L;
public Component getTableCellRendererComponent(JTable arg0, Object value, boolean arg2, boolean arg3, int arg4, int arg5) {
GroupGrantee groupGrantee = (GroupGrantee) value;
return super.getTableCellRendererComponent(arg0, groupGrantee.getIdentifier(), arg2, arg3, arg4, arg5);
}
});
DefaultCellEditor permissionCellEditor = new DefaultCellEditor(permissionComboBox);
permissionCellEditor.setClickCountToStart(2);
setDefaultEditor(Permission.class, permissionCellEditor);
}
示例4: deploy
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public void deploy(File jarFile) {
String deployBucket = getOrCry("deployBucket");
String deployFilename = getOrCry("deployFilename");
try {
getStorage().getOrCreateBucket(deployBucket);
AccessControlList bucketAcl = getStorage().getBucketAcl(
deployBucket);
bucketAcl.grantPermission(GroupGrantee.ALL_USERS,
Permission.PERMISSION_READ);
S3Object statFileObject = new S3Object(jarFile);
statFileObject.setKey(deployFilename);
statFileObject.setAcl(bucketAcl);
getStorage().putObject(deployBucket, statFileObject);
log.info("File " + jarFile + " now accessible at " + getJarUrl());
} catch (Exception e) {
log.warn("Failed to deploy or set permissions in bucket "
+ deployBucket + ", key " + deployFilename, e);
}
}
示例5: saveImage
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
private void saveImage(String filename, MultipartFile image)
throws ImageUploadException {
try {
AWSCredentials awsCredentials =
new AWSCredentials(s3AccessKey, s3SecretKey);
S3Service s3 = new RestS3Service(awsCredentials);
S3Bucket imageBucket = s3.getBucket("spitterImages");
S3Object imageObject = new S3Object(filename);
imageObject.setDataInputStream(
new ByteArrayInputStream(image.getBytes()));
imageObject.setContentLength(image.getBytes().length);
imageObject.setContentType("image/jpeg");
AccessControlList acl = new AccessControlList();
acl.setOwner(imageBucket.getOwner());
acl.grantPermission(GroupGrantee.ALL_USERS,
Permission.PERMISSION_READ);
imageObject.setAcl(acl);
s3.putObject(imageBucket, imageObject);
} catch (Exception e) {
throw new ImageUploadException("Unable to save image", e);
}
}
示例6: toXMLBuilder
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Override
public XMLBuilder toXMLBuilder() throws ServiceException, ParserConfigurationException,
FactoryConfigurationError, TransformerException
{
XMLBuilder builder = XMLBuilder.create("AccessControlList");
// Owner
if (owner != null) {
XMLBuilder ownerBuilder = builder.elem("Owner");
ownerBuilder.elem("ID").text(owner.getId()).up();
if (owner.getDisplayName() != null) {
ownerBuilder.elem("Name").text(owner.getDisplayName());
}
}
XMLBuilder accessControlList = builder.elem("Entries");
for (GrantAndPermission gap: grants) {
GranteeInterface grantee = gap.getGrantee();
Permission permission = gap.getPermission();
accessControlList
.elem("Entry")
.importXMLBuilder(grantee.toXMLBuilder())
.elem("Permission").text(permission.toString());
}
return builder;
}
示例7: getAclDescription
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public static String getAclDescription(AccessControlList acl) {
if (acl == null) {
return ACL_UNKNOWN_DESCRIPTION;
}
for (GrantAndPermission gap: acl.getGrantAndPermissions()) {
if (GroupGrantee.ALL_USERS.equals(gap.getGrantee())
&& Permission.PERMISSION_READ.equals(gap.getPermission()))
{
return ACL_PUBLIC_DESCRIPTION;
}
}
if (AccessControlList.REST_CANNED_PUBLIC_READ.equals(acl)) {
return ACL_PUBLIC_DESCRIPTION;
}
return ACL_PRIVATE_DESCRIPTION;
}
示例8: grantAcl
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public boolean grantAcl(S3Object object) throws ServiceException, InterruptedException {
if(Strings.isNullOrEmpty(s3Acl)){
return true;
}
for (int i = 0; i < s3AclRetries; ++i) {
try {
AccessControlList acl = s3Service.getObjectAcl(object.getBucketName(), object.getKey());
for (String id : s3Acl.split(",")) {
acl.grantPermission(new CanonicalGrantee(id), Permission.PERMISSION_READ);
}
s3Service.putObjectAcl(object.getBucketName(), object.getKey(), acl);
return true;
} catch (Exception e) {
log.error("Exception while granting ACL: " + e.getMessage(), e);
Thread.sleep(1000 * (i + 1));
}
}
return false;
}
示例9: test
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Test
public void test() throws Exception {
RestS3Service s3Service = mock(RestS3Service.class);
AccessControlList acl = new AccessControlList();
doReturn(acl).when(s3Service).getObjectAcl("bucket", "key");
doNothing().when(s3Service).putObjectAcl("bucket", "key", acl);
GrantAcl grantAcl = new GrantAcl(s3Service, "1,2,3", 1);
S3Object obj = new S3Object("key");
obj.setBucketName("bucket");
obj.setAcl(GSAccessControlList.REST_CANNED_BUCKET_OWNER_FULL_CONTROL);
assertTrue(grantAcl.grantAcl(obj));
Set<GrantAndPermission> grants = new HashSet<GrantAndPermission>(Arrays.asList(acl.getGrantAndPermissions()));
assertEquals(grants.size(), 3);
Set<GrantAndPermission> grantSet = new HashSet<GrantAndPermission>();
for (int i = 1; i <= 3; ++i) {
grantSet.add(new GrantAndPermission(new CanonicalGrantee(Integer.toString(i)), Permission.PERMISSION_READ));
}
}
示例10: getAvailableAclRoles
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Override
public List<Acl.Role> getAvailableAclRoles(final List<Path> files) {
return Arrays.asList(new Acl.Role(Permission.PERMISSION_FULL_CONTROL.toString()),
new Acl.Role(Permission.PERMISSION_READ.toString()),
new Acl.Role(Permission.PERMISSION_WRITE.toString()),
new Acl.Role(Permission.PERMISSION_READ_ACP.toString()),
new Acl.Role(Permission.PERMISSION_WRITE_ACP.toString()));
}
示例11: initData
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
/**
* Initialises the dialog with access control information for the given S3 items (bucket or objects)
*
* @param s3Items May be a single <code>S3Bucket</code>, or one or more <code>S3Object</code>s
* @param accessControlList the initial ACL settings to represent in the dialog.
*/
protected void initData(BaseS3Object[] s3Items, AccessControlList accessControlList) {
this.originalAccessControlList = accessControlList;
// Item(s) description.
if (s3Items.length > 1) {
// Only objects can be updated in multiples, buckets are always single.
itemsDescription.setText("<html><b>Object count</b>: " + s3Items.length + " objects");
} else {
if (s3Items[0] instanceof S3Bucket) {
itemsDescription.setText("<html><b>Bucket</b><br>" + ((S3Bucket)s3Items[0]).getName());
} else {
itemsDescription.setText("<html><b>Object</b><br>" + ((S3Object)s3Items[0]).getKey());
}
}
// Populate grantees tables.
canonicalGranteeTableModel.removeAllGrantAndPermissions();
emailGranteeTableModel.removeAllGrantAndPermissions();
groupGranteeTableModel.removeAllGrantAndPermissions();
Iterator grantIter = originalAccessControlList.getGrants().iterator();
while (grantIter.hasNext()) {
GrantAndPermission gap = (GrantAndPermission) grantIter.next();
GranteeInterface grantee = gap.getGrantee();
Permission permission = gap.getPermission();
if (grantee instanceof CanonicalGrantee) {
canonicalGranteeTableModel.addGrantee(grantee, permission);
} else if (grantee instanceof EmailAddressGrantee) {
emailGranteeTableModel.addGrantee(grantee, permission);
} else if (grantee instanceof GroupGrantee) {
groupGranteeTableModel.addGrantee(grantee, permission);
}
}
}
示例12: addGrantee
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public int addGrantee(GranteeInterface grantee, Permission permission) {
GrantAndPermission gap = new GrantAndPermission(grantee, permission);
int insertRow =
Collections.binarySearch(currentGrantees, gap, new Comparator() {
public int compare(Object o1, Object o2) {
GrantAndPermission g1 = (GrantAndPermission) o1;
GrantAndPermission g2 = (GrantAndPermission) o2;
return g1.getGrantee().getIdentifier().compareToIgnoreCase(
g2.getGrantee().getIdentifier());
}
});
if (insertRow >= 0) {
// We already have an item with this key, but that's OK.
} else {
insertRow = (-insertRow) - 1;
}
// New object to insert.
currentGrantees.add(insertRow, gap);
if (grantee instanceof GroupGrantee) {
this.insertRow(insertRow, new Object[] {grantee, permission});
} else if (grantee instanceof CanonicalGrantee) {
CanonicalGrantee canonicalGrantee = (CanonicalGrantee) grantee;
this.insertRow(insertRow, new Object[] {canonicalGrantee.getIdentifier(),
canonicalGrantee.getDisplayName(), permission});
} else {
this.insertRow(insertRow, new Object[] {grantee.getIdentifier(), permission});
}
return insertRow;
}
示例13: getColumnClass
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
public Class getColumnClass(int columnIndex) {
if (columnIndex == 0) {
if (GroupGrantee.class.equals(granteeClass))
return GroupGrantee.class;
else
return String.class;
} else if (columnIndex == permissionColumn) {
return Permission.class;
} else {
return String.class;
}
}
示例14: testGetBucketAcl
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
/**
* Test get bucket acl.
*
* @throws Exception the exception
*/
@Test
public void testGetBucketAcl() throws Exception {
s3RESTService.createBucket(AWS_S3_BUCKET);//create bucket for test
AccessControlList acl = s3RESTService.getBucketAcl(new S3Bucket(AWS_S3_BUCKET));
GrantAndPermission[] grantAndPermissions = acl.getGrantAndPermissions();
assertEquals(Permission.PERMISSION_FULL_CONTROL, grantAndPermissions[0].getPermission());
}
示例15: endElement
import org.jets3t.service.acl.Permission; //导入依赖的package包/类
@Override
public void endElement(String name, String elementText) {
// Owner details.
if (name.equals("ID") && !insideACL) {
owner.setId(elementText);
} else if (name.equals("Name") && !insideACL) {
owner.setDisplayName(elementText);
}
// ACL details.
else if (name.equals("ID")) {
currentGrantee.setIdentifier(elementText);
} else if (name.equals("EmailAddress")) {
currentGrantee.setIdentifier(elementText);
} else if (name.equals("URI")) {
currentGrantee.setIdentifier(elementText);
} else if (name.equals("Name")) {
if (currentGrantee instanceof UserByIdGrantee) {
((UserByIdGrantee) currentGrantee).setName(elementText);
} else if (currentGrantee instanceof UserByEmailAddressGrantee) {
((UserByEmailAddressGrantee) currentGrantee).setName(elementText);
} else if (currentGrantee instanceof GroupByIdGrantee) {
((GroupByIdGrantee) currentGrantee).setName(elementText);
} else if (currentGrantee instanceof GroupByEmailAddressGrantee) {
((GroupByEmailAddressGrantee) currentGrantee).setName(elementText);
}
} else if (name.equals("Permission")) {
currentPermission = Permission.parsePermission(elementText);
} else if (name.equals("Entry")) {
accessControlList.grantPermission(currentGrantee, currentPermission);
} else if (name.equals("Entries")) {
insideACL = false;
}
}