111 String prompt = (String)authRequest.getExtensions().get(PROMPT);
112 List<String> prompts = Splitter.on(PROMPT_SEPARATOR).splitToList(Strings.nullToEmpty(prompt));
113 ClientDetailsEntity client = null;
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;
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;
133 if (prompts.contains(
"none")) {
136 String url =
redirectResolver.resolveRedirect(authRequest.getRedirectUri(), client);
139 URIBuilder uriBuilder =
new URIBuilder(url);
141 uriBuilder.addParameter(
"error",
"interaction_required");
142 if (!Strings.isNullOrEmpty(authRequest.getState())) {
143 uriBuilder.addParameter(
"state", authRequest.getState());
146 return "redirect:" + uriBuilder.toString();
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;
155 model.put(
"auth_request", authRequest);
156 model.put(
"client", client);
158 String redirect_uri = authRequest.getRedirectUri();
160 model.put(
"redirect_uri", redirect_uri);
166 Set<SystemScope> sortedScopes =
new LinkedHashSet<>(scopes.size());
170 for (SystemScope s : systemScopes) {
171 if (scopes.contains(s)) {
177 sortedScopes.addAll(Sets.difference(scopes, systemScopes));
179 model.put(
"scopes", sortedScopes);
183 Map<String, Map<String, String>> claimsForScopes =
new HashMap<>();
185 JsonObject userJson = user.
toJson();
187 for (SystemScope systemScope : sortedScopes) {
188 Map<String, String> claimValues =
new HashMap<>();
191 for (String claim : claims) {
192 if (userJson.has(claim) && userJson.get(claim).isJsonPrimitive()) {
194 claimValues.put(claim, userJson.get(claim).getAsString());
198 claimsForScopes.put(systemScope.getValue(), claimValues);
202 model.put(
"claims", claimsForScopes);
206 model.put(
"count", count);
210 if (client.getContacts() != null) {
211 String contacts = Joiner.on(
", ").join(client.getContacts());
212 model.put(
"contacts", contacts);
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);
221 model.put(
"gras",
false);
ClientDetailsEntityService clientService
Definition: OAuthConfirmationController.java:74
Set< SystemScope > getAll()
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
Set< String > getClaimsForScope(String scope)
UserInfo getByUsername(String username)
ClientStat getCountForClientId(String clientId)
StatsService statsService
Definition: OAuthConfirmationController.java:86
UserInfoService userInfoService
Definition: OAuthConfirmationController.java:83
ClientDetailsEntity loadClientByClientId(String clientId)