Skip to content
This repository was archived by the owner on Feb 4, 2019. It is now read-only.

Commit df16a43

Browse files
committed
Example for updating the signed URLs key.
1 parent 6401800 commit df16a43

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

rackspace/src/main/java/org/jclouds/examples/rackspace/cloudfiles/GenerateTempURL.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.io.Closeable;
2626
import java.io.File;
2727
import java.io.IOException;
28+
import java.util.UUID;
2829

2930
import org.jclouds.ContextBuilder;
3031
import org.jclouds.blobstore.BlobStore;
@@ -38,6 +39,8 @@
3839
import org.jclouds.io.Payload;
3940
import org.jclouds.io.Payloads;
4041
import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;
42+
import org.jclouds.openstack.swift.v1.features.AccountApi;
43+
import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;
4144

4245
import com.google.common.io.ByteSource;
4346
import com.google.common.io.Closeables;
@@ -76,6 +79,7 @@ public static void main(String[] args) throws IOException {
7679
GenerateTempURL generateTempURL = new GenerateTempURL(args[0], args[1]);
7780

7881
try {
82+
generateTempURL.updatePrivateURLKey();
7983
generateTempURL.createContainer();
8084
generateTempURL.generatePutTempURL();
8185
generateTempURL.generateGetTempURL();
@@ -105,6 +109,19 @@ private void createContainer() throws IOException {
105109
}
106110
}
107111

112+
private void updatePrivateURLKey() throws IOException {
113+
// The key can be changed to quickly expire all existing signed URLs.
114+
AccountApi accountApi = blobStore
115+
.getContext()
116+
.unwrapApi(CloudFilesApi.class)
117+
.getAccountApi(REGION);
118+
119+
String key = UUID.randomUUID().toString();
120+
System.out.format("Setting key for signed URLs to %s%n", key);
121+
accountApi.updateTemporaryUrlKey(key);
122+
System.out.format("The key is now %s%n", accountApi.get().getMetadata().get("temp-url-key"));
123+
}
124+
108125
private void generatePutTempURL() throws IOException {
109126
System.out.format("Generate PUT Temp URL%n");
110127

0 commit comments

Comments
 (0)