S3DataStore extends AbstractSharedCachingDataStore implements ConfigurableDataRecordAccessProvider { public SharedBackend getBackend() { return backend; }  void setProperties(Properties properties); SharedBackend getBackend(); @Override int getMinRecordLength(); void setMinRecordLength(int minRecordLength); @Override void setDirectUploadURIExpirySeconds(int seconds); @Override void setBinaryTransferAccelerationEnabled(boolean enabled); @Nullable @Override DataRecordUpload initiateDataRecordUpload(long maxUploadSizeInBytes, int maxNumberOfURIs); @Nullable @Override DataRecordUpload initiateDataRecordUpload(long maxUploadSizeInBytes, int maxNumberOfURIs, @NotNull final DataRecordUploadOptions options); @NotNull @Override DataRecord completeDataRecordUpload(@NotNull String uploadToken); @Override void setDirectDownloadURIExpirySeconds(int seconds); @Override void setDirectDownloadURICacheSize(int maxSize); @Nullable @Override URI getDownloadURI(@NotNull DataIdentifier identifier,
                              @NotNull DataRecordDownloadOptions downloadOptions);  }
@Test public void testSecret() throws Exception { assumeTrue(isS3Configured()); Random randomGen = new Random(); props = S3DataStoreUtils.getS3Config(); props.put("cacheSize", "0"); ds = getS3DataStore(s3Class, props, dataStoreDir.getAbsolutePath()); bucket = props.getProperty(S3Constants.S3_BUCKET); byte[] data = new byte[4096]; randomGen.nextBytes(data); DataRecord rec = ds.addRecord(new ByteArrayInputStream(data)); assertEquals(data.length, rec.getLength()); String ref = rec.getReference(); assertNotNull(ref); String id = rec.getIdentifier().toString(); S3DataStore s3 = ((S3DataStore) ds); byte[] refKey = ((S3Backend) s3.getBackend()).getOrCreateReferenceKey(); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(new SecretKeySpec(refKey, "HmacSHA1")); byte[] hash = mac.doFinal(id.getBytes("UTF-8")); String calcRef = id + ':' + encodeHexString(hash); assertEquals("getReference() not equal", calcRef, ref); DataRecord refRec = s3.getMetadataRecord("reference.key"); assertNotNull("Reference data record null", refRec); byte[] refDirectFromBackend = IOUtils.toByteArray(refRec.getStream()); LOG.warn("Ref direct from backend {}", refDirectFromBackend); assertTrue("refKey in memory not equal to the metadata record", Arrays.equals(refKey, refDirectFromBackend)); }