test_class.declarator: HTTP_TRANSPORT = new NetHttpTransport()
test_class.modifier: public static final
test_class.original_string: public static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
test_class.type: HttpTransport
test_class.var_name: HTTP_TRANSPORT
test_class.declarator: JSON_FACTORY = JacksonFactory.getDefaultInstance()
test_class.modifier: public static final
test_class.original_string: public static final JacksonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
test_class.type: JacksonFactory
test_class.var_name: JSON_FACTORY
test_class.declarator: PROJECT = "test-project"
test_class.modifier: private static final
test_class.original_string: private static final String PROJECT = "test-project";
test_class.type: String
test_class.var_name: PROJECT
test_class.declarator: BUCKET_NAME = "test-bucket-name"
test_class.modifier: private static final
test_class.original_string: private static final String BUCKET_NAME = "test-bucket-name";
test_class.type: String
test_class.var_name: BUCKET_NAME
test_class.declarator: OBJECT_NAME = "/dir/test-object"
test_class.modifier: private static final
test_class.original_string: private static final String OBJECT_NAME = "/dir/test-object";
test_class.type: String
test_class.var_name: OBJECT_NAME
test_class.declarator: BUCKET_NAME_DST = "test-bucket-name-dst"
test_class.modifier: private static final
test_class.original_string: private static final String BUCKET_NAME_DST = "test-bucket-name-dst";
test_class.type: String
test_class.var_name: BUCKET_NAME_DST
test_class.declarator: OBJECT_NAME_DST = "/dir/test-object-dst"
test_class.modifier: private static final
test_class.original_string: private static final String OBJECT_NAME_DST = "/dir/test-object-dst";
test_class.type: String
test_class.var_name: OBJECT_NAME_DST
test_class.declarator: mockitoRule = MockitoJUnit.rule()
test_class.modifier: @Rule public
test_class.original_string: @Rule public MockitoRule mockitoRule = MockitoJUnit.rule();
test_class.type: MockitoRule
test_class.var_name: mockitoRule
test_class.declarator: mockHandler
test_class.modifier: @Mock
test_class.original_string: @Mock AuthorizationHandler mockHandler;
test_class.type: AuthorizationHandler
test_class.var_name: mockHandler
test_class.file: gcsio/src/test/java/com/google/cloud/hadoop/gcsio/authorization/StorageRequestAuthorizerTest.java
test_class.identifier: StorageRequestAuthorizerTest
test_case.body: @Test
    public void testDeleteBucket() throws Exception {
      Storage.Buckets.Delete delete = newStorage().buckets().delete(BUCKET_NAME);
  
      StorageRequestAuthorizer authorizer = new StorageRequestAuthorizer(mockHandler);
  
      authorizer.authorize(delete);
  
      ArgumentCaptor<URI> captor = ArgumentCaptor.forClass(URI.class);
  
      verify(mockHandler).handleDeleteBucket(captor.capture());
  
      assertThat(captor.getValue().getAuthority()).isEqualTo(BUCKET_NAME);
      assertThat(captor.getValue().getPath()).isEqualTo("/");
    }
test_case.class_method_signature: StorageRequestAuthorizerTest.testDeleteBucket()
test_case.full_signature: @Test public void testDeleteBucket()
test_case.identifier: testDeleteBucket
test_case.invocations: delete buckets newStorage authorize forClass handleDeleteBucket verify capture isEqualTo assertThat getAuthority getValue isEqualTo assertThat getPath getValue
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDeleteBucket()
focal_class.declarator: logger = GoogleLogger.forEnclosingClass()
focal_class.modifier: private static final
focal_class.original_string: private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();
focal_class.type: GoogleLogger
focal_class.var_name: logger
focal_class.declarator: authorizationHandler
focal_class.modifier: private final
focal_class.original_string: private final AuthorizationHandler authorizationHandler;
focal_class.type: AuthorizationHandler
focal_class.var_name: authorizationHandler
focal_class.file: gcsio/src/main/java/com/google/cloud/hadoop/gcsio/authorization/StorageRequestAuthorizer.java
focal_class.identifier: StorageRequestAuthorizer
focal_class.class_method_signature: StorageRequestAuthorizer.StorageRequestAuthorizer(
        Class<? extends AuthorizationHandler> handlerClass, Map<String, String> properties)
focal_class.full_signature: public  StorageRequestAuthorizer(
        Class<? extends AuthorizationHandler> handlerClass, Map<String, String> properties)
focal_class.identifier: StorageRequestAuthorizer
focal_class.modifiers: public
focal_class.parameters: (
        Class<? extends AuthorizationHandler> handlerClass, Map<String, String> properties)
focal_class.signature:  StorageRequestAuthorizer(
        Class<? extends AuthorizationHandler> handlerClass, Map<String, String> properties)
focal_class.class_method_signature: StorageRequestAuthorizer.StorageRequestAuthorizer(AuthorizationHandler authorizationHandler)
focal_class.full_signature: @VisibleForTesting  StorageRequestAuthorizer(AuthorizationHandler authorizationHandler)
focal_class.identifier: StorageRequestAuthorizer
focal_class.modifiers: @VisibleForTesting
focal_class.parameters: (AuthorizationHandler authorizationHandler)
focal_class.signature:  StorageRequestAuthorizer(AuthorizationHandler authorizationHandler)
focal_class.class_method_signature: StorageRequestAuthorizer.authorize(StorageRequest<?> request)
focal_class.full_signature: public void authorize(StorageRequest<?> request)
focal_class.identifier: authorize
focal_class.modifiers: public
focal_class.parameters: (StorageRequest<?> request)
focal_class.return: void
focal_class.signature: void authorize(StorageRequest<?> request)
focal_class.class_method_signature: StorageRequestAuthorizer.getData(StorageRequest<?> request)
focal_class.full_signature: private static Object getData(StorageRequest<?> request)
focal_class.identifier: getData
focal_class.modifiers: private static
focal_class.parameters: (StorageRequest<?> request)
focal_class.return: Object
focal_class.signature: Object getData(StorageRequest<?> request)
focal_class.class_method_signature: StorageRequestAuthorizer.getGcsUri(String bucketName, String objectPath)
focal_class.full_signature: private static URI getGcsUri(String bucketName, String objectPath)
focal_class.identifier: getGcsUri
focal_class.modifiers: private static
focal_class.parameters: (String bucketName, String objectPath)
focal_class.return: URI
focal_class.signature: URI getGcsUri(String bucketName, String objectPath)
focal_method.body: public void authorize(StorageRequest<?> request) throws AccessDeniedException {
      logger.atFine().log("authorizeStorageRequest(%s)", request);
  
      // Objects
      if (request instanceof Storage.Objects.List) {
        Storage.Objects.List listRequest = (Storage.Objects.List) request;
        authorizationHandler.handleListObjects(
            getGcsUri(listRequest.getBucket(), listRequest.getPrefix()));
      } else if (request instanceof Storage.Objects.Insert) {
        Storage.Objects.Insert insertRequest = (Storage.Objects.Insert) request;
        authorizationHandler.handleInsertObject(
            getGcsUri(insertRequest.getBucket(), ((StorageObject) getData(request)).getName()));
      } else if (request instanceof Storage.Objects.Compose) {
        Storage.Objects.Compose composeRequest = (Storage.Objects.Compose) request;
        String bucket = composeRequest.getDestinationBucket();
        URI destination = getGcsUri(bucket, composeRequest.getDestinationObject());
        List<URI> sources =
            ((ComposeRequest) getData(request))
                .getSourceObjects().stream()
                    .map(source -> getGcsUri(bucket, source.getName()))
                    .collect(toImmutableList());
        authorizationHandler.handleComposeObject(destination, sources);
      } else if (request instanceof Storage.Objects.Get) {
        Storage.Objects.Get getRequest = (Storage.Objects.Get) request;
        authorizationHandler.handleGetObject(
            getGcsUri(getRequest.getBucket(), getRequest.getObject()));
      } else if (request instanceof Storage.Objects.Delete) {
        Storage.Objects.Delete deleteRequest = (Storage.Objects.Delete) request;
        authorizationHandler.handleDeleteObject(
            getGcsUri(deleteRequest.getBucket(), deleteRequest.getObject()));
      } else if (request instanceof Storage.Objects.Rewrite) {
        Storage.Objects.Rewrite rewriteRequest = (Storage.Objects.Rewrite) request;
        authorizationHandler.handleRewriteObject(
            getGcsUri(rewriteRequest.getSourceBucket(), rewriteRequest.getSourceObject()),
            getGcsUri(rewriteRequest.getDestinationBucket(), rewriteRequest.getDestinationObject()));
  
      } else if (request instanceof Storage.Objects.Copy) {
        Storage.Objects.Copy copyRequest = (Storage.Objects.Copy) request;
        authorizationHandler.handleCopyObject(
            getGcsUri(copyRequest.getSourceBucket(), copyRequest.getSourceObject()),
            getGcsUri(copyRequest.getDestinationBucket(), copyRequest.getDestinationObject()));
      } else if (request instanceof Storage.Objects.Patch) {
        Storage.Objects.Patch patchRequest = (Storage.Objects.Patch) request;
        authorizationHandler.handlePatchObject(
            getGcsUri(patchRequest.getBucket(), patchRequest.getObject()));
      }
  
      // Buckets
      else if (request instanceof Storage.Buckets.List) {
        authorizationHandler.handleListBuckets(((Storage.Buckets.List) request).getProject());
      } else if (request instanceof Storage.Buckets.Insert) {
        authorizationHandler.handleInsertBucket(
            ((Storage.Buckets.Insert) request).getProject(),
            getGcsUri(((Bucket) getData(request)).getName(), /* objectPath= */ null));
      } else if (request instanceof Storage.Buckets.Get) {
        authorizationHandler.handleGetBucket(
            getGcsUri(((Storage.Buckets.Get) request).getBucket(), /* objectPath= */ null));
      } else if (request instanceof Storage.Buckets.Delete) {
        authorizationHandler.handleDeleteBucket(
            getGcsUri(((Storage.Buckets.Delete) request).getBucket(), /* objectPath= */ null));
      }
  
      // Unhandled request types. All storage request should be covered by the previous checks.
      else {
        throw new RuntimeException("Unhandled storage request type. Request: " + request);
      }
    }
focal_method.class_method_signature: StorageRequestAuthorizer.authorize(StorageRequest<?> request)
focal_method.full_signature: public void authorize(StorageRequest<?> request)
focal_method.identifier: authorize
focal_method.invocations: log atFine handleListObjects getGcsUri getBucket getPrefix handleInsertObject getGcsUri getBucket getName getData getDestinationBucket getGcsUri getDestinationObject collect map stream getSourceObjects getData getGcsUri getName toImmutableList handleComposeObject handleGetObject getGcsUri getBucket getObject handleDeleteObject getGcsUri getBucket getObject handleRewriteObject getGcsUri getSourceBucket getSourceObject getGcsUri getDestinationBucket getDestinationObject handleCopyObject getGcsUri getSourceBucket getSourceObject getGcsUri getDestinationBucket getDestinationObject handlePatchObject getGcsUri getBucket getObject handleListBuckets getProject handleInsertBucket getProject getGcsUri getName getData handleGetBucket getGcsUri getBucket handleDeleteBucket getGcsUri getBucket
focal_method.modifiers: public
focal_method.parameters: (StorageRequest<?> request)
focal_method.return: void
focal_method.signature: void authorize(StorageRequest<?> request)