我的应用,第三方应用链接生成

beetlsql3-dev
Mlxa0324 2 years ago
parent a659a2d9eb
commit e83eb4ef2d

@ -1,5 +1,6 @@
package com.ibeetl.jlw.entity;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -97,4 +98,21 @@ public class LoginTodo implements Serializable {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(this);
}
/**
* : <br>
* JSON
*
* @return {@link LoginTodo}
* @Author: lx
* @Date: 2022/12/11 17:33
*/
@SneakyThrows
public static LoginTodo jsonToEntity(String json) {
if (ObjectUtil.isNotEmpty(json)) {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(json, LoginTodo.class);
}
return null;
}
}

@ -35,6 +35,8 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static com.ibeetl.jlw.entity.LoginTodo.jsonToEntity;
/**
* ResourcesApplication Service
*/
@ -211,6 +213,7 @@ public class ResourcesApplicationService extends CoreBaseService<ResourcesApplic
CollectionUtil.emptyIfNull(list).forEach(item -> {
String applicationLink = item.getApplicationLink();
applicationLink = makeHaveKeyStr(applicationLink);
// 根据应用设置的Key生成单点登录的真实链接
String realUrl = applicationLink.concat(getKeyByCurrentUser(item.getLinkSecretKey()));
item.set("realUrl", realUrl);
});
@ -244,11 +247,16 @@ public class ResourcesApplicationService extends CoreBaseService<ResourcesApplic
* @Author: lx
* @Date: 2022/12/11 17:06
*/
public void decodeApplicationUrl(String linkSecretKey, String url) {
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(linkSecretKey)).build();
DecodedJWT jwt = verifier.verify(url);
System.out.println(jwt.getAudience().get(0));
public LoginTodo decodeApplicationUrl(String linkSecretKey, String url) {
try {
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(linkSecretKey)).build();
DecodedJWT jwt = verifier.verify(url);
String json = jwt.getAudience().get(0);
return jsonToEntity(json);
}catch(Exception e) {
System.err.println(e.getMessage());
}
return null;
}
/**

Loading…
Cancel
Save