mitreid-connect
公開メンバ関数 | 公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler クラス
org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler の継承関係図
Inheritance graph
org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler 連携図
Collaboration graph

公開メンバ関数

Map< String, Object > assembleFrom (OAuth2AccessTokenEntity accessToken, UserInfo userInfo, Set< String > authScopes)
 
Map< String, Object > assembleFrom (OAuth2RefreshTokenEntity refreshToken, UserInfo userInfo, Set< String > authScopes)
 

公開変数類

String TOKEN_TYPE = "token_type"
 
String CLIENT_ID = "client_id"
 
String USER_ID = "user_id"
 
String SUB = "sub"
 
String EXP = "exp"
 
String EXPIRES_AT = "expires_at"
 
String SCOPE_SEPARATOR = " "
 
String SCOPE = "scope"
 
String ACTIVE = "active"
 
DateFormatter dateFormat = new DateFormatter(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
 

静的非公開変数類

static final Logger logger = LoggerFactory.getLogger(DefaultIntrospectionResultAssembler.class)
 

詳解

Default implementation of the IntrospectionResultAssembler interface.

関数詳解

◆ assembleFrom() [1/2]

Map<String, Object> org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler.assembleFrom ( OAuth2AccessTokenEntity  accessToken,
UserInfo  userInfo,
Set< String >  authScopes 
)
inline

org.mitre.oauth2.service.IntrospectionResultAssemblerを実装しています。

49  {
50 
51  Map<String, Object> result = newLinkedHashMap();
52  OAuth2Authentication authentication = accessToken.getAuthenticationHolder().getAuthentication();
53 
54  result.put(ACTIVE, true);
55 
56  if (accessToken.getPermissions() != null && !accessToken.getPermissions().isEmpty()) {
57 
58  Set<Object> permissions = Sets.newHashSet();
59 
60  for (Permission perm : accessToken.getPermissions()) {
61  Map<String, Object> o = newLinkedHashMap();
62  o.put("resource_set_id", perm.getResourceSet().getId().toString());
63  Set<String> scopes = Sets.newHashSet(perm.getScopes());
64  o.put("scopes", scopes);
65  permissions.add(o);
66  }
67 
68  result.put("permissions", permissions);
69 
70  } else {
71  Set<String> scopes = Sets.intersection(authScopes, accessToken.getScope());
72 
73  result.put(SCOPE, Joiner.on(SCOPE_SEPARATOR).join(scopes));
74 
75  }
76 
77  if (accessToken.getExpiration() != null) {
78  try {
79  result.put(EXPIRES_AT, dateFormat.valueToString(accessToken.getExpiration()));
80  result.put(EXP, accessToken.getExpiration().getTime() / 1000L);
81  } catch (ParseException e) {
82  logger.error("Parse exception in token introspection", e);
83  }
84  }
85 
86  if (userInfo != null) {
87  // if we have a UserInfo, use that for the subject
88  result.put(SUB, userInfo.getSub());
89  } else {
90  // otherwise, use the authentication's username
91  result.put(SUB, authentication.getName());
92  }
93 
94  if(authentication.getUserAuthentication() != null) {
95  result.put(USER_ID, authentication.getUserAuthentication().getName());
96  }
97 
98  result.put(CLIENT_ID, authentication.getOAuth2Request().getClientId());
99 
100  result.put(TOKEN_TYPE, accessToken.getTokenType());
101 
102  return result;
103  }
String SCOPE
Definition: IntrospectionResultAssembler.java:40
String SUB
Definition: IntrospectionResultAssembler.java:36
String CLIENT_ID
Definition: IntrospectionResultAssembler.java:34
String TOKEN_TYPE
Definition: IntrospectionResultAssembler.java:33
static final Logger logger
Definition: DefaultIntrospectionResultAssembler.java:46
String EXP
Definition: IntrospectionResultAssembler.java:37
String ACTIVE
Definition: IntrospectionResultAssembler.java:41
DateFormatter dateFormat
Definition: IntrospectionResultAssembler.java:42
String USER_ID
Definition: IntrospectionResultAssembler.java:35
String EXPIRES_AT
Definition: IntrospectionResultAssembler.java:38
String SCOPE_SEPARATOR
Definition: IntrospectionResultAssembler.java:39

◆ assembleFrom() [2/2]

Map<String, Object> org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler.assembleFrom ( OAuth2RefreshTokenEntity  refreshToken,
UserInfo  userInfo,
Set< String >  authScopes 
)
inline

org.mitre.oauth2.service.IntrospectionResultAssemblerを実装しています。

106  {
107 
108  Map<String, Object> result = newLinkedHashMap();
109  OAuth2Authentication authentication = refreshToken.getAuthenticationHolder().getAuthentication();
110 
111  result.put(ACTIVE, true);
112 
113  Set<String> scopes = Sets.intersection(authScopes, authentication.getOAuth2Request().getScope());
114 
115  result.put(SCOPE, Joiner.on(SCOPE_SEPARATOR).join(scopes));
116 
117  if (refreshToken.getExpiration() != null) {
118  try {
119  result.put(EXPIRES_AT, dateFormat.valueToString(refreshToken.getExpiration()));
120  result.put(EXP, refreshToken.getExpiration().getTime() / 1000L);
121  } catch (ParseException e) {
122  logger.error("Parse exception in token introspection", e);
123  }
124  }
125 
126 
127  if (userInfo != null) {
128  // if we have a UserInfo, use that for the subject
129  result.put(SUB, userInfo.getSub());
130  } else {
131  // otherwise, use the authentication's username
132  result.put(SUB, authentication.getName());
133  }
134 
135  if(authentication.getUserAuthentication() != null) {
136  result.put(USER_ID, authentication.getUserAuthentication().getName());
137  }
138 
139  result.put(CLIENT_ID, authentication.getOAuth2Request().getClientId());
140 
141  return result;
142  }
String SCOPE
Definition: IntrospectionResultAssembler.java:40
String SUB
Definition: IntrospectionResultAssembler.java:36
String CLIENT_ID
Definition: IntrospectionResultAssembler.java:34
static final Logger logger
Definition: DefaultIntrospectionResultAssembler.java:46
String EXP
Definition: IntrospectionResultAssembler.java:37
String ACTIVE
Definition: IntrospectionResultAssembler.java:41
DateFormatter dateFormat
Definition: IntrospectionResultAssembler.java:42
String USER_ID
Definition: IntrospectionResultAssembler.java:35
String EXPIRES_AT
Definition: IntrospectionResultAssembler.java:38
String SCOPE_SEPARATOR
Definition: IntrospectionResultAssembler.java:39

メンバ詳解

◆ ACTIVE

String org.mitre.oauth2.service.IntrospectionResultAssembler.ACTIVE = "active"
inherited

◆ CLIENT_ID

String org.mitre.oauth2.service.IntrospectionResultAssembler.CLIENT_ID = "client_id"
inherited

◆ dateFormat

DateFormatter org.mitre.oauth2.service.IntrospectionResultAssembler.dateFormat = new DateFormatter(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
inherited

◆ EXP

String org.mitre.oauth2.service.IntrospectionResultAssembler.EXP = "exp"
inherited

◆ EXPIRES_AT

String org.mitre.oauth2.service.IntrospectionResultAssembler.EXPIRES_AT = "expires_at"
inherited

◆ logger

final Logger org.mitre.oauth2.service.impl.DefaultIntrospectionResultAssembler.logger = LoggerFactory.getLogger(DefaultIntrospectionResultAssembler.class)
staticprivate

Logger for this class

◆ SCOPE

String org.mitre.oauth2.service.IntrospectionResultAssembler.SCOPE = "scope"
inherited

◆ SCOPE_SEPARATOR

String org.mitre.oauth2.service.IntrospectionResultAssembler.SCOPE_SEPARATOR = " "
inherited

◆ SUB

String org.mitre.oauth2.service.IntrospectionResultAssembler.SUB = "sub"
inherited

◆ TOKEN_TYPE

String org.mitre.oauth2.service.IntrospectionResultAssembler.TOKEN_TYPE = "token_type"
inherited

◆ USER_ID

String org.mitre.oauth2.service.IntrospectionResultAssembler.USER_ID = "user_id"
inherited

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