DuoShibboleth { public boolean verifyResponseEqualsUsername(String duoResponse) { try { String duoVerifiedResponse = DuoWeb.verifyResponse(ikey, skey, akey, duoResponse); boolean usernameMatches = duoVerifiedResponse.equals(username); if (usernameMatches) { log.info(username + " successfully Duo two-factor authenticated."); return true; } else { log.info(username + " attempted Duo two-factor authentication but username " + duoVerifiedResponse + " was sent in the Duo response."); } } catch (Exception e) { log.error("An exception occurred while " + username + " attempted Duo two-factor authentication.", e); } return false; } private  DuoShibboleth(); private  DuoShibboleth(String ikey, String skey, String akey, String host, String username); static DuoShibboleth instance(String ikey, String skey, String akey, String host, String username); String performPreauth(String failmode); String signRequest(); boolean verifyResponseEqualsUsername(String duoResponse);  }
@Test public void testverifyResponseEqualsUsername_whenResponseBad() { String response = "junkresponse"; assertFalse(duoShibboleth.verifyResponseEqualsUsername(response)); }
@Test public void testverifyResponseEqualsUsername_whenResponseEmpty() { String response = ""; assertFalse(duoShibboleth.verifyResponseEqualsUsername(response)); }