nacx requested changes on this pull request.

Formatting is still an issue to merge the PR.
Please format all your code to use a 3 space indent.

>     public HttpRequest filter(HttpRequest request) throws HttpException {
+      if (this.isSAS){
+         request = filterSAS(request, this.credential);
+      } else {
+         request = filterKey(request);
+      }

[bit] prefer inline conditionals for this kind of stuff:
```java
request = this.isSAS ? filterSAS(request, this.credential) : filterKey(request);
```

> +   
+   /** 
+   * this filter method is applied only for the cases with SAS Authentication. 
+   * 
+   */
+   public HttpRequest filterSAS(HttpRequest request, String credential) throws 
HttpException {
+      String containerName = null;
+      String blobName = null;
+      URI requestUri = request.getEndpoint();
+      try {
+         String[] parametersArray = cutUri(requestUri); 
+         containerName = parametersArray[1];
+                
+         if (parametersArray.length == 3) {
+            blobName = parametersArray[2];
+            return 
removeAuthorizationHeader(replaceDateHeader(request.toBuilder().endpoint(Uris.uriBuilder(storageUrl).appendPath(containerName).appendPath(blobName).query(credential).build()).build()));

I meant to split that long line in something like:
```suggestion
            return removeAuthorizationHeader(
                  replaceDateHeader(request.toBuilder()
                     .endpoint(Uris.uriBuilder(storageUrl)
                        .appendPath(containerName)
                        .appendPath(blobName)
                        .query(credential)
                        .build())
                     .build()));
```

> @@ -110,7 +175,27 @@ HttpRequest replaceDateHeader(HttpRequest request) {
       request = 
request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build();
       return request;
    }
-
+   
+   /**
+   * this is the method to parse container name and blob name from the 
HttpRequest. 
+   * applicable for the cases with SAS Authentication 
+   * 
+   */ 
+   public String[] cutUri (URI uri) throws NullPointerException, 
IllegalArgumentException {
+      String path = uri.getPath();
+      String[] result = path.split("/");
+      if (result.length < 2) {
+         throw new IllegalArgumentException();

Add a message to the exception describing what's wrong.

> -
+   
+   /**
+   * this is the method to parse container name and blob name from the 
HttpRequest. 
+   * applicable for the cases with SAS Authentication 
+   * 
+   */ 
+   public String[] cutUri (URI uri) throws NullPointerException, 
IllegalArgumentException {
+      String path = uri.getPath();
+      String[] result = path.split("/");
+      if (result.length < 2) {
+         throw new IllegalArgumentException();
+      }
+      for (int i = 1; i < result.length; i++){
+         if (result[i] == null) {
+            throw new NullPointerException();

Add a message to the exception describing what's wrong.

> @@ -63,6 +64,17 @@ protected final String guiceProvideTimeStamp(@TimeStamp 
> Supplier<String> cache)
    protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
       return cache.get();
    }
+   
+   /** 
+   * checks which Authentication type is used 
+   *
+   */
+   @Named("sasAuth")
+   @Provides 
+   protected Boolean authSAS(@org.jclouds.location.Provider 
Supplier<Credentials> creds) {
+         String credential =  creds.get().credential;
+      return credential.matches("sv.*se.*sig.*");

So, would the following be a valid SAS credential? `svsesig`

I think we need some unit tests here to make it clear what are valid SAS 
formats, and also a stronger regular expression. Do the SAS credential has 
delimiters separating each field? Can we enforce they start with `sv`?, etc.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1270#pullrequestreview-202014382

Reply via email to