mitreid-connect
公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.mitre.openid.connect.web.UserInfoInterceptor クラス
org.mitre.openid.connect.web.UserInfoInterceptor の継承関係図
Inheritance graph
org.mitre.openid.connect.web.UserInfoInterceptor 連携図
Collaboration graph

公開メンバ関数

boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
 

非公開変数類

Gson gson
 
UserInfoService userInfoService
 
AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl()
 

詳解

Injects the UserInfo object for the current user into the current model's context, if both exist. Allows JSPs and the like to call "userInfo.name" and other fields.

著者
jricher

関数詳解

◆ preHandle()

boolean org.mitre.openid.connect.web.UserInfoInterceptor.preHandle ( HttpServletRequest  request,
HttpServletResponse  response,
Object  handler 
) throws Exception
inline
69  {
70 
71  Authentication auth = SecurityContextHolder.getContext().getAuthentication();
72 
73  if (auth instanceof Authentication){
74  request.setAttribute("userAuthorities", gson.toJson(auth.getAuthorities()));
75  }
76 
77  if (!trustResolver.isAnonymous(auth)) { // skip lookup on anonymous logins
78  if (auth instanceof OIDCAuthenticationToken) {
79  // if they're logging into this server from a remote OIDC server, pass through their user info
80  OIDCAuthenticationToken oidc = (OIDCAuthenticationToken) auth;
81  if (oidc.getUserInfo() != null) {
82  request.setAttribute("userInfo", oidc.getUserInfo());
83  request.setAttribute("userInfoJson", oidc.getUserInfo().toJson());
84  } else {
85  request.setAttribute("userInfo", null);
86  request.setAttribute("userInfoJson", "null");
87  }
88  } else {
89  // don't bother checking if we don't have a principal or a userInfoService to work with
90  if (auth != null && auth.getName() != null && userInfoService != null) {
91 
92  // try to look up a user based on the principal's name
93  UserInfo user = userInfoService.getByUsername(auth.getName());
94 
95  // if we have one, inject it so views can use it
96  if (user != null) {
97  request.setAttribute("userInfo", user);
98  request.setAttribute("userInfoJson", user.toJson());
99  }
100  }
101  }
102  }
103 
104  return true;
105  }
UserInfoService userInfoService
Definition: UserInfoInterceptor.java:64
Gson gson
Definition: UserInfoInterceptor.java:54
AuthenticationTrustResolver trustResolver
Definition: UserInfoInterceptor.java:66

メンバ詳解

◆ gson

Gson org.mitre.openid.connect.web.UserInfoInterceptor.gson
private
初期値:
= new GsonBuilder()
.registerTypeHierarchyAdapter(GrantedAuthority.class, new JsonSerializer<GrantedAuthority>() {
@Override
public JsonElement serialize(GrantedAuthority src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.getAuthority());
}
})
.create()

◆ trustResolver

AuthenticationTrustResolver org.mitre.openid.connect.web.UserInfoInterceptor.trustResolver = new AuthenticationTrustResolverImpl()
private

◆ userInfoService

UserInfoService org.mitre.openid.connect.web.UserInfoInterceptor.userInfoService
private

このクラス詳解は次のファイルから抽出されました: