2 * Copyright 2001-2007 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/binding/GenericRequest.h>
27 #include <saml/binding/SecurityPolicy.h>
28 #include <xmltooling/XMLObject.h>
32 class SAML_API SAMLArtifact;
34 class SAML_API Response;
37 class SAML_API SAML2Artifact;
38 class SAML_API ArtifactResponse;
41 class SAML_API MetadataProvider;
42 class SAML_API IDPSSODescriptor;
43 class SAML_API RoleDescriptor;
44 class SAML_API SSODescriptorType;
48 * Interface to SAML protocol binding message decoders.
50 class SAML_API MessageDecoder
52 MAKE_NONCOPYABLE(MessageDecoder);
54 virtual ~MessageDecoder() {}
57 * Interface to caller-supplied artifact resolution mechanism.
59 * Resolving artifacts requires internally performing a SOAP-based
60 * call to the artifact source, usually in a mutually authenticated fashion.
61 * The potential options vary widely, so the work is encapsulated by this
62 * interface, though of course other library facilities may be used.
64 * <p>A MessageDecoder implementation will invoke the supplied interface
65 * when it requires an artifact be resolved.
67 class SAML_API ArtifactResolver {
68 MAKE_NONCOPYABLE(ArtifactResolver);
73 virtual ~ArtifactResolver() {}
76 * Resolves one or more SAML 1.x artifacts into a response containing a set of
77 * resolved Assertions. The caller is responsible for the resulting Response.
78 * The supplied SecurityPolicy is used to access caller-supplied infrastructure
79 * and to pass back the result of authenticating the resolution process.
81 * @param artifacts one or more SAML 1.x artifacts
82 * @param idpDescriptor reference to IdP role of artifact issuer
83 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
84 * @return the corresponding SAML Assertions wrapped in a Response.
86 virtual saml1p::Response* resolve(
87 const std::vector<SAMLArtifact*>& artifacts,
88 const saml2md::IDPSSODescriptor& idpDescriptor,
89 SecurityPolicy& policy
93 * Resolves a SAML 2.0 artifact into the corresponding SAML protocol message.
94 * The caller is responsible for the resulting ArtifactResponse message.
95 * The supplied SecurityPolicy is used to access caller-supplied infrastructure
96 * and to pass back the result of authenticating the resolution process.
98 * @param artifact reference to a SAML 2.0 artifact
99 * @param ssoDescriptor reference to SSO role of artifact issuer (may be SP or IdP)
100 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
101 * @return the corresponding SAML protocol message or NULL
103 virtual saml2p::ArtifactResponse* resolve(
104 const saml2p::SAML2Artifact& artifact,
105 const saml2md::SSODescriptorType& ssoDescriptor,
106 SecurityPolicy& policy
111 * Provides an ArtifactResolver implementation for the MessageDecoder to use.
112 * The implementation's lifetime must be longer than the lifetime of this object.
113 * This method must be externally synchronized.
115 * @param artifactResolver an ArtifactResolver implementation to use
117 void setArtifactResolver(const ArtifactResolver* artifactResolver) {
118 m_artifactResolver = artifactResolver;
122 * Decodes a transport request into a SAML protocol message, and evaluates it
123 * against a supplied SecurityPolicy. If the transport request does not contain
124 * the information necessary to decode the request, NULL will be returned.
125 * Errors during the decoding process will be raised as exceptions.
127 * <p>Artifact-based bindings require an ArtifactResolver be set to
128 * turn an artifact into the corresponding message.
130 * @param relayState will be set to RelayState/TARGET value accompanying message
131 * @param genericRequest reference to interface for accessing transport request to decode
132 * @param policy reference to policy containing rules, MetadataProvider, TrustEngine, etc.
133 * @return the decoded message, or NULL if the decoder did not recognize the request content
135 virtual xmltooling::XMLObject* decode(
136 std::string& relayState,
137 const GenericRequest& genericRequest,
138 SecurityPolicy& policy
142 MessageDecoder() : m_artifactResolver(NULL) {}
144 /** Pointer to an ArtifactResolver implementation. */
145 const ArtifactResolver* m_artifactResolver;
149 * Registers MessageDecoder plugins into the runtime.
151 void SAML_API registerMessageDecoders();
154 #endif /* __saml_decoder_h__ */