gluu
公開メンバ関数 | 限定公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.xdi.oxauth.authorize.ws.rs.ConsentGathererService クラス
org.xdi.oxauth.authorize.ws.rs.ConsentGathererService 連携図
Collaboration graph

公開メンバ関数

boolean configure (String userDn, String clientId, String state)
 
boolean authorize ()
 
String prepareForStep ()
 
String result (String resultCode)
 
void addMessage (FacesMessage.Severity severity, String summary)
 
Map< String, String > getPageAttributes ()
 
boolean isConsentGathered ()
 
ConsentGatheringContext getContext ()
 

限定公開メンバ関数

CustomScriptConfiguration getScript (final SessionId session)
 

非公開メンバ関数

void onSuccess (HttpServletRequest httpRequest, SessionId session, ConsentGatheringContext context)
 
void errorPage (String errorKey)
 

非公開変数類

Logger log
 
ExternalConsentGatheringService external
 
AppConfiguration appConfiguration
 
FacesContext facesContext
 
ExternalContext externalContext
 
FacesService facesService
 
LanguageBean languageBean
 
ConsentGatheringSessionService sessionService
 
UserService userService
 
AuthorizeService authorizeService
 
final Map< String, String > pageAttributes = new HashMap<String, String>()
 
ConsentGatheringContext context
 

詳解

著者
Yuriy Movchan Date: 10/30/2017

関数詳解

◆ addMessage()

void org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.addMessage ( FacesMessage.Severity  severity,
String  summary 
)
inline
252  {
253  String msg = languageBean.getMessage(summary);
254  FacesMessage message = new FacesMessage(severity, msg, null);
255  facesContext.addMessage(null, message);
256  }
String getMessage(String key)
Definition: LanguageBean.java:59
LanguageBean languageBean
Definition: ConsentGathererService.java:60
FacesContext facesContext
Definition: ConsentGathererService.java:51

◆ authorize()

boolean org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.authorize ( )
inline
107  {
108  try {
109  final HttpServletRequest httpRequest = (HttpServletRequest) externalContext.getRequest();
110  final HttpServletResponse httpResponse = (HttpServletResponse) externalContext.getResponse();
111 
112  final SessionId session = sessionService.getSession(httpRequest, httpResponse, null, false);
113  if (session == null) {
114  log.error("Failed to restore claim-gathering session state");
115  errorPage("consent.gather.invalid.session");
116  return false;
117  }
118 
119  CustomScriptConfiguration script = getScript(session);
120  if (script == null) {
121  log.error("Failed to find script '{}' in session:", sessionService.getScriptName(session));
122  errorPage("consent.gather.failed");
123  return false;
124  }
125 
126  int step = sessionService.getStep(session);
127  if (!sessionService.isPassedPreviousSteps(session, step)) {
128  log.error("There are consent-gathering steps not marked as passed. scriptName: '{}', step: '{}'", script.getName(), step);
129  errorPage("consent.gather.invalid.step");
130  return false;
131  }
132 
133  this.context = new ConsentGatheringContext(script.getConfigurationAttributes(), httpRequest, httpResponse, session,
135  boolean authorizeResult = external.authorize(script, step, context);
136  log.debug("Consent-gathering result for script '{}', step: '{}', gatheredResult: '{}'", script.getName(), step, authorizeResult);
137 
138  int overridenNextStep = external.getNextStep(script, step, context);
139  if (!authorizeResult && overridenNextStep == -1) {
140  SessionId connectSession = sessionService.getConnectSession(httpRequest);
141  authorizeService.permissionDenied(connectSession);
142  return false;
143  }
144 
145  if (overridenNextStep != -1) {
146  sessionService.resetToStep(session, overridenNextStep, step);
147  step = overridenNextStep;
148  }
149 
150  int stepsCount = external.getStepsCount(script, context);
151  if (step < stepsCount || overridenNextStep != -1) {
152  int nextStep;
153  if (overridenNextStep != -1) {
154  nextStep = overridenNextStep;
155  } else {
156  nextStep = step + 1;
157  sessionService.markStep(session, step, true);
158  }
159 
160  sessionService.setStep(nextStep, session);
161 
162  String redirectTo = external.getPageForStep(script, nextStep, context);
163  context.persist();
164 
165  log.trace("Redirecting to page: '{}'", redirectTo);
166  facesService.redirectWithExternal(redirectTo, null);
167 
168  return true;
169  }
170 
171  if (step == stepsCount) {
172  context.persist();
173  onSuccess(httpRequest, session, context);
174  return true;
175  }
176  } catch (Exception e) {
177  log.error("Exception during gather() method call.", e);
178  }
179 
180  log.error("Failed to perform gather() method successfully.");
181  errorPage("consent.gather.failed");
182  return false;
183  }
ConsentGatheringContext context
Definition: ConsentGathererService.java:72
void permissionDenied(final SessionId session)
Definition: AuthorizeService.java:185
boolean authorize(CustomScriptConfiguration script, int step, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:76
final Map< String, String > pageAttributes
Definition: ConsentGathererService.java:71
FacesService facesService
Definition: ConsentGathererService.java:57
void persist()
Definition: ConsentGatheringContext.java:110
AppConfiguration appConfiguration
Definition: ConsentGathererService.java:48
Logger log
Definition: ConsentGathererService.java:42
boolean isPassedPreviousSteps(SessionId session, Integer step)
Definition: ConsentGatheringSessionService.java:133
UserService userService
Definition: ConsentGathererService.java:66
ExternalContext externalContext
Definition: ConsentGathererService.java:54
ExternalConsentGatheringService external
Definition: ConsentGathererService.java:45
int getStep(SessionId session)
Definition: ConsentGatheringSessionService.java:107
void errorPage(String errorKey)
Definition: ConsentGathererService.java:236
String getPageForStep(CustomScriptConfiguration script, int step, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:128
void onSuccess(HttpServletRequest httpRequest, SessionId session, ConsentGatheringContext context)
Definition: ConsentGathererService.java:185
CustomScriptConfiguration getScript(final SessionId session)
Definition: ConsentGathererService.java:262
int getStepsCount(CustomScriptConfiguration script, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:115
AuthorizeService authorizeService
Definition: ConsentGathererService.java:69
String getScriptName(SessionId session)
Definition: ConsentGatheringSessionService.java:151
int getNextStep(CustomScriptConfiguration script, int step, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:89
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63
SessionId getSession(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String userDn, boolean create)
Definition: ConsentGatheringSessionService.java:54

◆ configure()

boolean org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.configure ( String  userDn,
String  clientId,
String  state 
)
inline
74  {
75  final HttpServletRequest httpRequest = (HttpServletRequest) externalContext.getRequest();
76  final HttpServletResponse httpResponse = (HttpServletResponse) externalContext.getResponse();
77 
78  final SessionId session = sessionService.getSession(httpRequest, httpResponse, userDn, true);
79 
80  CustomScriptConfiguration script = external.getDefaultExternalCustomScript();
81  if (script == null) {
82  log.error("Failed to determine consent-gathering default script");
83  return false;
84  }
85 
86  sessionService.configure(session, script.getName(), clientId, state);
87 
88  this.context = new ConsentGatheringContext(script.getConfigurationAttributes(), httpRequest, httpResponse, session,
90  log.debug("Configuring consent-gathering script '{}'", script.getName());
91 
92  int step = sessionService.getStep(session);
93  String redirectTo = external.getPageForStep(script, step, context);
94  if (StringHelper.isEmpty(redirectTo)) {
95  log.error("Failed to determine page for consent-gathering script");
96  return false;
97  }
98 
99  context.persist();
100 
101  log.trace("Redirecting to page: '{}'", redirectTo);
102  facesService.redirectWithExternal(redirectTo, null);
103 
104  return true;
105  }
void configure(SessionId session, String scriptName, String clientId, String state)
Definition: ConsentGatheringSessionService.java:121
ConsentGatheringContext context
Definition: ConsentGathererService.java:72
final Map< String, String > pageAttributes
Definition: ConsentGathererService.java:71
FacesService facesService
Definition: ConsentGathererService.java:57
void persist()
Definition: ConsentGatheringContext.java:110
AppConfiguration appConfiguration
Definition: ConsentGathererService.java:48
Logger log
Definition: ConsentGathererService.java:42
UserService userService
Definition: ConsentGathererService.java:66
ExternalContext externalContext
Definition: ConsentGathererService.java:54
ExternalConsentGatheringService external
Definition: ConsentGathererService.java:45
String getPageForStep(CustomScriptConfiguration script, int step, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:128
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63
SessionId getSession(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String userDn, boolean create)
Definition: ConsentGatheringSessionService.java:54

◆ errorPage()

void org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.errorPage ( String  errorKey)
inlineprivate
236  {
237  addMessage(FacesMessage.SEVERITY_ERROR, errorKey);
238  facesService.redirect("/error.xhtml");
239  }
FacesService facesService
Definition: ConsentGathererService.java:57
void addMessage(FacesMessage.Severity severity, String summary)
Definition: ConsentGathererService.java:252

◆ getContext()

ConsentGatheringContext org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.getContext ( )
inline
274  {
275  return context;
276  }
ConsentGatheringContext context
Definition: ConsentGathererService.java:72

◆ getPageAttributes()

Map<String, String> org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.getPageAttributes ( )
inline
258  {
259  return pageAttributes;
260  }
final Map< String, String > pageAttributes
Definition: ConsentGathererService.java:71

◆ getScript()

CustomScriptConfiguration org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.getScript ( final SessionId  session)
inlineprotected
262  {
263  String scriptName = sessionService.getScriptName(session);
264  CustomScriptConfiguration script = external.getCustomScriptConfigurationByName(scriptName);
265 
266  return script;
267  }
ExternalConsentGatheringService external
Definition: ConsentGathererService.java:45
String getScriptName(SessionId session)
Definition: ConsentGatheringSessionService.java:151
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63

◆ isConsentGathered()

boolean org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.isConsentGathered ( )
inline
269  {
270  final HttpServletRequest httpRequest = (HttpServletRequest) externalContext.getRequest();
271  return sessionService.isSessionStateAuthenticated(httpRequest);
272  }
boolean isSessionStateAuthenticated(HttpServletRequest httpRequest)
Definition: ConsentGatheringSessionService.java:88
ExternalContext externalContext
Definition: ConsentGathererService.java:54
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63

◆ onSuccess()

void org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.onSuccess ( HttpServletRequest  httpRequest,
SessionId  session,
ConsentGatheringContext  context 
)
inlineprivate
185  {
186  sessionService.setAuthenticatedSessionState(httpRequest, session);
187 
188  SessionId connectSessionId = sessionService.getConnectSession(httpRequest);
189 
190  authorizeService.permissionGranted(httpRequest, connectSessionId);
191  }
void setAuthenticatedSessionState(HttpServletRequest httpRequest, SessionId sessionId)
Definition: ConsentGatheringSessionService.java:83
SessionId getConnectSession(HttpServletRequest httpRequest)
Definition: ConsentGatheringSessionService.java:44
void permissionGranted(HttpServletRequest httpRequest, final SessionId session)
Definition: AuthorizeService.java:140
AuthorizeService authorizeService
Definition: ConsentGathererService.java:69
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63

◆ prepareForStep()

String org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.prepareForStep ( )
inline
193  {
194  try {
195  final HttpServletRequest httpRequest = (HttpServletRequest) externalContext.getRequest();
196  final HttpServletResponse httpResponse = (HttpServletResponse) externalContext.getResponse();
197 
198  final SessionId session = sessionService.getSession(httpRequest, httpResponse, null, false);
199  if (session == null || session.getSessionAttributes().isEmpty()) {
200  log.error("Failed to restore claim-gathering session state");
201  return result(Constants.RESULT_EXPIRED);
202  }
203 
204  CustomScriptConfiguration script = getScript(session);
205  if (script == null) {
206  log.error("Failed to find script '{}' in session:", sessionService.getScriptName(session));
207  return result(Constants.RESULT_FAILURE);
208  }
209 
210  int step = sessionService.getStep(session);
211  if (step < 1) {
212  log.error("Invalid step: {}", step);
213  return result(Constants.RESULT_INVALID_STEP);
214  }
215 
216  if (!sessionService.isPassedPreviousSteps(session, step)) {
217  log.error("There are consent-gathering steps not marked as passed. scriptName: '{}', step: '{}'", script.getName(), step);
218  return result(Constants.RESULT_FAILURE);
219  }
220 
221  this.context = new ConsentGatheringContext(script.getConfigurationAttributes(), httpRequest, httpResponse, session,
223  boolean result = external.prepareForStep(script, step, context);
224  log.debug("Consent-gathering prepare for step result for script '{}', step: '{}', gatheredResult: '{}'", script.getName(), step, result);
225  if (result) {
226  context.persist();
227  return result(Constants.RESULT_SUCCESS);
228  }
229  } catch (Exception ex) {
230  log.error("Failed to prepareForStep()", ex);
231  }
232 
233  return result(Constants.RESULT_FAILURE);
234  }
ConsentGatheringContext context
Definition: ConsentGathererService.java:72
boolean prepareForStep(CustomScriptConfiguration script, int step, ConsentGatheringContext context)
Definition: ExternalConsentGatheringService.java:102
final Map< String, String > pageAttributes
Definition: ConsentGathererService.java:71
FacesService facesService
Definition: ConsentGathererService.java:57
void persist()
Definition: ConsentGatheringContext.java:110
AppConfiguration appConfiguration
Definition: ConsentGathererService.java:48
Logger log
Definition: ConsentGathererService.java:42
boolean isPassedPreviousSteps(SessionId session, Integer step)
Definition: ConsentGatheringSessionService.java:133
UserService userService
Definition: ConsentGathererService.java:66
ExternalContext externalContext
Definition: ConsentGathererService.java:54
ExternalConsentGatheringService external
Definition: ConsentGathererService.java:45
int getStep(SessionId session)
Definition: ConsentGatheringSessionService.java:107
CustomScriptConfiguration getScript(final SessionId session)
Definition: ConsentGathererService.java:262
String result(String resultCode)
Definition: ConsentGathererService.java:241
String getScriptName(SessionId session)
Definition: ConsentGatheringSessionService.java:151
ConsentGatheringSessionService sessionService
Definition: ConsentGathererService.java:63
SessionId getSession(HttpServletRequest httpRequest, HttpServletResponse httpResponse, String userDn, boolean create)
Definition: ConsentGatheringSessionService.java:54

◆ result()

String org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.result ( String  resultCode)
inline
241  {
242  if (Constants.RESULT_FAILURE.equals(resultCode)) {
243  addMessage(FacesMessage.SEVERITY_ERROR, "consent.gather.failed");
244  } else if (Constants.RESULT_INVALID_STEP.equals(resultCode)) {
245  addMessage(FacesMessage.SEVERITY_ERROR, "consent.gather.invalid.step");
246  } else if (Constants.RESULT_EXPIRED.equals(resultCode)) {
247  addMessage(FacesMessage.SEVERITY_ERROR, "consent.gather.invalid.session");
248  }
249  return resultCode;
250  }
void addMessage(FacesMessage.Severity severity, String summary)
Definition: ConsentGathererService.java:252

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.appConfiguration
private

◆ authorizeService

AuthorizeService org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.authorizeService
private

◆ context

ConsentGatheringContext org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.context
private

◆ external

ExternalConsentGatheringService org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.external
private

◆ externalContext

ExternalContext org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.externalContext
private

◆ facesContext

FacesContext org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.facesContext
private

◆ facesService

FacesService org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.facesService
private

◆ languageBean

LanguageBean org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.languageBean
private

◆ log

Logger org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.log
private

◆ pageAttributes

final Map<String, String> org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.pageAttributes = new HashMap<String, String>()
private

◆ sessionService

ConsentGatheringSessionService org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.sessionService
private

◆ userService

UserService org.xdi.oxauth.authorize.ws.rs.ConsentGathererService.userService
private

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