GUACAMOLE-1218: Replace use of "blacklist" with "denylist".

This commit is contained in:
Michael Jumper
2020-11-29 16:09:20 -08:00
parent 6b054f25ca
commit 66d28b8424
2 changed files with 22 additions and 22 deletions

View File

@@ -28,35 +28,35 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Atomic blacklist of UserData objects, stored by their associated * Atomic denylist of UserData objects, stored by their associated
* cryptographic signatures. UserData objects stored within this blacklist MUST * cryptographic signatures. UserData objects stored within this denylist MUST
* have an associated expiration timestamp, and will automatically be removed * have an associated expiration timestamp, and will automatically be removed
* from the blacklist once they have expired. * from the denylist once they have expired.
*/ */
public class UserDataBlacklist { public class UserDataDenylist {
/** /**
* Logger for this class. * Logger for this class.
*/ */
private final Logger logger = LoggerFactory.getLogger(UserDataBlacklist.class); private final Logger logger = LoggerFactory.getLogger(UserDataDenylist.class);
/** /**
* All blacklisted UserData objects, stored by their associated * All denylisted UserData objects, stored by their associated
* cryptographic signatures. NOTE: Each key into this map is the hex * cryptographic signatures. NOTE: Each key into this map is the hex
* string produced by encoding the binary signature using DatatypeConverter. * string produced by encoding the binary signature using DatatypeConverter.
* A byte[] cannot be used directly. * A byte[] cannot be used directly.
*/ */
private final ConcurrentMap<String, UserData> blacklist = private final ConcurrentMap<String, UserData> denylist =
new ConcurrentHashMap<String, UserData>(); new ConcurrentHashMap<String, UserData>();
/** /**
* Removes all expired UserData objects from the blacklist. This will * Removes all expired UserData objects from the denylist. This will
* automatically be invoked whenever new UserData is added to the blacklist. * automatically be invoked whenever new UserData is added to the denylist.
*/ */
public void removeExpired() { public void removeExpired() {
// Remove expired data from blacklist // Remove expired data from denylist
Iterator<Map.Entry<String, UserData>> current = blacklist.entrySet().iterator(); Iterator<Map.Entry<String, UserData>> current = denylist.entrySet().iterator();
while (current.hasNext()) { while (current.hasNext()) {
// Remove entry from map if its associated with expired data // Remove entry from map if its associated with expired data
@@ -69,20 +69,20 @@ public class UserDataBlacklist {
} }
/** /**
* Adds the given UserData to the blacklist, storing it according to the * Adds the given UserData to the denylist, storing it according to the
* provided cryptographic signature. The UserData MUST have an associated * provided cryptographic signature. The UserData MUST have an associated
* expiration timestamp. If any UserData objects already within the * expiration timestamp. If any UserData objects already within the
* blacklist have expired, they will automatically be removed when this * denylist have expired, they will automatically be removed when this
* function is invoked. * function is invoked.
* *
* @param data * @param data
* The UserData to store within the blacklist. * The UserData to store within the denylist.
* *
* @param signature * @param signature
* The cryptographic signature associated with the UserData. * The cryptographic signature associated with the UserData.
* *
* @return * @return
* true if the UserData was not already blacklisted and has * true if the UserData was not already denylisted and has
* successfully been added, false otherwise. * successfully been added, false otherwise.
*/ */
public boolean add(UserData data, byte[] signature) { public boolean add(UserData data, byte[] signature) {
@@ -97,13 +97,13 @@ public class UserDataBlacklist {
// Remove any expired entries // Remove any expired entries
removeExpired(); removeExpired();
// Expired user data is implicitly blacklisted // Expired user data is implicitly denylisted
if (data.isExpired()) if (data.isExpired())
return false; return false;
// Add to blacklist only if not already present // Add to denylist only if not already present
String signatureHex = DatatypeConverter.printHexBinary(signature); String signatureHex = DatatypeConverter.printHexBinary(signature);
return blacklist.putIfAbsent(signatureHex, data) == null; return denylist.putIfAbsent(signatureHex, data) == null;
} }

View File

@@ -64,9 +64,9 @@ public class UserDataService {
private static final ObjectMapper mapper = new ObjectMapper(); private static final ObjectMapper mapper = new ObjectMapper();
/** /**
* Blacklist of single-use user data objects which have already been used. * Denylist of single-use user data objects which have already been used.
*/ */
private final UserDataBlacklist blacklist = new UserDataBlacklist(); private final UserDataDenylist denylist = new UserDataDenylist();
/** /**
* Service for retrieving configuration information regarding the * Service for retrieving configuration information regarding the
@@ -201,8 +201,8 @@ public class UserDataService {
if (userData.isExpired()) if (userData.isExpired())
return null; return null;
// Reject if data is single-use and already present in the blacklist // Reject if data is single-use and already present in the denylist
if (userData.isSingleUse() && !blacklist.add(userData, correctSignature)) if (userData.isSingleUse() && !denylist.add(userData, correctSignature))
return null; return null;
return userData; return userData;