/** {@inheritDoc} */ @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final SubjectCanonicalizationContext c14nContext) { // Detect a previous attempted flow, and move it to the intermediate collection. // This will prevent re-selecting the same (probably failed) flow again. if (c14nContext.getAttemptedFlow() != null) { log.info("{} Moving incomplete flow {} to intermediate set, reselecting a different one", getLogPrefix(), c14nContext.getAttemptedFlow().getId()); c14nContext.getIntermediateFlows().put( c14nContext.getAttemptedFlow().getId(), c14nContext.getAttemptedFlow()); } return super.doPreExecute(profileRequestContext, c14nContext); }
/** * Select the first potential flow not found in the intermediate flows collection, * and that is applicable to the context. * * @param profileRequestContext the current IdP profile request context * @param c14nContext the current c14n context * @return an eligible flow, or null */ @Nullable private SubjectCanonicalizationFlowDescriptor selectUnattemptedFlow( @Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final SubjectCanonicalizationContext c14nContext) { for (final SubjectCanonicalizationFlowDescriptor flow : c14nContext.getPotentialFlows().values()) { if (!c14nContext.getIntermediateFlows().containsKey(flow.getId())) { log.debug("{} Checking canonicalization flow {} for applicability...", getLogPrefix(), flow.getId()); c14nContext.setAttemptedFlow(flow); if (flow.apply(profileRequestContext)) { return flow; } log.debug("{} Canonicalization flow {} was not applicable to this request", getLogPrefix(), flow.getId()); // Note that we don't exclude this flow from possible future selection, since one flow // could in theory do partial work and change the context such that this flow then applies. } } return null; }