Java Code Examples for com.google.cloud.storage.BlobInfo#CustomerEncryption
The following examples show how to use
com.google.cloud.storage.BlobInfo#CustomerEncryption .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PutGCSObjectTest.java From localization_nifi with Apache License 2.0 | 4 votes |
@Test public void testAttributesSetOnSuccessfulPut() throws Exception { reset(storage, blob); final PutGCSObject processor = getProcessor(); final TestRunner runner = buildNewRunner(processor); addRequiredPropertiesToRunner(runner); runner.assertValid(); when(storage.create(any(BlobInfo.class), any(InputStream.class), any(Storage.BlobWriteOption.class))) .thenReturn(blob); when(blob.getBucket()).thenReturn(BUCKET); when(blob.getName()).thenReturn(KEY); when(blob.getSize()).thenReturn(SIZE); when(blob.getCacheControl()).thenReturn(CACHE_CONTROL); when(blob.getComponentCount()).thenReturn(COMPONENT_COUNT); when(blob.getContentDisposition()).thenReturn(CONTENT_DISPOSITION); when(blob.getContentEncoding()).thenReturn(CONTENT_ENCODING); when(blob.getContentLanguage()).thenReturn(CONTENT_LANGUAGE); when(blob.getContentType()).thenReturn(CONTENT_TYPE); when(blob.getCrc32c()).thenReturn(CRC32C); final BlobInfo.CustomerEncryption mockEncryption = mock(BlobInfo.CustomerEncryption.class); when(blob.getCustomerEncryption()).thenReturn(mockEncryption); when(mockEncryption.getEncryptionAlgorithm()).thenReturn(ENCRYPTION); when(mockEncryption.getKeySha256()).thenReturn(ENCRYPTION_SHA256); when(blob.getEtag()).thenReturn(ETAG); when(blob.getGeneratedId()).thenReturn(GENERATED_ID); when(blob.getGeneration()).thenReturn(GENERATION); when(blob.getMd5()).thenReturn(MD5); when(blob.getMediaLink()).thenReturn(MEDIA_LINK); when(blob.getMetageneration()).thenReturn(METAGENERATION); when(blob.getSelfLink()).thenReturn(URI); when(blob.getCreateTime()).thenReturn(CREATE_TIME); when(blob.getUpdateTime()).thenReturn(UPDATE_TIME); runner.enqueue("test"); runner.run(); runner.assertAllFlowFilesTransferred(PutGCSObject.REL_SUCCESS); runner.assertTransferCount(PutGCSObject.REL_SUCCESS, 1); final MockFlowFile mockFlowFile = runner.getFlowFilesForRelationship(PutGCSObject.REL_SUCCESS).get(0); mockFlowFile.assertAttributeEquals(BUCKET_ATTR, BUCKET); mockFlowFile.assertAttributeEquals(KEY_ATTR, KEY); mockFlowFile.assertAttributeEquals(SIZE_ATTR, String.valueOf(SIZE)); mockFlowFile.assertAttributeEquals(CACHE_CONTROL_ATTR, CACHE_CONTROL); mockFlowFile.assertAttributeEquals(COMPONENT_COUNT_ATTR, String.valueOf(COMPONENT_COUNT)); mockFlowFile.assertAttributeEquals(CONTENT_DISPOSITION_ATTR, CONTENT_DISPOSITION); mockFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), FILENAME); mockFlowFile.assertAttributeEquals(CONTENT_ENCODING_ATTR, CONTENT_ENCODING); mockFlowFile.assertAttributeEquals(CONTENT_LANGUAGE_ATTR, CONTENT_LANGUAGE); mockFlowFile.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), CONTENT_TYPE); mockFlowFile.assertAttributeEquals(CRC32C_ATTR, CRC32C); mockFlowFile.assertAttributeEquals(ENCRYPTION_ALGORITHM_ATTR, ENCRYPTION); mockFlowFile.assertAttributeEquals(ENCRYPTION_SHA256_ATTR, ENCRYPTION_SHA256); mockFlowFile.assertAttributeEquals(ETAG_ATTR, ETAG); mockFlowFile.assertAttributeEquals(GENERATED_ID_ATTR, GENERATED_ID); mockFlowFile.assertAttributeEquals(GENERATION_ATTR, String.valueOf(GENERATION)); mockFlowFile.assertAttributeEquals(MD5_ATTR, MD5); mockFlowFile.assertAttributeEquals(MEDIA_LINK_ATTR, MEDIA_LINK); mockFlowFile.assertAttributeEquals(METAGENERATION_ATTR, String.valueOf(METAGENERATION)); mockFlowFile.assertAttributeEquals(URI_ATTR, URI); mockFlowFile.assertAttributeEquals(CREATE_TIME_ATTR, String.valueOf(CREATE_TIME)); mockFlowFile.assertAttributeEquals(UPDATE_TIME_ATTR, String.valueOf(UPDATE_TIME)); }
Example 2
Source File: ListGCSBucket.java From nifi with Apache License 2.0 | 4 votes |
private Record createRecordForListing(final Blob blob) { final Map<String, Object> values = new HashMap<>(); values.put(BUCKET, blob.getBucket()); values.put(NAME, blob.getName()); values.put(SIZE, blob.getSize()); values.put(CACHE_CONTROL, blob.getCacheControl()); values.put(COMPONENT_COUNT, blob.getComponentCount()); values.put(CONTENT_DISPOSITION, blob.getContentDisposition()); values.put(CONTENT_ENCODING, blob.getContentEncoding()); values.put(CONTENT_LANGUAGE, blob.getContentLanguage()); values.put(CRC32C, blob.getCrc32c()); values.put(CREATE_TIME, blob.getCreateTime() == null ? null : new Timestamp(blob.getCreateTime())); values.put(UPDATE_TIME, blob.getUpdateTime() == null ? null : new Timestamp(blob.getUpdateTime())); final BlobInfo.CustomerEncryption encryption = blob.getCustomerEncryption(); if (encryption != null) { values.put(ENCRYPTION_ALGORITHM, encryption.getEncryptionAlgorithm()); values.put(ENCRYPTION_KEY_SHA256, encryption.getKeySha256()); } values.put(ETAG, blob.getEtag()); values.put(GENERATED_ID, blob.getGeneratedId()); values.put(GENERATION, blob.getGeneration()); values.put(MD5, blob.getMd5()); values.put(MEDIA_LINK, blob.getMediaLink()); values.put(METAGENERATION, blob.getMetageneration()); final Acl.Entity owner = blob.getOwner(); if (owner != null) { if (owner instanceof Acl.User) { values.put(OWNER, ((Acl.User) owner).getEmail()); values.put(OWNER_TYPE, "user"); } else if (owner instanceof Acl.Group) { values.put(OWNER, ((Acl.Group) owner).getEmail()); values.put(OWNER_TYPE, "group"); } else if (owner instanceof Acl.Domain) { values.put(OWNER, ((Acl.Domain) owner).getDomain()); values.put(OWNER_TYPE, "domain"); } else if (owner instanceof Acl.Project) { values.put(OWNER, ((Acl.Project) owner).getProjectId()); values.put(OWNER_TYPE, "project"); } } values.put(URI, blob.getSelfLink()); return new MapRecord(RECORD_SCHEMA, values); }
Example 3
Source File: StorageAttributes.java From nifi with Apache License 2.0 | 4 votes |
public static Map<String, String> createAttributes(final Blob blob) { final Map<String, String> attributes = new HashMap<>(); addAttribute(attributes, BUCKET_ATTR, blob.getBucket()); addAttribute(attributes, KEY_ATTR, blob.getName()); addAttribute(attributes, SIZE_ATTR, blob.getSize()); addAttribute(attributes, CACHE_CONTROL_ATTR, blob.getCacheControl()); addAttribute(attributes, COMPONENT_COUNT_ATTR, blob.getComponentCount()); addAttribute(attributes, CONTENT_DISPOSITION_ATTR, blob.getContentDisposition()); addAttribute(attributes, CONTENT_ENCODING_ATTR, blob.getContentEncoding()); addAttribute(attributes, CONTENT_LANGUAGE_ATTR, blob.getContentLanguage()); addAttribute(attributes, CoreAttributes.MIME_TYPE.key(), blob.getContentType()); addAttribute(attributes, CRC32C_ATTR, blob.getCrc32c()); if (blob.getCustomerEncryption() != null) { final BlobInfo.CustomerEncryption encryption = blob.getCustomerEncryption(); addAttribute(attributes, ENCRYPTION_ALGORITHM_ATTR, encryption.getEncryptionAlgorithm()); addAttribute(attributes, ENCRYPTION_SHA256_ATTR, encryption.getKeySha256()); } addAttribute(attributes, ETAG_ATTR, blob.getEtag()); addAttribute(attributes, GENERATED_ID_ATTR, blob.getGeneratedId()); addAttribute(attributes, GENERATION_ATTR, blob.getGeneration()); addAttribute(attributes, MD5_ATTR, blob.getMd5()); addAttribute(attributes, MEDIA_LINK_ATTR, blob.getMediaLink()); addAttribute(attributes, METAGENERATION_ATTR, blob.getMetageneration()); if (blob.getOwner() != null) { final Acl.Entity entity = blob.getOwner(); if (entity instanceof Acl.User) { addAttribute(attributes, OWNER_ATTR, ((Acl.User) entity).getEmail()); addAttribute(attributes, OWNER_TYPE_ATTR, "user"); } else if (entity instanceof Acl.Group) { addAttribute(attributes, OWNER_ATTR, ((Acl.Group) entity).getEmail()); addAttribute(attributes, OWNER_TYPE_ATTR, "group"); } else if (entity instanceof Acl.Domain) { addAttribute(attributes, OWNER_ATTR, ((Acl.Domain) entity).getDomain()); addAttribute(attributes, OWNER_TYPE_ATTR, "domain"); } else if (entity instanceof Acl.Project) { addAttribute(attributes, OWNER_ATTR, ((Acl.Project) entity).getProjectId()); addAttribute(attributes, OWNER_TYPE_ATTR, "project"); } } addAttribute(attributes, URI_ATTR, blob.getSelfLink()); addAttribute(attributes, CoreAttributes.FILENAME.key(), blob.getName()); addAttribute(attributes, CREATE_TIME_ATTR, blob.getCreateTime()); addAttribute(attributes, UPDATE_TIME_ATTR, blob.getUpdateTime()); return attributes; }
Example 4
Source File: ListGCSBucketTest.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testAttributesSet() throws Exception { reset(storage, mockBlobPage); final ListGCSBucket processor = getProcessor(); final TestRunner runner = buildNewRunner(processor); addRequiredPropertiesToRunner(runner); runner.assertValid(); final Blob blob = buildMockBlob("test-bucket-1", "test-key-1", 2L); when(blob.getSize()).thenReturn(SIZE); when(blob.getCacheControl()).thenReturn(CACHE_CONTROL); when(blob.getComponentCount()).thenReturn(COMPONENT_COUNT); when(blob.getContentEncoding()).thenReturn(CONTENT_ENCODING); when(blob.getContentLanguage()).thenReturn(CONTENT_LANGUAGE); when(blob.getContentType()).thenReturn(CONTENT_TYPE); when(blob.getCrc32c()).thenReturn(CRC32C); final BlobInfo.CustomerEncryption mockEncryption = mock(BlobInfo.CustomerEncryption.class); when(mockEncryption.getEncryptionAlgorithm()).thenReturn(ENCRYPTION); when(mockEncryption.getKeySha256()).thenReturn(ENCRYPTION_SHA256); when(blob.getCustomerEncryption()).thenReturn(mockEncryption); when(blob.getEtag()).thenReturn(ETAG); when(blob.getGeneratedId()).thenReturn(GENERATED_ID); when(blob.getGeneration()).thenReturn(GENERATION); when(blob.getMd5()).thenReturn(MD5); when(blob.getMediaLink()).thenReturn(MEDIA_LINK); when(blob.getMetageneration()).thenReturn(METAGENERATION); when(blob.getSelfLink()).thenReturn(URI); when(blob.getContentDisposition()).thenReturn(CONTENT_DISPOSITION); when(blob.getCreateTime()).thenReturn(CREATE_TIME); when(blob.getUpdateTime()).thenReturn(UPDATE_TIME); final Iterable<Blob> mockList = ImmutableList.of(blob); when(mockBlobPage.getValues()).thenReturn(mockList); when(mockBlobPage.getNextPage()).thenReturn(null); when(storage.list(anyString(), any(Storage.BlobListOption[].class))).thenReturn(mockBlobPage); runner.enqueue("test"); runner.run(); runner.assertAllFlowFilesTransferred(FetchGCSObject.REL_SUCCESS); runner.assertTransferCount(FetchGCSObject.REL_SUCCESS, 1); final MockFlowFile flowFile = runner.getFlowFilesForRelationship(FetchGCSObject.REL_SUCCESS).get(0); assertEquals(CACHE_CONTROL, flowFile.getAttribute(CACHE_CONTROL_ATTR)); assertEquals(COMPONENT_COUNT,Integer.valueOf(flowFile.getAttribute(COMPONENT_COUNT_ATTR))); assertEquals(CONTENT_ENCODING, flowFile.getAttribute(CONTENT_ENCODING_ATTR)); assertEquals(CONTENT_LANGUAGE, flowFile.getAttribute(CONTENT_LANGUAGE_ATTR)); assertEquals(CONTENT_TYPE, flowFile.getAttribute(CoreAttributes.MIME_TYPE.key())); assertEquals(CRC32C, flowFile.getAttribute(CRC32C_ATTR)); assertEquals(ENCRYPTION, flowFile.getAttribute(ENCRYPTION_ALGORITHM_ATTR)); assertEquals(ENCRYPTION_SHA256, flowFile.getAttribute(ENCRYPTION_SHA256_ATTR)); assertEquals(ETAG, flowFile.getAttribute(ETAG_ATTR)); assertEquals(GENERATED_ID, flowFile.getAttribute(GENERATED_ID_ATTR)); assertEquals(GENERATION, Long.valueOf(flowFile.getAttribute(GENERATION_ATTR))); assertEquals(MD5, flowFile.getAttribute(MD5_ATTR)); assertEquals(MEDIA_LINK, flowFile.getAttribute(MEDIA_LINK_ATTR)); assertEquals(METAGENERATION, Long.valueOf(flowFile.getAttribute(METAGENERATION_ATTR))); assertEquals(URI, flowFile.getAttribute(URI_ATTR)); assertEquals(CONTENT_DISPOSITION, flowFile.getAttribute(CONTENT_DISPOSITION_ATTR)); assertEquals(CREATE_TIME, Long.valueOf(flowFile.getAttribute(CREATE_TIME_ATTR))); assertEquals(UPDATE_TIME, Long.valueOf(flowFile.getAttribute(UPDATE_TIME_ATTR))); }
Example 5
Source File: PutGCSObjectTest.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testAttributesSetOnSuccessfulPut() throws Exception { reset(storage, blob); final PutGCSObject processor = getProcessor(); final TestRunner runner = buildNewRunner(processor); addRequiredPropertiesToRunner(runner); runner.assertValid(); when(storage.create(any(BlobInfo.class), any(InputStream.class), any(Storage.BlobWriteOption.class))) .thenReturn(blob); when(blob.getBucket()).thenReturn(BUCKET); when(blob.getName()).thenReturn(KEY); when(blob.getSize()).thenReturn(SIZE); when(blob.getCacheControl()).thenReturn(CACHE_CONTROL); when(blob.getComponentCount()).thenReturn(COMPONENT_COUNT); when(blob.getContentDisposition()).thenReturn(CONTENT_DISPOSITION); when(blob.getContentEncoding()).thenReturn(CONTENT_ENCODING); when(blob.getContentLanguage()).thenReturn(CONTENT_LANGUAGE); when(blob.getContentType()).thenReturn(CONTENT_TYPE); when(blob.getCrc32c()).thenReturn(CRC32C); final BlobInfo.CustomerEncryption mockEncryption = mock(BlobInfo.CustomerEncryption.class); when(blob.getCustomerEncryption()).thenReturn(mockEncryption); when(mockEncryption.getEncryptionAlgorithm()).thenReturn(ENCRYPTION); when(mockEncryption.getKeySha256()).thenReturn(ENCRYPTION_SHA256); when(blob.getEtag()).thenReturn(ETAG); when(blob.getGeneratedId()).thenReturn(GENERATED_ID); when(blob.getGeneration()).thenReturn(GENERATION); when(blob.getMd5()).thenReturn(MD5); when(blob.getMediaLink()).thenReturn(MEDIA_LINK); when(blob.getMetageneration()).thenReturn(METAGENERATION); when(blob.getSelfLink()).thenReturn(URI); when(blob.getCreateTime()).thenReturn(CREATE_TIME); when(blob.getUpdateTime()).thenReturn(UPDATE_TIME); runner.enqueue("test"); runner.run(); runner.assertAllFlowFilesTransferred(PutGCSObject.REL_SUCCESS); runner.assertTransferCount(PutGCSObject.REL_SUCCESS, 1); final MockFlowFile mockFlowFile = runner.getFlowFilesForRelationship(PutGCSObject.REL_SUCCESS).get(0); mockFlowFile.assertAttributeEquals(BUCKET_ATTR, BUCKET); mockFlowFile.assertAttributeEquals(KEY_ATTR, KEY); mockFlowFile.assertAttributeEquals(SIZE_ATTR, String.valueOf(SIZE)); mockFlowFile.assertAttributeEquals(CACHE_CONTROL_ATTR, CACHE_CONTROL); mockFlowFile.assertAttributeEquals(COMPONENT_COUNT_ATTR, String.valueOf(COMPONENT_COUNT)); mockFlowFile.assertAttributeEquals(CONTENT_DISPOSITION_ATTR, CONTENT_DISPOSITION); mockFlowFile.assertAttributeEquals(CoreAttributes.FILENAME.key(), FILENAME); mockFlowFile.assertAttributeEquals(CONTENT_ENCODING_ATTR, CONTENT_ENCODING); mockFlowFile.assertAttributeEquals(CONTENT_LANGUAGE_ATTR, CONTENT_LANGUAGE); mockFlowFile.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), CONTENT_TYPE); mockFlowFile.assertAttributeEquals(CRC32C_ATTR, CRC32C); mockFlowFile.assertAttributeEquals(ENCRYPTION_ALGORITHM_ATTR, ENCRYPTION); mockFlowFile.assertAttributeEquals(ENCRYPTION_SHA256_ATTR, ENCRYPTION_SHA256); mockFlowFile.assertAttributeEquals(ETAG_ATTR, ETAG); mockFlowFile.assertAttributeEquals(GENERATED_ID_ATTR, GENERATED_ID); mockFlowFile.assertAttributeEquals(GENERATION_ATTR, String.valueOf(GENERATION)); mockFlowFile.assertAttributeEquals(MD5_ATTR, MD5); mockFlowFile.assertAttributeEquals(MEDIA_LINK_ATTR, MEDIA_LINK); mockFlowFile.assertAttributeEquals(METAGENERATION_ATTR, String.valueOf(METAGENERATION)); mockFlowFile.assertAttributeEquals(URI_ATTR, URI); mockFlowFile.assertAttributeEquals(CREATE_TIME_ATTR, String.valueOf(CREATE_TIME)); mockFlowFile.assertAttributeEquals(UPDATE_TIME_ATTR, String.valueOf(UPDATE_TIME)); }