Package net.shibboleth.idp.attribute.resolver.ad.impl

# Class ScriptedIdPAttributeImpl

java.lang.Object
net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedIdPAttributeImpl

All Implemented Interfaces:
  `ScriptedIdPAttribute`

public class ScriptedIdPAttributeImpl extends Object implements 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

Fields
Modifier and Type
Field
Description
`private List<Object>`
`attributeValues`
All the `StringAttributeValue`, but as strings.
`private boolean`
`calledGetNativeAttribute`
has method `getNativeAttribute()` be called.
`private final IdPAttribute`
`encapsulatedAttribute`
The `IdPAttribute` we are encapsulating.
`private final org.slf4j.Logger`
`log`
Logger.
`private final String`
`logPrefix`
The prefix for logging.

## Constructor Summary

Constructors
Constructor
Description
`ScriptedIdPAttributeImpl(IdPAttribute attribute, String prefix)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`private void`
`addAsIdPAttributeValue(List<IdPAttributeValue> values, Object value)`
Add the provided value to the provided list, converting `String` to `StringAttributeValue`.
`void`
`addValue(Object what)`
Add the provided object to the attribute values, policing for type.
`String`
`getId()`
Get the encapsulated attributeId.
`protected String`
`getLogPrefix()`
The prefix for the logs.
`IdPAttribute`
`getNativeAttribute()`
return the underlying attribute.
`protected IdPAttribute`
`getResultingAttribute()`
Function to reconstruct the attribute after the scripting.
`Collection<Object>`
`getValues()`
Return all the values, but with `StringAttributeValue` values returned as strings.
`private void`
`policeValueType(Object what)`
Check that provided object is of type `String` or `IdPAttributeValue`.
`private void`
`setupAttributeValues()`
We use an internal list of attribute values to allow the legacy use of getValues().add().

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Logger.

### encapsulatedAttribute

@Nonnull private final IdPAttribute encapsulatedAttribute
The `IdPAttribute` we are encapsulating.

### calledGetNativeAttribute

private boolean calledGetNativeAttribute
has method `getNativeAttribute()` be called.

### attributeValues

private List<Object> attributeValues
All the `StringAttributeValue`, but as strings.

All other attributes as their native representation. If null then the `getValues()` method has not been called.

### logPrefix

@Nonnull private final String logPrefix
The prefix for logging. Derived from the definition's logPrefix and the attribute ID.

## Constructor Details

### ScriptedIdPAttributeImpl

public ScriptedIdPAttributeImpl(@Nonnull IdPAttribute attribute, @Nullable String prefix)
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

@Nullable @Live public Collection<Object> getValues() throws ResolutionException
Return all the values, but with `StringAttributeValue` values returned as strings.

This method is a helper method for V2 compatibility.

Specified by:
  `getValues` in interface `ScriptedIdPAttribute`
Returns:
  a modifiable collection of the string attributes (not the String
Throws:
  `ResolutionException` - if the script has called `getNativeAttribute()`

### getNativeAttribute

@Nonnull public IdPAttribute getNativeAttribute() throws ResolutionException
return the underlying attribute.

Specified by:
  `getNativeAttribute` in interface `ScriptedIdPAttribute`
Returns:
  the attribute
Throws:
  `ResolutionException` - if the script has called getValues.

### getId

@Nonnull @NotEmpty public String getId()
Get the encapsulated attributeId.

Specified by:
  `getId` in interface `ScriptedIdPAttribute`
Returns:
  the id

### addAsIdPAttributeValue

private void addAsIdPAttributeValue(@Nonnull List<IdPAttributeValue> values, @Nullable Object value)
Add the provided value to the provided list, converting `String` to `StringAttributeValue`.

Parameters:
  `values` - the list to add to.
  `value` - the value to add. Known to be a `String` or an `IdPAttributeValue`

### policeValueType

private void policeValueType(@Nullable Object what) throws ResolutionException
Check that provided object is of type `String` or `IdPAttributeValue`.

Parameters:
  `what` - value to check
Throws:
  `ResolutionException` - if there is a type conflict.

### addValue

public void addValue(@Nullable Object what) throws ResolutionException
Add the provided object to the attribute values, policing for type.

Specified by:
  `addValue` in interface `ScriptedIdPAttribute`
Parameters:
  `what` - a `String` or a `IdPAttributeValue` to 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. If `getValues()` 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