Ok, I got the solution and it's kinda silly, but since I didn't spot it anywhere else inspite of seeing similar questions, I'm going to post the solution.
The ConnectorConfig config = new ConnectorConfig();
is used multiple times; in my case, it is first used to login using new EnterpriseConnection(config)).login(username, password);
and next to obtain a metadata connection using new MetadataConnection(config);
. Since I'm creating 2 ConnectorConfig objects, I would need to use the setProxy method on both, which I...forgot. Hope this solution helps other people having the same problem.
Cheers!