-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
GroupGrantee.java
119 lines (106 loc) · 3.96 KB
/
GroupGrantee.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright 2010-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.s3.model;
/**
* Specifies constants defining a group of Amazon S3 users
* who can be granted permissions to
* Amazon S3 buckets and objects. This enumeration contains all the valid Amazon S3
* group grantees.
*/
public enum GroupGrantee implements Grantee {
/**
* Grants anonymous access to any Amazon S3 object or bucket. Any user will
* be able to access the object by omitting the Amazon Web Services Key ID and Signature
* from a request.
* <p>
* Amazon highly recommends that users do not grant the
* <code>AllUsers</code> group write
* access to their buckets. If granted, users will have no control over the objects
* others can store and their associated charges.
* </p>
*/
AllUsers("http://acs.amazonaws.com/groups/global/AllUsers"),
/**
* Grants access to buckets or objects to anyone with an Amazon Web Services account.
* Although this is inherently insecure as any Amazon Web Services user who is aware of the
* bucket or object will be able to access it, users may find this authentication
* method useful.
*/
AuthenticatedUsers("http://acs.amazonaws.com/groups/global/AuthenticatedUsers"),
/**
* Grants access to Amazon S3 log delivery so that an S3 bucket can receive
* server access logs. Turning on server access logging for an Amazon S3
* bucket requires that the bucket receiving the logs is granted permission
* for the log delivery group to deliver logs.
*/
LogDelivery("http://acs.amazonaws.com/groups/s3/LogDelivery");
/* (non-Javadoc)
* @see com.amazonaws.services.s3.model.Grantee#getTypeIdentifier()
*/
@Override
public String getTypeIdentifier() {
return "uri";
}
private String groupUri;
private GroupGrantee(String groupUri) {
this.groupUri = groupUri;
}
/**
* Gets the group grantee's URI.
*
* @return The group grantee's URI.
*/
public String getIdentifier() {
return groupUri;
}
/**
* For internal use only. Group grantees have preset identifiers that cannot
* be modified.
*/
public void setIdentifier(String id) {
throw new UnsupportedOperationException(
"Group grantees have preset identifiers that cannot be modified.");
}
/**
* @see java.lang.Enum#toString()
*/
public String toString() {
return "GroupGrantee [" + groupUri + "]";
}
/**
* Gets the {@link GroupGrantee} enumeration value
* with the specified Amazon S3 group URI (eg.
* http://acs.amazonaws.com/groups/global/AllUsers).
* Returns <code>null</code> if an invalid
* Amazon S3 group URI is specified.
*
* @param groupUri
* A string representation of an Amazon S3 group URI (eg.
* http://acs.amazonaws.com/groups/global/AllUsers)
*
* @return The {@link GroupGrantee} object represented by the given Amazon S3 group
* URI string. Returns <code>null</code>
* if the string isn't a valid Amazon S3 group
* URI.
*/
public static GroupGrantee parseGroupGrantee(String groupUri) {
for (GroupGrantee grantee : GroupGrantee.values()) {
if (grantee.groupUri.equals(groupUri)) {
return grantee;
}
}
return null;
}
}