Skip to content
Permalink
Browse files
Example for updating the signed URLs key.
  • Loading branch information
zack-shoylev committed Jun 7, 2016
1 parent 6401800 commit df16a4383baf8bf2e4b1fb7320b01dc2ae2b658f
Showing 1 changed file with 17 additions and 0 deletions.
@@ -25,6 +25,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStore;
@@ -38,6 +39,8 @@
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.openstack.swift.v1.blobstore.RegionScopedBlobStoreContext;
import org.jclouds.openstack.swift.v1.features.AccountApi;
import org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi;

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

try {
generateTempURL.updatePrivateURLKey();
generateTempURL.createContainer();
generateTempURL.generatePutTempURL();
generateTempURL.generateGetTempURL();
@@ -105,6 +109,19 @@ private void createContainer() throws IOException {
}
}

private void updatePrivateURLKey() throws IOException {
// The key can be changed to quickly expire all existing signed URLs.
AccountApi accountApi = blobStore
.getContext()
.unwrapApi(CloudFilesApi.class)
.getAccountApi(REGION);

String key = UUID.randomUUID().toString();
System.out.format("Setting key for signed URLs to %s%n", key);
accountApi.updateTemporaryUrlKey(key);
System.out.format("The key is now %s%n", accountApi.get().getMetadata().get("temp-url-key"));
}

private void generatePutTempURL() throws IOException {
System.out.format("Generate PUT Temp URL%n");

0 comments on commit df16a43

Please sign in to comment.