public boolean apply(final ProfileInterceptorFlowDescriptor input) { return input.getId().equals(flowId); } });
/** {@inheritDoc} */ @Override public int hashCode() { return getId().hashCode(); }
/** {@inheritDoc} */ @Override public String toString() { return MoreObjects.toStringHelper(this) .add("flowId", getId()) .add("nonBrowserSupported", supportsNonBrowser) .toString(); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final ProfileInterceptorFlowDescriptor flow = selectUnattemptedFlow(profileRequestContext, interceptorContext); if (flow == null) { log.debug("{} No flows available to choose from", getLogPrefix()); return; } log.debug("{} Selecting flow {}", getLogPrefix(), flow.getId()); ActionSupport.buildEvent(profileRequestContext, flow.getId()); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final Map<String, ProfileInterceptorFlowDescriptor> availableFlows = interceptorContext.getAvailableFlows(); final Iterator<Entry<String, ProfileInterceptorFlowDescriptor>> descriptorIterator = availableFlows.entrySet().iterator(); while (descriptorIterator.hasNext()) { final ProfileInterceptorFlowDescriptor descriptor = descriptorIterator.next().getValue(); if (descriptor.isNonBrowserSupported()) { log.debug("{} Retaining flow '{}', it supports non-browser authentication", getLogPrefix(), descriptor.getId()); } else { log.debug("{} Removing flow '{}', it does not support non-browser authentication", getLogPrefix(), descriptor.getId()); descriptorIterator.remove(); } } if (availableFlows.size() == 0) { log.info("{} No available interceptor flows remain after filtering", getLogPrefix()); } else { log.debug("{} Available interceptor flows after filtering: '{}'", getLogPrefix(), availableFlows); } }
/** * Select the first potential flow not found in the completed flows collection, and that is applicable to the * context. * * @param profileRequestContext the current IdP profile request context * @param interceptorContext the current profile interceptor context * @return an eligible flow, or null */ @Nullable private ProfileInterceptorFlowDescriptor selectUnattemptedFlow( @Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { for (final ProfileInterceptorFlowDescriptor flow : interceptorContext.getAvailableFlows().values()) { log.debug("{} Checking flow {} for applicability...", getLogPrefix(), flow.getId()); if (flow.apply(profileRequestContext)) { interceptorContext.setAttemptedFlow(flow); return flow; } log.debug("{} 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; }
/** {@inheritDoc} */ @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { if (!super.doPreExecute(profileRequestContext, interceptorContext)) { return false; } // Detect a previous attempted flow, and move it to the intermediate collection. // This will prevent re-selecting the same flow again. if (interceptorContext.getAttemptedFlow() != null) { log.debug("{} Moving completed flow {} to completed set, selecting next one", getLogPrefix(), interceptorContext.getAttemptedFlow().getId()); interceptorContext.getAvailableFlows().remove(interceptorContext.getAttemptedFlow().getId()); interceptorContext.setAttemptedFlow(null); } return true; }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { interceptorContext.getAvailableFlows().clear(); interceptorContext.setAttemptedFlow(null); final Collection<String> activeFlows = activeFlowsLookupStrategy.apply(profileRequestContext); if (activeFlows != null) { for (final String id : activeFlows) { final String flowId = ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + id; final Optional<ProfileInterceptorFlowDescriptor> flow = Iterables.tryFind(availableFlows, new Predicate<ProfileInterceptorFlowDescriptor>() { public boolean apply(final ProfileInterceptorFlowDescriptor input) { return input.getId().equals(flowId); } }); if (flow.isPresent()) { log.debug("{} Installing flow {} into interceptor context", getLogPrefix(), flowId); interceptorContext.getAvailableFlows().put(flow.get().getId(), flow.get()); } else { log.error("{} Configured interceptor flow {} not available for use", getLogPrefix(), flowId); ActionSupport.buildEvent(profileRequestContext, IdPEventIds.INVALID_PROFILE_CONFIG); return; } } } }