Redesign condition and profile processing based on new policy rules. Fix element...
[shibboleth/cpp-sp.git] / shibsp / handler / AssertionConsumerService.h
index 90d363d..752e86c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -62,30 +62,71 @@ namespace shibsp {
          * @param log   a logging object to use
          */
         AssertionConsumerService(const xercesc::DOMElement* e, const char* appId, xmltooling::logging::Category& log);
+
+        /**
+         * Enforce address checking requirements.
+         * 
+         * @param application   reference to application receiving message
+         * @param httpRequest   client request that initiated session
+         * @param issuedTo      address for which security assertion was issued
+         */
+        void checkAddress(const Application& application, const xmltooling::HTTPRequest& httpRequest, const char* issuedTo) const;
         
 #ifndef SHIBSP_LITE
+        void generateMetadata(opensaml::saml2md::SPSSODescriptor& role, const char* handlerURL) const;
+        
+        /**
+         * Returns a SecurityPolicy instance to use for an incoming request.
+         *
+         * <p>Allows handlers to customize the type of policy object their policy rules might require.
+         * <p>The caller <strong>MUST</strong> lock the application's MetadataProvider for the life
+         * of the returned object.
+         *
+         * @param application   reference to application receiving message
+         * @param role          identifies the role (generally IdP or SP) of the policy peer
+         * @param validate      true iff XML parsing should be done with validation
+         * @param policyId      identifies policy rules to auto-attach, defaults to the application's set
+         * @return  a new policy instance, which the caller is responsible for freeing
+         */
+        virtual opensaml::SecurityPolicy* createSecurityPolicy(
+            const Application& application, const xmltooling::QName* role, bool validate, const char* policyId
+            ) const;
+
         /**
          * Implement protocol-specific handling of the incoming decoded message.
          * 
          * <p>The result of implementing the protocol should be an exception or
-         * the key to a newly created session.
+         * modifications to the request/response objects to reflect processing
+         * of the message.
          * 
          * @param application   reference to application receiving message
          * @param httpRequest   client request that included message
+         * @param httpResponse  response to client
          * @param policy        the SecurityPolicy in effect, after having evaluated the message
          * @param settings      policy configuration settings in effect
          * @param xmlObject     a protocol-specific message object
-         * @return  the key to the newly created session
          */
-        virtual std::string implementProtocol(
+        virtual void implementProtocol(
             const Application& application,
             const xmltooling::HTTPRequest& httpRequest,
+            xmltooling::HTTPResponse& httpResponse,
             opensaml::SecurityPolicy& policy,
             const PropertySet* settings,
             const xmltooling::XMLObject& xmlObject
             ) const=0;
 
         /**
+         * Extracts policy-relevant assertion details.
+         * 
+         * @param assertion the incoming assertion
+         * @param protocol  the protocol family in use
+         * @param policy    SecurityPolicy to provide various components and track message data
+         */
+        virtual void extractMessageDetails(
+            const opensaml::Assertion& assertion, const XMLCh* protocol, opensaml::SecurityPolicy& policy
+            ) const;
+
+        /**
          * Attempt SSO-initiated attribute resolution using the supplied information,
          * including NameID and token extraction and filtering followed by
          * secondary resolution.
@@ -111,32 +152,29 @@ namespace shibsp {
             const XMLCh* authncontext_decl=NULL,
             const std::vector<const opensaml::Assertion*>* tokens=NULL
             ) const;
+
+    public:
+        const char* getType() const {
+            return "AssertionConsumerService";
+        }
+
 #endif
-        
-        /**
-         * Enforce address checking requirements.
-         * 
-         * @param application   reference to application receiving message
-         * @param httpRequest   client request that initiated session
-         * @param issuedTo      address for which security assertion was issued
-         */
-        void checkAddress(
-            const Application& application, const xmltooling::HTTPRequest& httpRequest, const char* issuedTo
+    private:
+        std::pair<bool,long> processMessage(
+            const Application& application, const xmltooling::HTTPRequest& httpRequest, xmltooling::HTTPResponse& httpResponse
             ) const;
         
-    private:
-        std::string processMessage(
+        std::pair<bool,long> sendRedirect(
             const Application& application,
-            xmltooling::HTTPRequest& httpRequest,
-            std::string& entityID,
-            std::string& relayState
+            const xmltooling::HTTPRequest& request,
+            xmltooling::HTTPResponse& response,
+            const char* entityID,
+            const char* relayState
             ) const;
-            
-        std::pair<bool,long> sendRedirect(
-            SPRequest& request, const char* key, const char* entityID, const char* relayState
+
+        void maintainHistory(
+            const Application& application, const xmltooling::HTTPRequest& request, xmltooling::HTTPResponse& response, const char* entityID
             ) const;
-        
-        void maintainHistory(SPRequest& request, const char* entityID, const char* cookieProps) const;
                 
 #ifndef SHIBSP_LITE
         opensaml::MessageDecoder* m_decoder;