ffcbd78571cb1f37299867c740ccbd2c5a1d8d0b
[shibboleth/cpp-opensaml.git] / saml / saml1 / core / SAMLArtifactType0002.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 /**\r
18  * @file saml/saml1/core/SAMLArtifactType0002.h\r
19  * \r
20  * Type 0x0002 SAML 1.x artifact class\r
21  */\r
22 \r
23 #ifndef __saml_artifacttype0002_h__\r
24 #define __saml_artifacttype0002_h__\r
25 \r
26 #include <saml/SAMLArtifact.h>\r
27 \r
28 namespace opensaml {\r
29     namespace saml1p {\r
30         \r
31         /**\r
32          * Type 0x0002 SAML 1.x artifact class\r
33          */\r
34         class SAML_API SAMLArtifactType0002 : public SAMLArtifact\r
35         {\r
36             SAMLArtifactType0002& operator=(const SAMLArtifactType0002& src);\r
37         public:\r
38             /**\r
39              * Decodes a base64-encoded type 0x0002 artifact\r
40              * \r
41              * @param s NULL-terminated base64-encoded string \r
42              */        \r
43             SAMLArtifactType0002(const char* s);\r
44 \r
45             /**\r
46              * Constructs an artifact with the specified source URL, but a random assertion handle.\r
47              * \r
48              * @param sourceLocation source URL\r
49              */        \r
50             SAMLArtifactType0002(const std::string& sourceLocation);\r
51 \r
52             /**\r
53              * Constructs an artifact with the specified source URL and assertion handle.\r
54              * \r
55              * @param sourceLocation    source URL\r
56              * @param handle            HANDLE_LENGTH bytes of binary data \r
57              */        \r
58             SAMLArtifactType0002(const std::string& sourceLocation, const std::string& handle);\r
59     \r
60             virtual ~SAMLArtifactType0002() {}\r
61             \r
62             virtual SAMLArtifactType0002* clone() const {\r
63                 return new SAMLArtifactType0002(*this);\r
64             }\r
65             \r
66             virtual std::string getMessageHandle() const {\r
67                 return m_raw.substr(TYPECODE_LENGTH, HANDLE_LENGTH);    // bytes 3-22\r
68             }\r
69 \r
70             virtual std::string getSource() const {\r
71                 return m_raw.c_str() + TYPECODE_LENGTH + HANDLE_LENGTH; // bytes 23-terminating null\r
72             }\r
73             \r
74             /** Length of assertion handle */\r
75             static const unsigned int HANDLE_LENGTH;\r
76     \r
77         protected:\r
78             SAMLArtifactType0002(const SAMLArtifact& src) : SAMLArtifact(src) {}\r
79         };\r
80         \r
81     };\r
82 };\r
83 \r
84 #endif /* __saml_artifacttype0002_h__ */\r