Class BasicAgent

All Implemented Interfaces:
Predicate<ProfileRequestContext>, RelyingPartyConfiguration, RelyingPartyConfigurationResolver, Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent, Resolver<RelyingPartyConfiguration,CriteriaSet>, Agent, Application

public class BasicAgent extends BasicApplication implements Agent
Basic implementation of an Agent.
  • Field Details

    • supportsCachedAuthentication

      private boolean supportsCachedAuthentication
      Whether cached authentication is supported.
    • allowedAddressRanges

      @Nonnull private Set<IPRange> allowedAddressRanges
      Allowed address ranges.
    • authenticationMethod

      @Nullable @NotEmpty String authenticationMethod
      Authentication method.
    • supportsPostPreservation

      private boolean supportsPostPreservation
      Whether to support form submission preservation and recovery.
    • postLimit

      private long postLimit
      Limit on size of form data to preserve.
    • encoding

      @Nonnull private Charset encoding
      Character set encoding for POST recovery.
    • credentials

      @Nonnull private Map<String,String> credentials
      Internally configured shared secrets.
    • applicationMap

      @Nonnull private Map<String,Application> applicationMap
      Application map.
  • Constructor Details

  • Method Details

    • getApplicationId

      @Nonnull @NotEmpty public String getApplicationId()
      Dedicated method to access application ID for explicitness.
      Specified by:
      getApplicationId in interface Application
      Overrides:
      getApplicationId in class BasicApplication
      Returns:
      application ID
    • getAllowedAddressRanges

      @Nonnull public Set<IPRange> getAllowedAddressRanges()
      Get the network addresses or ranges of addresses from which requests from this agent may originate.
      Specified by:
      getAllowedAddressRanges in interface Agent
      Returns:
      set of address ranges
    • setAllowedAddressRanges

      public void setAllowedAddressRanges(@Nullable Set<IPRange> ranges)
      Set the network ranges from which this agent may make requests.
      Parameters:
      ranges - allowed ranges
    • isAllowed

      public boolean isAllowed(@Nonnull InetAddress address)
      Returns true iff the supplied address matches one of the allowed ranges.
      Specified by:
      isAllowed in interface Agent
      Parameters:
      address - address to test
      Returns:
      true iff the supplied address matches one of the allowed ranges
    • getAuthenticationMethod

      @Nullable @NotEmpty public String getAuthenticationMethod()
      Get the authentication method to use for the agent.

      Authentication methods are in addition to address restrictions.

      The only currently defined value is Agent.AUTH_METHOD_BASIC.

      Specified by:
      getAuthenticationMethod in interface Agent
      Returns:
      authentication method/type, null for none
    • setAuthenticationMethod

      public void setAuthenticationMethod(@Nullable @NotEmpty String method)
      Set the authentication method to require for this agent.

      Defaults to Agent.AUTH_METHOD_BASIC.

      Parameters:
      method - method identifier
    • getCredentials

      @Nonnull @NotLive @Unmodifiable public Map<String,String> getCredentials()
      Get the credentials configured to authenticate requests from this Agent.

      The map keys expose the "identifiers" usable by the Agent when authenticating itself (service account username(s) in other words). The values MAY be null in the case that actual authentication is handled using LDAP, Kerberos, etc., but MAY be populated for direct configuration of shared secrets.

      If a map key is null, then the Agent's unique ID can be used as a "username".

      Specified by:
      getCredentials in interface Agent
      Returns:
      set of username/shared secret mappings, either of which may be null
    • setCredentials

      public void setCredentials(@Nullable Map<String,String> creds)
      Sets the credentials to store directly in this Agent.

      A null key may be used to fall back to AbstractIdentifiedInitializableComponent.getId(), while a null value may be used to signify an "external" authentication mechanism be used.

      Parameters:
      creds - mappings of username/secret pairs to accept
    • setUsernames

      public void setUsernames(@Nullable Collection<String> usernames)
      Sets the usernames to use for this Agent, implying that the passwords are maintained externally.
      Parameters:
      usernames - usernames for Agent authentication
    • isSupportsCachedAuthentication

      public boolean isSupportsCachedAuthentication()
      Returns true iff the agent supports cached authentication via cookie.
      Specified by:
      isSupportsCachedAuthentication in interface Agent
      Returns:
      true iff the agent supports cached authentication via cookie
    • setSupportsCachedAuthentication

      public void setSupportsCachedAuthentication(boolean flag)
      Sets whether this agent supports cached authentication via cookie.

      Defaults to true.

      Parameters:
      flag - flag to set
    • isSupportsPostPreservation

      public boolean isSupportsPostPreservation()
      Returns true iff the agent is permitted to submit form data to preserve during SSO.

      Defaults to false.

      Specified by:
      isSupportsPostPreservation in interface Agent
      Returns:
      true iff the agent is permitted to submit form data to preserve
    • setSupportsPostPreservation

      public void setSupportsPostPreservation(boolean flag)
      Sets whether agent is permitted to submit form data for preservation during SSO.
      Parameters:
      flag - flag to set
    • getPostLimit

      public long getPostLimit()
      Gets the size limit to apply to form data preservation attempts.

      The default is 1024 * 1024.

      Zero indicates no inherent limit.

      Specified by:
      getPostLimit in interface Agent
      Returns:
      size limit for form data preservation
    • setPostLimit

      public void setPostLimit(@NonNegative long limit)
      Sets limit on size of form data to preserve.
      Parameters:
      limit - size limit or 0 for none
    • getCharacterEncoding

      @Nonnull public Charset getCharacterEncoding()
      Gets the character encoding to apply during URI processing and POST recovery.

      Defaults to UTF-8.

      Specified by:
      getCharacterEncoding in interface Agent
      Returns:
      name of encoding
    • setCharacterEncoding

      public void setCharacterEncoding(@Nonnull String name)
      Sets the character encoding to apply for POST recovery.
      Parameters:
      name - name of encoding
    • setApplications

      public void setApplications(@Nullable Set<Application> applications)
      Sets the Application instances associated with this agent.
      Parameters:
      applications - applications associated with this agent
    • getApplication

      @Nullable public Application getApplication(@Nonnull String id)
      Get an Application associated with this agent.
      Specified by:
      getApplication in interface Agent
      Parameters:
      id - application id
      Returns:
      the corresponding application or null
    • getApplications

      @Nonnull public Collection<Application> getApplications()
      Get all Application instances associated with this agent.
      Specified by:
      getApplications in interface Agent
      Returns:
      collection of applications
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class BasicApplication
      Throws:
      ComponentInitializationException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BasicApplication
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class BasicApplication
    • toString

      public String toString()
      Overrides:
      toString in class BasicApplication