Change audience handling and validators to separate out entityID.
[shibboleth/sp.git] / shibsp / Application.h
index ae6e76f..9660e7a 100644 (file)
@@ -33,6 +33,7 @@
 # include <xmltooling/security/TrustEngine.h>
 #endif
 #include <xmltooling/io/HTTPRequest.h>
+#include <xmltooling/util/Threads.h>
 
 namespace shibsp {
     
@@ -41,11 +42,17 @@ namespace shibsp {
     class SHIBSP_API AttributeFilter;
     class SHIBSP_API AttributeResolver;
 #endif
+    class SHIBSP_API Attribute;
     class SHIBSP_API Handler;
     class SHIBSP_API ServiceProvider;
     class SHIBSP_API SessionInitiator;
     class SHIBSP_API SPRequest;
 
+#if defined (_MSC_VER)
+    #pragma warning( push )
+    #pragma warning( disable : 4251 )
+#endif
+
     /**
      * Interface to a Shibboleth Application instance.
      * 
@@ -59,23 +66,42 @@ namespace shibsp {
     {
         MAKE_NONCOPYABLE(Application);
     protected:
-        Application() {}
+        /**
+         * Constructor.
+         *
+         * @param sp    parent ServiceProvider instance
+         */
+        Application(const ServiceProvider* sp);
+        
+        /** Pointer to parent SP instance. */
+        const ServiceProvider* m_sp;
+
+        /** Shared lock for manipulating application state. */
+        mutable xmltooling::RWLock* m_lock;
+
+        /** Pairs of raw and normalized CGI header names to clear. */
+        mutable std::vector< std::pair<std::string,std::string> > m_unsetHeaders;
+
     public:
-        virtual ~Application() {}
+        virtual ~Application();
 
         /**
          * Returns the owning ServiceProvider instance.
          *
          * @return a locked ServiceProvider
          */
-        virtual const ServiceProvider& getServiceProvider() const=0;
+        const ServiceProvider& getServiceProvider() const {
+            return *m_sp;
+        }
 
         /**
          * Returns the Application's ID.
          * 
          * @return  the ID
          */        
-        virtual const char* getId() const=0;
+        virtual const char* getId() const {
+            return getString("id").second;
+        }
 
         /**
          * Returns a unique hash for the Application.
@@ -146,37 +172,36 @@ namespace shibsp {
         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
 
         /**
-         * Returns the set of audience values associated with this Application.
+         * Returns any additional audience values associated with this Application.
          * 
-         * @return set of audience values associated with the Application
+         * @return additional audience values associated with the Application, or NULL
          */
-        virtual const std::vector<const XMLCh*>& getAudiences() const=0;
+        virtual const std::vector<const XMLCh*>* getAudiences() const=0;
 #endif
 
         /**
          * Returns the designated notification URL, or an empty string if no more locations are specified.
          *
-         * @param request   SP request to use to fill in missing pieces of URL
+         * @param request   requested URL to use to fill in missing pieces of notification URL
          * @param front     true iff front channel notification is desired, false iff back channel is desired
          * @param index     zero-based index of URL to return
          * @return  the designated URL, or an empty string
          */
-        virtual std::string getNotificationURL(const xmltooling::HTTPRequest& request, bool front, unsigned int index) const=0;
+        virtual std::string getNotificationURL(const char* request, bool front, unsigned int index) const=0;
 
         /**
-         * Returns a set of attribute IDs to use as a REMOTE_USER value.
-         * <p>The first attribute with a value (and only a single value) will be used.
+         * Returns an array of attribute IDs to use as a REMOTE_USER value, in order of preference.
          *
-         * @return  a set of attribute IDs, or an empty set
+         * @return  an array of attribute IDs, possibly empty
          */
-        virtual const std::set<std::string>& getRemoteUserAttributeIds() const=0;
+        virtual const std::vector<std::string>& getRemoteUserAttributeIds() const=0;
 
         /**
          * Clears any headers that may be used to hold attributes after export.
          *
          * @param request   SP request to clear
          */
-        virtual void clearAttributeHeaders(SPRequest& request) const=0;
+        virtual void clearAttributeHeaders(SPRequest& request) const;
 
         /**
          * Returns the default SessionInitiator when automatically requesting a session.
@@ -227,7 +252,19 @@ namespace shibsp {
          * @return the mapped Handler, or NULL 
          */
         virtual const Handler* getHandler(const char* path) const=0;
+
+        /**
+         * Returns all registered Handlers.
+         *
+         * @param handlers  array to populate
+         */
+        virtual void getHandlers(std::vector<const Handler*>& handlers) const=0;
     };
+
+#if defined (_MSC_VER)
+    #pragma warning( pop )
+#endif
+
 };
 
 #endif /* __shibsp_app_h__ */