/** * Returns a regular user populated with the provided values, or if the user should be anonymous, a well-formed instance of the anonymous user with the provided values. * * @param identity the user's identity * @param chain the proxied entities * @param clientAddress the requesting IP address * @param isAnonymous if true, an anonymous user will be returned (identity will be ignored) * @return the populated user */ protected static NiFiUser createUser(String identity, Set<String> groups, NiFiUser chain, String clientAddress, boolean isAnonymous) { if (isAnonymous) { return StandardNiFiUser.populateAnonymousUser(chain, clientAddress); } else { return new Builder().identity(identity).groups(groups).chain(chain).clientAddress(clientAddress).build(); } }
/** * Returns a regular user populated with the provided values, or if the user should be anonymous, a well-formed instance of the anonymous user with the provided values. * * @param identity the user's identity * @param chain the proxied entities * @param clientAddress the requesting IP address * @param isAnonymous if true, an anonymous user will be returned (identity will be ignored) * @return the populated user */ protected static NiFiUser createUser(String identity, Set<String> groups, NiFiUser chain, String clientAddress, boolean isAnonymous) { if (isAnonymous) { return StandardNiFiUser.populateAnonymousUser(chain, clientAddress); } else { return new Builder().identity(identity).groups(groups).chain(chain).clientAddress(clientAddress).build(); } }
/** * This static builder allows the chain and clientAddress to be populated without allowing calling code to provide a non-anonymous identity of the anonymous user. * * @param chain the proxied entities in {@see NiFiUser} form * @param clientAddress the address the request originated from * @return an anonymous user instance with the identity "anonymous" */ public static StandardNiFiUser populateAnonymousUser(NiFiUser chain, String clientAddress) { return new Builder().identity(ANONYMOUS_IDENTITY).chain(chain).clientAddress(clientAddress).anonymous(true).build(); }