Factored out credential retrieval to its own class in javalib

Closes #8