java.lang.ClassCastException: java.util.HashMap$EntrySet cannot be cast to java.util.Map$Entry
You are trying to cast a set to a single entry.
You can use each entry item by iterating the set:
Iterator it = authentication.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next(); //current entry in a loop
/*
* do something for each entry
*/
}
Well, yes.
You are trying to cast a Set<Map.Entry<String, String>>
as a single Map.Entry<String, String>
.
You need to pick an element in the set, or iterate each entry and process it.
Something in the lines of:
for (Map.Entry<String, String> entry: authentication.entrySet()) {
// TODO logic with single entry
}
Map.Entry<String, String> authInfo =(Entry<String, String>) authentication.entrySet();
Here you are doing a wrong cast. The auth method you mentioned seem to be expecting just the values of username/password pair. So something like below would do:
Map<String, String> authentication = new HashMap<String, String>();
authentication.put("testname", "testpassword");
Map.Entry<String, String> authInfo = authentication.entrySet().iterator().next();
AuthMethod.auth(authInfo)