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/SAMLArtifact.h
20 * Base class for SAML 1.x and 2.0 artifacts.
23 #ifndef __saml_artifact_h__
24 #define __saml_artifact_h__
26 #include <saml/base.h>
33 * Base class for SAML 1.x and 2.0 artifacts.
35 class SAML_API SAMLArtifact
37 SAMLArtifact& operator=(const SAMLArtifact& src);
39 virtual ~SAMLArtifact() {}
42 * Returns artifact encoded into null-terminated base64 for transmission.
44 virtual std::string encode() const;
47 * Builds a duplicate, independent artifact of the same type.
49 * @return the new artifact
51 virtual SAMLArtifact* clone() const=0;
54 * Returns all of the raw binary data that makes up the artifact.
55 * The result is NOT null-terminated.
57 * @return the binary artifact data
59 virtual std::string getBytes() const;
62 * Returns the binary type code of the artifact.
63 * The result MAY contain embedded null characters.
65 * @return the binary type code
67 virtual std::string getTypeCode() const;
70 * Returns the binary artifact data following the type code.
71 * The result MAY contain embedded null characters.
73 * @return the binary artifact data
75 virtual std::string getRemainingArtifact() const;
78 * Returns a string that identifies the source of the artifact.
79 * The exact form this takes depends on the type but should match
80 * the syntax needed for metadata lookup.
82 * @return null-terminated source string
84 virtual std::string getSource() const=0;
87 * Returns the binary data that references the message (2.0) or assertion (1.x)
88 * The exact form this takes depends on the type.
89 * The result MAY contain embedded null characters.
91 * @return the binary reference data
93 virtual std::string getMessageHandle() const=0;
95 /** Length of type code */
96 static const unsigned int TYPECODE_LENGTH;
99 * Parses a base64-encoded null-terminated string into an artifact,
100 * if the type is known.
102 * @param s base64-encoded artifact
103 * @return the decoded artifact
105 static SAMLArtifact* parse(const char* s);
108 * Parses a base64-encoded null-terminated string into an artifact,
109 * if the type is known.
111 * @param s base64-encoded artifact
112 * @return the decoded artifact
114 static SAMLArtifact* parse(const XMLCh* s);
117 * Converts binary data to hex notation.
119 * @param s the bytes to convert
120 * @return the data in hex form, 2 characters per byte
122 static std::string toHex(const std::string& s);
128 * Decodes a base64-encoded artifact into its raw form.
130 * @param s NULL-terminated base64-encoded string
132 SAMLArtifact(const char* s);
134 SAMLArtifact(const SAMLArtifact& src) : m_raw(src.m_raw) {}
136 /** Raw binary data that makes up an artifact. */
140 DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing);
143 * Registers SAMLArtifact subclasses into the runtime.
145 void SAML_API registerSAMLArtifacts();
148 #endif /* __saml_artifact_h__ */