Update copyright.
[shibboleth/cpp-opensaml.git] / saml / saml1 / binding / SAMLArtifactType0002.h
1 /*
2  *  Copyright 2001-2007 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file saml/saml1/binding/SAMLArtifactType0002.h
19  * 
20  * Type 0x0002 SAML 1.x artifact class
21  */
22
23 #ifndef __saml_artifacttype0002_h__
24 #define __saml_artifacttype0002_h__
25
26 #include <saml/binding/SAMLArtifact.h>
27
28 namespace opensaml {
29     namespace saml1p {
30         
31         /**
32          * Type 0x0002 SAML 1.x artifact class
33          */
34         class SAML_API SAMLArtifactType0002 : public SAMLArtifact
35         {
36             SAMLArtifactType0002& operator=(const SAMLArtifactType0002& src);
37         public:
38             /**
39              * Decodes a base64-encoded type 0x0002 artifact
40              * 
41              * @param s NULL-terminated base64-encoded string 
42              */        
43             SAMLArtifactType0002(const char* s);
44
45             /**
46              * Constructs an artifact with the specified source URL, but a random assertion handle.
47              * 
48              * @param sourceLocation source URL
49              */        
50             SAMLArtifactType0002(const std::string& sourceLocation);
51
52             /**
53              * Constructs an artifact with the specified source URL and assertion handle.
54              * 
55              * @param sourceLocation    source URL
56              * @param handle            HANDLE_LENGTH bytes of binary data 
57              */        
58             SAMLArtifactType0002(const std::string& sourceLocation, const std::string& handle);
59     
60             virtual ~SAMLArtifactType0002() {}
61             
62             virtual SAMLArtifactType0002* clone() const {
63                 return new SAMLArtifactType0002(*this);
64             }
65             
66             virtual std::string getMessageHandle() const {
67                 return m_raw.substr(TYPECODE_LENGTH, HANDLE_LENGTH);    // bytes 3-22
68             }
69
70             virtual std::string getSource() const {
71                 return m_raw.c_str() + TYPECODE_LENGTH + HANDLE_LENGTH; // bytes 23-terminating null
72             }
73             
74             /** Length of assertion handle */
75             static const unsigned int HANDLE_LENGTH;
76     
77         protected:
78             SAMLArtifactType0002(const SAMLArtifactType0002& src) : SAMLArtifact(src) {}
79         };
80         
81     };
82 };
83
84 #endif /* __saml_artifacttype0002_h__ */