SSO非侵入式开发示例
#接口拦截功能,开发者可以配置拦截API地址,进行接口前拦截和拦截后操作
#用于实现生态的单点登录,无需侵入,通常用于连接第三方认证方案WeaverBoot IOC
1 考前准备
扫描范围
//com.**.Impl;com.**.impl
//Like below path, the system could scan the program
package com.api.cs.detailImp202004181935.service.impl;
//If the method in jar package, there should a prefix("_") in jar package naem like _xxx.jar
预依赖关系
需要安装最新的电子代码包
2 拦截类配置
拦截类需要用注解进行注解,注解中可以写出名称,容器会根据这个名称注入这个类。默认情况下,它将根据类的路径注入,如以下示例所示@WeaSsoIocComponent
package com.api.cs.test20200529.service.impl;
@WeaSsoIocComponent("demoService") //if no name, then inject with full path
public class TestLogin {
}
3 SSO 方法用法
pre-方法是在执行接口之前将要执行的操作
具体配置方法如下:
package com.api.cs.test20200529.service.impl;
import com.weaverboot.frame.ioc.anno.classAnno.WeaSsoIocComponent;
import com.weaverboot.frame.ioc.anno.methodAnno.WeaSsoIoc;
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaSsoParam;
import com.weaverboot.tools.logTools.LogTools;
@WeaSsoIocComponent("demoService") //if no name, then inject with full path
public class TestLogin {
//parameter weaSsoParam,field as request response paramMap
@WeaSsoIoc(order = 1, description = "SSO login logical")
public void sso1(WeaSsoParam weaSsoParam){
// LogTools.info("sso1");
}
}