|
25 | 25 | import java.io.Closeable; |
26 | 26 | import java.io.File; |
27 | 27 | import java.io.IOException; |
| 28 | +import java.util.UUID; |
28 | 29 |
|
29 | 30 | import org.jclouds.ContextBuilder; |
30 | 31 | import org.jclouds.blobstore.BlobStore; |
|
38 | 39 | import org.jclouds.io.Payload; |
39 | 40 | import org.jclouds.io.Payloads; |
40 | 41 | 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; |
41 | 44 |
|
42 | 45 | import com.google.common.io.ByteSource; |
43 | 46 | import com.google.common.io.Closeables; |
@@ -76,6 +79,7 @@ public static void main(String[] args) throws IOException { |
76 | 79 | GenerateTempURL generateTempURL = new GenerateTempURL(args[0], args[1]); |
77 | 80 |
|
78 | 81 | try { |
| 82 | + generateTempURL.updatePrivateURLKey(); |
79 | 83 | generateTempURL.createContainer(); |
80 | 84 | generateTempURL.generatePutTempURL(); |
81 | 85 | generateTempURL.generateGetTempURL(); |
@@ -105,6 +109,19 @@ private void createContainer() throws IOException { |
105 | 109 | } |
106 | 110 | } |
107 | 111 |
|
| 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 | + |
108 | 125 | private void generatePutTempURL() throws IOException { |
109 | 126 | System.out.format("Generate PUT Temp URL%n"); |
110 | 127 |
|
|
0 commit comments