@Override @Nullable protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { final ProfileRequestContext prc = prcLookupStrategy.apply(resolutionContext); @Nullable final List<IdPAttributeValue<?>> results = attributeValuesFunction.apply(prc); if (null == results) { log.debug("{} Generated no values.", getLogPrefix()); return null; } log.debug("{} Generated {} values.", getLogPrefix(), results.size()); log.trace("{} Values:", getLogPrefix(), results); final IdPAttribute attribute = new IdPAttribute(getId()); attribute.setValues(results); return attribute; }
/** * Encode the provided string. * * @param value the value to encode or null if that failed * @return null or the attribute. */ @Nullable protected Map<String, IdPAttribute> encodeAsAttribute(@Nullable final String value) { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); if (null == value) { // The message will have been logged above return null; } final IdPAttribute attribute = new IdPAttribute(getGeneratedAttributeId()); attribute.setValues(Collections.singletonList(StringAttributeValue.valueOf(value))); return Collections.singletonMap(getGeneratedAttributeId(), attribute); }
/** {@inheritDoc} */ @Override @Nonnull protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { Constraint.isNotNull(workContext, "AttributeResolverWorkContext cannot be null"); final IdPAttribute result = new IdPAttribute(getId()); result.setValues(PluginDependencySupport.getMergedAttributeValues(workContext, getDependencies(), getId())); return result; }
@Override @Nullable protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { final String principalName = StringSupport.trimOrNull(resolutionContext.getPrincipal()); if (null == principalName) { throw new ResolutionException(getLogPrefix() + " provided principal name was empty"); } final IdPAttribute attribute = new IdPAttribute(getId()); attribute.setValues(Collections.singletonList(new StringAttributeValue(principalName))); return attribute; }
/** {@inheritDoc} */ @Override @Nullable protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { final String method = StringSupport.trimOrNull(resolutionContext.getPrincipalAuthenticationMethod()); if (null == method) { log.info("{} null or empty method was returned", getLogPrefix()); return null; } final IdPAttribute attribute = new IdPAttribute(getId()); attribute.setValues(Collections.singletonList(new StringAttributeValue(method))); return attribute; } }
attribute.setValues(keepers); return keepers.size();
/** * Function to reconstruct the attribute after the scripting. If {@link #getValues()} has been called then this is * taken as the content and the attribute updated, otherwise the Attribute is returned. * * @return a suitable modified attribute. * @throws ResolutionException if we find the wrong type. */ @Nonnull protected IdPAttribute getResultingAttribute() throws ResolutionException { if (null == attributeValues) { log.debug("{} return initial attribute unchanged", getLogPrefix()); return encapsulatedAttribute; } // Otherwise re-marshall the {@link #attributeValues} final List<IdPAttributeValue<?>> valueList = new ArrayList<>(attributeValues.size()); log.debug("{} recreating attribute contents from {}", getLogPrefix(), attributeValues); for (final Object object : attributeValues) { policeValueType(object); addAsIdPAttributeValue(valueList, object); } encapsulatedAttribute.setValues(valueList); log.debug("{} recreated attribute contents are {}", getLogPrefix(), valueList); return encapsulatedAttribute; }
/** * Ensure that all the values in the attribute are of the correct type. * * @param attribute the attribute to look at */ private void checkValues(final IdPAttribute attribute) { if (null == attribute.getValues()) { log.info("{} Attribute '{}' has no values provided.", getLogPrefix(), attribute.getId()); attribute.setValues(Collections.<IdPAttributeValue<?>> emptyList()); return; } log.debug("{} Attribute '{}' has {} value(s).", getLogPrefix(), attribute.getId(), attribute.getValues().size()); final List<IdPAttributeValue<?>> inputValues = attribute.getValues(); final List<IdPAttributeValue<?>> outputValues = new ArrayList<>(inputValues.size()); for (final Object o : inputValues) { if (o instanceof IdPAttributeValue<?>) { outputValues.add((IdPAttributeValue<?>) o); } else { log.error("{} Attribute '{} has attribute value of type {}. This will be ignored", getLogPrefix(), attribute.getId(), o.getClass().getName()); } } attribute.setValues(outputValues); } }
/** * Ensure that all the values in the attribute are of the correct type. * * @param attribute the attribute to look at */ private void checkValues(final IdPAttribute attribute) { if (null == attribute.getValues()) { log.info("{} Attribute '{}' has no values provided.", getLogPrefix(), attribute.getId()); attribute.setValues(Collections.<IdPAttributeValue<?>> emptyList()); return; } log.debug("{} Attribute '{}' has {} value(s).", getLogPrefix(), attribute.getId(), attribute.getValues().size()); final List<IdPAttributeValue<?>> inputValues = attribute.getValues(); final List<IdPAttributeValue<?>> outputValues = new ArrayList<>(inputValues.size()); for (final Object o : inputValues) { if (o instanceof IdPAttributeValue<?>) { outputValues.add((IdPAttributeValue<?>) o); } else { log.error("{} Attribute '{} has attribute value of type {}. This will be ignored", getLogPrefix(), attribute.getId(), o.getClass().getName()); } } attribute.setValues(outputValues); }
/** * Prepare name id attribute id p attribute. * * @param casAssertion the assertion * @param nameFormat the name format * @param adaptor the adaptor * @return the idp attribute */ protected IdPAttribute prepareNameIdAttribute(final Object casAssertion, final String nameFormat, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) { val assertion = Assertion.class.cast(casAssertion); val attribute = new IdPAttribute(AttributePrincipal.class.getName()); val principalName = assertion.getPrincipal().getName(); LOGGER.debug("Preparing NameID attribute for principal [{}]", principalName); val nameIdValue = getNameIdValueFromNameFormat(nameFormat, adaptor, principalName); val value = new StringAttributeValue(nameIdValue); LOGGER.debug("NameID attribute value is set to [{}]", value); attribute.setValues(CollectionUtils.wrap(value)); return attribute; }
result.setValues(outputValues);
result.setValues(outputValues);
attribute.setValues(values); return new IdPAttributePrincipal(attribute); } else {
/** {@inheritDoc} */ @Override @Nonnull protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); final String attributeRecipientID = getAttributeRecipientID(resolutionContext); final String principalName = getPrincipal(resolutionContext); try { final String transientId = idGenerator.generate(attributeRecipientID, principalName); log.debug("{} creating new transient ID '{}'", new Object[] {getLogPrefix(), transientId,}); final IdPAttribute result = new IdPAttribute(getId()); result.setValues(Collections.singletonList(new StringAttributeValue(transientId))); return result; } catch (final SAMLException e) { throw new ResolutionException(e); } }
/** * Clones an attribute. The clone will contains defensive copies of this objects display descriptions and names, * encoders, and values. The elements of each collection, however, are not themselves cloned. * * {@inheritDoc} */ @Override @Nonnull public IdPAttribute clone() throws CloneNotSupportedException { final IdPAttribute clone = (IdPAttribute) super.clone(); clone.setDisplayDescriptions(getDisplayDescriptions()); clone.setDisplayNames(getDisplayNames()); clone.setEncoders(getEncoders()); clone.setValues(getValues()); return clone; }
new Object[] {getLogPrefix(), dependencyAttribute.getKey(), dependencyAttribute.getValue(),}); final IdPAttribute pseudoAttribute = new IdPAttribute(dependencyAttribute.getKey()); pseudoAttribute.setValues(dependencyAttribute.getValue());
/** {@inheritDoc} */ @Override @Nonnull protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); final IdPAttribute resultantAttribute = new IdPAttribute(getId()); final List<IdPAttributeValue<?>> dependencyValues = PluginDependencySupport.getMergedAttributeValues(workContext, getDependencies(), getId()); final List<StringAttributeValue> valueList = new ArrayList<>(dependencyValues.size()); for (final IdPAttributeValue dependencyValue : dependencyValues) { if (dependencyValue instanceof EmptyAttributeValue) { final EmptyAttributeValue emptyVal = (EmptyAttributeValue) dependencyValue; log.debug("{} ignored empty value of type {}", getLogPrefix(), emptyVal.getDisplayValue()); continue; } if (!(dependencyValue instanceof StringAttributeValue)) { throw new ResolutionException(new UnsupportedAttributeTypeException(getLogPrefix() + "This attribute definition only supports attribute value types of " + StringAttributeValue.class.getName() + " not values of type " + dependencyValue.getClass().getName())); } valueList.add(new ScopedStringAttributeValue((String) dependencyValue.getValue(), scope)); } resultantAttribute.setValues(valueList); return resultantAttribute; }
/** {@inheritDoc} */ @Override @Nullable protected IdPAttribute doAttributeDefinitionResolve( @Nonnull final AttributeResolutionContext resolutionContext, @Nonnull final AttributeResolverWorkContext workContext) throws ResolutionException { Constraint.isNotNull(workContext, getLogPrefix() + " AttributeResolverWorkContext cannot be null"); ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); final IdPAttribute resultantAttribute = new IdPAttribute(getId()); final List<IdPAttributeValue<?>> dependencyValues = PluginDependencySupport.getMergedAttributeValues(workContext, getDependencies(), getId()); log.debug("{} Dependencies {} provided unmapped values of {}", getLogPrefix(), getDependencies(), dependencyValues); final List<IdPAttributeValue<?>> valueList = new ArrayList<>(dependencyValues.size()); for (final IdPAttributeValue<?> dependencyValue : dependencyValues) { if (dependencyValue instanceof EmptyAttributeValue) { final EmptyAttributeValue emptyVal = (EmptyAttributeValue) dependencyValue; log.debug("{} ignored empty value of type {}", getLogPrefix(), emptyVal.getDisplayValue()); continue; } if (!(dependencyValue instanceof StringAttributeValue)) { throw new ResolutionException(new UnsupportedAttributeTypeException(getLogPrefix() + "This attribute definition only supports attribute value types of " + StringAttributeValue.class.getName() + " not values of type " + dependencyValue.getClass().getName())); } valueList.add(buildScopedStringAttributeValue((StringAttributeValue) dependencyValue)); } resultantAttribute.setValues(valueList); return resultantAttribute; }
val principalName = request.getTicketGrantingTicket().getAuthentication().getPrincipal().getId(); LOGGER.trace("Preparing NameID attribute for principal [{}]", principalName); attribute.setValues(CollectionUtils.wrap(new StringAttributeValue(principalName))); val nameId = encoder.encode(attribute);