- * Example: - *
- * Provided DN: {@code jdoe> Алйс
- * Provided DN: {@code Алйс} -> {@code <Алйс>} cannot be encoded/decoded as ASCII
- *
- * @param rawDn the unsanitized DN
- * @return the sanitized DN
- */
- private static String sanitizeDn(final String rawDn) {
- if (StringUtils.isEmpty(rawDn)) {
- return rawDn;
- } else {
-
- // First, escape any GT [>] or LT [<] characters, which are not safe
- final String escapedDn = rawDn.replaceAll(GT, ESCAPED_GT).replaceAll(LT, ESCAPED_LT);
- if (!escapedDn.equals(rawDn)) {
- logger.warn("The provided DN [{}] contained dangerous characters that were escaped to [{}]", rawDn, escapedDn);
- }
-
- // Second, check for characters outside US-ASCII.
- // This is necessary because X509 Certs can contain international/Unicode characters,
- // but this value will be passed in an HTTP Header which must be US-ASCII.
- // If non-ascii characters are present, base64 encode the DN and wrap in
@@ -281,19 +194,7 @@ private static String unsanitizeDn(final String sanitizedDn) {
}
/**
- * Base64 encodes a DN and wraps it in angled brackets to indicate the value is base64 and not a raw DN.
- *
- * @param rawValue The value to encode
- * @return A string containing a wrapped, encoded value.
- */
- private static String base64Encode(final String rawValue) {
- final String base64String = Base64.getEncoder().encodeToString(rawValue.getBytes(StandardCharsets.UTF_8));
- final String wrappedEncodedValue = LT + base64String + GT;
- return wrappedEncodedValue;
- }
-
- /**
- * Performs the reverse of ${@link #base64Encode(String)}.
+ * Performs the reverse of Base64 encoding
*
* @param encodedValue the encoded value to decode.
* @return The original, decoded string.
@@ -314,7 +215,7 @@ private static boolean isValidChainFormat(final String rawProxiedEntitiesChain)
}
/**
- * Check if a value has been encoded by ${@link #base64Encode(String)}, and therefore needs to be decoded.
+ * Check if a value has been encoded by Base64 encoding and therefore needs to be decoded.
*
* @param token the value to check
* @return true if the value is encoded, false otherwise.
@@ -332,14 +233,4 @@ private static boolean isBase64Encoded(final String token) {
private static boolean isWrappedInAngleBrackets(final String string) {
return string.startsWith(LT) && string.endsWith(GT);
}
-
- /**
- * Check if a string contains only pure ascii characters.
- *
- * @param stringWithUnknownCharacters - the string to check
- * @return true if string can be encoded as ascii. false otherwise.
- */
- private static boolean isPureAscii(final String stringWithUnknownCharacters) {
- return StandardCharsets.US_ASCII.newEncoder().canEncode(stringWithUnknownCharacters);
- }
}
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/ProxiedEntitiesUtilsTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/ProxiedEntitiesUtilsTest.java
index 503ae3cb94cc..8eb72b5f23b9 100644
--- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/ProxiedEntitiesUtilsTest.java
+++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/ProxiedEntitiesUtilsTest.java
@@ -19,8 +19,6 @@
import org.apache.nifi.authorization.user.NiFiUser;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -33,7 +31,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -45,7 +42,6 @@ public class ProxiedEntitiesUtilsTest {
private static final String SAFE_USER_NAME_PROXY_2 = "proxy2.nifi.apache.org";
private static final String SAFE_USER_DN_PROXY_2 = "CN=" + SAFE_USER_NAME_PROXY_2 + ", OU=Apache NiFi";
private static final String MALICIOUS_USER_NAME_JOHN = SAFE_USER_NAME_JOHN + ", OU=Apache NiFi>