public class ProxiedEntitiesUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
private static String |
ANONYMOUS_CHAIN |
private static String |
ANONYMOUS_IDENTITY |
private static String |
ESCAPED_GT |
private static String |
ESCAPED_LT |
private static String |
GT |
private static org.slf4j.Logger |
logger |
private static String |
LT |
static String |
PROXY_ENTITIES_ACCEPTED |
static String |
PROXY_ENTITIES_CHAIN |
static String |
PROXY_ENTITIES_DETAILS |
static String |
PROXY_ENTITY_GROUPS |
static String |
PROXY_ENTITY_GROUPS_EMPTY |
| Constructor and Description |
|---|
ProxiedEntitiesUtils() |
| Modifier and Type | Method and Description |
|---|---|
private static String |
base64Decode(String encodedValue)
Performs the reverse of $
base64Encode(String). |
private static String |
base64Encode(String rawValue)
Base64 encodes a DN and wraps it in angled brackets to indicate the value is base64 and not a raw DN.
|
static String |
buildProxiedEntitiesChainString(NiFiUser user)
Builds the proxy chain for the specified user.
|
static String |
buildProxiedEntityGroupsString(Set<String> groups)
Builds the string representation for a set of groups that belong to a proxied entity.
|
static String |
formatProxyDn(String dn)
Formats the specified DN to be set as a HTTP header using well known conventions.
|
static String |
getProxiedEntitiesChain(List<String> proxiedEntities)
Formats a list of DN/usernames to be set as a HTTP header using well known conventions.
|
static String |
getProxiedEntitiesChain(String... proxiedEntities)
Formats a list of DN/usernames to be set as a HTTP header using well known conventions.
|
private static boolean |
isBase64Encoded(String token)
Check if a value has been encoded by $
base64Encode(String), and therefore needs to be decoded. |
private static boolean |
isPureAscii(String stringWithUnknownCharacters)
Check if a string contains only pure ascii characters.
|
private static boolean |
isValidChainFormat(String rawProxiedEntitiesChain)
Check if a String is in the expected format and can be safely tokenized.
|
private static boolean |
isWrappedInAngleBrackets(String string)
Check if a string is wrapped with <angle brackets>.
|
private static String |
sanitizeDn(String rawDn)
Sanitizes a DN for safe and lossless transmission.
|
static void |
successfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
If a successfully authenticated request was made via a proxy, relevant proxy headers will be added to the response.
|
static List<String> |
tokenizeProxiedEntitiesChain(String rawProxyChain)
Tokenizes the specified proxy chain.
|
static Set<String> |
tokenizeProxiedEntityGroups(String rawProxyEntityGroups)
Tokenizes the specified proxied entity groups which are formatted the same as a proxy chain.
|
private static String |
unsanitizeDn(String sanitizedDn)
Reconstitutes the original DN from the sanitized version passed in the proxy chain.
|
static void |
unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.security.core.AuthenticationException failed)
If an unauthenticated request was made via a proxy, add proxy headers to explain why authentication failed.
|
private static final org.slf4j.Logger logger
public static final String PROXY_ENTITIES_CHAIN
public static final String PROXY_ENTITIES_ACCEPTED
public static final String PROXY_ENTITIES_DETAILS
public static final String PROXY_ENTITY_GROUPS
public static final String PROXY_ENTITY_GROUPS_EMPTY
private static final String GT
private static final String ESCAPED_GT
private static final String LT
private static final String ESCAPED_LT
private static final String ANONYMOUS_CHAIN
private static final String ANONYMOUS_IDENTITY
public static String getProxiedEntitiesChain(String... proxiedEntities)
proxiedEntities - the raw identities (usernames and DNs) to be formatted as a chainpublic static String getProxiedEntitiesChain(List<String> proxiedEntities)
proxiedEntities - the raw identities (usernames and DNs) to be formatted as a chainpublic static List<String> tokenizeProxiedEntitiesChain(String rawProxyChain)
rawProxyChain - raw chainpublic static Set<String> tokenizeProxiedEntityGroups(String rawProxyEntityGroups)
rawProxyEntityGroups - the raw proxy entity groupspublic static String buildProxiedEntitiesChainString(NiFiUser user)
user - The current userpublic static String buildProxiedEntityGroupsString(Set<String> groups)
"<group1><group2><group3> groups - the set of groupspublic static void successfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - The proxied client request that was successfully authenticated.response - A servlet response to the client containing the successful authentication details.public static void unsuccessfulAuthentication(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.springframework.security.core.AuthenticationException failed)
request - The original client request that failed to be authenticated.response - Servlet response to the client containing the unsuccessful authentication attempt details.failed - The related exception thrown and explanation for the unsuccessful authentication attempt.public static String formatProxyDn(String dn)
dn - raw dnprivate static String sanitizeDn(String rawDn)
Example:
Provided DN: jdoe><alopresto -> <jdoe><alopresto><proxy...> would allow the user to impersonate jdoe
Алйс
Provided DN: Алйс -> <Алйс> cannot be encoded/decoded as ASCII
rawDn - the unsanitized DNprivate static String unsanitizeDn(String sanitizedDn)
Example:
alopresto\>\<proxy1 -> alopresto><proxy1
<0JDQu9C50YE=> -> Алйс
sanitizedDn - the sanitized DNprivate static String base64Encode(String rawValue)
rawValue - The value to encodeprivate static String base64Decode(String encodedValue)
base64Encode(String).encodedValue - the encoded value to decode.private static boolean isValidChainFormat(String rawProxiedEntitiesChain)
rawProxiedEntitiesChain - the value to checkprivate static boolean isBase64Encoded(String token)
base64Encode(String), and therefore needs to be decoded.token - the value to checkprivate static boolean isWrappedInAngleBrackets(String string)
string - the value to checkprivate static boolean isPureAscii(String stringWithUnknownCharacters)
stringWithUnknownCharacters - - the string to checkCopyright © 2023 Apache NiFi Project. All rights reserved.