Class CopyNameIDFromRequest

  • All Implemented Interfaces:
    net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent, org.opensaml.profile.action.ProfileAction

    public class CopyNameIDFromRequest
    extends org.opensaml.profile.action.AbstractProfileAction
    Action that builds a NameID and adds it to the Subject of all the statements in all the assertions found in a Response. The message to update is returned by a lookup strategy, by default the message returned by InOutOperationContext.getOutboundMessageContext().

    No assertions or statements will be created by this action, but if no Subject exists in the statements found, it will be created.

    The source of the NameID is a SAMLSubjectNameIdentifierContext returned by a lookup strategy.

    Event:
    EventIds.PROCEED_EVENT_ID, EventIds.INVALID_MSG_CTX
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Logger log
      Class logger.
      private org.opensaml.saml.saml2.core.NameID nameId
      NameID to copy.
      private org.opensaml.saml.common.SAMLObjectBuilder<org.opensaml.saml.saml2.core.NameID> nameIdBuilder
      Builder for NameID objects.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.common.messaging.context.SAMLSubjectNameIdentifierContext> nameIdentifierContextLookupStrategy
      Strategy used to locate the name identifier context to copy from.
      private boolean overwriteExisting
      Flag controlling whether to overwrite an existing NameID.
      private org.opensaml.saml.saml2.core.Response response
      Response to modify.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.core.Response> responseLookupStrategy
      Strategy used to locate the Response to operate on.
      private org.opensaml.saml.common.SAMLObjectBuilder<org.opensaml.saml.saml2.core.Subject> subjectBuilder
      Builder for Subject objects.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.opensaml.saml.saml2.core.NameID cloneNameID()
      Create an efficient field-wise copy of a NameID.
      protected void doExecute​(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
      protected boolean doPreExecute​(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
      private org.opensaml.saml.saml2.core.Subject getAssertionSubject​(org.opensaml.saml.saml2.core.Assertion assertion)
      Get the subject to which the name identifier will be added.
      void setNameIDContextLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.common.messaging.context.SAMLSubjectNameIdentifierContext> strategy)
      Set the strategy used to locate the SAMLSubjectNameIdentifierContext to copy from.
      void setOverwriteExisting​(boolean flag)
      Set whether to overwrite any existing NameID objects found.
      void setResponseLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.core.Response> strategy)
      Set the strategy used to locate the Response to operate on.
      • Methods inherited from class org.opensaml.profile.action.AbstractProfileAction

        doPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletResponse, getLogPrefix, setHttpServletRequest, setHttpServletResponse
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent

        destroy, doDestroy, doInitialize, initialize, isDestroyed, isInitialized
      • Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent

        initialize, isInitialized
    • Field Detail

      • log

        @Nonnull
        private final Logger log
        Class logger.
      • subjectBuilder

        @Nonnull
        private final org.opensaml.saml.common.SAMLObjectBuilder<org.opensaml.saml.saml2.core.Subject> subjectBuilder
        Builder for Subject objects.
      • nameIdBuilder

        @Nonnull
        private final org.opensaml.saml.common.SAMLObjectBuilder<org.opensaml.saml.saml2.core.NameID> nameIdBuilder
        Builder for NameID objects.
      • overwriteExisting

        private boolean overwriteExisting
        Flag controlling whether to overwrite an existing NameID.
      • nameIdentifierContextLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.common.messaging.context.SAMLSubjectNameIdentifierContext> nameIdentifierContextLookupStrategy
        Strategy used to locate the name identifier context to copy from.
      • responseLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.core.Response> responseLookupStrategy
        Strategy used to locate the Response to operate on.
      • nameId

        @Nullable
        private org.opensaml.saml.saml2.core.NameID nameId
        NameID to copy.
      • response

        @Nullable
        private org.opensaml.saml.saml2.core.Response response
        Response to modify.
    • Constructor Detail

      • CopyNameIDFromRequest

        public CopyNameIDFromRequest()
        Constructor.
    • Method Detail

      • setOverwriteExisting

        public void setOverwriteExisting​(boolean flag)
        Set whether to overwrite any existing NameID objects found.
        Parameters:
        flag - true iff the action should overwrite any existing objects
      • setNameIDContextLookupStrategy

        public void setNameIDContextLookupStrategy​(@Nonnull
                                                   Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.common.messaging.context.SAMLSubjectNameIdentifierContext> strategy)
        Set the strategy used to locate the SAMLSubjectNameIdentifierContext to copy from.
        Parameters:
        strategy - lookup strategy
      • setResponseLookupStrategy

        public void setResponseLookupStrategy​(@Nonnull
                                              Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.core.Response> strategy)
        Set the strategy used to locate the Response to operate on.
        Parameters:
        strategy - lookup strategy
      • doPreExecute

        protected boolean doPreExecute​(@Nonnull
                                       org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
        Overrides:
        doPreExecute in class org.opensaml.profile.action.AbstractProfileAction
      • doExecute

        protected void doExecute​(@Nonnull
                                 org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
        Overrides:
        doExecute in class org.opensaml.profile.action.AbstractProfileAction
      • getAssertionSubject

        @Nonnull
        private org.opensaml.saml.saml2.core.Subject getAssertionSubject​(@Nonnull
                                                                         org.opensaml.saml.saml2.core.Assertion assertion)
        Get the subject to which the name identifier will be added.
        Parameters:
        assertion - the assertion being modified
        Returns:
        the assertion to which the name identifier will be added
      • cloneNameID

        @Nonnull
        private org.opensaml.saml.saml2.core.NameID cloneNameID()
        Create an efficient field-wise copy of a NameID.
        Returns:
        the copy