@Test public void verifyUsernamePassword() { UserIdentityDO userIdentity = setUp1(); userIdentityService.createIdentity(userIdentity); boolean valid = userIdentityService.verifyUsernamePassword(userIdentity.getUserId(), "pedro", "123456"); assertTrue(valid); }
@Override public boolean verifyUsernamePassword(Long userId, String username, String password) { QueryWrapper<UserIdentityDO> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UserIdentityDO::getUserId, userId) .eq(UserIdentityDO::getIdentityType, IdentityConsts.USERNAME_PASSWORD_IDENTITY) .eq(UserIdentityDO::getIdentifier, username); UserIdentityDO userIdentity = this.baseMapper.selectOne(wrapper); return EncryptUtil.verify(userIdentity.getCredential(), password); }
UserIdentityServiceImpl extends ServiceImpl<UserIdentityMapper, UserIdentityDO> implements UserIdentityService { @Override public boolean verifyUsernamePassword(Long userId, String username, String password) { QueryWrapper<UserIdentityDO> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UserIdentityDO::getUserId, userId) .eq(UserIdentityDO::getIdentityType, IdentityConsts.USERNAME_PASSWORD_IDENTITY) .eq(UserIdentityDO::getIdentifier, username); UserIdentityDO userIdentity = this.baseMapper.selectOne(wrapper); return EncryptUtil.verify(userIdentity.getCredential(), password); } }
UserIdentityServiceImpl extends ServiceImpl<UserIdentityMapper, UserIdentityDO> implements UserIdentityService { @Override public boolean verifyUsernamePassword(Long userId, String username, String password) { QueryWrapper<UserIdentityDO> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UserIdentityDO::getUserId, userId) .eq(UserIdentityDO::getIdentityType, IdentityConsts.USERNAME_PASSWORD_IDENTITY) .eq(UserIdentityDO::getIdentifier, username); UserIdentityDO userIdentity = this.baseMapper.selectOne(wrapper); return EncryptUtil.verify(userIdentity.getCredential(), password); }  }
UserIdentityServiceImpl extends ServiceImpl<UserIdentityMapper, UserIdentityDO> implements UserIdentityService { @Override public boolean verifyUsernamePassword(Long userId, String username, String password) { QueryWrapper<UserIdentityDO> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UserIdentityDO::getUserId, userId) .eq(UserIdentityDO::getIdentityType, IdentityConsts.USERNAME_PASSWORD_IDENTITY) .eq(UserIdentityDO::getIdentifier, username); UserIdentityDO userIdentity = this.baseMapper.selectOne(wrapper); return EncryptUtil.verify(userIdentity.getCredential(), password); }  @Override UserIdentityDO createIdentity(Long userId, String identityType, String identifier, String credential); @Override UserIdentityDO createIdentity(UserIdentityDO userIdentity); @Override UserIdentityDO createUsernamePasswordIdentity(Long userId, String identifier, String credential); @Override boolean verifyUsernamePassword(Long userId, String username, String password); @Override boolean changePassword(Long userId, String password); @Override boolean changeUsername(Long userId, String username); @Override boolean changeUsernamePassword(Long userId, String username, String password); }
UserIdentityServiceImpl extends ServiceImpl<UserIdentityMapper, UserIdentityDO> implements UserIdentityService { @Override public boolean verifyUsernamePassword(Long userId, String username, String password) { QueryWrapper<UserIdentityDO> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UserIdentityDO::getUserId, userId) .eq(UserIdentityDO::getIdentityType, IdentityConsts.USERNAME_PASSWORD_IDENTITY) .eq(UserIdentityDO::getIdentifier, username); UserIdentityDO userIdentity = this.baseMapper.selectOne(wrapper); return EncryptUtil.verify(userIdentity.getCredential(), password); }  @Override UserIdentityDO createIdentity(Long userId, String identityType, String identifier, String credential); @Override UserIdentityDO createIdentity(UserIdentityDO userIdentity); @Override UserIdentityDO createUsernamePasswordIdentity(Long userId, String identifier, String credential); @Override boolean verifyUsernamePassword(Long userId, String username, String password); @Override boolean changePassword(Long userId, String password); @Override boolean changeUsername(Long userId, String username); @Override boolean changeUsernamePassword(Long userId, String username, String password);  }