Class AttributeConsumingServiceSelector

java.lang.Object
org.opensaml.saml.metadata.support.AttributeConsumingServiceSelector

public class AttributeConsumingServiceSelector
extends Object
Metadata support class which selects an AttributeConsumingService based on input of a mandatory RoleDescriptor and an optional index.

This implementation supports selecting an AttributeConsumingService from parent role descriptors of the following types:

  1. the standard SAML 2 metadata type SPSSODescriptor
  2. the extension type AttributeQueryDescriptorType

Subclasses should override getCandidates() if support for additional sources of attribute consuming services is needed.

The selection algorithm is:

  1. 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.
  2. 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.
  • Field Details

    • 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.
  • Constructor Details

    • AttributeConsumingServiceSelector

      public AttributeConsumingServiceSelector()
  • Method Details

    • 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:

      1. the standard SAML 2 metadata type SPSSODescriptor
      2. 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
    • 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