Class AttributeConsumingServiceSelector
- java.lang.Object
-
- org.opensaml.saml.metadata.support.AttributeConsumingServiceSelector
-
public class AttributeConsumingServiceSelector extends Object
Metadata support class which selects anAttributeConsumingService
based on input of a mandatoryRoleDescriptor
and an optional index.This implementation supports selecting an AttributeConsumingService from parent role descriptors of the following types:
- the standard SAML 2 metadata type
SPSSODescriptor
- the extension type
AttributeQueryDescriptorType
Subclasses should override
getCandidates()
if support for additional sources of attribute consuming services is needed.The selection algorithm is:
- If an index is supplied, the service with that index is returned. If no such service exists in metadata: if
isOnBadIndexUseDefault()
is true, then the default service is returned as described below; otherwise null is returned. - If an index is not supplied, then the default service is returned as follows: The service with an explicit isDefault of true is returned. If no such service exists, then the first service without an explicit isDefault is returned. If no service is yet selected, then the first service listed in metadata is returned.
- the standard SAML 2 metadata type
-
-
Field Summary
Fields Modifier and Type Field Description private Integer
index
The requested service index.private org.slf4j.Logger
log
Class logger.private boolean
onBadIndexUseDefault
Flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService.private RoleDescriptor
roleDescriptor
The AttributeConsumingService's parent role descriptor.
-
Constructor Summary
Constructors Constructor Description AttributeConsumingServiceSelector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<AttributeConsumingService>
getCandidates()
Get the list of candidate attribute consuming services.Integer
getIndex()
Get the index of the desired service.RoleDescriptor
getRoleDescriptor()
Get the AttributeConsumingServie's parent RoleDescriptor.boolean
isOnBadIndexUseDefault()
Get the flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService.private AttributeConsumingService
selectByIndex(List<AttributeConsumingService> candidates)
Select the service based on the index value.private AttributeConsumingService
selectDefault(List<AttributeConsumingService> candidates)
Select the default service.AttributeConsumingService
selectService()
Select the AttributeConsumingService.void
setIndex(Integer requestedIndex)
Set the index of the desired service.void
setOnBadIndexUseDefault(boolean flag)
Set the flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService.void
setRoleDescriptor(RoleDescriptor descriptor)
Set the AttributeConsumingServie's parent RoleDescriptor.
-
-
-
Field Detail
-
log
private org.slf4j.Logger log
Class logger.
-
index
private Integer index
The requested service index.
-
roleDescriptor
private RoleDescriptor roleDescriptor
The AttributeConsumingService's parent role descriptor.
-
onBadIndexUseDefault
private boolean onBadIndexUseDefault
Flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService.
-
-
Method Detail
-
getIndex
public Integer getIndex()
Get the index of the desired service.- Returns:
- Returns the index.
-
setIndex
public void setIndex(Integer requestedIndex)
Set the index of the desired service.- Parameters:
requestedIndex
- The index to set.
-
getRoleDescriptor
public RoleDescriptor getRoleDescriptor()
Get the AttributeConsumingServie's parent RoleDescriptor.- Returns:
- Returns the spSSODescriptor.
-
setRoleDescriptor
public void setRoleDescriptor(RoleDescriptor descriptor)
Set the AttributeConsumingServie's parent RoleDescriptor.- Parameters:
descriptor
- The roleDescriptor to set.
-
setOnBadIndexUseDefault
public void setOnBadIndexUseDefault(boolean flag)
Set the flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService. Defaults to false.- Parameters:
flag
- The onBadIndexUseDefault to set.
-
isOnBadIndexUseDefault
public boolean isOnBadIndexUseDefault()
Get the flag which determines whether, in the case of an invalid index, to return the default AttributeConsumingService. Defaults to false.- Returns:
- Returns the onBadIndexUseDefault.
-
selectService
public AttributeConsumingService selectService()
Select the AttributeConsumingService.- Returns:
- the selected AttributeConsumingService, or null
-
getCandidates
protected List<AttributeConsumingService> getCandidates()
Get the list of candidate attribute consuming services.This implementation supports selecting an AttributeConsumingService from parent role descriptors of the following types:
- the standard SAML 2 metadata type
SPSSODescriptor
- the extension type
AttributeQueryDescriptorType
Subclasses should override if support for additional sources of attribute consuming services is needed.
- Returns:
- the list of candidate AttributeConsumingServices, or null if none could be resolved
- the standard SAML 2 metadata type
-
selectByIndex
private AttributeConsumingService selectByIndex(List<AttributeConsumingService> candidates)
Select the service based on the index value.- Parameters:
candidates
- the list of candiate services- Returns:
- the selected candidate or null
-
selectDefault
private AttributeConsumingService selectDefault(List<AttributeConsumingService> candidates)
Select the default service.- Parameters:
candidates
- the list of candiate services- Returns:
- the selected candidate or null
-
-