The Cumulocity IoT API does support fetching all users:
https://cumulocity.com/api/core/10.16.0/#operation/getUserCollectionResource
But the Java SDK does not implement that functionality. You would have to do the REST call yourself. Here is some discussion about how to best do that:
Can only comment on your first question…
Where is the best way to get the different parts of the url?
The platform URL should be available as environment variable C8Y_BASEURL.
See here : “[…]The Cumulocity IoT exposes the REST endpoint /user/currentUser. The microservice retrieves the Cumulocity IoT address from the C8Y_BASEURL operating system environment variable.”