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

福州网站设计软件公司办宽带需要多少钱

福州网站设计软件公司,办宽带需要多少钱,wordpress重置后导航没反应,外包公司排名前十springboot实现数据脱敏 怎么说呢#xff0c;写着写着发觉 ”这写的什么玩意“ 。 总的来说就是#xff0c;这篇文章并不能解决数据脱敏问题#xff0c;但以下链接可以。 SpringBoot中利用自定义注解优雅地实现隐私数据脱敏 然后回到本文#xff0c;本来是想基于AOP代理写着写着发觉 ”这写的什么玩意“ 。 总的来说就是这篇文章并不能解决数据脱敏问题但以下链接可以。 SpringBoot中利用自定义注解优雅地实现隐私数据脱敏 然后回到本文本来是想基于AOP代理实现返回数据脱敏的具体流程是 在controller做切面实现返回通知 返回通知中获取返回值对象 利用反射获取返回值字段 标有脱敏注释的字段做脱敏处理 说着好像一套一套的但事实上忽略了一个重要的问题复杂对象很难做反射例如集合ListSetMap或者对象的引用也是对象就算用多重判断深度遍历但是反射带来的耗时以及空间开销都是值得思考的总而言之这是一个很low的方案。 但是我很少用到反射并且感觉既然都写到这了不如记录一下aop和反射结合以后可能会用来实现其他有趣的功能也说不定。那就记录一下吧。 1. 引入依赖 !-- 引入aop支持 --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-aop/artifactId/dependency2. 实现两个注解 一个标注在controller方法上Service也可以 Target(ElementType.METHOD) Retention(RetentionPolicy.RUNTIME) public interface DesensitizeResult {}一个标注在属性上 Target(ElementType.FIELD) Retention(RetentionPolicy.RUNTIME) public interface DesensitizeField {// 字段名称给字段起个名字而已没啥用String name() default 字段名;// 前面正常显示字符长度不脱敏长度int prefixShow() default 1;// 后面正常显示字符长度不脱敏长度int suffixShow() default 0;// 脱敏引用符号String symbol() default *; }3. 编写切面方法类 Aspect Component public class DesensitizeAspect {Pointcut(annotation(com.example.testdemo.annotation.DesensitizeResult))public void getDesensitizeAnno(){}/*** 返回贴面编程对返回结果result做脱敏操作* param joinPoint 切点* param result 目标方法返回结果*/AfterReturning(pointcut getDesensitizeAnno(),returning result)public void afterReturn(JoinPoint joinPoint,Object result){// 获取返回结果类的所有属性数组Class resultClass result.getClass();Field[] declaredFields resultClass.getDeclaredFields();for (Field field : declaredFields){// 循环判断属性中是否存在自定义脱敏注解DesensitizeFieldfor (Annotation annotation : field.getAnnotations()) {Class? extends Annotation aClass annotation.annotationType();if (aClass.equals(DesensitizeField.class)){DesensitizeField desensitizeField (DesensitizeField) annotation;// 对标有DesensitizeField的属性进行脱敏处理field.setAccessible(true); // 先将该属性改为允许值修改try {String originStr (String)field.get(result); // 获取原来的值// 字符串脱敏String desensitizeValue this.desensitizeStr(originStr, desensitizeField.prefixShow(),desensitizeField.suffixShow(), desensitizeField.symbol());field.set(result,desensitizeValue); // 将脱敏后的字符串写入} catch (IllegalAccessException e) {throw new RuntimeException(e);}}}}}/*** * param originStr 原字符串* param prefixShow 前置正常字符串长度* param suffixShow 后置正常字符串长度* param symbol 脱敏字符显示标志* return 脱敏后字符串*/private String desensitizeStr(String originStr, int prefixShow, int suffixShow, String symbol){int length originStr.length();// 避免out of indexprefixShow Math.min(prefixShow, length);suffixShow Math.min(suffixShow,length);// 前后显示数据超过数据是指长度处理OutOfRange处理if (prefixShowsuffixShowlength){prefixShowlength;suffixShow0;}String desensitizeValue originStr.substring(0,prefixShow)symbol.repeat(length-prefixShow-suffixShow)originStr.substring(length-suffixShow);return desensitizeValue;}} 如上代码所示只是针对单个简单对象做字段脱敏复杂对象就完了 4. 测试实体类 Data ToString public class UserInfo {private String id;private String account;private String nickname;DesensitizeField(name 真实姓名,prefixShow 1)private String realName;DesensitizeField(name 密码,prefixShow 0)private String password;DesensitizeField(name 手机号,prefixShow 3,suffixShow 1)private String mobile;DesensitizeField(name 身份证号,prefixShow 3)private String identityId;private String createTime;}5. 测试接口 RestController public class TestController {DesensitizeResult // aop切面脱敏数据GetMapping(/userInfo)public UserInfo getUserInfo(){UserInfo userInfo new UserInfo();userInfo.setId(123456);userInfo.setAccount(abcdef);userInfo.setMobile(13579246810);userInfo.setNickname(BigBoss);userInfo.setRealName(张小凡);userInfo.setIdentityId(430121200001011321);userInfo.setPassword(Mm123456#);return userInfo;} }6.测试 至此全文完毕另外盘算着下次把上面链接的方案偷过来再发一篇。
http://www.hkea.cn/news/14568897/

相关文章:

  • 北京 网站备案月付购物网站建站
  • 有经验的永州网站建设wordpress 加速版
  • 个人网站注销原因seo网站优化培训多少价格
  • 网站cms相关知识温州中小企业网站制作
  • 电脑网站转手机版自考都到哪个网站找题做
  • 除了做视频网站还能做什么网站深圳网站建设制作开发公司
  • 网站前台设计模板网上服装定制平台
  • 网站备份怎么做做新闻微网站有哪些方面
  • 邢台做网站备案东营列表网
  • 做网站几天能学会今天国际大事新闻
  • 建个网站大概需要多久seo搜索排名优化
  • app制作教程课seo标题关键词怎么写
  • 学做宝宝衣服网站网站建设流程html
  • 烟台网站建设多少钱足球最新比赛消息
  • 养殖p2p网站建设你好多莉wordpress
  • 创业项目网站建设规划陕西交通建设集团网站贴吧
  • 做淘宝客的网站所需空间义乌专业做网站
  • 网站开发php教程个人用wordpress做网页
  • 商城建站系统源码地宝网 网站建设
  • 做网站需要了解什么东西p2p网站建设时间
  • 广州企业网站设计网站建设项目验收付款
  • 订货网站开发价格邯郸做小程序的网络公司
  • 邯郸移动网站建设公司做网站的是怎么赚钱的
  • 西安工程网站建设网站建设及优化方案
  • 阿克苏网站建设优化在线图片编辑像素
  • 上传下载网站模板网站建设域名注册
  • 文汇智能建站平台网站建设规划怎么写
  • 淘宝客网站程序模板泰州网站制作套餐
  • php网站开发示例网站自定义功能实现
  • 厦门网络公司网站网站模板内容怎么改