الجواب وبالله التوفيق
The first situation as per your question is that something which is not in a person’s possession (i.e. they do not have the ownership of it), in this case it is impermissible to sell it. It has been mentioned in a hadith of Rasulullah Sallallaho Alyhi Wasallam:
(لا تبع ما لیس عندک (ترمذی شریف، باب ما جاء فی کراھیۃ بیع ما لیس عندہ
Translation: Do not perform (business) transaction on something that you do not possess (even when that thing is available in the open market).
The second situation as per your question will be that of a dallal(i.e. broker). In this situation a middle man performs an agreement with both the seller and the buyer that he will help them sell and buy a product and that he will charge a fees on these transactions. This situation is considered permissible. Inherently even this condition is not correct, however the fuqahah have found a provision for its use due to the conventionality of this action and it being exigency.
(سئل محمد بن سلمۃ عن اجرۃ السمسار و نقال او جوانہ لا با ءس بہ وان کان فی الاصل فاسد الکثرۃ التعامل وکثیر من ھذا غیر جائز فجوزہ لحاجۃ الناس (حاشیہ فتاوی محمودیہ ، ص ۲۸۶، ج۲۵، بحوالہ شامی
واللہ اعلم بالصواب