1 | /* |
2 | * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
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 | * A copy of the License is located at |
7 | * |
8 | * http://aws.amazon.com/apache2.0 |
9 | * |
10 | * or in the "license" file accompanying this file. This file is distributed |
11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
12 | * express or implied. See the License for the specific language governing |
13 | * permissions and limitations under the License. |
14 | */ |
15 | |
16 | #include <aws/s3/model/Encryption.h> |
17 | #include <aws/core/utils/xml/XmlSerializer.h> |
18 | #include <aws/core/utils/StringUtils.h> |
19 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
20 | |
21 | #include <utility> |
22 | |
23 | using namespace Aws::Utils::Xml; |
24 | using namespace Aws::Utils; |
25 | |
26 | namespace Aws |
27 | { |
28 | namespace S3 |
29 | { |
30 | namespace Model |
31 | { |
32 | |
33 | Encryption::Encryption() : |
34 | m_encryptionType(ServerSideEncryption::NOT_SET), |
35 | m_encryptionTypeHasBeenSet(false), |
36 | m_kMSKeyIdHasBeenSet(false), |
37 | m_kMSContextHasBeenSet(false) |
38 | { |
39 | } |
40 | |
41 | Encryption::Encryption(const XmlNode& xmlNode) : |
42 | m_encryptionType(ServerSideEncryption::NOT_SET), |
43 | m_encryptionTypeHasBeenSet(false), |
44 | m_kMSKeyIdHasBeenSet(false), |
45 | m_kMSContextHasBeenSet(false) |
46 | { |
47 | *this = xmlNode; |
48 | } |
49 | |
50 | Encryption& Encryption::operator =(const XmlNode& xmlNode) |
51 | { |
52 | XmlNode resultNode = xmlNode; |
53 | |
54 | if(!resultNode.IsNull()) |
55 | { |
56 | XmlNode encryptionTypeNode = resultNode.FirstChild("EncryptionType" ); |
57 | if(!encryptionTypeNode.IsNull()) |
58 | { |
59 | m_encryptionType = ServerSideEncryptionMapper::GetServerSideEncryptionForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(encryptionTypeNode.GetText()).c_str()).c_str()); |
60 | m_encryptionTypeHasBeenSet = true; |
61 | } |
62 | XmlNode kMSKeyIdNode = resultNode.FirstChild("KMSKeyId" ); |
63 | if(!kMSKeyIdNode.IsNull()) |
64 | { |
65 | m_kMSKeyId = Aws::Utils::Xml::DecodeEscapedXmlText(kMSKeyIdNode.GetText()); |
66 | m_kMSKeyIdHasBeenSet = true; |
67 | } |
68 | XmlNode kMSContextNode = resultNode.FirstChild("KMSContext" ); |
69 | if(!kMSContextNode.IsNull()) |
70 | { |
71 | m_kMSContext = Aws::Utils::Xml::DecodeEscapedXmlText(kMSContextNode.GetText()); |
72 | m_kMSContextHasBeenSet = true; |
73 | } |
74 | } |
75 | |
76 | return *this; |
77 | } |
78 | |
79 | void Encryption::AddToNode(XmlNode& parentNode) const |
80 | { |
81 | Aws::StringStream ss; |
82 | if(m_encryptionTypeHasBeenSet) |
83 | { |
84 | XmlNode encryptionTypeNode = parentNode.CreateChildElement("EncryptionType" ); |
85 | encryptionTypeNode.SetText(ServerSideEncryptionMapper::GetNameForServerSideEncryption(m_encryptionType)); |
86 | } |
87 | |
88 | if(m_kMSKeyIdHasBeenSet) |
89 | { |
90 | XmlNode kMSKeyIdNode = parentNode.CreateChildElement("KMSKeyId" ); |
91 | kMSKeyIdNode.SetText(m_kMSKeyId); |
92 | } |
93 | |
94 | if(m_kMSContextHasBeenSet) |
95 | { |
96 | XmlNode kMSContextNode = parentNode.CreateChildElement("KMSContext" ); |
97 | kMSContextNode.SetText(m_kMSContext); |
98 | } |
99 | |
100 | } |
101 | |
102 | } // namespace Model |
103 | } // namespace S3 |
104 | } // namespace Aws |
105 | |