@Override public void updateUsername(String externalId, String username) { InternalAuthDAO internalAuthDAO = DAOFactory.getInstance().getInternalAuthDAO(); InternalAuth internalAuth = internalAuthDAO.findById(NumberUtils.createLong(externalId)); internalAuthDAO.updateUsername(internalAuth, username); }
/** * Returns the username of a user corresponding to the given identifier, or <code>null</code> if * not found. * * @param externalId The user identifier * @return The username of the user corresponding to the given identifier, or <code>null</code> if * not found */ public String getUsername(String externalId) { InternalAuthDAO internalAuthDAO = DAOFactory.getInstance().getInternalAuthDAO(); Long internalAuthId = NumberUtils.createLong(externalId); if (internalAuthId != null && internalAuthId > 0) { InternalAuth internalAuth = internalAuthDAO.findById(internalAuthId); return internalAuth == null ? null : internalAuth.getUsername(); } return null; }
@Override public void updatePassword(String externalId, String password) { InternalAuthDAO internalAuthDAO = DAOFactory.getInstance().getInternalAuthDAO(); try { InternalAuth internalAuth = internalAuthDAO.findById(NumberUtils.createLong(externalId)); String newPasswordEncoded = EncodingUtils.md5EncodeString(password); internalAuthDAO.updatePassword(internalAuth, newPasswordEncoded); } catch (UnsupportedEncodingException e) { throw new SmvcRuntimeException(e); } catch (NoSuchAlgorithmException e) { throw new SmvcRuntimeException(e); } }