@Override public InputStream getContent() throws IOException { return new DigestCalculatingInputStream( getTarget().getContent(), messageDigest, contextKey, context ); }
protected void prepareStorageFileItemForStore( final StorageFileItem item ) throws LocalStorageException { try { // replace content locator ChecksummingContentLocator sha1cl = new ChecksummingContentLocator( item.getContentLocator(), MessageDigest.getInstance( "SHA1" ), StorageFileItem.DIGEST_SHA1_KEY, item.getItemContext() ); // md5 is deprecated but still calculated ChecksummingContentLocator md5cl = new ChecksummingContentLocator( sha1cl, MessageDigest.getInstance( "MD5" ), StorageFileItem.DIGEST_MD5_KEY, item.getItemContext() ); item.setContentLocator( md5cl ); } catch ( NoSuchAlgorithmException e ) { throw new LocalStorageException( "The JVM does not support SHA1 MessageDigest or MD5 MessageDigest, that is essential for Nexus. We cannot write to local storage! Please run Nexus on JVM that does provide these MessageDigests.", e ); } } }