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

北京餐饮网络营销公司浙江网站建设抖音seo优化

北京餐饮网络营销公司,浙江网站建设抖音seo优化,西安做酒店用品的网站,手机界面设计Spring Security可以为您做很多事情。 帐户被封锁#xff0c;密码盐。 但是蛮力阻断剂呢#xff1f; 那是你必须自己做的。 幸运的是#xff0c;Spring是一个非常灵活的框架#xff0c;因此对其进行配置并不是什么大问题。 让我向您展示一些如何针对Grails应用程序执行… Spring Security可以为您做很多事情。 帐户被封锁密码盐。 但是蛮力阻断剂呢 那是你必须自己做的。 幸运的是Spring是一个非常灵活的框架因此对其进行配置并不是什么大问题。 让我向您展示一些如何针对Grails应用程序执行此操作的指南。 首先您必须在config.groovy中启用springSecurityEventListener grails.plugins.springsecurity.useSecurityEventListener true 然后实现监听器 在/ src / bruteforce中创建类 /** Registers all failed attempts to login. Main purpose to count attempts for particular account ant block user*/ class AuthenticationFailureListener implements ApplicationListener {LoginAttemptCacheService loginAttemptCacheServiceOverridevoid onApplicationEvent(AuthenticationFailureBadCredentialsEvent e) {loginAttemptCacheService.failLogin(e.authentication.name)} } 接下来我们必须创建用于成功登录的侦听器 在同一包装中 /**Listener for successfull logins. Used for reseting number on unsuccessfull logins for specific account */ class AuthenticationSuccessEventListener implements ApplicationListener{LoginAttemptCacheService loginAttemptCacheServiceOverridevoid onApplicationEvent(AuthenticationSuccessEvent e) {loginAttemptCacheService.loginSuccess(e.authentication.name)} } 我们没有将它们放在grails-app文件夹中因此我们需要将这些类作为spring bean重新命名。 在grails-app / conf / spring / resources.groovy中添加下一行 beans {authenticationFailureListener(AuthenticationFailureListener) {loginAttemptCacheService ref(loginAttemptCacheService)}authenticationSuccessEventListener(AuthenticationSuccessEventListener) {loginAttemptCacheService ref(loginAttemptCacheService)} } 您可能会注意到LoginAttemptCacheService loginAttemptCacheService的用法 让我们实现它。 这将是典型的grails服务 package com.picsel.officeanywhereimport com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCacheimport java.util.concurrent.TimeUnit import org.apache.commons.lang.math.NumberUtils import javax.annotation.PostConstructclass LoginAttemptCacheService {private LoadingCacheattempts;private int allowedNumberOfAttemptsdef grailsApplicationPostConstructvoid init() {allowedNumberOfAttempts grailsApplication.config.brutforce.loginAttempts.allowedNumberOfAttemptsint time grailsApplication.config.brutforce.loginAttempts.timelog.info account block configured for $time minutesattempts CacheBuilder.newBuilder().expireAfterWrite(time, TimeUnit.MINUTES).build({0} as CacheLoader);}/*** Triggers on each unsuccessful login attempt and increases number of attempts in local accumulator* param login - username which is trying to login* return*/def failLogin(String login) {def numberOfAttempts attempts.get(login)log.debug fail login $login previous number for attempts $numberOfAttemptsnumberOfAttemptsif (numberOfAttempts allowedNumberOfAttempts) {blockUser(login)attempts.invalidate(login)} else {attempts.put(login, numberOfAttempts)}}/*** Triggers on each successful login attempt and resets number of attempts in local accumulator* param login - username which is login*/def loginSuccess(String login) {log.debug successfull login for $loginattempts.invalidate(login)}/*** Disable user account so it would not able to login* param login - username that has to be disabled*/private void blockUser(String login) {log.debug blocking user: $logindef user User.findByUsername(login)if (user) {user.accountLocked true;user.save(flush: true)}} } 我们将使用Google番石榴库中的CacheBuilder。 因此将下一行添加到BuildConfig.groovy dependencies {runtime com.google.guava:guava:11.0.1} 最后一步将服务配置添加到cinfig.groovy brutforce {loginAttempts {time 5allowedNumberOfAttempts 3} 就是这样您准备运行您的应用程序。 对于典型的Java项目几乎一切都是一样的。 相同的侦听器和相同的服务。 有关Spring Security Events的更多信息 有关使用Google番石榴进行缓存的更多信息 Grails用户可以简单地使用此插件https://github.com/grygoriy/bruteforcedefender 祝您编程愉快别忘了分享 参考 Grygoriy Mykhalyuno博客博客中的JCG合作伙伴 Grygoriy Mykhalyuno 使用Spring Security防止暴力攻击 。 翻译自: https://www.javacodegeeks.com/2012/10/spring-security-prevent-brute-force.html
http://www.huolong8.cn/news/62917/

相关文章:

  • 上海企业网站制作方法自己做的网站怎么管理用户
  • 做得好的网站90设计赚钱
  • 腾讯网站安全检测ip地址做网站
  • 宣讲家网站官网加强作风建设快速建站软件排名
  • 优质的广州微网站建设台州中兴建设咨询有限公司网站
  • 网站h1标签用在哪里公司网站平台的作用
  • 珠海网站推广建设食品商购网站
  • 南京网站推广¥做下拉去118cr国外网页游戏网站
  • 一般在百度做网站多少钱超八成搜索网站存在信息泄露问题
  • 高端网站设计公司有上海公司注册一站式企业服务
  • 网站平台怎么推广营销网站售后调查系统
  • 自助建设手机网站做企业网站的尺寸是多少钱
  • 一个网站的建设需要哪些流程图响应式网站404页面怎么做
  • 经典企业网站欣赏溧阳网页设计
  • 网站开发属于无形资产福州小程序开发定制
  • 太原开发网站公司淘宝开店流程步骤图片
  • 海南建设网网站网站搜索页面怎么做
  • 定制网站建设的释义南昌城市旅游网站建设
  • wordpress 企业网站 教程事件营销ppt
  • 重庆网站建设业务招聘莱芜在线广告信息
  • 南通网站建设排名公司哪家好网站建设的广告投入
  • 漳州做网站建设网络运维工资一般多少
  • 建设银行网站怎么看交易记录电影网站设计说明书
  • 外贸网站推广方式cad协同设计平台
  • 章丘做网站单位哪家好进行公司网站建设方案
  • 买房网站排名高校校园网站建设的要求
  • 网站设计与实现毕业设计上海在建工程查询
  • 一个人做网站好累网站忘了怎么办
  • 四模网站叫别人做网站后怎么更改密码
  • 网站合同 下载如何获取网站访客qq