Use shibboleth-sp as package name for compatibility.
[shibboleth/cpp-sp.git] / shibsp / Application.h
index cfd38e7..dde11f2 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2001-2009 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
 
 #include <shibsp/util/PropertySet.h>
 
-#include <set>
+#include <string>
+#include <vector>
 #ifndef SHIBSP_LITE
 # include <saml/binding/MessageEncoder.h>
-# include <saml/saml2/metadata/MetadataProvider.h>
-# include <xmltooling/security/CredentialResolver.h>
-# include <xmltooling/security/TrustEngine.h>
 #endif
-#include <xmltooling/io/HTTPRequest.h>
-#include <xmltooling/util/Threads.h>
+
+namespace xmltooling {
+    class XMLTOOL_API CredentialResolver;
+    class XMLTOOL_API GenericRequest;
+    class XMLTOOL_API RWLock;
+    class XMLTOOL_API SOAPTransport;
+    class XMLTOOL_API StorageService;
+    class XMLTOOL_API TrustEngine;
+};
+
+#ifndef SHIBSP_LITE
+namespace opensaml {
+    class SAML_API SecurityPolicyRule;
+    namespace saml2md {
+        class SAML_API MetadataProvider;
+    };
+};
+#endif
 
 namespace shibsp {
 
@@ -90,18 +108,14 @@ namespace shibsp {
          *
          * @return a locked ServiceProvider
          */
-        const ServiceProvider& getServiceProvider() const {
-            return *m_sp;
-        }
+        const ServiceProvider& getServiceProvider() const;
 
         /**
          * Returns the Application's ID.
          *
          * @return  the ID
          */
-        virtual const char* getId() const {
-            return getString("id").second;
-        }
+        virtual const char* getId() const;
 
         /**
          * Returns a unique hash for the Application.
@@ -117,14 +131,14 @@ namespace shibsp {
          * @param lifetime  if non-null, will be populated with a suggested lifetime for the cookie, or 0 if session-bound
          * @return  a pair containing the cookie name and the string to append to the cookie value
          */
-        virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime=NULL) const;
+        virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix, time_t* lifetime=nullptr) const;
 
 #ifndef SHIBSP_LITE
         /**
          * Returns a MetadataProvider for use with this Application.
          *
          * @param required  true iff an exception should be thrown if no MetadataProvider is available
-         * @return  a MetadataProvider instance, or NULL
+         * @return  a MetadataProvider instance, or nullptr
          */
         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
 
@@ -132,35 +146,35 @@ namespace shibsp {
          * Returns a TrustEngine for use with this Application.
          *
          * @param required  true iff an exception should be thrown if no TrustEngine is available
-         * @return  a TrustEngine instance, or NULL
+         * @return  a TrustEngine instance, or nullptr
          */
         virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
 
         /**
          * Returns an AttributeExtractor for use with this Application.
          *
-         * @return  an AttributeExtractor, or NULL
+         * @return  an AttributeExtractor, or nullptr
          */
         virtual AttributeExtractor* getAttributeExtractor() const=0;
 
         /**
          * Returns an AttributeFilter for use with this Application.
          *
-         * @return  an AttributeFilter, or NULL
+         * @return  an AttributeFilter, or nullptr
          */
         virtual AttributeFilter* getAttributeFilter() const=0;
 
         /**
          * Returns an AttributeResolver for use with this Application.
          *
-         * @return  an AttributeResolver, or NULL
+         * @return  an AttributeResolver, or nullptr
          */
         virtual AttributeResolver* getAttributeResolver() const=0;
 
         /**
          * Returns the CredentialResolver instance associated with this Application.
          *
-         * @return  a CredentialResolver, or NULL
+         * @return  a CredentialResolver, or nullptr
          */
         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
 
@@ -184,7 +198,7 @@ namespace shibsp {
          * @deprecated
          * Returns any additional audience values associated with this Application.
          *
-         * @return additional audience values associated with the Application, or NULL
+         * @return additional audience values associated with the Application, or nullptr
          */
         virtual const std::vector<const XMLCh*>* getAudiences() const=0;
 #endif
@@ -243,7 +257,7 @@ namespace shibsp {
         /**
          * Returns the default SessionInitiator when automatically requesting a session.
          *
-         * @return the default SessionInitiator, or NULL
+         * @return the default SessionInitiator, or nullptr
          */
         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
 
@@ -251,7 +265,7 @@ namespace shibsp {
          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
          *
          * @param id    an identifier unique to the Application
-         * @return the designated SessionInitiator, or NULL
+         * @return the designated SessionInitiator, or nullptr
          */
         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
 
@@ -259,7 +273,7 @@ namespace shibsp {
          * Returns the default AssertionConsumerService Handler
          * for use in AuthnRequest messages.
          *
-         * @return the default AssertionConsumerService, or NULL
+         * @return the default AssertionConsumerService, or nullptr
          */
         virtual const Handler* getDefaultAssertionConsumerService() const=0;
 
@@ -268,11 +282,22 @@ namespace shibsp {
          * for use in AuthnRequest messages.
          *
          * @param index an index unique to an application
-         * @return the designated AssertionConsumerService, or NULL
+         * @return the designated AssertionConsumerService, or nullptr
          */
         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
 
         /**
+         * Returns an AssertionConsumerService Handler that supports
+         * a particular protocol "family" and optional binding.
+         *
+         * @param protocol  a protocol identifier
+         * @param binding   a binding identifier
+         * @return a matching AssertionConsumerService, or nullptr
+         */
+        virtual const Handler* getAssertionConsumerServiceByProtocol(const XMLCh* protocol, const char* binding=nullptr) const;
+
+        /**
+         * @deprecated
          * Returns one or more AssertionConsumerService Handlers that support
          * a particular protocol binding.
          *
@@ -286,7 +311,7 @@ namespace shibsp {
          *
          * @param path  the PATH_INFO appended to the end of a base Handler location
          *              that invokes the Handler
-         * @return the mapped Handler, or NULL
+         * @return the mapped Handler, or nullptr
          */
         virtual const Handler* getHandler(const char* path) const=0;
 
@@ -296,6 +321,16 @@ namespace shibsp {
          * @param handlers  array to populate
          */
         virtual void getHandlers(std::vector<const Handler*>& handlers) const=0;
+
+        /**
+         * Checks a proposed redirect URL against application-specific settings for legal redirects,
+         * such as same-host restrictions or whitelisted domains, and raises a SecurityPolicyException
+         * in the event of a violation.
+         *
+         * @param request   the request leading to the redirect
+         * @param url       an absolute URL to validate
+         */
+        virtual void limitRedirect(const xmltooling::GenericRequest& request, const char* url) const;
     };
 
 #if defined (_MSC_VER)