File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
src/main/java/com/yunionyun/mcp/mcclient/keystone Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 44
55 <groupId >com.yunionyun.mcp</groupId >
66 <artifactId >mcclient</artifactId >
7- <version >3.2.19 </version >
7+ <version >3.2.20 </version >
88 <packaging >jar</packaging >
99
1010 <name >${project.groupId} :${project.artifactId} </name >
Original file line number Diff line number Diff line change 1+ package com .yunionyun .mcp .mcclient .keystone ;
2+
3+ import com .alibaba .fastjson .JSONObject ;
4+
5+ public class AuthContext {
6+ private String source ;
7+ private String ip ;
8+
9+ public AuthContext (String source , String ip ) {
10+ this .source = source ;
11+ this .ip = ip ;
12+ }
13+
14+ public AuthContext (JSONObject context ) {
15+ this (context .getString ("source" ), context .getString ("ip" ));
16+ }
17+
18+ public String getSource () {
19+ return source ;
20+ }
21+
22+ public String getIp () {
23+ return ip ;
24+ }
25+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ public class TokenCredential {
1919 private Role [] roles ;
2020 private Service [] services ;
2121 private Date expires ;
22+ private AuthContext context ;
2223
2324 public TokenCredential (String token ) {
2425 this .token = token ;
@@ -52,6 +53,8 @@ public void parseJSON(JSONObject result) {
5253 this .services [i ] = new Service ();
5354 this .services [i ].parseJSON (serviceJSON .getJSONObject (i ));
5455 }
56+ JSONObject context = token .getJSONObject ("context" );
57+ this .context = new AuthContext (context );
5558 }
5659
5760 public String getToken () {
@@ -90,6 +93,10 @@ public String getProjectName() {
9093 return this .project .getName ();
9194 }
9295
96+ public AuthContext getContext () {
97+ return context ;
98+ }
99+
93100 public boolean isValid () {
94101 Date now = new Date ();
95102 return this .expires .after (now );
You can’t perform that action at this time.
0 commit comments