-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge integration into feature/email-country-blacklists-v2
- Loading branch information
Showing
35 changed files
with
962 additions
and
575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIG7TCCBNWgAwIBAgITGAAAAAecWWKCXTfeJAAAAAAABzANBgkqhkiG9w0BAQsF | ||
ADAVMRMwEQYDVQQDEwpOSVNUUm9vdDAyMB4XDTIxMTIwMTE4MDU0NloXDTI2MTIw | ||
MTE4MTU0NlowgcIxCzAJBgNVBAYTAlVTMREwDwYDVQQIEwhNYXJ5bGFuZDEVMBMG | ||
A1UEBxMMR2FpdGhlcnNidXJnMTcwNQYDVQQKEy5OYXRpb25hbCBJbnN0aXR1dGUg | ||
b2YgU3RhbmRhcmRzIGFuZCBUZWNobm9sb2d5MQ0wCwYDVQQLEwRPSVNNMR4wHAYD | ||
VQQDDBVGb3J3YXJkX1Byb3h5X05JU1RfQ0ExITAfBgkqhkiG9w0BCQEWEm5ldHNl | ||
Y3VyZUBuaXN0LmdvdjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL/8 | ||
PgucU6LfbThmVCiQU5zH7HRdJ0QeM8xa9Hy3BnBdD4/CxQklo7dz+AXquaOfI5Br | ||
H8SYZCySWTveFeJW+XvhjmEVpobz8GGrEgdR5nAKg3ZJHvAMPKgGMSnXja227TVj | ||
qqCZX9cIWQifqcM1iWTkS4BW2oZazwXYCqs5dfwy92ey5f/7AYC4dFeL//QtqQs/ | ||
EUFApYabhKLcDLleDh4hwlhbT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qGSIb3DQEBCwUAA4ICAQB3OCkcbjepVN7tbK3PlLzG5HkRBG1QSmFsRnQdUTov | ||
/rWhdLDpHGKO4k/W2zTxNNxPW8ooD1PCy+cIlBLGcq8YcyhvWk0V2Gx1P+/f4+eq | ||
eH4hcUQO/7INohcnh4QXiSVMa7jNaLC+/usqWbsmTvVDbl2aYbQtwizXnUW1qNhz | ||
Bt76OoM7C95rNktNiaJ1VmFmd+Z3rRhzAZiC9XFIwIN1F+um7IG43nsoM4hnCByc | ||
/SBb3LC8R+7vNUYedkrfNPq8SGCHuPuK8H0gJX+8/8hmaaNPtZoe0VZkTdNXitnY | ||
HNof6w5mDoPu9lgLmNO0c36dNrmhHlPAu71EkL3afBhrdgb4Gel0WlENaur2MWf+ | ||
yg6IQz7+aCTu2bMIkW3gm942tp7IrkXMGshUsJjLHFVrpIVkP+70QnO0wGzzQWlI | ||
gt+/gKvj951KGagVzsFyiQtFL9uFYMiS0awLVkSLYtBzdykm8mpG1n6EO5DlEYWe | ||
MOhVSeki05s0+6zUWU6TIhVDgCeUJYvAYAtWVA07Tbb1lb1vP+KbWzFMuAQMrKXV | ||
I0sL/gjcwaj18n8vb0NdVU2n4qoW44gBi8ocgbuBntt63J4GHpaIn/I4OHBiwu/2 | ||
IwUrfePEVCI2pAm/sBfw2XiofAclxBhhJniiRoMYPKCOdnPRP1nUWOdotzPJFPJe | ||
1Q== | ||
-----END CERTIFICATE----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFBTCCAu2gAwIBAgIQdRxyg4+47KRFWKY+545EJjANBgkqhkiG9w0BAQsFADAV | ||
MRMwEQYDVQQDEwpOSVNUUm9vdDAyMB4XDTE4MDgwMTE4MTgzOVoXDTM4MDgwMTE4 | ||
Mjc1M1owFTET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I | ||
ONyHbGOnuWGXatwRNXUIhhx2UGeAy38xrIU8Z0ssTCsRY374WSFYaR5Ww7hfunyi | ||
eBmofMY+j6flNxEqckV3BeIarJxWmpEaAihczZxJsnZXW+D0B7h4EKZ/DakOl2QA | ||
59aE740ToPAl+pAF4OhT53xPlju+tqkaLnVJg/kI7Qrc0S2mHGrXnDl1FUya8VFS | ||
Vm8bf3nd483e3nWnSVU+vItlRIrtoHnLQ7xzMkurUNo2pROR+JgsL5WL0+NDGFjv | ||
Ixf9ReYGN9ujrHtojZiFaDLMPUftV6EVk2qc2d8BMEAnVzy8WJk6iqiWsmYaE2uq | ||
wdQHiP8kwQhXXRbqhfFZWwSisga4TIZu65rR88ah08DOGaTLfqKUnb9WD4dzTDFH | ||
XBl6ryuOeJGBoeJVbjy5938ZKHSS/nP3H/zYwve7xBw8CkmKAA1ECLJ47iWFmlyr | ||
mQkr8lkaupRMxgV8LUml35hI4lT2SbvAbdsuP/RvuvrK+mHS2UEDjG/qz4aTuXrm | ||
uMnUuya/1QGPhFD1oztxrhem2ob2jfkRfWT6wbv8UK7Mniw2zBfISXY= | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This directory contains non-standard CA certificates needed to build the docker | ||
images. | ||
|
||
Failures building the Docker containers defined in ../ due to SSL certificate | ||
verification errors may be a consequence of your local network's firewall. In | ||
particular, the firewall may be substituting external site certificates with | ||
its own signed by a non-standard CA certficate (chain). If so, you can place | ||
the necessary certificates into this directory; they will be passed into the | ||
containers, allowing them to safely connect to those external sites. | ||
|
||
Be sure the certificates are in PEM format and include a .crt file extension. | ||
|
||
Do not remove this README file; doing so may cause a Docker build faiure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This directory contains non-standard CA certificates needed to build the docker | ||
images. | ||
|
||
Failures building the Docker containers defined in ../ due to SSL certificate | ||
verification errors may be a consequence of your local network's firewall. In | ||
particular, the firewall may be substituting external site certificates with | ||
its own signed by a non-standard CA certficate (chain). If so, you can place | ||
the necessary certificates into this directory; they will be passed into the | ||
containers, allowing them to safely connect to those external sites. | ||
|
||
Be sure the certificates are in PEM format and include a .crt file extension. | ||
|
||
Do not remove this README file; doing so may cause a Docker build faiure. |
82 changes: 82 additions & 0 deletions
82
src/main/java/gov/nist/oar/distrib/cachemgr/CacheExpiryCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package gov.nist.oar.distrib.cachemgr; | ||
|
||
import gov.nist.oar.distrib.StorageVolumeException; | ||
|
||
import java.time.Instant; | ||
|
||
/** | ||
* Implements a cache object check to identify and remove objects that have been in the cache | ||
* longer than a specified duration, specifically two weeks. This check helps in | ||
* managing cache integrity by ensuring that stale or outdated data are removed | ||
* from the cache. | ||
*/ | ||
public class CacheExpiryCheck implements CacheObjectCheck { | ||
|
||
private StorageInventoryDB inventoryDB; | ||
|
||
public CacheExpiryCheck(StorageInventoryDB inventoryDB) { | ||
this.inventoryDB = inventoryDB; | ||
} | ||
|
||
/** | ||
* Checks if a cache object is expired and removes it from the cache if it is. | ||
* The method uses the {@code expires} metadata field to determine the expiration status. | ||
* The expiration time is calculated based on the {@code LastModified} time plus the {@code expires} duration. | ||
* If the current time is past the calculated expiry time, the object is removed from the inventory database. | ||
* | ||
* @param co The cache object to check for expiration. | ||
* @throws IntegrityException If the object is found to be corrupted during the check. | ||
* @throws StorageVolumeException If there's an error accessing the storage volume during the check. | ||
* @throws CacheManagementException If there's an error managing the cache, including removing the expired object. | ||
*/ | ||
@Override | ||
public void check(CacheObject co) throws IntegrityException, StorageVolumeException, CacheManagementException { | ||
if (co == null || inventoryDB == null) { | ||
throw new IllegalArgumentException("CacheObject or StorageInventoryDB is null"); | ||
} | ||
|
||
if (co.hasMetadatum("expires")) { | ||
long expiresDuration = co.getMetadatumLong("expires", -1L); | ||
if (expiresDuration == -1L) { | ||
throw new IntegrityException("Invalid 'expires' metadata value"); | ||
} | ||
|
||
long lastModified = co.getLastModified(); | ||
if (lastModified == -1L) { | ||
throw new IntegrityException("CacheObject 'lastModified' time not available"); | ||
} | ||
|
||
long expiryTime = lastModified + expiresDuration; | ||
long currentTime = Instant.now().toEpochMilli(); | ||
|
||
// Check if the object is expired | ||
if (expiryTime < currentTime) { | ||
try { | ||
boolean removed = removeObject(co); | ||
if (!removed) { | ||
throw new CacheManagementException("Failed to remove expired object: " + co.name); | ||
} | ||
} catch (InventoryException e) { | ||
throw new CacheManagementException("Error removing expired object from inventory database: " + co.name, e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Attempts to remove a cache object from both its physical volume and the inventory database. | ||
* Synchronization ensures thread-safe removal operations. | ||
* | ||
* @param co The cache object to be removed. | ||
* @return true if the object was successfully removed from its volume, false otherwise. | ||
* @throws StorageVolumeException if an error occurs accessing the storage volume. | ||
* @throws InventoryException if an error occurs updating the inventory database. | ||
*/ | ||
protected boolean removeObject(CacheObject co) throws StorageVolumeException, InventoryException { | ||
synchronized (inventoryDB) { | ||
boolean out = co.volume.remove(co.name); | ||
inventoryDB.removeObject(co.volname, co.name); | ||
return out; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.