Class AbstractEncryptAction

  • 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
    Direct Known Subclasses:
    EncryptAssertions, EncryptAttributes, EncryptNameIDs

    public abstract class AbstractEncryptAction
    extends org.opensaml.profile.action.AbstractConditionalProfileAction
    Abstract base class for actions that perform simple unicast SAML encryption to a single decrypting party.

    The EncryptionContext governing the encryption process is located by a lookup strategy, by default a child of the outbound message context.

    An optional recipient name is also obtained from a lookup strategy.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.opensaml.saml.saml2.encryption.Encrypter encrypter
      The encryption object.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.profile.context.EncryptionContext> encryptionCtxLookupStrategy
      Strategy used to locate the EncryptionContext.
      private Predicate<org.opensaml.profile.context.ProfileRequestContext> encryptToSelf
      Predicate used to determine whether to perform encrypt-to-self.
      private Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.xmlsec.EncryptionParameters>,​List<org.opensaml.xmlsec.EncryptionParameters>> encryptToSelfParametersStrategy
      Strategy used to resolve the encrypt-to-self parameters.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.encryption.Encrypter.KeyPlacement> keyPlacementLookupStrategy
      Strategy used to determine encrypted key placement.
      private org.slf4j.Logger log
      Class logger.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​String> recipientLookupStrategy
      Strategy used to locate the encryption recipient.
      private Function<org.opensaml.profile.context.ProfileRequestContext,​String> selfRecipientLookupStrategy
      Strategy used to obtain the self recipient value.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean doPreExecute​(org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
      protected abstract org.opensaml.xmlsec.EncryptionParameters getApplicableParameters​(org.opensaml.saml.saml2.profile.context.EncryptionContext ctx)
      Return the right set of parameters for the operation to be performed, or none if no encryption should occur.
      org.opensaml.saml.saml2.encryption.Encrypter getEncrypter()
      Get the encrypter.
      void setEncryptionContextLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.profile.context.EncryptionContext> strategy)
      Set the strategy used to locate the EncryptionContext associated with a given ProfileRequestContext.
      void setEncryptToSelf​(Predicate<org.opensaml.profile.context.ProfileRequestContext> predicate)
      Set the predicate used to determine whether to perform encrypt-to-self.
      void setEncryptToSelfParametersStrategy​(Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.xmlsec.EncryptionParameters>,​List<org.opensaml.xmlsec.EncryptionParameters>> strategy)
      Set the strategy used to resolve the encrypt-to-self parameters.
      void setKeyPlacementLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.encryption.Encrypter.KeyPlacement> strategy)
      Set the strategy used to determine the encrypted key placement strategy.
      void setRecipientLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​String> strategy)
      Set the strategy used to locate the encryption recipient.
      void setSelfRecipientLookupStrategy​(Function<org.opensaml.profile.context.ProfileRequestContext,​String> strategy)
      Set the strategy used to locate the self identity value to use.
      • Methods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction

        getActivationCondition, setActivationCondition
      • Methods inherited from class org.opensaml.profile.action.AbstractProfileAction

        doExecute, 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 org.slf4j.Logger log
        Class logger.
      • encryptionCtxLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.profile.context.EncryptionContext> encryptionCtxLookupStrategy
        Strategy used to locate the EncryptionContext.
      • recipientLookupStrategy

        @Nullable
        private Function<org.opensaml.profile.context.ProfileRequestContext,​String> recipientLookupStrategy
        Strategy used to locate the encryption recipient.
      • keyPlacementLookupStrategy

        @Nonnull
        private Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.encryption.Encrypter.KeyPlacement> keyPlacementLookupStrategy
        Strategy used to determine encrypted key placement.
      • encryptToSelf

        @Nonnull
        private Predicate<org.opensaml.profile.context.ProfileRequestContext> encryptToSelf
        Predicate used to determine whether to perform encrypt-to-self.
      • encryptToSelfParametersStrategy

        @Nullable
        private Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.xmlsec.EncryptionParameters>,​List<org.opensaml.xmlsec.EncryptionParameters>> encryptToSelfParametersStrategy
        Strategy used to resolve the encrypt-to-self parameters.
      • selfRecipientLookupStrategy

        @Nullable
        private Function<org.opensaml.profile.context.ProfileRequestContext,​String> selfRecipientLookupStrategy
        Strategy used to obtain the self recipient value.
      • encrypter

        @Nullable
        private org.opensaml.saml.saml2.encryption.Encrypter encrypter
        The encryption object.
    • Constructor Detail

      • AbstractEncryptAction

        public AbstractEncryptAction()
        Constructor.
    • Method Detail

      • setEncryptionContextLookupStrategy

        public void setEncryptionContextLookupStrategy​(@Nonnull
                                                       Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.profile.context.EncryptionContext> strategy)
        Set the strategy used to locate the EncryptionContext associated with a given ProfileRequestContext.
        Parameters:
        strategy - lookup strategy
      • setRecipientLookupStrategy

        public void setRecipientLookupStrategy​(@Nonnull
                                               Function<org.opensaml.profile.context.ProfileRequestContext,​String> strategy)
        Set the strategy used to locate the encryption recipient.
        Parameters:
        strategy - lookup strategy
      • setKeyPlacementLookupStrategy

        public void setKeyPlacementLookupStrategy​(@Nonnull
                                                  Function<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.saml.saml2.encryption.Encrypter.KeyPlacement> strategy)
        Set the strategy used to determine the encrypted key placement strategy.
        Parameters:
        strategy - lookup strategy
      • setEncryptToSelf

        public void setEncryptToSelf​(@Nonnull
                                     Predicate<org.opensaml.profile.context.ProfileRequestContext> predicate)
        Set the predicate used to determine whether to perform encrypt-to-self.
        Parameters:
        predicate - the encrypt-to-self predicate
      • setEncryptToSelfParametersStrategy

        public void setEncryptToSelfParametersStrategy​(@Nullable
                                                       Function<net.shibboleth.utilities.java.support.collection.Pair<org.opensaml.profile.context.ProfileRequestContext,​org.opensaml.xmlsec.EncryptionParameters>,​List<org.opensaml.xmlsec.EncryptionParameters>> strategy)
        Set the strategy used to resolve the encrypt-to-self parameters.
        Parameters:
        strategy - the encrypt-to-self predicate
      • setSelfRecipientLookupStrategy

        public void setSelfRecipientLookupStrategy​(@Nullable
                                                   Function<org.opensaml.profile.context.ProfileRequestContext,​String> strategy)
        Set the strategy used to locate the self identity value to use.
        Parameters:
        strategy - lookup strategy
      • getEncrypter

        @Nullable
        public org.opensaml.saml.saml2.encryption.Encrypter getEncrypter()
        Get the encrypter.
        Returns:
        the encrypter
      • doPreExecute

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

        @Nullable
        protected abstract org.opensaml.xmlsec.EncryptionParameters getApplicableParameters​(@Nullable
                                                                                            org.opensaml.saml.saml2.profile.context.EncryptionContext ctx)
        Return the right set of parameters for the operation to be performed, or none if no encryption should occur.
        Parameters:
        ctx - possibly null input context to pull parameters from
        Returns:
        the right parameter set, or null for none