mitreid-connect
公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.mitre.oauth2.web.OAuthConfirmationController クラス
org.mitre.oauth2.web.OAuthConfirmationController 連携図
Collaboration graph

公開メンバ関数

 OAuthConfirmationController ()
 
 OAuthConfirmationController (ClientDetailsEntityService clientService)
 
String confimAccess (Map< String, Object > model, @ModelAttribute("authorizationRequest") AuthorizationRequest authRequest, Principal p)
 
ClientDetailsEntityService getClientService ()
 
void setClientService (ClientDetailsEntityService clientService)
 

非公開変数類

ClientDetailsEntityService clientService
 
SystemScopeService scopeService
 
ScopeClaimTranslationService scopeClaimTranslationService
 
UserInfoService userInfoService
 
StatsService statsService
 
RedirectResolver redirectResolver
 

静的非公開変数類

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

詳解

著者
jricher

構築子と解体子

◆ OAuthConfirmationController() [1/2]

org.mitre.oauth2.web.OAuthConfirmationController.OAuthConfirmationController ( )
inline
96  {
97 
98  }

◆ OAuthConfirmationController() [2/2]

org.mitre.oauth2.web.OAuthConfirmationController.OAuthConfirmationController ( ClientDetailsEntityService  clientService)
inline
100  {
102  }
ClientDetailsEntityService clientService
Definition: OAuthConfirmationController.java:74

関数詳解

◆ confimAccess()

String org.mitre.oauth2.web.OAuthConfirmationController.confimAccess ( Map< String, Object >  model,
@ModelAttribute("authorizationRequest") AuthorizationRequest  authRequest,
Principal  p 
)
inline
107  {
108 
109  // Check the "prompt" parameter to see if we need to do special processing
110 
111  String prompt = (String)authRequest.getExtensions().get(PROMPT);
112  List<String> prompts = Splitter.on(PROMPT_SEPARATOR).splitToList(Strings.nullToEmpty(prompt));
113  ClientDetailsEntity client = null;
114 
115  try {
116  client = clientService.loadClientByClientId(authRequest.getClientId());
117  } catch (OAuth2Exception e) {
118  logger.error("confirmAccess: OAuth2Exception was thrown when attempting to load client", e);
119  model.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
120  return HttpCodeView.VIEWNAME;
121  } catch (IllegalArgumentException e) {
122  logger.error("confirmAccess: IllegalArgumentException was thrown when attempting to load client", e);
123  model.put(HttpCodeView.CODE, HttpStatus.BAD_REQUEST);
124  return HttpCodeView.VIEWNAME;
125  }
126 
127  if (client == null) {
128  logger.error("confirmAccess: could not find client " + authRequest.getClientId());
129  model.put(HttpCodeView.CODE, HttpStatus.NOT_FOUND);
130  return HttpCodeView.VIEWNAME;
131  }
132 
133  if (prompts.contains("none")) {
134  // if we've got a redirect URI then we'll send it
135 
136  String url = redirectResolver.resolveRedirect(authRequest.getRedirectUri(), client);
137 
138  try {
139  URIBuilder uriBuilder = new URIBuilder(url);
140 
141  uriBuilder.addParameter("error", "interaction_required");
142  if (!Strings.isNullOrEmpty(authRequest.getState())) {
143  uriBuilder.addParameter("state", authRequest.getState()); // copy the state parameter if one was given
144  }
145 
146  return "redirect:" + uriBuilder.toString();
147 
148  } catch (URISyntaxException e) {
149  logger.error("Can't build redirect URI for prompt=none, sending error instead", e);
150  model.put("code", HttpStatus.FORBIDDEN);
151  return HttpCodeView.VIEWNAME;
152  }
153  }
154 
155  model.put("auth_request", authRequest);
156  model.put("client", client);
157 
158  String redirect_uri = authRequest.getRedirectUri();
159 
160  model.put("redirect_uri", redirect_uri);
161 
162 
163  // pre-process the scopes
164  Set<SystemScope> scopes = scopeService.fromStrings(authRequest.getScope());
165 
166  Set<SystemScope> sortedScopes = new LinkedHashSet<>(scopes.size());
167  Set<SystemScope> systemScopes = scopeService.getAll();
168 
169  // sort scopes for display based on the inherent order of system scopes
170  for (SystemScope s : systemScopes) {
171  if (scopes.contains(s)) {
172  sortedScopes.add(s);
173  }
174  }
175 
176  // add in any scopes that aren't system scopes to the end of the list
177  sortedScopes.addAll(Sets.difference(scopes, systemScopes));
178 
179  model.put("scopes", sortedScopes);
180 
181  // get the userinfo claims for each scope
182  UserInfo user = userInfoService.getByUsername(p.getName());
183  Map<String, Map<String, String>> claimsForScopes = new HashMap<>();
184  if (user != null) {
185  JsonObject userJson = user.toJson();
186 
187  for (SystemScope systemScope : sortedScopes) {
188  Map<String, String> claimValues = new HashMap<>();
189 
190  Set<String> claims = scopeClaimTranslationService.getClaimsForScope(systemScope.getValue());
191  for (String claim : claims) {
192  if (userJson.has(claim) && userJson.get(claim).isJsonPrimitive()) {
193  // TODO: this skips the address claim
194  claimValues.put(claim, userJson.get(claim).getAsString());
195  }
196  }
197 
198  claimsForScopes.put(systemScope.getValue(), claimValues);
199  }
200  }
201 
202  model.put("claims", claimsForScopes);
203 
204  // client stats
205  Integer count = statsService.getCountForClientId(client.getClientId()).getApprovedSiteCount();
206  model.put("count", count);
207 
208 
209  // contacts
210  if (client.getContacts() != null) {
211  String contacts = Joiner.on(", ").join(client.getContacts());
212  model.put("contacts", contacts);
213  }
214 
215  // if the client is over a week old and has more than one registration, don't give such a big warning
216  // instead, tag as "Generally Recognized As Safe" (gras)
217  Date lastWeek = new Date(System.currentTimeMillis() - (60 * 60 * 24 * 7 * 1000));
218  if (count > 1 && client.getCreatedAt() != null && client.getCreatedAt().before(lastWeek)) {
219  model.put("gras", true);
220  } else {
221  model.put("gras", false);
222  }
223 
224  return "approve";
225  }
ClientDetailsEntityService clientService
Definition: OAuthConfirmationController.java:74
SystemScopeService scopeService
Definition: OAuthConfirmationController.java:77
Set< SystemScope > fromStrings(Set< String > scope)
ScopeClaimTranslationService scopeClaimTranslationService
Definition: OAuthConfirmationController.java:80
static final Logger logger
Definition: OAuthConfirmationController.java:94
RedirectResolver redirectResolver
Definition: OAuthConfirmationController.java:89
ClientStat getCountForClientId(String clientId)
StatsService statsService
Definition: OAuthConfirmationController.java:86
UserInfoService userInfoService
Definition: OAuthConfirmationController.java:83
ClientDetailsEntity loadClientByClientId(String clientId)

◆ getClientService()

ClientDetailsEntityService org.mitre.oauth2.web.OAuthConfirmationController.getClientService ( )
inline
戻り値
the clientService
230  {
231  return clientService;
232  }
ClientDetailsEntityService clientService
Definition: OAuthConfirmationController.java:74

◆ setClientService()

void org.mitre.oauth2.web.OAuthConfirmationController.setClientService ( ClientDetailsEntityService  clientService)
inline
引数
clientServicethe clientService to set
237  {
239  }
ClientDetailsEntityService clientService
Definition: OAuthConfirmationController.java:74

メンバ詳解

◆ clientService

ClientDetailsEntityService org.mitre.oauth2.web.OAuthConfirmationController.clientService
private

◆ logger

final Logger org.mitre.oauth2.web.OAuthConfirmationController.logger = LoggerFactory.getLogger(OAuthConfirmationController.class)
staticprivate

Logger for this class

◆ redirectResolver

RedirectResolver org.mitre.oauth2.web.OAuthConfirmationController.redirectResolver
private

◆ scopeClaimTranslationService

ScopeClaimTranslationService org.mitre.oauth2.web.OAuthConfirmationController.scopeClaimTranslationService
private

◆ scopeService

SystemScopeService org.mitre.oauth2.web.OAuthConfirmationController.scopeService
private

◆ statsService

StatsService org.mitre.oauth2.web.OAuthConfirmationController.statsService
private

◆ userInfoService

UserInfoService org.mitre.oauth2.web.OAuthConfirmationController.userInfoService
private

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