/** {@inheritDoc} */ @Override @Nonnull protected IdPAttribute newAttribute(@Nonnull final Attribute input, @Nonnull @NotEmpty final String id) { return new IdPAttribute(id); }
/** {@inheritDoc} */ @Override @Nonnull protected IdPAttribute newAttribute(@Nonnull final AttributeDesignator input, @Nonnull @NotEmpty final String id) { return new IdPAttribute(id); }
/** * Constructor. * * @param id The attribute Id. */ public BasicAttribute(final String id) { super(new IdPAttribute(id), "Scripted Attribute Definition: "); log.info("{} Use of V2 emulated class \"BasicAttribute\", consider replacing this code", getLogPrefix()); } }
@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; } }
/** * 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; }
final List<IdPAttributeValue<?>> inputValues; List<? extends IdPAttributeValue<?>> outputValues = null; final IdPAttribute result = new IdPAttribute(getId());
final List<? extends IdPAttributeValue<?>> inputValues; List<? extends IdPAttributeValue<?>> outputValues = null; final IdPAttribute result = new IdPAttribute(getId());
final JsonArray vals = obj.getJsonArray(PRINCIPAL_ENTRY_FIELD); if (str != null && !Strings.isNullOrEmpty(str.getString()) && vals != null) { final IdPAttribute attribute = new IdPAttribute(str.getString()); final List<IdPAttributeValue<?>> values = new ArrayList<>();
/** {@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); } }
log.trace("{} Adding dependent attribute '{}' with the following values to the script context: {}", new Object[] {getLogPrefix(), dependencyAttribute.getKey(), dependencyAttribute.getValue(),}); final IdPAttribute pseudoAttribute = new IdPAttribute(dependencyAttribute.getKey()); pseudoAttribute.setValues(dependencyAttribute.getValue());
final IdPAttribute resultantAttribute = new IdPAttribute(getId());
/** {@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; }
final IdPAttribute resultAttribute = new IdPAttribute(getId());
} else { log.debug("{} Adding to-be-populated attribute to script context", getLogPrefix()); final IdPAttribute newAttribute = new IdPAttribute(getId()); scriptContext.setAttribute(getId(), new ScriptedIdPAttributeImpl(newAttribute, getLogPrefix()), ScriptContext.ENGINE_SCOPE); log.trace("{} Adding dependent attribute '{}' with the following values to the script context: {}", new Object[] {getLogPrefix(), dependencyAttribute.getKey(), dependencyAttribute.getValue(),}); final IdPAttribute pseudoAttribute = new IdPAttribute(dependencyAttribute.getKey()); pseudoAttribute.setValues(dependencyAttribute.getValue());
/** {@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; }
encoder.setNameQualifier(samlService.getNameIdQualifier()); val attribute = new IdPAttribute(AttributePrincipal.class.getName()); val principalName = request.getTicketGrantingTicket().getAuthentication().getPrincipal().getId(); LOGGER.trace("Preparing NameID attribute for principal [{}]", principalName);