Package net.shibboleth.idp.saml.attribute.transcoding

# Class SAMLEncoderSupport

java.lang.Object
net.shibboleth.idp.saml.attribute.transcoding.SAMLEncoderSupport

public final class SAMLEncoderSupport extends Object
Support class for encoding IdP Attributes and their value.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final org.slf4j.Logger`
`LOG`
Class logger.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`SAMLEncoderSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static XMLObject`
`encodeByteArrayValue(IdPAttribute attribute, QName attributeValueElementName, byte[] value, boolean withType)`
Base64 encodes a `byte[]` into a SAML attribute value element.
`static XMLObject`
`encodeDateTimeValue(IdPAttribute attribute, QName attributeValueElementName, Instant value, boolean withType)`
Encodes a date/time value into a SAML attribute value element.
`static XMLObject`
`encodeScopedStringValueAttribute(IdPAttribute attribute, QName attributeValueElementName, ScopedStringAttributeValue value, String scopeAttributeName, boolean withType)`
Encode a `ScopedStringAttributeValue` value in to an SAML attribute value element using the (older Shibboleth) sytnax where the scope is inside an XML attribute.
`static XMLObject`
`encodeScopedStringValueInline(IdPAttribute attribute, QName attributeValueElementName, ScopedStringAttributeValue value, String scopeDelimiter, boolean withType)`
Encode a `ScopedStringAttributeValue` value into a SAML attribute value element using the "inline" syntax where the scope and value are combined into a string.
`static XMLObject`
`encodeStringValue(IdPAttribute attribute, QName attributeValueElementName, String value, boolean withType)`
Encodes a String value into a SAML attribute value element.
`static XMLObject`
`encodeXMLObjectValue(IdPAttribute attribute, QName attributeValueElementName, XMLObject value)`
Encodes an `XMLObject` value in to a `XSAny` SAML attribute value.

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

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

## Field Details

### LOG

@Nonnull private static final org.slf4j.Logger LOG
Class logger.

## Constructor Details

### SAMLEncoderSupport

private SAMLEncoderSupport()
Constructor.

## Method Details

### encodeStringValue

@Nullable public static XMLObject encodeStringValue(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable String value, boolean withType)
Encodes a String value into a SAML attribute value element.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the element name to create
  `value` - value to encoded
  `withType` - whether to include xsi:type
Returns:
  the attribute value element or null if the given value was null or empty

### encodeByteArrayValue

@Nullable public static XMLObject encodeByteArrayValue(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable byte[] value, boolean withType) throws EncodingException
Base64 encodes a `byte[]` into a SAML attribute value element.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the element name to create
  `value` - value to encoded
  `withType` - whether to include xsi:type
Returns:
  the attribute value element or null if the given value was null or empty
Throws:
  `EncodingException` - if the byte array can not be base64 encoded.

### encodeXMLObjectValue

@Nullable public static XMLObject encodeXMLObjectValue(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable XMLObject value)
Encodes an `XMLObject` value in to a `XSAny` SAML attribute value.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the SAML 1 or SAML 1 attribute name
  `value` - value to encoded
Returns:
  the attribute value element or null if the given value was null or empty

### encodeScopedStringValueAttribute

@Nullable public static XMLObject encodeScopedStringValueAttribute(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable ScopedStringAttributeValue value, @Nonnull @NotEmpty String scopeAttributeName, boolean withType)
Encode a `ScopedStringAttributeValue` value in to an SAML attribute value element using the (older Shibboleth) sytnax where the scope is inside an XML attribute.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the element name to create
  `value` - value to encoded
  `scopeAttributeName` - the name that the attribute will be given
  `withType` - whether to include xsi:type
Returns:
  the attribute value element or null if the given value was null or empty

### encodeScopedStringValueInline

@Nullable public static XMLObject encodeScopedStringValueInline(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable ScopedStringAttributeValue value, @Nonnull String scopeDelimiter, boolean withType)
Encode a `ScopedStringAttributeValue` value into a SAML attribute value element using the "inline" syntax where the scope and value are combined into a string.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the element name to create
  `value` - value to encoded
  `scopeDelimiter` - the delimiter to put between the value and the scope
  `withType` - whether to include xsi:type
Returns:
  the attribute value element or null if the given value was null or empty

### encodeDateTimeValue

@Nullable public static XMLObject encodeDateTimeValue(@Nonnull IdPAttribute attribute, @Nonnull QName attributeValueElementName, @Nullable Instant value, boolean withType)
Encodes a date/time value into a SAML attribute value element.

Parameters:
  `attribute` - attribute to be encoded
  `attributeValueElementName` - the element name to create
  `value` - value to encoded
  `withType` - whether to include xsi:type
Returns:
  the attribute value element or null if the given value was null or empty
Since:
  4.3.0