Class ScriptedIdPAttributeImpl
- java.lang.Object
-
- net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedIdPAttributeImpl
-
- All Implemented Interfaces:
ScriptedIdPAttribute
- Direct Known Subclasses:
BasicAttribute
public class ScriptedIdPAttributeImpl extends Object implements ScriptedIdPAttribute
An encapsulated Attribute suitable for handing to scripts. This handles some of the cumbersome issues associated withIdPAttributeand 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
Fields Modifier and Type Field Description private List<Object>attributeValuesAll theStringAttributeValue, but as strings.private booleancalledGetNativeAttributehas methodgetNativeAttribute()be called.private IdPAttributeencapsulatedAttributeTheIdPAttributewe are encapsulating.private org.slf4j.LoggerlogLogger.private StringlogPrefixThe prefix for logging.
-
Constructor Summary
Constructors Constructor Description ScriptedIdPAttributeImpl(IdPAttribute attribute, String prefix)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddAsIdPAttributeValue(List<IdPAttributeValue> values, Object value)Add the provided value to the provided list, convertingStringtoStringAttributeValue.voidaddValue(Object what)Add the provided object to the attribute values, policing for type.StringgetId()Get the encapsulated attributeId.protected StringgetLogPrefix()The prefix for the logs.IdPAttributegetNativeAttribute()return the underlying attribute.protected IdPAttributegetResultingAttribute()Function to reconstruct the attribute after the scripting.Collection<Object>getValues()Return all the values, but withStringAttributeValuevalues returned as strings.private voidpoliceValueType(Object what)Check that provided object is of typeStringorIdPAttributeValue.private voidsetupAttributeValues()We use an internal list of attribute values to allow the legacy use of getValues().add().
-
-
-
Field Detail
-
encapsulatedAttribute
private final IdPAttribute encapsulatedAttribute
TheIdPAttributewe are encapsulating.
-
log
private final org.slf4j.Logger log
Logger.
-
calledGetNativeAttribute
private boolean calledGetNativeAttribute
has methodgetNativeAttribute()be called.
-
attributeValues
private List<Object> attributeValues
All theStringAttributeValue, but as strings.All other attributes as their native representation. If null then the
getValues()method has not been called.
-
logPrefix
private final String logPrefix
The prefix for logging. Derived from the definition's logPrefix and the attribute ID.
-
-
Constructor Detail
-
ScriptedIdPAttributeImpl
public ScriptedIdPAttributeImpl(@Nonnull IdPAttribute attribute, String prefix)Constructor.- Parameters:
attribute- the attribute we are encapsulating.prefix- the log path from the definition.
-
-
Method Detail
-
setupAttributeValues
private void setupAttributeValues()
We use an internal list of attribute values to allow the legacy use of getValues().add().
-
getValues
@Nullable @NonnullElements public Collection<Object> getValues() throws ResolutionException
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
@Nonnull public IdPAttribute getNativeAttribute() throws ResolutionException
return the underlying attribute.- Specified by:
getNativeAttributein interfaceScriptedIdPAttribute- Returns:
- the attribute
- Throws:
ResolutionException- if the script has called getValues.
-
getId
@Nonnull @NotEmpty public String getId()
Get the encapsulated attributeId.- Specified by:
getIdin interfaceScriptedIdPAttribute- Returns:
- the id
-
addAsIdPAttributeValue
private void addAsIdPAttributeValue(List<IdPAttributeValue> values, 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
private void policeValueType(@Nullable Object what) throws ResolutionExceptionCheck that provided object is of typeStringorIdPAttributeValue.- Parameters:
what- value to check- Throws:
ResolutionException- if there is a type conflict.
-
addValue
public void addValue(@Nullable Object what) throws ResolutionExceptionAdd 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
@Nonnull protected IdPAttribute getResultingAttribute() throws ResolutionException
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
@Nonnull protected String getLogPrefix()
The prefix for the logs.- Returns:
- the prefix
-
-