/** * Apply configured transforms to input identifier. * * @param id the identifier to transform * @return transformed value */ @Nullable protected String decode(@Nonnull @NotEmpty final String id) { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); String s = id; for (final Pair<Pattern,String> p : transforms) { final Matcher m = p.getFirst().matcher(s); log.debug("Applying replacement expression '{}' against input '{}'", p.getFirst().pattern(), s); s = m.replaceAll(p.getSecond()); log.debug("Result of replacement is '{}'", s); } return s; }
/** * Conditionally starts one or more timers based on the supplied object identifier. * * <p>The configured state of the context is used to determine whether, and which, * timers to start, further influenced by the runtime state of the system with regard * to enabling of metrics.</p> * * @param objectId ID of the object being timed */ public void start(@Nonnull @NotEmpty final String objectId) { for (final Pair<String,String> timer : timerMap.get(objectId)) { if (timer != null) { timerContextMap.put(timer.getSecond(), MetricsSupport.getMetricRegistry().timer(timer.getFirst()).time()); } } }
/** {@inheritDoc} */ @Override @Nullable public List<String> apply(@Nullable final Pair<ProfileRequestContext, List<String>> input) { if (input == null || input.getFirst() == null || input.getSecond() == null) { return null; } try { final ProfileRequestContext profileRequestContext = input.getFirst(); final List<String> storageKeys = input.getSecond(); final Map<String, Long> keyToCounterMap = getStorageKeyCounters(profileRequestContext, storageKeys); final Comparator<String> comparator = new CounterStorageKeyComparator(storageKeys, keyToCounterMap); Collections.sort(storageKeys, comparator); return storageKeys; } catch (final ConstraintViolationException e) { log.warn("Unable to apply counter storage key function", e); return input.getSecond(); } }
/** {@inheritDoc} */ @Override @Nullable public List<String> apply(@Nullable final Pair<ProfileRequestContext, List<String>> input) { if (input == null || input.getFirst() == null || input.getSecond() == null) { return null; } try { final ProfileRequestContext profileRequestContext = input.getFirst(); final List<String> storageKeys = input.getSecond(); final Map<String, Long> keyToCounterMap = getStorageKeyCounters(profileRequestContext, storageKeys); final Comparator<String> comparator = new CounterStorageKeyComparator(storageKeys, keyToCounterMap); Collections.sort(storageKeys, comparator); return storageKeys; } catch (final ConstraintViolationException e) { log.warn("Unable to apply counter storage key function", e); return input.getSecond(); } }
/** {@inheritDoc} */ @Override @Nullable public RelyingPartyContext apply(@Nullable final Pair<MultiRelyingPartyContext,String> input) { if (input == null || input.getFirst() == null) { return null; } final String id = StringSupport.trimOrNull(input.getSecond()); if (id == null) { return null; } RelyingPartyContext rpCtx = input.getFirst().getRelyingPartyContextById(id); if (rpCtx == null && label != null) { rpCtx = new RelyingPartyContext(); rpCtx.setRelyingPartyId(id); input.getFirst().addRelyingPartyContext(label, rpCtx); } return rpCtx; }
/** * Set the JAAS application name(s) to use, along with an optional collection of custom principals to * apply to the result. * * @param configs list of JAAS application names and custom principals to use */ public void setLoginConfigurations(@Nullable final Collection<Pair<String,Collection<Principal>>> configs) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); if (configs != null) { loginConfigurations = new ArrayList<>(configs.size()); for (final Pair<String,Collection<Principal>> config : configs) { final String trimmed = StringSupport.trimOrNull(config.getFirst()); if (trimmed != null) { if (config.getSecond() == null || config.getSecond().isEmpty()) { loginConfigurations.add(new Pair<String,Subject>(trimmed, null)); } else { final Subject subject = new Subject(); subject.getPrincipals().addAll(config.getSecond()); loginConfigurations.add(new Pair<String,Subject>(trimmed, subject)); } } } } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection) throws StageProcessingException { Collection<Item<T>> selectedItems; final ArrayList<Future<Collection<Item<T>>>> pipelineFutures = new ArrayList<>(); for (Pair<Pipeline<T>, Predicate<Item<T>>> pipelineAndStrategy : pipelineAndStrategies) { final Pipeline<T> pipeline = pipelineAndStrategy.getFirst(); final Predicate<Item<T>> selectionStrategy = pipelineAndStrategy.getSecond(); selectedItems = collectionFactory.get(); for (Item<T> item : itemCollection) { if (selectionStrategy.apply(item)) { // @SuppressWarnings("unchecked") final ItemType copied = (ItemType) item.copy(); // selectedItems.add(copied); selectedItems.add(item.copy()); } } pipelineFutures.add(executorService.submit(new PipelineCallable<>(pipeline, selectedItems))); } if (isWaitingForPipelines()) { for (Future<Collection<Item<T>>> pipelineFuture : pipelineFutures) { FutureSupport.futureItems(pipelineFuture); } } }
/** * Sets the pipeline and item selection strategies used to demultiplex item collections within this stage. * * @param passes pipeline and item selection strategies used to demultiplex item collections within this stage */ public synchronized void setPipelineAndSelectionStrategies( @Nonnull @NonnullElements final List<Pair<Pipeline<T>, Predicate<Item<T>>>> passes) { ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); if (passes == null || passes.isEmpty()) { pipelineAndStrategies = Collections.emptyList(); return; } final Builder<Pair<Pipeline<T>, Predicate<Item<T>>>> checkedPasses = new Builder<>(); for (Pair<Pipeline<T>, Predicate<Item<T>>> pass : passes) { Constraint.isNotNull(pass.getFirst(), "Pipeline can not be null"); Constraint.isNotNull(pass.getSecond(), "Predicate can not be null"); checkedPasses.add(new Pair<>(pass)); } pipelineAndStrategies = checkedPasses.build(); }
if (input == null || input.getFirst() == null) { log.debug("Input Pair or ProfileRequestContext was null, skipping"); return Collections.emptyList(); List<Credential> credentials = resolveCredentials(input.getFirst()); if (credentials.isEmpty()) { log.debug("No self-encryption credentials were resolved, skipping further processing"); List<EncryptionConfiguration> baseConfigs = resolveBaseConfigurations(input.getFirst()); log.debug("Resolved {} base EncryptionConfigurations", baseConfigs.size());
/** {@inheritDoc} */ @Override protected void doInitialize() throws ComponentInitializationException { super.doInitialize(); if (pipelineAndStrategies.isEmpty()) { throw new ComponentInitializationException( "Pipeline and selection strategy collection can not be null or empty"); } Pipeline<T> pipeline; for (Pair<Pipeline<T>, Predicate<Item<T>>> pipelineAndStrategy : pipelineAndStrategies) { pipeline = pipelineAndStrategy.getFirst(); if (!pipeline.isInitialized()) { pipeline.initialize(); } } } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final AuthenticationContext authenticationContext) { final Pair<String, String> usernamePassword = extractUsernamePassword(inboundMessage); if (usernamePassword == null) { log.debug("{} inbound message does not contain a username and password", getLogPrefix()); ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_CREDENTIALS); return; } authenticationContext.getSubcontext(UsernamePasswordContext.class, true) .setUsername(usernamePassword.getFirst()).setPassword(usernamePassword.getSecond()); }
/** * A collection of regular expression and replacement pairs. * * @param newTransforms collection of replacement transforms */ public void setTransforms(@Nonnull @NonnullElements final Collection<Pair<String,String>> newTransforms) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(newTransforms, "Transforms collection cannot be null"); transforms = new ArrayList(); for (final Pair<String,String> p : newTransforms) { final Pattern pattern = Pattern.compile(StringSupport.trimOrNull(p.getFirst())); transforms.add(new Pair(pattern, Constraint.isNotNull( StringSupport.trimOrNull(p.getSecond()), "Replacement expression cannot be null"))); } }
/** * A collection of regular expression and replacement pairs. * * @param newTransforms collection of replacement transforms */ public void setTransforms(@Nonnull @NonnullElements final Collection<Pair<String, String>> newTransforms) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(newTransforms, "Transforms collection cannot be null"); transforms = new ArrayList(); for (final Pair<String,String> p : newTransforms) { final Pattern pattern = Pattern.compile(StringSupport.trimOrNull(p.getFirst())); transforms.add(new Pair(pattern, Constraint.isNotNull( StringSupport.trimOrNull(p.getSecond()), "Replacement expression cannot be null"))); } }
/** * A collection of regular expression and replacement pairs. * * @param newTransforms collection of replacement transforms */ public void setTransforms(@Nonnull @NonnullElements final Collection<Pair<String, String>> newTransforms) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); Constraint.isNotNull(newTransforms, "Transforms collection cannot be null"); transforms = new ArrayList(); for (final Pair<String,String> p : newTransforms) { final Pattern pattern = Pattern.compile(StringSupport.trimOrNull(p.getFirst())); transforms.add(new Pair(pattern, Constraint.isNotNull( StringSupport.trimOrNull(p.getSecond()), "Replacement expression cannot be null"))); } }
if (keyCertPair.getFirst() == null && keyCertPair.getSecond() == null) { log.debug("Neither the presenter's certificate nor its public key were provided"); context.setValidationFailureMessage("Neither the presenter's certificate nor its public key were provided"); if (matchesKeyValue(keyCertPair.getFirst(), keyInfo)) { log.debug("Successfully matched public key in subject confirmation data to supplied key param"); context.getDynamicParameters().put(SAML2AssertionValidationParameters.SC_HOK_CONFIRMED_KEYINFO,
return new SAML2SPSession(issuer, now, expiration, result.getFirst().getSubject().getNameID(), result.getSecond().getSessionIndex());
persistentCacheInitMetrics.entriesTotal++; final EntityDescriptor descriptor = cacheEntry.getSecond(); final String currentKey = cacheEntry.getFirst(); log.trace("{} Loaded EntityDescriptor from cache store with entityID '{}' and storage key '{}'", getLogPrefix(), descriptor.getEntityID(), currentKey);
upCtx.setUsername(applyTransforms(decodedCredentials.getFirst())).setPassword(decodedCredentials.getSecond());