Commit 06a96460 authored by dong's avatar dong

后端单点登录sso地址的修改

parent 66ba8d97
......@@ -10,6 +10,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import com.archser.aserver.interceptor.JwtInterceptor;
import com.archser.aserver.model.Config;
import com.archser.aserver.service.SystemService;
import com.archser.aserver.validator.SettingValidator;
......@@ -89,13 +91,18 @@ public class SettingController extends Controller {
// @Before(UnifiedErrorInterceptor.class)
public void sso() {
String val = null;
String val2 = null;
String listenprot = null;
try {
val = this.getConfig("sso");
val2=this.getConfig("ssotwo");
listenprot=this.getConfig("listenprot");
val="http://127.0.0.1:11028";
} catch (Exception e) {
this.renderJson(Ret.fail("msg", e.getMessage()));
}
this.renderJson(Ret.ok("sso", val));
this.renderJson(Ret.ok("sso", val).set("ssotwo",val2).set("listenprot",listenprot));
}
/**
......@@ -164,6 +171,8 @@ public class SettingController extends Controller {
* @throws Exception
*/
private String getConfig(String name) throws Exception {
String ip= JwtInterceptor.getIpAddr(getRequest());
System.out.println("ip->>>>"+ip);
String val = Db.queryStr(Db.getSql("getConfigByName"), name);
if (val == null) {
throw new Exception("配置项不存在(name='" + name + "')");
......
......@@ -13,6 +13,7 @@ import java.util.*;
import java.util.Map.Entry;
import javax.inject.Inject;
import com.archser.aserver.interceptor.JwtInterceptor;
import com.archser.aserver.model.Fond;
import com.archser.aserver.model.Organ;
import com.archser.aserver.model.User;
......@@ -63,7 +64,15 @@ public class UserController extends Controller {
user.put("organ_name", userFondOrgan.getName());
}
}
this.renderJson(Ret.ok("userInfo", user));
try {
String uiUrl =this.getConfig("uiUrl");
String listenprot =this.getConfig("listenprot");
this.renderJson(Ret.ok("userInfo", user).set("uiUrl",uiUrl).set("listenprot",listenprot));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
......@@ -198,5 +207,22 @@ public class UserController extends Controller {
public String image2Base64(byte[] image) {
return Base64.encodeBase64String(image);
}
/**
* 获取配置项目
*
* @param name
* @return
* @throws Exception
*/
private String getConfig(String name) throws Exception {
String ip= JwtInterceptor.getIpAddr(getRequest());
System.out.println("ip->>>>"+ip);
String val = Db.queryStr(Db.getSql("getConfigByName"), name);
if (val == null) {
throw new Exception("配置项不存在(name='" + name + "')");
}
return val;
}
}
......@@ -61,6 +61,9 @@ public class JwtInterceptor implements Interceptor {
.setSigningKeyResolver(new JwtSigningKeyResolver())
// 解析jwt
.parseClaimsJws(token).getBody();
String ip=getIpAddr(inv.getController().getRequest());
System.out.println("解析验证请求中的ip--->"+ip);
System.out.println("解析验证tooken中的ip--->"+claims.get("ip"));
// 验证IP
if (!filterIpAddress(getIpAddr(inv.getController().getRequest()), claims.get("ip", String.class))) {
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment