/** {@inheritDoc} */ @Override protected final void doExecute( @Nonnull final ProfileRequestContext<InboundMessageType, OutboundMessageType> profileRequestContext) { doExecute(profileRequestContext, profileInterceptorContext); }
/** {@inheritDoc} */ @Override protected void doInitialize() throws ComponentInitializationException { super.doInitialize(); if (activeFlowsLookupStrategy == null) { throw new ComponentInitializationException("Flow lookup strategy cannot be null"); } }
/** * Store a profile interceptor result. * * @param result the profile interceptor result to be stored * @throws IOException if an error occurs */ protected void store(@Nonnull final ProfileInterceptorResult result) throws IOException { final String context = result.getStorageContext(); final String key = result.getStorageKey(); final String value = result.getStorageValue(); final Long expiration = result.getStorageExpiration(); // Create / update loop until we succeed or exhaust attempts. int attempts = 10; boolean success = false; do { success = storageService.create(context, key, value, expiration); if (!success) { // The record already exists, so we need to overwrite via an update. success = storageService.update(context, key, value, expiration); } } while (!success && attempts-- > 0); if (!success) { log.error("{} Exhausted retry attempts storing result '{}'", getLogPrefix(), result); } }
/** {@inheritDoc} */ @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { if (!super.doPreExecute(profileRequestContext, interceptorContext)) { return false; } results = interceptorContext.getResults(); if (results.isEmpty()) { log.debug("{} No results available from interceptor context, nothing to store", getLogPrefix()); return false; } flowDescriptor = interceptorContext.getAttemptedFlow(); if (flowDescriptor == null) { log.warn("{} No flow descriptor within interceptor context", getLogPrefix()); return false; } storageService = flowDescriptor.getStorageService(); if (storageService == null) { log.warn("{} No storage service available from interceptor flow descriptor", getLogPrefix()); return false; } return true; }
/** {@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 boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { if (profileRequestContext.isBrowserProfile()) { log.debug("{} Request does not have non-browser requirement, nothing to do", getLogPrefix()); return false; } return super.doPreExecute(profileRequestContext, interceptorContext); }
/** {@inheritDoc} */ @Override protected boolean doPreExecute(@Nonnull final ProfileRequestContext profileRequestContext) { profileInterceptorContext = interceptorContextlookupStrategy.apply(profileRequestContext); if (profileInterceptorContext == null) { log.error("{} Unable to create or locate profile interceptor context", getLogPrefix()); ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_PROFILE_CTX); return false; } return doPreExecute(profileRequestContext, profileInterceptorContext) && super.doPreExecute(profileRequestContext); }
/** {@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()); }
/** * Store a profile interceptor result and maintain an index record containing the storage keys for the storage * context. Storage records are pruned so that the number of records stored is less than or equal to * {@link net.shibboleth.idp.consent.flow.impl.ConsentFlowDescriptor#getMaximumNumberOfStoredRecords()}. * * @param profileRequestContext the profile request context * @param result the profile interceptor result to be stored * @throws IOException if an error occurs */ protected void storeResultWithIndex(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorResult result) throws IOException { pruneStorageRecords(profileRequestContext); storeResult(result); addKeyToStorageIndex(result.getStorageKey()); } }
/** * Get the storage service from the flow descriptor of the profile interceptor context. The profile interceptor * context is retrieved by applying the profile interceptor context lookup strategy to the profile request context. * The storage service is retrieved from the flow descriptor of the last interceptor flow which was attempted. * * @param profileRequestContext the profile request context * @return the storage service * @throws net.shibboleth.utilities.java.support.logic.ConstraintViolationException if the lookup strategy returns * <code>null</code>, the interceptor flow descriptor is <code>null</code>, or the storage service is * <code>null</code> */ @Nonnull protected StorageService getStorageService(@Nonnull final ProfileRequestContext profileRequestContext) { Constraint.isNotNull(profileRequestContext, "Profile request context cannot be null"); final ProfileInterceptorContext interceptorContext = interceptorContextlookupStrategy.apply(profileRequestContext); Constraint.isNotNull(interceptorContext, "Profile interceptor context not available from profile request context"); final ProfileInterceptorFlowDescriptor flowDescriptor = interceptorContext.getAttemptedFlow(); Constraint.isNotNull(flowDescriptor, "Profile interceptor flow descriptor not available from profile interceptor context"); return Constraint.isNotNull(flowDescriptor.getStorageService(), "Storage service not available from interceptor flow descriptor"); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final AttributeReleaseContext attributeReleaseContext = new AttributeReleaseContext(); log.debug("{} Created attribute release context '{}'", getLogPrefix(), attributeReleaseContext); profileRequestContext.addSubcontext(attributeReleaseContext, true); super.doExecute(profileRequestContext, interceptorContext); } }
/** * Store a profile interceptor result and maintain an index record containing the storage keys for the storage * context. Storage records are pruned so that the number of records stored is less than or equal to * {@link net.shibboleth.idp.consent.flow.ConsentFlowDescriptor#getMaximumNumberOfStoredRecords()}. * * @param profileRequestContext the profile request context * @param result the profile interceptor result to be stored * @throws IOException if an error occurs */ protected void storeResultWithIndex(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorResult result) throws IOException { pruneStorageRecords(profileRequestContext); storeResult(result); addKeyToStorageIndex(result.getStorageKey()); } }
/** * Get the storage service from the flow descriptor of the profile interceptor context. The profile interceptor * context is retrieved by applying the profile interceptor context lookup strategy to the profile request context. * The storage service is retrieved from the flow descriptor of the last interceptor flow which was attempted. * * @param profileRequestContext the profile request context * @return the storage service * @throws net.shibboleth.utilities.java.support.logic.ConstraintViolationException if the lookup strategy returns * <code>null</code>, the interceptor flow descriptor is <code>null</code>, or the storage service is * <code>null</code> */ @Nonnull protected StorageService getStorageService(@Nonnull final ProfileRequestContext profileRequestContext) { Constraint.isNotNull(profileRequestContext, "Profile request context cannot be null"); final ProfileInterceptorContext interceptorContext = interceptorContextlookupStrategy.apply(profileRequestContext); Constraint.isNotNull(interceptorContext, "Profile interceptor context not available from profile request context"); final ProfileInterceptorFlowDescriptor flowDescriptor = interceptorContext.getAttemptedFlow(); Constraint.isNotNull(flowDescriptor, "Profile interceptor flow descriptor not available from profile interceptor context"); return Constraint.isNotNull(flowDescriptor.getStorageService(), "Storage service not available from interceptor flow descriptor"); }
public boolean apply(final ProfileInterceptorFlowDescriptor input) { return input.getId().equals(flowId); } });
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final ConsentContext consentContext = new ConsentContext(); log.debug("{} Created consent context '{}'", getLogPrefix(), consentContext); profileRequestContext.addSubcontext(consentContext, true); super.doExecute(profileRequestContext, interceptorContext); } }
/** {@inheritDoc} */ @Override public int hashCode() { return getId().hashCode(); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final AttributeReleaseContext attributeReleaseContext = new AttributeReleaseContext(); log.debug("{} Created attribute release context '{}'", getLogPrefix(), attributeReleaseContext); profileRequestContext.addSubcontext(attributeReleaseContext, true); super.doExecute(profileRequestContext, interceptorContext); } }
/** {@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 ConsentContext consentContext = new ConsentContext(); log.debug("{} Created consent context '{}'", getLogPrefix(), consentContext); profileRequestContext.addSubcontext(consentContext, true); super.doExecute(profileRequestContext, interceptorContext); } }