Skip to content

Commit 94897f8

Browse files
author
yujiale
committed
feat:新增认证侧鉴权针对树资源方法
1 parent 78b2223 commit 94897f8

10 files changed

+457
-0
lines changed

src/main/java/cn/authing/sdk/java/client/AuthenticationClient.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,6 +1969,35 @@ public GetUserAuthResourceListRespDto getUserAuthorizedResourcesList() {
19691969
return deserialize(response, GetUserAuthResourceListRespDto.class);
19701970
}
19711971

1972+
/**
1973+
* @summary 获取用户在登录应用下被授权资源列表
1974+
* @description 获取用户指定资源权限列表,用户获取在某个应用下所拥有的资源列表
1975+
**/
1976+
public GetUserAuthResourcePermissionListRespDto getUserAuthResourcePermissionList(
1977+
GetUserAuthResourcePermissionListDto reqDto) {
1978+
AuthingRequestConfig config = new AuthingRequestConfig();
1979+
config.setUrl("/api/v3/get-user-auth-resource-permission-list");
1980+
config.setBody(reqDto);
1981+
config.setMethod("POST");
1982+
String response = request(config);
1983+
return deserialize(response, GetUserAuthResourcePermissionListRespDto.class);
1984+
}
1985+
1986+
/**
1987+
* @summary 获取用户在登录应用下被授权资源列表
1988+
* @description 获取用户指定资源权限列表,用户获取在某个应用下所拥有的资源列表
1989+
**/
1990+
public GetUserAuthResourceStructRespDto getUserAuthResourceStruct(
1991+
GetUserAuthResourceStructDto reqDto) {
1992+
AuthingRequestConfig config = new AuthingRequestConfig();
1993+
config.setUrl("/api/v3/get-user-auth-resource-struct");
1994+
config.setBody(reqDto);
1995+
config.setMethod("POST");
1996+
String response = request(config);
1997+
return deserialize(response, GetUserAuthResourceStructRespDto.class);
1998+
}
1999+
2000+
19722001
// ==== AUTO GENERATED AUTHENTICATION METHODS END ====
19732002

19742003
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
6+
public class GetUserAuthResourcePermissionList {
7+
/**
8+
* 权限空间 code
9+
*/
10+
@JsonProperty("namespaceCode")
11+
private String namespaceCode;
12+
/**
13+
* 数据资源权限操作列表
14+
*/
15+
@JsonProperty("actions")
16+
private List<String> actions;
17+
/**
18+
* 资源路径
19+
*/
20+
@JsonProperty("resource")
21+
private String resource;
22+
23+
public String getNamespaceCode() {
24+
return namespaceCode;
25+
}
26+
public void setNamespaceCode(String namespaceCode) {
27+
this.namespaceCode = namespaceCode;
28+
}
29+
30+
public List<String> getActions() {
31+
return actions;
32+
}
33+
public void setActions(List<String> actions) {
34+
this.actions = actions;
35+
}
36+
37+
public String getResource() {
38+
return resource;
39+
}
40+
public void setResource(String resource) {
41+
this.resource = resource;
42+
}
43+
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
6+
public class GetUserAuthResourcePermissionListDataDto {
7+
8+
9+
/**
10+
* 用户权限列表
11+
*/
12+
@JsonProperty("userPermissionList")
13+
private List<GetUserAuthResourcePermissionList> permissionList;
14+
15+
public List<GetUserAuthResourcePermissionList> getUserPermissionList() {
16+
return permissionList;
17+
}
18+
public void setUserPermissionList(List<GetUserAuthResourcePermissionList> userPermissionList) {
19+
this.permissionList = userPermissionList;
20+
}
21+
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
6+
public class GetUserAuthResourcePermissionListDto {
7+
/**
8+
* 树数据资源路径列表,
9+
*/
10+
@JsonProperty("resources")
11+
private List<String> resources;
12+
public List<String> getResources() {
13+
return resources;
14+
}
15+
public void setResources(List<String> resources) {
16+
this.resources = resources;
17+
}
18+
19+
20+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class GetUserAuthResourcePermissionListRespDto {
6+
/**
7+
* 业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。
8+
*/
9+
@JsonProperty("statusCode")
10+
private Integer statusCode;
11+
/**
12+
* 描述信息
13+
*/
14+
@JsonProperty("message")
15+
private String message;
16+
/**
17+
* 细分错误码,可通过此错误码得到具体的错误类型。
18+
*/
19+
@JsonProperty("apiCode")
20+
private Integer apiCode;
21+
/**
22+
* 响应数据
23+
*/
24+
@JsonProperty("data")
25+
private GetUserAuthResourcePermissionListDataDto data;
26+
27+
public Integer getStatusCode() {
28+
return statusCode;
29+
}
30+
public void setStatusCode(Integer statusCode) {
31+
this.statusCode = statusCode;
32+
}
33+
34+
public String getMessage() {
35+
return message;
36+
}
37+
public void setMessage(String message) {
38+
this.message = message;
39+
}
40+
41+
public Integer getApiCode() {
42+
return apiCode;
43+
}
44+
public void setApiCode(Integer apiCode) {
45+
this.apiCode = apiCode;
46+
}
47+
48+
public GetUserAuthResourcePermissionListDataDto getData() {
49+
return data;
50+
}
51+
public void setData(GetUserAuthResourcePermissionListDataDto data) {
52+
this.data = data;
53+
}
54+
55+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import cn.authing.sdk.java.dto.GetUserResourceStructDataDto.ResourceType;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
public class GetUserAuthResourceStructDataDto {
7+
/**
8+
* 权限空间 Code
9+
*/
10+
@JsonProperty("namespaceCode")
11+
private String namespaceCode;
12+
/**
13+
* 数据资源 Code
14+
*/
15+
@JsonProperty("resourceCode")
16+
private String resourceCode;
17+
/**
18+
* 数据资源类型,目前支持树结构(TREE)、字符串(STRING)、数组(ARRAY)三种类型,根据不同的类型返回不同的结构。
19+
* - `STRING`: 字符串类型结果 StrResourceAuthAction
20+
* - `ARRAY`: 数组类型 ArrResourceAuthAction
21+
* - `TREE`: 树类型 TreeResourceAuthAction
22+
*/
23+
@JsonProperty("resourceType")
24+
private GetUserResourceStructDataDto.ResourceType resourceType;
25+
/**
26+
* 字符串资源授权
27+
*/
28+
@JsonProperty("strResourceAuthAction")
29+
private StrResourceAuthAction strResourceAuthAction;
30+
/**
31+
* 数组资源授权
32+
*/
33+
@JsonProperty("arrResourceAuthAction")
34+
private ArrResourceAuthAction arrResourceAuthAction;
35+
/**
36+
* 树资源授权
37+
*/
38+
@JsonProperty("treeResourceAuthAction")
39+
private TreeResourceAuthAction treeResourceAuthAction;
40+
41+
public String getNamespaceCode() {
42+
return namespaceCode;
43+
}
44+
public void setNamespaceCode(String namespaceCode) {
45+
this.namespaceCode = namespaceCode;
46+
}
47+
48+
public String getResourceCode() {
49+
return resourceCode;
50+
}
51+
public void setResourceCode(String resourceCode) {
52+
this.resourceCode = resourceCode;
53+
}
54+
55+
public GetUserResourceStructDataDto.ResourceType getResourceType() {
56+
return resourceType;
57+
}
58+
public void setResourceType(GetUserResourceStructDataDto.ResourceType resourceType) {
59+
this.resourceType = resourceType;
60+
}
61+
62+
public StrResourceAuthAction getStrResourceAuthAction() {
63+
return strResourceAuthAction;
64+
}
65+
public void setStrResourceAuthAction(StrResourceAuthAction strResourceAuthAction) {
66+
this.strResourceAuthAction = strResourceAuthAction;
67+
}
68+
69+
public ArrResourceAuthAction getArrResourceAuthAction() {
70+
return arrResourceAuthAction;
71+
}
72+
public void setArrResourceAuthAction(ArrResourceAuthAction arrResourceAuthAction) {
73+
this.arrResourceAuthAction = arrResourceAuthAction;
74+
}
75+
76+
public TreeResourceAuthAction getTreeResourceAuthAction() {
77+
return treeResourceAuthAction;
78+
}
79+
public void setTreeResourceAuthAction(TreeResourceAuthAction treeResourceAuthAction) {
80+
this.treeResourceAuthAction = treeResourceAuthAction;
81+
}
82+
83+
84+
/**
85+
* 数据资源类型,目前支持树结构(TREE)、字符串(STRING)、数组(ARRAY)三种类型,根据不同的类型返回不同的结构。
86+
* - `STRING`: 字符串类型结果 StrResourceAuthAction
87+
* - `ARRAY`: 数组类型 ArrResourceAuthAction
88+
* - `TREE`: 树类型 TreeResourceAuthAction
89+
*/
90+
public static enum ResourceType {
91+
92+
@JsonProperty("TREE")
93+
TREE("TREE"),
94+
95+
@JsonProperty("STRING")
96+
STRING("STRING"),
97+
98+
@JsonProperty("ARRAY")
99+
ARRAY("ARRAY"),
100+
;
101+
102+
private String value;
103+
104+
ResourceType(String value) {
105+
this.value = value;
106+
}
107+
108+
public String getValue() {
109+
return value;
110+
}
111+
}
112+
113+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class GetUserAuthResourceStructDto {
6+
/**
7+
* 数据资源 Code
8+
*/
9+
@JsonProperty("resource")
10+
private String resource;
11+
12+
public String getResource() {
13+
return resource;
14+
}
15+
public void setResource(String resource) {
16+
this.resource = resource;
17+
}
18+
19+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package cn.authing.sdk.java.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
public class GetUserAuthResourceStructRespDto {
6+
/**
7+
* 业务状态码,可以通过此状态码判断操作是否成功,200 表示成功。
8+
*/
9+
@JsonProperty("statusCode")
10+
private Integer statusCode;
11+
/**
12+
* 描述信息
13+
*/
14+
@JsonProperty("message")
15+
private String message;
16+
/**
17+
* 细分错误码,可通过此错误码得到具体的错误类型。
18+
*/
19+
@JsonProperty("apiCode")
20+
private Integer apiCode;
21+
/**
22+
* 响应数据
23+
*/
24+
@JsonProperty("data")
25+
private GetUserAuthResourceStructDataDto data;
26+
27+
public Integer getStatusCode() {
28+
return statusCode;
29+
}
30+
public void setStatusCode(Integer statusCode) {
31+
this.statusCode = statusCode;
32+
}
33+
34+
public String getMessage() {
35+
return message;
36+
}
37+
public void setMessage(String message) {
38+
this.message = message;
39+
}
40+
41+
public Integer getApiCode() {
42+
return apiCode;
43+
}
44+
public void setApiCode(Integer apiCode) {
45+
this.apiCode = apiCode;
46+
}
47+
48+
public GetUserAuthResourceStructDataDto getData() {
49+
return data;
50+
}
51+
public void setData(GetUserAuthResourceStructDataDto data) {
52+
this.data = data;
53+
}
54+
55+
}

0 commit comments

Comments
 (0)