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>
29 #include <xmltooling/exceptions.h>
34 * Base class for SAML 1.x and 2.0 artifacts.
36 class SAML_API SAMLArtifact
38 SAMLArtifact& operator=(const SAMLArtifact& src);
40 virtual ~SAMLArtifact();
43 * Returns artifact encoded into null-terminated base64 for transmission.
45 virtual std::string encode() const;
48 * Builds a duplicate, independent artifact of the same type.
50 * @return the new artifact
52 virtual SAMLArtifact* clone() const=0;
55 * Returns all of the raw binary data that makes up the artifact.
56 * The result is NOT null-terminated.
58 * @return the binary artifact data
60 virtual std::string getBytes() const;
63 * Returns the binary type code of the artifact.
64 * The result MAY contain embedded null characters.
66 * @return the binary type code
68 virtual std::string getTypeCode() const;
71 * Returns the binary artifact data following the type code.
72 * The result MAY contain embedded null characters.
74 * @return the binary artifact data
76 virtual std::string getRemainingArtifact() const;
79 * Returns a string that identifies the source of the artifact.
80 * The exact form this takes depends on the type but should match
81 * the syntax needed for metadata lookup.
83 * @return null-terminated source string
85 virtual std::string getSource() const=0;
88 * Returns the binary data that references the message (2.0) or assertion (1.x)
89 * The exact form this takes depends on the type.
90 * The result MAY contain embedded null characters.
92 * @return the binary reference data
94 virtual std::string getMessageHandle() const=0;
96 /** Length of type code */
97 static const unsigned int TYPECODE_LENGTH;
100 * Parses a base64-encoded null-terminated string into an artifact,
101 * if the type is known.
103 * @param s base64-encoded artifact
104 * @return the decoded artifact
106 static SAMLArtifact* parse(const char* s);
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 XMLCh* s);
118 * Converts binary data to hex notation.
120 * @param s the bytes to convert
121 * @return the data in hex form, 2 characters per byte
123 static std::string toHex(const std::string& s);
129 * Decodes a base64-encoded artifact into its raw form.
131 * @param s NULL-terminated base64-encoded string
133 SAMLArtifact(const char* s);
135 SAMLArtifact(const SAMLArtifact& src);
137 /** Raw binary data that makes up an artifact. */
141 DECL_XMLTOOLING_EXCEPTION(ArtifactException,SAML_EXCEPTIONAPI(SAML_API),opensaml,xmltooling::XMLToolingException,Exceptions related to artifact parsing);
144 * Registers SAMLArtifact subclasses into the runtime.
146 void SAML_API registerSAMLArtifacts();
149 #endif /* __saml_artifact_h__ */