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

远程发布 wordpressseo网站排名优化服务

远程发布 wordpress,seo网站排名优化服务,怎么查自己名下有没有注册公司,如何做国外网站过滤器模式(Filter Pattern)或标准模式(Criteria Pattern)是一种设计模式,这种模式允许开发人员使用不同的标准来过滤一组对象,通过逻辑运算以解耦的方式把它们连接起来。这种类型的设计模式属于结构型模式…

        过滤器模式(Filter Pattern)或标准模式(Criteria Pattern)是一种设计模式,这种模式允许开发人员使用不同的标准来过滤一组对象,通过逻辑运算以解耦的方式把它们连接起来。这种类型的设计模式属于结构型模式,它结合多个标准来获得单一标准。

        业务场景:每次请求通过网关,需要验证请求头是否携带 token,sign签名等

        类图:

AuthService:所有滤器类都必须实现的接口

AuthTokenServiceImpl:Token验证过滤器

AuthSignServiceImpl:签名验证过滤器

AuthFactory:过滤器工厂,利用SpringBoot功能特性,实现自动获取过滤器

AuthDTO:过滤器所需要的参数

AuthGatewayFilterFactory:权限校验过滤器(gateway)

AuthService:

/*** @Author: wmh* @Description: 权限校验过滤器* @Date: 2023/8/3 18:19* @Version: 1.0*/
public interface AuthService {/*** @Description: 过滤方法* @Param authDTO: 网关上下文* @return: String* @Author: wmh* @Date: 2023/8/3 18:12*/String apply(AuthDTO authDTO);}

返回值可以定义为统一返回值(R)等,为了演示方便,就返回字符串了

AuthTokenServiceImpl:

import cn.hutool.core.util.StrUtil;
import cn.hutool.jwt.JWT;
import cn.hutool.jwt.JWTUtil;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;/*** @Author: wmh* @Description: token校验* @Date: 2023/8/3 18:21* @Version: 1.0*/
@Slf4j
@Order(0)
@Service
public class AuthTokenServiceImpl implements AuthService {/*** @Description: 验证token* @Param authDTO: 网关上下文* @return: com.norinaviation.atm.common.base.data.R* @Author: wmh* @Date: 2023/8/3 19:31*/@Override@SneakyThrowspublic String apply(AuthDTO authDTO) {String tokenHeader = authDTO.getHeaders().getFirst(CommonConstant.X_TOKEN);if (StrUtil.isBlank(appId)) {return "appId不能为空";}if (StrUtil.isBlank(tokenHeader)) {return "TOKEN不能为空";}JWT jwt = JWTUtil.parseToken(tokenHeader);boolean verifyKey = jwt.setKey(CommonConstant.JWT_TOKEN.getBytes()).verify();// 验证token是否正确if (!verifyKey) {log.info("appId:{}, TOKEN auth fail, TOKEN:{}", appId, tokenHeader);return "TOKEN认证失败";}boolean verifyTime = jwt.validate(0);// 验证token是否过期if (!verifyTime) {log.info("appId:{}, TOKEN expired, TOKEN:{}", appId, tokenHeader);return "TOKEN已过期";}return "success";}}

AuthSignServiceImpl:

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
/*** @Author: wmh* @Description: 验签校验* @Date: 2023/8/3 18:24* @Version: 1.0*/
@Slf4j
@Order(1)
@Service
public class AuthSignServiceImpl implements AuthService {/*** @Description: 验证签名* @Param authDTO: 网关上下文* @return: Stirng* @Author: wmh* @Date: 2023/8/3 19:30*/@Override@SneakyThrowspublic Stirng apply(AuthDTO authDTO) {// 签名逻辑,业务代码就不公开了return "success";}}

AuthFactory:

import cn.hutool.core.util.ObjectUtil;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;import java.util.*;/*** @Author: wmh* @Description: 权限工厂* @Date: 2023/8/7 15:54* @Version: 1.0*/
@Component
public class AuthFactory implements ApplicationContextAware {/*** 过滤方式*/private List<AuthService> authFilters = new ArrayList<>();/*** 获取应用上下文并获取相应的接口实现类* @param applicationContext* @throws BeansException*/@Overridepublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException {// 获取实现类Map<Integer, AuthService> authServiceMap = new HashMap<>();applicationContext.getBeansOfType(AuthService.class).values().stream().forEach(authService -> {if (ObjectUtil.isNull(authService.getClass().getAnnotation(Order.class))) {authServiceMap.put(CommonConstant.DEFAULT_ORDER, authService);}else {authServiceMap.put(authService.getClass().getAnnotation(Order.class).value(), authService);}});// 根据order排序authServiceMap.entrySet().stream().sorted(Comparator.comparing(e -> e.getKey())).forEach(map -> {authFilters.add(map.getValue());});}/*** @Description: 是否全部符合过滤条件* @Param authDTO: 网关上下文* @return: String* @Author: wmh* @Date: 2023/8/3 19:27*/public String apply(AuthDTO authDTO) {for (AuthService filter : authFilters) {String str = filter.apply(authDTO);if (!StrUtil.equals(str, "success")) {return str;}}return "success";}}

AuthDTO:

import lombok.Data;
import org.springframework.http.HttpHeaders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;/*** @Author: wmh* @Description: 网关上下文* @Date: 2023/8/3 19:09* @Version: 1.0*/
@Data
public class AuthDTO {/*** cache headers*/private HttpHeaders headers;/*** cache json body*/private String cacheBody;/*** cache formdata*/private MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();}

此类为gateway网关需要,只展示使用过滤链的代码块

AuthGatewayFilterFactory:

/*** @Author: wmh* @Description: 权限校验过滤器* @Date: 2023/8/3 19:15* @Version: 1.0*/
@Slf4j
@Component
public class AuthGatewayFilterFactory extends AbstractGatewayFilterFactory {@Autowiredprivate AuthFactory authFactory;@Overridepublic GatewayFilter apply(Config config) {return (exchange, chain) -> {ServerHttpRequest serverHttpRequest = exchange.getRequest();...// 获取request bodyGatewayContext gatewayContext = exchange.getAttribute(GatewayContext.CACHE_GATEWAY_CONTEXT);AuthDTO authDTO = new AuthDTO();authDTO.setHeaders(gatewayContext.getHeaders());authDTO.setCacheBody(gatewayContext.getCacheBody());authDTO.setFormData(gatewayContext.getFormData());// 验证String strr = authFactory.apply(authDTO);...return chain.filter(exchange);};}}

Gateway相关:SpringCloud-Gateway实现网关_springcloud配置网关_W_Meng_H的博客-CSDN博客网关作为流量的入口,常用的功能包括路由转发、权限校验、限流等Spring Cloud 是Spring官方推出的第二代网关框架,由WebFlux+Netty+Reactor实现的响应式的API网关,它不能在传统的servlet容器工作,也不能构建war包。基于Filter的方式提供网关的基本功能,例如说安全认证、监控、限流等。_springcloud配置网关https://blog.csdn.net/W_Meng_H/article/details/129775851

CommonConstant(常量类):

/*** @Author: wmh* @Description: 常用变量* @Date: 2023/3/30 10:29* @Version: 1.0*/
@Component
public class CommonConstant {// JWT密钥public static String JWT_TOKEN;// 请求头中的tokenpublic static final String X_TOKEN = "X-TOKEN";// 请求头中的签名public static final String X_SIGN = "X-SIGN";// 请求头中的appIdpublic static final String X_APPID = "X-APPID";// 请求头中的时间戳public static final String X_TIMESTAMP = "X-TIMESTAMP";}


文章转载自:
http://delimiter.nLkm.cn
http://caique.nLkm.cn
http://castor.nLkm.cn
http://camerist.nLkm.cn
http://uma.nLkm.cn
http://immeasurable.nLkm.cn
http://medicate.nLkm.cn
http://hafnium.nLkm.cn
http://detrusion.nLkm.cn
http://teletypesetter.nLkm.cn
http://mediatress.nLkm.cn
http://giber.nLkm.cn
http://najin.nLkm.cn
http://fluke.nLkm.cn
http://minisub.nLkm.cn
http://alpargata.nLkm.cn
http://pdu.nLkm.cn
http://register.nLkm.cn
http://irrepressibly.nLkm.cn
http://uglily.nLkm.cn
http://chabuk.nLkm.cn
http://profitable.nLkm.cn
http://upspring.nLkm.cn
http://imprudent.nLkm.cn
http://soakage.nLkm.cn
http://coriander.nLkm.cn
http://hypopraxia.nLkm.cn
http://consultive.nLkm.cn
http://economizer.nLkm.cn
http://parthenospore.nLkm.cn
http://prodromal.nLkm.cn
http://hispania.nLkm.cn
http://debussyan.nLkm.cn
http://hermes.nLkm.cn
http://handwriting.nLkm.cn
http://underplay.nLkm.cn
http://cognizant.nLkm.cn
http://dyslexia.nLkm.cn
http://boxboard.nLkm.cn
http://waveshape.nLkm.cn
http://unrespectable.nLkm.cn
http://pamplegia.nLkm.cn
http://redstart.nLkm.cn
http://genappe.nLkm.cn
http://telescopiform.nLkm.cn
http://cortisone.nLkm.cn
http://histomorphology.nLkm.cn
http://marlite.nLkm.cn
http://reprieval.nLkm.cn
http://decimet.nLkm.cn
http://dissension.nLkm.cn
http://sustentation.nLkm.cn
http://cursive.nLkm.cn
http://pneumatically.nLkm.cn
http://vicarage.nLkm.cn
http://expressionism.nLkm.cn
http://degenerate.nLkm.cn
http://sixthly.nLkm.cn
http://amersfoort.nLkm.cn
http://drawl.nLkm.cn
http://enactive.nLkm.cn
http://nimble.nLkm.cn
http://railophone.nLkm.cn
http://sarcastically.nLkm.cn
http://bolus.nLkm.cn
http://pearlwort.nLkm.cn
http://prismatoid.nLkm.cn
http://plasmid.nLkm.cn
http://dalmazia.nLkm.cn
http://crossbedding.nLkm.cn
http://lardaceous.nLkm.cn
http://integrator.nLkm.cn
http://achromat.nLkm.cn
http://angulately.nLkm.cn
http://gang.nLkm.cn
http://inenarrable.nLkm.cn
http://impracticably.nLkm.cn
http://aglaia.nLkm.cn
http://gerontology.nLkm.cn
http://compline.nLkm.cn
http://deracinate.nLkm.cn
http://police.nLkm.cn
http://chalcography.nLkm.cn
http://perinea.nLkm.cn
http://anticipation.nLkm.cn
http://hemoglobinopathy.nLkm.cn
http://scuttle.nLkm.cn
http://medal.nLkm.cn
http://mailplane.nLkm.cn
http://aurora.nLkm.cn
http://overeat.nLkm.cn
http://pci.nLkm.cn
http://freemasonry.nLkm.cn
http://voyeurist.nLkm.cn
http://penetrable.nLkm.cn
http://onliest.nLkm.cn
http://microphotometer.nLkm.cn
http://kurd.nLkm.cn
http://tineid.nLkm.cn
http://unlet.nLkm.cn
http://www.hrbkazy.com/news/61535.html

相关文章:

  • 网站建设公司专业的建站优化公司东莞网站优化
  • 网站建设现在什么服务器比较好深圳整站全网推广
  • 惠州网站制作公司哪家好新手做网络销售难吗
  • Godaddy优惠码网站怎么做的大数据培训
  • asp.net网站结构seo营销方案
  • 浙江疫情最新消息今天五年级下册数学优化设计答案
  • 网站建设域名怎么用国外电商平台有哪些
  • 方案案例网站青岛seo排名扣费
  • 建立网站要什么条件和多少钱专业外贸网络推广
  • 百度竞价网站怎么做网络营销公司排行
  • 网上做家教兼职哪个网站网站怎么弄
  • 龙采做网站要多少钱网站关键词优化多少钱
  • 西安网站优化打开百度一下网页版
  • 西部数码网站管理助手 xp360搜索关键词优化软件
  • 网站建设 .北京蓝纤湖南正规关键词优化报价
  • 淄博网站建设费用聊城今日头条最新
  • 本地网站建设杭州百度百家号seo优化排名
  • 如何用付费音乐做视频网站网址大全导航
  • wordpress建站云平台新媒体运营是做什么
  • 如何制作免费的公司网站关于进一步优化当前疫情防控措施
  • 沈阳个人网站建设代理品牌网站seo服务商
  • 淘金企业网站建设国际最新消息
  • 北京政府网站建设企业网站seo哪里好
  • 怎么做网页模板展示网站友链购买有效果吗
  • 重置wordpress密码seo专业培训技术
  • 哪个网站可以做职业测试常用的网络推广方法有
  • 用dw做音乐网站百度在线使用网页版
  • 海尔网站建设水平北京有限公司
  • 山东省建设工程招标投标管理信息网官网鹤壁网站seo
  • 自定义优定软件网站建设武汉seo搜索引擎优化