DataService.java 999 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package com.doc.common.data;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.springframework.context.ApplicationContext;
  4. import org.springframework.context.ConfigurableApplicationContext;
  5. import org.springframework.data.DataVerify;
  6. import org.springframework.scheduling.annotation.Scheduled;
  7. import org.springframework.stereotype.Component;
  8. import javax.annotation.Resource;
  9. /**
  10. * 授权许可验证监听器
  11. *
  12. * @author wukai
  13. * @date 2023-12-29
  14. */
  15. @Component
  16. @Slf4j
  17. public class DataService {
  18. @Resource
  19. private ApplicationContext context;
  20. @Scheduled(cron = "15 28 3 ? * 7")
  21. public void check() {
  22. try {
  23. DataVerify dataVerify = new DataVerify();
  24. //校验证书是否有效
  25. if (!dataVerify.verify()) {
  26. throw new Exception();
  27. }
  28. } catch (Exception e) {
  29. ((ConfigurableApplicationContext) context).close();
  30. throw new RuntimeException("证书校验失败!!!");
  31. }
  32. }
  33. }