Update copyright.
[shibboleth/cpp-opensaml.git] / saml / saml2 / binding / SAML2ArtifactType0004.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/saml2/core/SAML2ArtifactType0004.h
19  * 
20  * Type 0x0004 SAML 2.0 artifact class
21  */
22
23 #ifndef __saml_artifacttype0004_h__
24 #define __saml_artifacttype0004_h__
25
26 #include <saml/saml2/binding/SAML2Artifact.h>
27
28 namespace opensaml {
29     namespace saml2p {
30         
31         /**
32          * Type 0x0004 SAML 2.0 artifact class
33          */
34         class SAML_API SAML2ArtifactType0004 : public SAML2Artifact
35         {
36             SAML2ArtifactType0004& operator=(const SAML2ArtifactType0004& src);
37         public:
38             /**
39              * Decodes a base64-encoded type 0x0004 artifact
40              * 
41              * @param s NULL-terminated base64-encoded string 
42              */        
43             SAML2ArtifactType0004(const char* s);
44
45             /**
46              * Constructs an artifact with the specified source ID and index, but a random message handle.
47              * 
48              * @param sourceid  SOURCEID_LENGTH bytes of binary data
49              * @param index     endpoint index
50              */        
51             SAML2ArtifactType0004(const std::string& sourceid, int index);
52
53             /**
54              * Constructs an artifact with the specified source ID and assertion handle.
55              * 
56              * @param sourceid  SOURCEID_LENGTH bytes of binary data
57              * @param index     endpoint index
58              * @param handle    HANDLE_LENGTH bytes of binary data 
59              */        
60             SAML2ArtifactType0004(const std::string& sourceid, int index, const std::string& handle);
61     
62             virtual ~SAML2ArtifactType0004() {}
63             
64             virtual SAML2ArtifactType0004* clone() const {
65                 return new SAML2ArtifactType0004(*this);
66             }
67             
68             virtual std::string getSource() const {
69                 return toHex(getSourceID());
70             }
71
72             /**
73              * Returns the binary data that identifies the source.
74              * The result MAY contain embedded null characters.
75              * 
76              * @return the binary source ID
77              */
78             virtual std::string getSourceID() const {
79                 return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH, SOURCEID_LENGTH);    // bytes 5-24
80             }
81             
82             virtual std::string getMessageHandle() const {
83                 return m_raw.substr(TYPECODE_LENGTH + INDEX_LENGTH + SOURCEID_LENGTH, HANDLE_LENGTH);    // bytes 25-44
84             }
85
86             /** Length of source ID */            
87             static const unsigned int SOURCEID_LENGTH;
88
89             /** Length of message handle */            
90             static const unsigned int HANDLE_LENGTH;
91     
92         protected:
93             SAML2ArtifactType0004(const SAML2ArtifactType0004& src) : SAML2Artifact(src) {}
94         };
95         
96     };
97 };
98
99 #endif /* __saml_artifacttype0004_h__ */