Class ScriptedIdPAttributeImpl
java.lang.Object
net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedIdPAttributeImpl
- All Implemented Interfaces:
ScriptedIdPAttribute
An encapsulated Attribute suitable for handing to scripts. This handles some of the cumbersome issues associated with
IdPAttribute and also a lot of the V2 backwards compatibility stuff.
NOTE, the java signature for this class may and will change on minor version changes. However the Scripting interface will remain the same (methods will never be removed).
-
Field Summary
FieldsModifier and TypeFieldDescriptionAll theStringAttributeValue, but as strings.private booleanhas methodgetNativeAttribute()be called.private final IdPAttributeTheIdPAttributewe are encapsulating.private final org.slf4j.LoggerLogger.private final StringThe prefix for logging. -
Constructor Summary
ConstructorsConstructorDescriptionScriptedIdPAttributeImpl(IdPAttribute attribute, String prefix) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAsIdPAttributeValue(List<IdPAttributeValue> values, Object value) Add the provided value to the provided list, convertingStringtoStringAttributeValue.voidAdd the provided object to the attribute values, policing for type.getId()Get the encapsulated attributeId.protected StringThe prefix for the logs.return the underlying attribute.protected IdPAttributeFunction to reconstruct the attribute after the scripting.Return all the values, but withStringAttributeValuevalues returned as strings.private voidpoliceValueType(Object what) Check that provided object is of typeStringorIdPAttributeValue.private voidWe use an internal list of attribute values to allow the legacy use of getValues().add().
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logLogger. -
encapsulatedAttribute
TheIdPAttributewe are encapsulating. -
calledGetNativeAttribute
private boolean calledGetNativeAttributehas methodgetNativeAttribute()be called. -
attributeValues
All theStringAttributeValue, but as strings.All other attributes as their native representation. If null then the
getValues()method has not been called. -
logPrefix
The prefix for logging. Derived from the definition's logPrefix and the attribute ID.
-
-
Constructor Details
-
ScriptedIdPAttributeImpl
Constructor.- Parameters:
attribute- the attribute we are encapsulating.prefix- the log path from the definition.
-
-
Method Details
-
setupAttributeValues
private void setupAttributeValues()We use an internal list of attribute values to allow the legacy use of getValues().add(). -
getValues
Return all the values, but withStringAttributeValuevalues returned as strings.This method is a helper method for V2 compatibility.
- Specified by:
getValuesin interfaceScriptedIdPAttribute- Returns:
- a modifiable collection of the string attributes (not the String
- Throws:
ResolutionException- if the script has calledgetNativeAttribute()
-
getNativeAttribute
return the underlying attribute.- Specified by:
getNativeAttributein interfaceScriptedIdPAttribute- Returns:
- the attribute
- Throws:
ResolutionException- if the script has called getValues.
-
getId
Get the encapsulated attributeId.- Specified by:
getIdin interfaceScriptedIdPAttribute- Returns:
- the id
-
addAsIdPAttributeValue
private void addAsIdPAttributeValue(@Nonnull List<IdPAttributeValue> values, @Nullable Object value) Add the provided value to the provided list, convertingStringtoStringAttributeValue.- Parameters:
values- the list to add to.value- the value to add. Known to be aStringor anIdPAttributeValue
-
policeValueType
Check that provided object is of typeStringorIdPAttributeValue.- Parameters:
what- value to check- Throws:
ResolutionException- if there is a type conflict.
-
addValue
Add the provided object to the attribute values, policing for type.- Specified by:
addValuein interfaceScriptedIdPAttribute- Parameters:
what- aStringor aIdPAttributeValueto add.- Throws:
ResolutionException- if the provided value is of the wrong type
-
getResultingAttribute
Function to reconstruct the attribute after the scripting. IfgetValues()has been called then this is taken as the content and the attribute updated, otherwise the Attribute is returned.- Returns:
- a suitable modified attribute.
- Throws:
ResolutionException- if we find the wrong type.
-
getLogPrefix
The prefix for the logs.- Returns:
- the prefix
-