@Test public void testValidateLoginToken() { boolean isTokenValid = userAccountHelper.validateLoginToken(TEST_USER_NAME, TEST_USER_LOGIN_TOKEN); assertTrue(isTokenValid); boolean isTokenValid1 = userAccountHelper.validateLoginToken(null, TEST_USER_LOGIN_TOKEN); assertFalse(isTokenValid1); boolean isTokenValid2 = userAccountHelper.validateLoginToken(TEST_USER_NAME, null); assertFalse(isTokenValid2); }
public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; }
UserAccountHelper { public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; } }
UserAccountHelper { public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; }  }
UserAccountHelper { public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; }  @Autowired void setLocaleStore(ILocaleStore localeStore); @Autowired void setLocaleManagerFactory(LocaleManagerFactory localeManagerFactory); @Autowired void setLocalAccountDao(ILocalAccountDao accountDao); @Autowired void setPortalPasswordService(IPortalPasswordService passwordService); @Resource(name = "accountEditAttributes") void setAccountEditAttributes(List<Preference> accountEditAttributes); @Autowired void setPortalUrlProvider(IPortalUrlProvider urlProvider); @Autowired void setMessageSource(MessageSource messageSource); @Autowired void setPersonManager(IPersonManager personManager); @Autowired void setGroupListHelper(IGroupListHelper groupListHelper); @Autowired void setPasswordResetNotification(IPasswordResetNotification passwordResetNotification); @Value("${org.apereo.portal.folder.login-layout:welcome}") void setLoginPortletFolderName(String loginPortletFolderName); PersonForm getNewAccountForm(); PersonForm getForm(String username); List<JsonEntityBean> getParentGroups(String target); boolean canEditUser(IPerson currentUser, String target); List<Preference> getEditableUserAttributes(IPerson currentUser); List<GroupedPersonAttribute> groupPersonAttributes(
            final IPersonAttributes user, final HttpServletRequest request); boolean canDeleteUser(IPerson currentUser, String target); void deleteAccount(IPerson currentUser, String target); void updateAccount(IPerson currentUser, PersonForm form); String getRandomToken(); boolean validateLoginToken(String username, String token); void sendLoginToken(HttpServletRequest request, ILocalAccountPerson account); void sendLoginToken(
            HttpServletRequest request,
            ILocalAccountPerson account,
            IPasswordResetNotification notification); void createPassword(PersonForm form, String token); }
UserAccountHelper { public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; }  @Autowired void setLocaleStore(ILocaleStore localeStore); @Autowired void setLocaleManagerFactory(LocaleManagerFactory localeManagerFactory); @Autowired void setLocalAccountDao(ILocalAccountDao accountDao); @Autowired void setPortalPasswordService(IPortalPasswordService passwordService); @Resource(name = "accountEditAttributes") void setAccountEditAttributes(List<Preference> accountEditAttributes); @Autowired void setPortalUrlProvider(IPortalUrlProvider urlProvider); @Autowired void setMessageSource(MessageSource messageSource); @Autowired void setPersonManager(IPersonManager personManager); @Autowired void setGroupListHelper(IGroupListHelper groupListHelper); @Autowired void setPasswordResetNotification(IPasswordResetNotification passwordResetNotification); @Value("${org.apereo.portal.folder.login-layout:welcome}") void setLoginPortletFolderName(String loginPortletFolderName); PersonForm getNewAccountForm(); PersonForm getForm(String username); List<JsonEntityBean> getParentGroups(String target); boolean canEditUser(IPerson currentUser, String target); List<Preference> getEditableUserAttributes(IPerson currentUser); List<GroupedPersonAttribute> groupPersonAttributes(
            final IPersonAttributes user, final HttpServletRequest request); boolean canDeleteUser(IPerson currentUser, String target); void deleteAccount(IPerson currentUser, String target); void updateAccount(IPerson currentUser, PersonForm form); String getRandomToken(); boolean validateLoginToken(String username, String token); void sendLoginToken(HttpServletRequest request, ILocalAccountPerson account); void sendLoginToken(
            HttpServletRequest request,
            ILocalAccountPerson account,
            IPasswordResetNotification notification); void createPassword(PersonForm form, String token);  }