log.info("Activated, logins={}", logins);
}
@Override
public Result execute() {
final FormattingResultLog resultLog = new FormattingResultLog();
int checked=0;
int failures=0;
for(String login : logins) {
final String [] parts = login.split(":");
if(parts.length != 2) {
resultLog.warn("Expected login in the form username:password, got [{}]", login);
continue;
}
checked++;
final String username = parts[0].trim();
final String password = parts[1].trim();
final Credentials creds = new SimpleCredentials(username, password.toCharArray());
Session s = null;
try {
s = repository.login(creds);
if(s != null) {
failures++;
resultLog.warn("Login as [{}] succeeded, was expecting it to fail", username);
} else {
resultLog.debug("Login as [{}] didn't throw an Exception but returned null Session", username);
}
} catch(RepositoryException re) {
resultLog.debug("Login as [{}] failed, as expected", username);
} finally {
if(s != null) {
s.logout();
}
}
}
if(checked==0) {
resultLog.warn("Did not check any logins, configured logins={}", logins);
} else if(failures != 0){
resultLog.warn("Checked {} logins, {} failures", checked, failures);
} else {
resultLog.debug("Checked {} logins, all successful", checked, failures);
}
return new Result(resultLog);
}