From: Scott Cantor Date: Sat, 19 May 2007 18:07:08 +0000 (+0000) Subject: Moved request/response APIs out. X-Git-Tag: 2.0-alpha1~16 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-opensaml.git;a=commitdiff_plain;h=058cbd0d0333f2c1b019c9efc51293514ec799a2 Moved request/response APIs out. --- diff --git a/saml/Makefile.am b/saml/Makefile.am index a922c78..6d59ef0 100644 --- a/saml/Makefile.am +++ b/saml/Makefile.am @@ -38,10 +38,6 @@ libsamlinclude_HEADERS = \ samlbindinclude_HEADERS = \ binding/ArtifactMap.h \ - binding/GenericRequest.h \ - binding/GenericResponse.h \ - binding/HTTPRequest.h \ - binding/HTTPResponse.h \ binding/MessageDecoder.h \ binding/MessageEncoder.h \ binding/SAMLArtifact.h \ diff --git a/saml/SAMLConfig.cpp b/saml/SAMLConfig.cpp index 570ba1a..49869c2 100644 --- a/saml/SAMLConfig.cpp +++ b/saml/SAMLConfig.cpp @@ -67,6 +67,7 @@ extern "C" void SAML_API xmltooling_extension_term() } DECL_XMLTOOLING_EXCEPTION_FACTORY(ArtifactException,opensaml); +DECL_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml); DECL_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md); DECL_XMLTOOLING_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md); DECL_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml); @@ -108,6 +109,7 @@ bool SAMLInternalConfig::init(bool initXMLTooling) } REGISTER_XMLTOOLING_EXCEPTION_FACTORY(ArtifactException,opensaml); + REGISTER_XMLTOOLING_EXCEPTION_FACTORY(SecurityPolicyException,opensaml); REGISTER_XMLTOOLING_EXCEPTION_FACTORY(MetadataException,opensaml::saml2md); REGISTER_XMLTOOLING_EXCEPTION_FACTORY(MetadataFilterException,opensaml::saml2md); REGISTER_XMLTOOLING_EXCEPTION_FACTORY(BindingException,opensaml); diff --git a/saml/binding/GenericRequest.h b/saml/binding/GenericRequest.h deleted file mode 100644 index 5bca3d0..0000000 --- a/saml/binding/GenericRequest.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2001-2007 Internet2 - * - * 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 - * - * 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. - */ - -/** - * @file saml/binding/GenericRequest.h - * - * Interface to generic protocol requests that transport SAML messages. - */ - -#ifndef __saml_genreq_h__ -#define __saml_genreq_h__ - -#include -#include -#include -#include - -namespace opensaml { - - /** - * Interface to caller-supplied shim for accessing generic transport - * request context. - * - *

This interface need not be threadsafe. - */ - class SAML_API GenericRequest { - MAKE_NONCOPYABLE(GenericRequest); - protected: - GenericRequest() {} - public: - virtual ~GenericRequest() {} - - /** - * Returns the URL scheme of the request (http, https, ftp, ldap, etc.) - * - * @return the URL scheme - */ - virtual const char* getScheme() const=0; - - /** - * Returns true iff the request is over a confidential channel. - * - * @return confidential channel indicator - */ - virtual bool isSecure() const=0; - - /** - * Returns hostname of service that received request. - * - * @return hostname of service - */ - virtual const char* getHostname() const=0; - - /** - * Returns incoming port. - * - * @return incoming port - */ - virtual int getPort() const=0; - - /** - * Returns the MIME type of the request, if known. - * - * @return the MIME type, or an empty string - */ - virtual std::string getContentType() const=0; - - /** - * Returns the length of the request body, if known. - * - * @return the content length, or -1 if unknown - */ - virtual long getContentLength() const=0; - - /** - * Returns the raw request body. - * - * @return the request body, or NULL - */ - virtual const char* getRequestBody() const=0; - - /** - * Returns a decoded named parameter value from the request. - * If a parameter has multiple values, only one will be returned. - * - * @param name the name of the parameter to return - * @return a single parameter value or NULL - */ - virtual const char* getParameter(const char* name) const=0; - - /** - * Returns all of the decoded values of a named parameter from the request. - * All values found will be returned. - * - * @param name the name of the parameter to return - * @param values a vector in which to return pointers to the decoded values - * @return the number of values returned - */ - virtual std::vector::size_type getParameters( - const char* name, std::vector& values - ) const=0; - - /** - * Returns the transport-authenticated identity associated with the request, - * if authentication is solely handled by the transport. - * - * @return the authenticated username or an empty string - */ - virtual std::string getRemoteUser() const=0; - - /** - * Returns the IP address of the client. - * - * @return the client's IP address - */ - virtual std::string getRemoteAddr() const=0; - - /** - * Returns the chain of certificates sent by the client. - * They are not guaranteed to be valid according to any particular definition. - * - * @return the client's certificate chain - */ - virtual const std::vector& getClientCertificates() const=0; - }; -}; - -#endif /* __saml_genreq_h__ */ diff --git a/saml/binding/GenericResponse.h b/saml/binding/GenericResponse.h deleted file mode 100644 index 69830a9..0000000 --- a/saml/binding/GenericResponse.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2001-2007 Internet2 - * - * 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 - * - * 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. - */ - -/** - * @file saml/binding/GenericResponse.h - * - * Interface to generic protocol responses that transport SAML messages. - */ - -#ifndef __saml_genres_h__ -#define __saml_genres_h__ - -#include -#include - -namespace opensaml { - - /** - * Interface to caller-supplied shim for accessing generic transport - * request context. - * - *

This interface need not be threadsafe. - */ - class SAML_API GenericResponse { - MAKE_NONCOPYABLE(GenericResponse); - protected: - GenericResponse() {} - public: - virtual ~GenericResponse() {} - - /** - * Sets or clears the MIME type of the response. - * - * @param type the MIME type, or NULL to clear - */ - virtual void setContentType(const char* type=NULL)=0; - - /** - * Sends a completed response to the client along with a - * transport-specific "OK" indication. Used for "normal" responses. - * - * @param inputStream reference to source of response data - * @return a result code to return from the calling MessageEncoder - */ - virtual long sendResponse(std::istream& inputStream)=0; - - /** - * Sends an "error" response to the client along with a - * transport-specific error indication. - * - * @param inputStream reference to source of response data - * @return a result code to return from the calling MessageEncoder - */ - virtual long sendError(std::istream& inputStream)=0; - - /** - * Sends a completed response to the client. - * - * @param inputStream reference to source of response data - * @param status transport-specific status to return - * @return a result code to return from the calling MessageEncoder - */ - virtual long sendResponse(std::istream& inputStream, long status)=0; - }; -}; - -#endif /* __saml_genres_h__ */ diff --git a/saml/binding/HTTPRequest.h b/saml/binding/HTTPRequest.h deleted file mode 100644 index 362a457..0000000 --- a/saml/binding/HTTPRequest.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2001-2007 Internet2 - * - * 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 - * - * 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. - */ - -/** - * @file saml/binding/HTTPRequest.h - * - * Interface to HTTP requests - */ - -#ifndef __saml_httpreq_h__ -#define __saml_httpreq_h__ - -#include - -namespace opensaml { - - /** - * Interface to caller-supplied shim for accessing HTTP request context. - * - *

To supply information from the surrounding web server environment, - * a shim must be supplied in the form of this interface to adapt the - * library to different proprietary server APIs. - * - *

This interface need not be threadsafe. - */ - class SAML_API HTTPRequest : public GenericRequest { - MAKE_NONCOPYABLE(HTTPRequest); - protected: - HTTPRequest() {} - public: - virtual ~HTTPRequest() {} - - bool isSecure() const { - return strcmp(getScheme(),"https")==0; - } - - /** - * Returns the HTTP method of the request (GET, POST, etc.) - * - * @return the HTTP method - */ - virtual const char* getMethod() const=0; - - /** - * Returns the request URI. - * - * @return the request URI - */ - virtual const char* getRequestURI() const=0; - - /** - * Returns the complete request URL, including scheme, host, port, and URI. - * - * @return the request URL - */ - virtual const char* getRequestURL() const=0; - - /** - * Returns the HTTP query string appened to the request. The query - * string is returned without any decoding applied, everything found - * after the ? delimiter. - * - * @return the query string - */ - virtual const char* getQueryString() const=0; - - /** - * Returns a request header value. - * - * @param name the name of the header to return - * @return the header's value, or an empty string - */ - virtual std::string getHeader(const char* name) const=0; - }; -}; - -#endif /* __saml_httpreq_h__ */ diff --git a/saml/binding/HTTPResponse.h b/saml/binding/HTTPResponse.h deleted file mode 100644 index 6c87fdb..0000000 --- a/saml/binding/HTTPResponse.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2001-2007 Internet2 - * - * 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 - * - * 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. - */ - -/** - * @file saml/binding/HTTPResponse.h - * - * Interface to HTTP requests - */ - -#ifndef __saml_httpres_h__ -#define __saml_httpres_h__ - -#include - -namespace opensaml { - - /** - * Interface to caller-supplied shim for issuing an HTTP response. - * - *

To supply information to the surrounding web server environment, - * a shim must be supplied in the form of this interface to adapt the - * library to different proprietary server APIs. - * - *

This interface need not be threadsafe. - */ - class SAML_API HTTPResponse : public GenericResponse { - MAKE_NONCOPYABLE(HTTPResponse); - protected: - HTTPResponse() {} - public: - virtual ~HTTPResponse() {} - - void setContentType(const char* type) { - setResponseHeader("Content-Type", type); - } - - /** - * Sets or clears a response header. - * - * @param name header name - * @param value value to set, or NULL to clear - */ - virtual void setResponseHeader(const char* name, const char* value)=0; - - /** - * Sets a client cookie. - * - * @param name cookie name - * @param value value to set, or NULL to clear - */ - virtual void setCookie(const char* name, const char* value) { - std::string cookie(name); - cookie = cookie + '=' + value; - setResponseHeader("Set-Cookie", cookie.c_str()); - } - - /** - * Redirect the client to the specified URL and complete the response. - * Any headers previously set will be sent ahead of the redirect. - * - * @param url location to redirect client - * @return a result code to return from the calling MessageEncoder - */ - virtual long sendRedirect(const char* url)=0; - - /** Some common HTTP status codes. */ - enum status_t { - SAML_HTTP_STATUS_OK = 200, - SAML_HTTP_STATUS_MOVED = 302, - SAML_HTTP_STATUS_FORBIDDEN = 403, - SAML_HTTP_STATUS_NOTFOUND = 404, - SAML_HTTP_STATUS_ERROR = 500 - }; - - using GenericResponse::sendResponse; - - long sendError(std::istream& inputStream) { - return sendResponse(inputStream, SAML_HTTP_STATUS_ERROR); - } - - long sendResponse(std::istream& inputStream) { - return sendResponse(inputStream, SAML_HTTP_STATUS_OK); - } - }; -}; - -#endif /* __saml_httpres_h__ */ diff --git a/saml/binding/MessageDecoder.h b/saml/binding/MessageDecoder.h index d797f83..31649cc 100644 --- a/saml/binding/MessageDecoder.h +++ b/saml/binding/MessageDecoder.h @@ -23,9 +23,9 @@ #ifndef __saml_decoder_h__ #define __saml_decoder_h__ -#include #include #include +#include namespace opensaml { @@ -134,7 +134,7 @@ namespace opensaml { */ virtual xmltooling::XMLObject* decode( std::string& relayState, - const GenericRequest& genericRequest, + const xmltooling::GenericRequest& genericRequest, SecurityPolicy& policy ) const=0; diff --git a/saml/binding/MessageEncoder.h b/saml/binding/MessageEncoder.h index 0bb70ee..1bc8e1c 100644 --- a/saml/binding/MessageEncoder.h +++ b/saml/binding/MessageEncoder.h @@ -23,10 +23,11 @@ #ifndef __saml_encoder_h__ #define __saml_encoder_h__ -#include +#include #include #include +#include #include namespace opensaml { @@ -121,7 +122,7 @@ namespace opensaml { * @param digestAlg optional reference digest algorithm identifier */ virtual long encode( - GenericResponse& genericResponse, + xmltooling::GenericResponse& genericResponse, xmltooling::XMLObject* xmlObject, const char* destination, const char* recipientID=NULL, diff --git a/saml/binding/SecurityPolicy.h b/saml/binding/SecurityPolicy.h index cb451ab..b9e323b 100644 --- a/saml/binding/SecurityPolicy.h +++ b/saml/binding/SecurityPolicy.h @@ -23,11 +23,12 @@ #ifndef __saml_secpol_h__ #define __saml_secpol_h__ -#include +#include #include #include #include +#include #include #if defined (_MSC_VER) @@ -200,7 +201,7 @@ namespace opensaml { * * @throws BindingException raised if the message/request is invalid according to the supplied rules */ - void evaluate(const xmltooling::XMLObject& message, const GenericRequest* request=NULL); + void evaluate(const xmltooling::XMLObject& message, const xmltooling::GenericRequest* request=NULL); /** * Resets the policy object and clears any per-message state. diff --git a/saml/binding/SecurityPolicyRule.h b/saml/binding/SecurityPolicyRule.h index 0f3090c..1f58170 100644 --- a/saml/binding/SecurityPolicyRule.h +++ b/saml/binding/SecurityPolicyRule.h @@ -52,7 +52,7 @@ namespace opensaml { * @throws BindingException raised if the message/request is not acceptable to the policy rule */ virtual void evaluate( - const xmltooling::XMLObject& message, const GenericRequest* request, SecurityPolicy& policy + const xmltooling::XMLObject& message, const xmltooling::GenericRequest* request, SecurityPolicy& policy ) const=0; }; diff --git a/saml/binding/impl/SimpleSigningRule.cpp b/saml/binding/impl/SimpleSigningRule.cpp index f450f25..2c5a805 100644 --- a/saml/binding/impl/SimpleSigningRule.cpp +++ b/saml/binding/impl/SimpleSigningRule.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/SecurityPolicyRule.h" #include "saml2/core/Assertions.h" #include "saml2/metadata/Metadata.h" @@ -31,6 +30,7 @@ #include #include +#include using namespace opensaml::saml2md; using namespace opensaml; diff --git a/saml/saml.vcproj b/saml/saml.vcproj index 2172bd5..70249a5 100644 --- a/saml/saml.vcproj +++ b/saml/saml.vcproj @@ -835,22 +835,6 @@ > - - - - - - - - diff --git a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp index cb60c7d..3a5fbbf 100644 --- a/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp +++ b/saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/MessageDecoder.h" #include "binding/SAMLArtifact.h" #include "saml1/core/Protocols.h" @@ -30,6 +29,7 @@ #include "saml2/metadata/MetadataProvider.h" #include +#include #include #include diff --git a/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp b/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp index 0435136..5920997 100644 --- a/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp +++ b/saml/saml1/binding/impl/SAML1ArtifactEncoder.cpp @@ -23,7 +23,6 @@ #include "internal.h" #include "exceptions.h" #include "binding/ArtifactMap.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" #include "binding/SAMLArtifact.h" #include "saml1/core/Assertions.h" @@ -31,6 +30,7 @@ #include #include +#include #include #include diff --git a/saml/saml1/binding/impl/SAML1POSTDecoder.cpp b/saml/saml1/binding/impl/SAML1POSTDecoder.cpp index de2d1d2..bf3395e 100644 --- a/saml/saml1/binding/impl/SAML1POSTDecoder.cpp +++ b/saml/saml1/binding/impl/SAML1POSTDecoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/MessageDecoder.h" #include "saml1/core/Assertions.h" #include "saml1/core/Protocols.h" @@ -31,6 +30,7 @@ #include #include +#include #include #include diff --git a/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp b/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp index 2d0c6d4..c8e9e56 100644 --- a/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp +++ b/saml/saml1/binding/impl/SAML1SOAPEncoder.cpp @@ -22,13 +22,13 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" #include "signature/ContentReference.h" #include "saml1/core/Protocols.h" #include #include +#include #include #include diff --git a/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp b/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp index 7fe371d..b05e3e2 100644 --- a/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp +++ b/saml/saml2/binding/impl/SAML2ArtifactDecoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/MessageDecoder.h" #include "saml2/binding/SAML2Artifact.h" #include "saml2/core/Protocols.h" @@ -30,6 +29,7 @@ #include "saml2/metadata/MetadataProvider.h" #include +#include #include #include diff --git a/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp b/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp index 8fa33ce..6b682ec 100644 --- a/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp +++ b/saml/saml2/binding/impl/SAML2ArtifactEncoder.cpp @@ -23,7 +23,6 @@ #include "internal.h" #include "exceptions.h" #include "binding/ArtifactMap.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" #include "saml2/binding/SAML2Artifact.h" #include "saml2/core/Protocols.h" @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/saml/saml2/binding/impl/SAML2POSTDecoder.cpp b/saml/saml2/binding/impl/SAML2POSTDecoder.cpp index 14a06ae..692950b 100644 --- a/saml/saml2/binding/impl/SAML2POSTDecoder.cpp +++ b/saml/saml2/binding/impl/SAML2POSTDecoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/MessageDecoder.h" #include "saml2/core/Protocols.h" #include "saml2/metadata/Metadata.h" @@ -30,6 +29,7 @@ #include #include +#include #include #include diff --git a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp index c5a78a9..08f54d8 100644 --- a/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp +++ b/saml/saml2/binding/impl/SAML2RedirectDecoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPRequest.h" #include "binding/MessageDecoder.h" #include "saml2/binding/SAML2Redirect.h" #include "saml2/core/Protocols.h" @@ -31,6 +30,7 @@ #include #include +#include #include #include diff --git a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp index 70e3f5d..24050d6 100644 --- a/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp +++ b/saml/saml2/binding/impl/SAML2RedirectEncoder.cpp @@ -22,7 +22,6 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" #include "saml2/binding/SAML2Redirect.h" #include "saml2/core/Protocols.h" @@ -31,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp index 19802e3..24b05d1 100644 --- a/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp +++ b/saml/saml2/binding/impl/SAML2SOAPEncoder.cpp @@ -22,13 +22,13 @@ #include "internal.h" #include "exceptions.h" -#include "binding/HTTPResponse.h" #include "binding/MessageEncoder.h" #include "signature/ContentReference.h" #include "saml2/core/Protocols.h" #include #include +#include #include #include diff --git a/saml/util/CGIParser.h b/saml/util/CGIParser.h index 00ea7c1..d419a96 100644 --- a/saml/util/CGIParser.h +++ b/saml/util/CGIParser.h @@ -23,7 +23,8 @@ #ifndef __saml_cgi_h__ #define __saml_cgi_h__ -#include +#include +#include namespace opensaml { @@ -39,7 +40,7 @@ namespace opensaml { * * @param request HTTP request interface */ - CGIParser(const HTTPRequest& request); + CGIParser(const xmltooling::HTTPRequest& request); ~CGIParser(); diff --git a/samltest/binding.h b/samltest/binding.h index 36442ff..cdaa3bc 100644 --- a/samltest/binding.h +++ b/samltest/binding.h @@ -17,13 +17,13 @@ #include "internal.h" #include -#include -#include #include #include #include #include #include +#include +#include #include #include