当前位置: 首页 > news >正文

泉州市网站制作企业wordpress中英双语选择

泉州市网站制作企业,wordpress中英双语选择,网站开发需要什么,电子政务网站建设出版社用户类 优化用户主要是要解决用户的连接量。已经对用户的访问速度和吞吐量。 预初始化 在前面的带面中提出来了用户的预初始化。这里就不在贴出来了。下面将redis用户库连接池处理贴出来UserJedisPoolManager public class UserJedisPoolManager extends BasicModule{private s… 用户类 优化用户主要是要解决用户的连接量。已经对用户的访问速度和吞吐量。 预初始化 在前面的带面中提出来了用户的预初始化。这里就不在贴出来了。下面将redis用户库连接池处理贴出来UserJedisPoolManager public class UserJedisPoolManager extends BasicModule{private static final Logger log LoggerFactory.getLogger(UserJedisPoolManager.class);private static final String OF_ALL_USER select username, encryptedPassword, name, email, moblie, creationDate, modificationDate from ofuser;private static final String OF_USER_VCARD select username, vcard from ofvcard;private static final String OF_PRESENCE select username, offlinePresence, offlineDate from ofPresence;//private static final String REDIS_USER REDIS_USER;private static final Integer timeout 1000*10;private static final int maxActive 5000 * 10;private static final int maxIdle 50;private static final long maxWait (1000 * 100);private static JedisPool pool;private static XMPPServer loaclserver;private static JedisPoolConfig configs;public UserJedisPoolManager() {super(User redis manager);}private static JedisPoolConfig createConfig() {configs new JedisPoolConfig();configs.setMaxActive(maxActive);configs.setMaxIdle(maxIdle);configs.setMaxWait(maxWait);configs.setTestOnBorrow(false);return configs;}private void createJedisPool() {RedisConfig redisConfig loaclserver.getJedisConfDao().getRedisConfig(REDIS_USER);if (redisConfig ! null) { ,auto: redisConfig.getAuto());System.out.println(redisConfig.getAuto() .equals() );pool new JedisPool(createConfig(), redisConfig.getIp(), Integer.valueOf(redisConfig.getPort().trim()), timeout, redisConfig.getAuto().equals() ? null : redisConfig.getAuto());Jedis jedis pool.getResource();jedis.select(0);if(!jedis.exists(OFUSER:admin)) {DefaultAuthProvider dup new DefaultAuthProvider();try {String password dup.getPassword(admin);password AuthFactory.encryptPassword(password);MapString, String map new HashMapString, String();map.put(NAME, admin);map.put(PASSWORD, password);map.put(CREATIONDATE, 0);map.put(MODIFICATIONDATE, 0);jedis.hmset(OFUSER:admin, map);} catch (UserNotFoundException e) {e.printStackTrace();}finally{pool.returnResource(jedis);} }}}private void poolInit() {createJedisPool();}public Jedis getJedis() {if (pool null){poolInit();}Jedis jedis pool.getResource();jedis.select(0);return jedis;}public void returnRes(Jedis jedis) {pool.returnResource(jedis);}Overridepublic void initialize(XMPPServer server) {super.initialize(server);loaclserver server;poolInit();log.info(UserManager By Redis: start init....);}public CollectionUser getAllUser() {CollectionUser users new ArrayListUser();PreparedStatement pstmt null;Connection con null;ResultSet rs null;try {con (Connection) DbConnectionManager.getConnection();pstmt con.prepareStatement(OF_ALL_USER);rs pstmt.executeQuery();while(rs.next()) {User user new User();user.setUsername(rs.getString(1));user.setPassword(rs.getString(2));user.setName(rs.getString(3));user.setEmail(rs.getString(4));user.setMoblie(rs.getString(5));user.setCreationDate(rs.getString(6));user.setModificationDate(rs.getString(7));users.add(user);}}catch (Exception e) {log.info( e.getMessage());e.printStackTrace();}finally {DbConnectionManager.closeConnection(pstmt, con);}return users;}public CollectionUserVcard getUserVcard() {CollectionUserVcard userVcards new ArrayListUserVcard();PreparedStatement pstmt null;Connection con null;ResultSet rs null;try {con (Connection) DbConnectionManager.getConnection();pstmt con.prepareStatement(OF_USER_VCARD);rs pstmt.executeQuery();while(rs.next()) {UserVcard user new UserVcard();user.setUsername(rs.getString(1));user.setVcard(rs.getString(2));userVcards.add(user);}}catch (Exception e) {log.info( e.getMessage());e.printStackTrace();}finally {DbConnectionManager.closeConnection(pstmt, con);}return userVcards;}public CollectionPresence getPresences() {......} }在上面createJedisPool方法中预置了管理员的账号。这是因为我们需要修改openfire的用户认证dao。也就是说web控制台的管理员。在登陆web页面的时候我们认证也是先走redis验证的。 用户认证 用户认证首先需要重新实现AuthProvider。Openfire当中默认使用的是DefaultAuthProvider来操作数据层。当然他也提供了其他的方式实现接口比如HybridAuthProvider、JDBCAuthProvider、NativeAuthProvider、POP3AuthProvider等。 写完AuthProvider的Redis实现后接下来需要基于Redis的用户DAO。 下面是两个类的源码清单 RedisAuthProvider public class RedisAuthProvider implements AuthProvider{private static final Logger log LoggerFactory.getLogger(RedisAuthProvider.class);private static HmThreadPool threadPool new HmThreadPool(3);......Overridepublic void authenticate(String username, String password)throws UnauthorizedException, ConnectionException,InternalUnauthenticatedException {......}Overridepublic void authenticate(String username, String token, String digest)throws UnauthorizedException, ConnectionException,InternalUnauthenticatedException {......}Overridepublic String getPassword(String username) throws UserNotFoundException,UnsupportedOperationException {Jedis jedis XMPPServer.getInstance().getUserJedis().getJedis();try {String pw jedis.hmget(OFUSER: username, PASSWORD).get(0);if (pw null) {String userid jedis.get(MOBILE: username);pw jedis.hmget(OFUSER: userid, PASSWORD).get(0);}return AuthFactory.decryptPassword(pw);} finally {XMPPServer.getInstance().getUserJedis().returnRes(jedis);}}Overridepublic void setPassword(String username, String password)throws UserNotFoundException, UnsupportedOperationException {Jedis jedis XMPPServer.getInstance().getUserJedis().getJedis();try {password AuthFactory.encryptPassword(password);jedis.hset(OFUSER: username, PASSWORD, password);} finally {XMPPServer.getInstance().getUserJedis().returnRes(jedis);}threadPool.execute(createTask(XMPPServer.getInstance().getJedisConfDao().getAuthProvider(), username, password));}Overridepublic boolean supportsPasswordRetrieval() {// TODO Auto-generated method stubreturn true;}private static final String UPDATE_PASSWORD UPDATE ofUser SET encryptedPassword? WHERE username?;private Runnable createTask(final AuthProvider edp, final String username, final String password) { return new Runnable() { public void run() {try {//edp.setPassword(username, password);Connection con null;PreparedStatement pstmt null;try {con DbConnectionManager.getConnection();pstmt con.prepareStatement(UPDATE_PASSWORD);if (password null) {pstmt.setNull(1, Types.VARCHAR);}else {pstmt.setString(1, password);}pstmt.setString(2, username);pstmt.executeUpdate();}catch (SQLException sqle) {throw new UserNotFoundException(sqle);}finally {DbConnectionManager.closeConnection(pstmt, con);}} catch (UserNotFoundException e) {log.info(UserNotFoundException: username);}} }; } }用户认证写完后要记得修改系统属性表ofProperty provider.auth.className org.jivesoftware.util.redis.expand.RedisAuthProvider RedisUserProvider public class RedisUserProvider implements UserProvider{ ......public User loadUser(String username) throws UserNotFoundException {if(username.contains()) {if (!XMPPServer.getInstance().isLocal(new JID(username))) {throw new UserNotFoundException(Cannot load user of remote server: username);}username username.substring(0,username.lastIndexOf());}Jedis jedis XMPPServer.getInstance().getUserJedis().getJedis();try {MapString, String map jedis.hgetAll(OFUSER: username);String usernames username;if (map.isEmpty()) {String userid jedis.get(OFUSER: username);map jedis.hgetAll(OFUSER: userid);if (map.isEmpty()) {return XMPPServer.getInstance().getJedisConfDao().getUserProvider().loadUser(username);}usernames userid;}String name map.get(NAME);String email map.get(EMAIL);String mobile map.get(MOBILE);String creationDate map.get(CREATIONDATE);String modificationDate map.get(MODIFICATIONDATE);User user new User(usernames, name, email, mobile, new Date(Long.parseLong(creationDate.equals(0)||creationDate.equals() ? StringUtils.dateToMillis(new Date()) : creationDate)), new Date(Long.parseLong(modificationDate.equals(0)||modificationDate.equals() ? StringUtils.dateToMillis(new Date()) : modificationDate)));return user;} finally {XMPPServer.getInstance().getUserJedis().returnRes(jedis);}}public User createUser(String username, String password, String name, String email)throws UserAlreadyExistsException{return createUser(username, password, name, email, null);}public User createUser(String username, String password, String name, String email, String moblie)throws UserAlreadyExistsException{try {loadUser(username);// The user already exists since no exception, so:throw new UserAlreadyExistsException(Username username already exists);}catch (UserNotFoundException unfe) {Jedis jedis XMPPServer.getInstance().getUserJedis().getJedis();MapString, String hash new HashMapString, String();password AuthFactory.encryptPassword(password);hash.put(PASSWORD, password);if (name ! null !.equals(name))hash.put(NAME, name);if (email ! null !.equals(email)) hash.put(EMAIL, email);if (moblie ! null !.equals(moblie)) hash.put(MOBILE, moblie);Date now new Date();hash.put(CREATIONDATE, StringUtils.dateToMillis(now));hash.put(MODIFICATIONDATE, StringUtils.dateToMillis(now));try {jedis.hmset(OFUSER: username, hash);} finally {XMPPServer.getInstance().getUserJedis().returnRes(jedis);}threadPool.execute(createTaskAddUser(username, null, password, name, email, moblie));return new User(username, name, email, moblie, now, now);}}private Runnable createTaskAddUser(final String username, final String password, final String encryptedPassword, final String name, final String email, final String moblie) {return new Runnable() {public void run () {.....}};}public void deleteUser(String username) {......}public int getUserCount() {int count 0;Connection con null;PreparedStatement pstmt null;ResultSet rs null;try {con DbConnectionManager.getConnection();pstmt con.prepareStatement(USER_COUNT);rs pstmt.executeQuery();if (rs.next()) {count rs.getInt(1);}}catch (SQLException e) {Log.error(e.getMessage(), e);}finally {DbConnectionManager.closeConnection(rs, pstmt, con);}return count;}public CollectionUser getUsers() {CollectionString usernames getUsernames(0, Integer.MAX_VALUE);return new UserCollection(usernames.toArray(new String[usernames.size()]));}public CollectionString getUsernames() {return getUsernames(0, Integer.MAX_VALUE);}private CollectionString getUsernames(int startIndex, int numResults) {......}public CollectionUser getUsers(int startIndex, int numResults) {CollectionString usernames getUsernames(startIndex, numResults);return new UserCollection(usernames.toArray(new String[usernames.size()]));}public void setName(String username, String name) throws UserNotFoundException {......}public void setEmail(String username, String email) throws UserNotFoundException {......}public void setCreationDate(String username, Date creationDate) throws UserNotFoundException {......}public void setModificationDate(String username, Date modificationDate) throws UserNotFoundException {......}public SetString getSearchFields() throws UnsupportedOperationException {return new LinkedHashSetString(Arrays.asList(Username, Name, Email));}public CollectionUser findUsers(SetString fields, String query) throws UnsupportedOperationException {return findUsers(fields, query, 0, 100);}public CollectionUser findUsers(SetString fields, String query, int startIndex,int numResults) throws UnsupportedOperationException{......}/*** Make sure that Log.isDebugEnabled()true before calling this method.* Twenty elements will be logged in every log line, so for 81-100 elements* five log lines will be generated* param listElements a list of Strings which will be logged */private void LogResults(ListString listElements) {......}Overridepublic void setMoblie(String username, String moblie)throws UserNotFoundException {......} }注意这里有个moblie字段。在原来openfire用户认证表里面是没有这个字段的。这里是本人新加的字段。方便手机登陆。看各自的页面场景啦。 转载于:https://www.cnblogs.com/huwf/p/4273347.html
http://www.sadfv.cn/news/226636/

相关文章:

  • 国家官方网站做dj网站
  • 如何挑选网站主机珠海高端网站制作公司
  • 怎么建设百度网站企业建设网站的需求分析
  • 铜仁网站建设哪家专业自己做电影网站违法
  • 网站制作国际连锁做网站常州
  • 创建一个网站的步骤是公司网站建设服务费入什么科目
  • 做网站跳转怎么收费wordpress 绿色主题
  • 网站怎做简述什么是网站
  • 扶风网站建设传媒网站建设方案
  • 怎么知道网站关键词的搜索来源天津公共资源交易平台官网
  • 网站建设需要营业执照吗网站项目报价单模板免费下载
  • 银川网站建设报价长沙营销型网站
  • 做网站的如何开发业务母婴网站建设方案
  • 网站建设公司十大电子商务经营范围有哪些?
  • 聊城专业网站设计公司代运营公司怎么收费
  • 湖北建站电子商务网站建设工具
  • 建设银行春招网站成都广告公司排名
  • 做农业种子的网站中国十大龙头企业排名
  • 网站备案 域名过期摄影师网站制作
  • 网站建设公司应该怎么转型俄罗斯的最新军事新闻
  • 工作表格excel下载国内seo公司哪家最好
  • asp.net网站开发教程下载网站开发能进无形资产吗
  • 和一起做网店差不多的网站.net简单网站开发视频教程
  • 南京网站推广企业网站的规划与设计
  • 网站建设方案及报微信注册小程序收费吗
  • 网站平台建设公司中信建设有限责任公司客户
  • 华威桥网站建设在一家传媒公司做网站编辑 如何
  • 北京欢迎你网站建设网站制作 青岛
  • win7 iis发布网站教程宁德网页设计
  • 做网站用花生壳哪个版本自己的电脑可以做网站服务器