2 * Copyright 2001-2009 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file saml/binding/MessageDecoder.h
20 * Interface to SAML protocol binding message decoders.
23 #ifndef __saml_decoder_h__
24 #define __saml_decoder_h__
26 #include <saml/base.h>
28 namespace xmltooling {
29 class XMLTOOL_API GenericRequest;
30 class XMLTOOL_API XMLObject;
35 class SAML_API SAMLArtifact;
36 class SAML_API SecurityPolicy;
38 class SAML_API Response;
41 class SAML_API SAML2Artifact;
42 class SAML_API ArtifactResponse;
45 class SAML_API MetadataProvider;
46 class SAML_API IDPSSODescriptor;
47 class SAML_API RoleDescriptor;
48 class SAML_API SSODescriptorType;
52 * Interface to SAML protocol binding message decoders.
54 class SAML_API MessageDecoder
56 MAKE_NONCOPYABLE(MessageDecoder);
58 virtual ~MessageDecoder() {}
61 * Indicates whether a web browser or similar user agent delivered the message.
63 * @return true iff the message was delivered by a user agent
65 virtual bool isUserAgentPresent() const;
68 * Interface to caller-supplied artifact resolution mechanism.
70 * Resolving artifacts requires internally performing a SOAP-based
71 * call to the artifact source, usually in a mutually authenticated fashion.
72 * The potential options vary widely, so the work is encapsulated by this
73 * interface, though of course other library facilities may be used.
75 * <p>A MessageDecoder implementation will invoke the supplied interface
76 * when it requires an artifact be resolved.
78 class SAML_API ArtifactResolver {
79 MAKE_NONCOPYABLE(ArtifactResolver);
84 virtual ~ArtifactResolver() {}
87 * Resolves one or more SAML 1.x artifacts into a response containing a set of
88 * resolved Assertions. The caller is responsible for the resulting Response.
89 * The supplied SecurityPolicy is used to access caller-supplied infrastructure
90 * and to pass back the result of authenticating the resolution process.
92 * @param artifacts one or more SAML 1.x artifacts
93 * @param idpDescriptor reference to IdP role of artifact issuer
94 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
95 * @return the corresponding SAML Assertions wrapped in a Response.
97 virtual saml1p::Response* resolve(
98 const std::vector<SAMLArtifact*>& artifacts,
99 const saml2md::IDPSSODescriptor& idpDescriptor,
100 SecurityPolicy& policy
104 * Resolves a SAML 2.0 artifact into the corresponding SAML protocol message.
105 * The caller is responsible for the resulting ArtifactResponse message.
106 * The supplied SecurityPolicy is used to access caller-supplied infrastructure
107 * and to pass back the result of authenticating the resolution process.
109 * @param artifact reference to a SAML 2.0 artifact
110 * @param ssoDescriptor reference to SSO role of artifact issuer (may be SP or IdP)
111 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
112 * @return the corresponding SAML protocol message or NULL
114 virtual saml2p::ArtifactResponse* resolve(
115 const saml2p::SAML2Artifact& artifact,
116 const saml2md::SSODescriptorType& ssoDescriptor,
117 SecurityPolicy& policy
121 * Returns true iff the metadata provided includes a supported artifact resolution service.
123 * @param ssoDescriptor reference to SSO role of artifact issuer (may be SP or IdP)
124 * @return true iff the artifact issuer offers endpoints supported by this resolver
126 virtual bool isSupported(const saml2md::SSODescriptorType& ssoDescriptor) const;
130 * Provides an ArtifactResolver implementation for the MessageDecoder to use.
131 * The implementation's lifetime must be longer than the lifetime of this object.
132 * This method must be externally synchronized.
134 * @param artifactResolver an ArtifactResolver implementation to use
136 void setArtifactResolver(const ArtifactResolver* artifactResolver) {
137 m_artifactResolver = artifactResolver;
141 * Decodes a transport request into a SAML protocol message, and evaluates it
142 * against a supplied SecurityPolicy. If the transport request does not contain
143 * the information necessary to decode the request, NULL will be returned.
144 * Errors during the decoding process will be raised as exceptions.
146 * <p>Artifact-based bindings require an ArtifactResolver be set to
147 * turn an artifact into the corresponding message.
149 * @param relayState will be set to RelayState/TARGET value accompanying message
150 * @param genericRequest reference to interface for accessing transport request to decode
151 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
152 * @return the decoded message, or NULL if the decoder did not recognize the request content
154 virtual xmltooling::XMLObject* decode(
155 std::string& relayState,
156 const xmltooling::GenericRequest& genericRequest,
157 SecurityPolicy& policy
161 MessageDecoder() : m_artifactResolver(NULL) {}
163 /** Pointer to an ArtifactResolver implementation. */
164 const ArtifactResolver* m_artifactResolver;
167 * Extracts policy-relevant message details.
169 * @param message the incoming message
170 * @param request the protocol request
171 * @param protocol the protocol family in use
172 * @param policy SecurityPolicy to provide various components and track message data
174 virtual void extractMessageDetails (
175 const xmltooling::XMLObject& message,
176 const xmltooling::GenericRequest& request,
177 const XMLCh* protocol,
178 SecurityPolicy& policy
183 * Registers MessageDecoder plugins into the runtime.
185 void SAML_API registerMessageDecoders();
188 #endif /* __saml_decoder_h__ */