public static boolean isUserEnoughIdentified() {
JosmUserIdentityManager identManager = JosmUserIdentityManager.getInstance();
if (identManager.isFullyIdentified()) {
return true;
} else {
CredentialsManager credManager = CredentialsManager.getInstance();
try {
if (JosmPreferencesCredentialAgent.class.equals(credManager.getCredentialsAgentClass())) {
if (OsmApi.isUsingOAuth()) {
return credManager.lookupOAuthAccessToken() != null;
} else {
String username = Main.pref.get("osm-server.username", null);
String password = Main.pref.get("osm-server.password", null);
return username != null && !username.isEmpty() && password != null && !password.isEmpty();
}
} else {
CredentialsAgentResponse credentials = credManager.getCredentials(
RequestorType.SERVER, OsmApi.getOsmApi().getHost(), false);
if (credentials != null) {
String username = credentials.getUsername();
char[] password = credentials.getPassword();
return username != null && !username.isEmpty() && password != null && password.length > 0;