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

网站的目的lnmp wordpress 安装

网站的目的,lnmp wordpress 安装,南昌商城建设,订阅号如何申请spring启动执行Spring Boot Actuator提供了审核功能#xff0c;用于在启用了Spring Security的Spring Boot应用程序中发布和侦听与安全相关的事件。 默认事件是身份验证成功#xff0c;身份验证失败和访问被拒绝#xff0c;但是可以使用自定义事件进行扩展。 确保在项目中启… spring启动执行 Spring Boot Actuator提供了审核功能用于在启用了Spring Security的Spring Boot应用程序中发布和侦听与安全相关的事件。 默认事件是身份验证成功身份验证失败和访问被拒绝但是可以使用自定义事件进行扩展。 确保在项目中启用了Spring Boot Security和Actuator dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-security/artifactId /dependency dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId /dependency执行器 默认情况下 /auditevents端点/auditevents启用状态因此在启动应用程序并使用应用程序日志中提供的用户名user和password登录后您可以看到当前的安全事件 {events: [{timestamp: 2017-03-14T22:59:580000,principal: user,type: AUTHENTICATION_FAILURE,data: {details: {remoteAddress: 0:0:0:0:0:0:0:1,sessionId: null},type: org.springframework.security.authentication.BadCredentialsException,message: Bad credentials}},{timestamp: 2017-03-14T23:00:070000,principal: user,type: AUTHENTICATION_SUCCESS,data: {details: {remoteAddress: 0:0:0:0:0:0:0:1,sessionId: null}}}] } /auditevents端点接受请求的可选参数 pricipal -主体名称 after –事件发生后的日期格式如下 yyyy-MM-ddTHH:mm:ssZ type –事件类型例如AUTHORIZATION_FAILUREAUTHENTICATION_SUCCESSAUTHENTICATION_FAILUREAUTHENTICATION_SWITCH 请求示例 http// localhost8080 / auditeventstype AUTHORIZATION_FAILUREafter 2017-03-14T233A143A122B0000principal anonymousUser 端点实现使用org.springframework.boot.actuate.audit.AuditEventRepository返回所有已注册的审核事件。 自定义/auditevents端点 您可以使用endpoints.auditevents.*属性来自定义端点。 例如要更改审核事件端点的路径只需使用endpoints.auditevents.path属性。 使用 安全事件由执行器中的org.springframework.boot.actuate.audit.AuditEvent值对象表示。 该对象包含时间戳用户名事件类型和事件数据。 获得有关审核事件的最简单方法是通过Spring的org.springframework.context.event.EventListener订阅org.springframework.boot.actuate.audit.listener.AuditApplicationEvent事件 Component public class AuditApplicationEventListener {private static final Logger LOG LoggerFactory.getLogger(AuditApplicationEventListener.class);EventListenerpublic void onAuditEvent(AuditApplicationEvent event) {AuditEvent actualAuditEvent event.getAuditEvent();LOG.info(On audit application event: timestamp: {}, principal: {}, type: {}, data: {},actualAuditEvent.getTimestamp(),actualAuditEvent.getPrincipal(),actualAuditEvent.getType(),actualAuditEvent.getData());} } 输出示例 2017-03-15 00:44:12.921 INFO 13316 --- [nio-8080-exec-1] p.c.d.s.s.AuditApplicationEventListener : On audit event: timestamp: Wed Mar 15 00:44:12 CET 2017, principal: user, type: AUTHENTICATION_SUCCESS, data: {detailsorg.springframework.security.web.authentication.WebAuthenticationDetailsb364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null}异步事件 EventListener是同步的但是如果需要异步行为则可以使用Async注释事件侦听器方法并确保启用了异步例如通过EnableAsync Component public class AuditApplicationEventListener {private static final Logger LOG LoggerFactory.getLogger(AuditApplicationEventListener.class);EventListenerAsyncpublic void onAuditEvent(AuditApplicationEvent event) {} } 并配置 SpringBootApplication EnableAsync public class Application {public static void main(String[] args) {SpringApplication.run(Application.class);} }使用 另外您可以扩展org.springframework.boot.actuate.audit.listener.AbstractAuditListener并覆盖其org.springframework.boot.actuate.audit.listener.AbstractAuditListener#onAuditEvent方法 Component public class AuditEventListener extends AbstractAuditListener {private static final Logger LOG LoggerFactory.getLogger(AuditEventListener.class);Overrideprotected void onAuditEvent(AuditEvent event) {LOG.info(On audit event: timestamp: {}, principal: {}, type: {}, data: {},event.getTimestamp(),event.getPrincipal(),event.getType(),event.getData());} } 注意事件存储库中不会存储任何事件因此/auditevents端点将始终返回空数组。 要解决此问题您可以注入审核存储库也可以直接从org.springframework.boot.actuate.audit.listener.AuditListener扩展 Component public class AuditEventListener extends AbstractAuditListener {private static final Logger LOG LoggerFactory.getLogger(AuditEventListener.class);Autowiredprivate AuditEventRepository auditEventRepository;Overrideprotected void onAuditEvent(AuditEvent event) {LOG.info(On audit event: timestamp: {}, principal: {}, type: {}, data: {},event.getTimestamp(),event.getPrincipal(),event.getType(),event.getData());auditEventRepository.add(event);} }与事件发布者发布自己的审核事件 在下面的示例中使用了应用程序事件发布者 org.springframework.context.ApplicationEventPublisher 来发布类型为CUSTOM_AUDIT_EVENT的自定义审核事件。 新的侦听器方法仅侦听那些新事件而先前的方法将忽略它们请注意这只是一个示例。 与其他事件一样自定义事件将使用审核事件存储库进行存储。 Component public class AuditApplicationEventListener {private static final Logger LOG LoggerFactory.getLogger(AuditApplicationEventListener.class);Autowiredprivate ApplicationEventPublisher applicationEventPublisher;EventListener(condition #event.auditEvent.type ! CUSTOM_AUDIT_EVENT)Asyncpublic void onAuditEvent(AuditApplicationEvent event) {AuditEvent actualAuditEvent event.getAuditEvent();LOG.info(On audit application event: timestamp: {}, principal: {}, type: {}, data: {},actualAuditEvent.getTimestamp(),actualAuditEvent.getPrincipal(),actualAuditEvent.getType(),actualAuditEvent.getData());applicationEventPublisher.publishEvent(new AuditApplicationEvent(new AuditEvent(actualAuditEvent.getPrincipal(), CUSTOM_AUDIT_EVENT)));}EventListener(condition #event.auditEvent.type CUSTOM_AUDIT_EVENT)public void onCustomAuditEvent(AuditApplicationEvent event) {LOG.info(Handling custom audit event ...);} }注意示例代码 可以在spring-boot-thymeleaf存储库中找到本文的示例代码。 默认情况下两个配置文件均禁用安全性。 通过更改application.properties的security.basic.enabled属性来启用它。 翻译自: https://www.javacodegeeks.com/2017/03/spring-boot-security-events-actuator.htmlspring启动执行
http://www.pierceye.com/news/760682/

相关文章:

  • wps2016怎么做网站企业主题展厅设计公司
  • 网页设计与网站建设实训目的wordpress 别名插件
  • 做婚庆网站的功能定位5分钟建站wordpress
  • 淄博网站制作优化北京高端网页
  • 专业网站设计速寻亿企邦wordpress下载官网
  • 水网站源码网站建设客户合同
  • 网站制作遨游免费企业网站备案查询
  • 保洁公司网站怎么做阿里企业邮箱个人版
  • 网站开发里的输入网站的内容建设
  • 怎么到国外网站去接模具订单做socks5免费代理地址
  • 青海西宁做网站多少钱网页设计与网站规划
  • 铁岭建设网站古典网站案例
  • 织梦html网站地图外国人讲汉语做网站的视频
  • 唯品会购物网站开发项目h5网站建设的具体内容
  • 苏州网站设计电话显示网站建设精美页面
  • 怎么做外汇返佣的网站电商网站 收费与免费
  • 网站建设 计划书繁体网站模板
  • 设计公司做网站有用吗互联网营销的概念
  • 网站中数据库教程网站未续费到期后打开会怎样
  • 企业网站的规划与建设纯静态网站开发
  • 静海集团网站建设网址收录查询
  • 怎样做网站的外链怎么做自己的网站
  • nas 建网站asp.net 做网站源代码
  • 做网站的详细步骤叫别人做网站权重被转移了
  • 做网站好还是网店做网站是怎样赚钱的
  • 国内网站 备案北京模板网站建站
  • 怎么建立网站?婚纱网站策划书模板下载
  • 接单子做网站词类似酷家乐做庭院的网站
  • 道路建设网站专题推广做黄页网站
  • 做展柜平时在哪里网站推广青岛原创工程设计有限公司