2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file saml/binding/SAMLArtifact.h
24 * Base class for SAML 1.x and 2.0 artifacts.
27 #ifndef __saml_artifact_h__
28 #define __saml_artifact_h__
30 #include <saml/base.h>
33 #include <xmltooling/exceptions.h>
37 #if defined (_MSC_VER)
38 #pragma warning( push )
39 #pragma warning( disable : 4251 )
43 * Base class for SAML 1.x and 2.0 artifacts.
45 class SAML_API SAMLArtifact
47 SAMLArtifact& operator=(const SAMLArtifact& src);
49 virtual ~SAMLArtifact();
52 * Returns artifact encoded into null-terminated base64 for transmission.
54 virtual std::string encode() const;
57 * Builds a duplicate, independent artifact of the same type.
59 * @return the new artifact
61 virtual SAMLArtifact* clone() const=0;
64 * Returns all of the raw binary data that makes up the artifact.
65 * The result is NOT null-terminated.
67 * @return the binary artifact data
69 virtual std::string getBytes() const;
72 * Returns the binary type code of the artifact.
73 * The result MAY contain embedded null characters.
75 * @return the binary type code
77 virtual std::string getTypeCode() const;
80 * Returns the binary artifact data following the type code.
81 * The result MAY contain embedded null characters.
83 * @return the binary artifact data
85 virtual std::string getRemainingArtifact() const;
88 * Returns a string that identifies the source of the artifact.
89 * The exact form this takes depends on the type but should match
90 * the syntax needed for metadata lookup.
92 * @return null-terminated source string
94 virtual std::string getSource() const=0;
97 * Returns the binary data that references the message (2.0) or assertion (1.x)
98 * The exact form this takes depends on the type.
99 * The result MAY contain embedded null characters.
101 * @return the binary reference data
103 virtual std::string getMessageHandle() const=0;
105 /** Length of type code */
106 static const unsigned int TYPECODE_LENGTH;
109 * Parses a base64-encoded null-terminated string into an artifact,
110 * if the type is known.
112 * @param s base64-encoded artifact
113 * @return the decoded artifact
115 static SAMLArtifact* parse(const char* s);
118 * Parses a base64-encoded null-terminated string into an artifact,
119 * if the type is known.
121 * @param s base64-encoded artifact
122 * @return the decoded artifact
124 static SAMLArtifact* parse(const XMLCh* s);
127 * Converts binary data to hex notation.
129 * @param s the bytes to convert
130 * @return the data in hex form, 2 characters per byte
132 static std::string toHex(const std::string& s);
138 * Decodes a base64-encoded artifact into its raw form.
140 * @param s NULL-terminated base64-encoded string
142 SAMLArtifact(const char* s);
144 SAMLArtifact(const SAMLArtifact& src);
146 /** Raw binary data that makes up an artifact. */
150 #if defined (_MSC_VER)
151 #pragma warning( pop )
154 DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing);
157 * Registers SAMLArtifact subclasses into the runtime.
159 void SAML_API registerSAMLArtifacts();
162 #endif /* __saml_artifact_h__ */