Access points (Java SDK V2)
Create, query, list, and delete access points, and manage access point policies by using OSS Java SDK V2. Access points apply fine-grained access control to an entire bucket or to the objects under a specific prefix within a bucket.
Features
An access point is a custom access entry point that operates at the bucket level or prefix level. Each access point has its own access domain (alias), ARN, and access policy, which lets you restrict what different applications or users can access within a bucket. OSS Java SDK V2 lets you manage the following resources:
Access points: create (
CreateAccessPoint), query (GetAccessPoint), list (ListAccessPoints), and delete (DeleteAccessPoint) them. When you create an access point, usenetworkOriginto specify the network origin (Internetorvpc). For access points in a VPC, you can also specifyvpcId.Access point policies: set (
PutAccessPointPolicy), get (GetAccessPointPolicy), and delete (DeleteAccessPointPolicy) policies at the access point level. Policy content is in JSON format.Object Process access points: use
CreateAccessPointForObjectProcessto create an access point that supports WriteGetObjectResponse and customizes response content.
After you create an access point, access point-level settings such as policies and Block Public Access take effect together with the bucket-level settings. For detailed rules, see the access points user guide.
Usage notes
Access point operations require
alibabacloud-oss-v2(OSS Java SDK V2) 0.3.1 or later.The sample code in this topic uses
cn-hangzhou, the region ID of the China (Hangzhou) region, as an example. If you use another region, replace it with the actual region ID.The examples in this topic obtain access credentials from environment variables. Make sure that your AccessKey credentials are configured before you run the sample code.
In requests that are related to access points, pass the bucket name in the
bucketparameter and the access point name inaccessPointName. Each bucket supports a limited number of access points, and requests that exceed the limit return an error.Delete the policy of an access point before you delete the access point. Deleted access points cannot be restored. You can also manage access points in the OSS console.
An Alibaba Cloud account can create up to 1,000 access points. An access point name must be unique within the account in a region, be 3 to 19 characters in length, contain only lowercase letters, digits, and hyphens (-), and cannot start or end with a hyphen or end with
-ossalias.Anonymous access is not supported for access points.
After an access point is created, only its policy can be modified. Basic information such as the name and alias cannot be changed.
You can also create and manage access points in the OSS console, by calling API operations, or by using ossutil.
Sample code
Create an access point
Query access point details
List access points
Manage access point policies
Delete an access point
References
For synchronous sample code, see CreateAccessPoint.java, GetAccessPoint.java, ListAccessPoints.java, PutAccessPointPolicy.java, DeleteAccessPoint.java, CreateAccessPointForObjectProcess.java, and WriteGetObjectResponse.java.
For asynchronous sample code, see CreateAccessPointAsync.java, GetAccessPointAsync.java, ListAccessPointsAsync.java, PutAccessPointPolicyAsync.java, DeleteAccessPointAsync.java, CreateAccessPointForObjectProcessAsync.java, and WriteGetObjectResponseAsync.java.