private static boolean isUserTokenPolicyCompatible(UserTokenPolicy policy, String username) {
        if ((policy.getTokenType() == UserTokenType.userTokenTypeAnonymous) && username == null) {
            return true;
        }
        return policy.getTokenType() == UserTokenType.userTokenTypeUserName && username != null;
    }
Confirms that given policy matches the connection string used by client.

@param policy - UserTokenPolicy configured for server endpoint.
@return True if given token policy matches client configuration.
plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java