Package org.jclouds.blobstore

Examples of org.jclouds.blobstore.BlobRequestSigner


        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here


        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

    // same logic as AWSS3BlobRequestSigner.signForTemporaryAccess.
    @Ignore
    @Test
    public void testUrlSigning() throws Exception {
        HttpClient httpClient = s3Context.utils().http();
        BlobRequestSigner signer = s3Context.getSigner();

        String blobName = "blob";
        ByteSource byteSource = ByteSource.wrap(new byte[1]);
        Blob blob = s3BlobStore.blobBuilder(blobName)
                .payload(byteSource)
                .contentLength(byteSource.size())
                .build();
        HttpRequest putRequest = signer.signPutBlob(containerName, blob, 10);
        HttpResponse putResponse = httpClient.invoke(putRequest);
        assertThat(putResponse.getStatusCode())
                .isEqualTo(HttpServletResponse.SC_OK);

        HttpRequest getRequest = signer.signGetBlob(containerName, blobName,
                10);
        HttpResponse getResponse = httpClient.invoke(getRequest);
        assertThat(getResponse.getStatusCode())
                .isEqualTo(HttpServletResponse.SC_OK);
    }
View Full Code Here

        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

        String containerName = "container";
        String blobName = "blob";
        URI endPoint = new URI("http", "localhost",
                String.format("/transient/%s/%s", containerName, blobName),
                /*fragment=*/ null);
        BlobRequestSigner signer = context.getSigner();
        HttpRequest request;
        HttpRequest expected;

        request = signer.signGetBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("GET")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        request = signer.signRemoveBlob(containerName, blobName);
        expected = HttpRequest.builder()
                .method("DELETE")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .build();
        assertEquals(expected, request);

        Blob blob = blobStore.blobBuilder(blobName).forSigning().build();
        request = signer.signPutBlob(containerName, blob);
        expected = HttpRequest.builder()
                .method("PUT")
                .endpoint(endPoint)
                .headers(request.getHeaders())
                .payload(new PhantomPayload())
View Full Code Here

         String blobName = "test-" + UUID.randomUUID();
         Blob blob2 = region.blobBuilder(blobName).forSigning()
               .contentLength(input.size())
               .contentMD5(input.hash(Hashing.md5()).asBytes())
               .contentType(MediaType.OCTET_STREAM.toString()).build();
         BlobRequestSigner signer = ctx.getSigner(regionId);
         HttpResponse response;
         try {
            HttpRequest putRequest;
            putRequest = signer.signPutBlob(containerName, blob2, 600);
            MutableContentMetadata metadata = blob2.getMetadata()
                  .getContentMetadata();
            HttpRequest.Builder<?> putRequestBuilder = putRequest.toBuilder()
                  .addHeader(HttpHeaders.CONTENT_TYPE,
                        metadata.getContentType());
            putRequestBuilder.addHeader(HttpHeaders.CONTENT_LENGTH,
                  String.valueOf(input.size()));
            putRequestBuilder.payload(input);
            putRequest = putRequestBuilder.build();
            Payload payload = Payloads.newPayload(input.read());
            putRequest.setPayload(payload);
            assertNotNull(putRequest, "regionId=" + regionId + ", container="
                  + containerName + ", blob=" + blobName);
            response = client.invoke(putRequest);
            if (response.getStatusCode() != 200
                  && response.getStatusCode() != 201) {
               fail("Signed PUT expected to return 200 or 201 but returned "
                     + response.getStatusCode());
            }
         } catch (Exception e) {
            fail("Failed signed put test: " + e);
         }

         // test signed get
         try {
            HttpRequest getRequest = signer.signGetBlob(containerName,
                  blobName);
            assertNotNull(getRequest, "regionId=" + regionId + ", container="
                  + containerName + ", blob=" + blobName);
            response = client.invoke(getRequest);
            if (response.getStatusCode() != 200) {
View Full Code Here

TOP

Related Classes of org.jclouds.blobstore.BlobRequestSigner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.