1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 /*
21  * XSEC
22  *
23  * XKMSResultImpl := Implementation of Result Messages
24  *
25  * $Id: XKMSResultImpl.cpp 1833340 2018-06-11 15:40:13Z scantor $
26  *
27  */
28 
29 #include <xsec/framework/XSECDefs.hpp>
30 #include <xsec/framework/XSECError.hpp>
31 #include <xsec/framework/XSECEnv.hpp>
32 
33 #ifdef XSEC_XKMS_ENABLED
34 
35 #include "../../utils/XSECDOMUtils.hpp"
36 
37 #include "XKMSResultImpl.hpp"
38 
39 #include <xsec/xkms/XKMSConstants.hpp>
40 
41 #include <xercesc/dom/DOM.hpp>
42 
43 XERCES_CPP_NAMESPACE_USE
44 
45 // --------------------------------------------------------------------------------
46 //           Construct/Destruct
47 // --------------------------------------------------------------------------------
48 
XKMSResultImpl(const XSECEnv * env)49 XKMSResultImpl::XKMSResultImpl(
50 		const XSECEnv * env) :
51 m_result(env),
52 m_msg(m_result.m_msg) {
53 
54 }
55 
XKMSResultImpl(const XSECEnv * env,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node)56 XKMSResultImpl::XKMSResultImpl(
57 		const XSECEnv * env,
58 		XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node) :
59 m_result(env, node),
60 m_msg(m_result.m_msg) {
61 
62 }
63 
~XKMSResultImpl()64 XKMSResultImpl::~XKMSResultImpl() {
65 
66 
67 }
68 
69 
70 // --------------------------------------------------------------------------------
71 //           Load from DOM
72 // --------------------------------------------------------------------------------
73 
74 // Load elements
load()75 void XKMSResultImpl::load() {
76 
77 	if (m_msg.mp_messageAbstractTypeElement == NULL) {
78 
79 		// Attempt to load an empty element
80 		throw XSECException(XSECException::XKMSError,
81 			"XKMSResult::load - called on empty DOM");
82 
83 	}
84 
85 	if (!strEquals(getXKMSLocalName(m_msg.mp_messageAbstractTypeElement),
86 									XKMSConstants::s_tagResult)) {
87 
88 		throw XSECException(XSECException::XKMSError,
89 			"XKMSResult::load - called incorrect node");
90 
91 	}
92 
93 	// Load the base message
94 	m_result.load();
95 
96 }
97 
98 // --------------------------------------------------------------------------------
99 //           Create a blank one
100 // --------------------------------------------------------------------------------
createBlankResult(const XMLCh * service,const XMLCh * id,ResultMajor rmaj,ResultMinor rmin)101 DOMElement * XKMSResultImpl::createBlankResult(
102 		const XMLCh * service,
103 		const XMLCh * id,
104 		ResultMajor rmaj,
105 		ResultMinor rmin) {
106 
107 	return m_result.createBlankResultType(
108 		XKMSConstants::s_tagResult, service, id, rmaj, rmin);
109 
110 }
111 
112 // --------------------------------------------------------------------------------
113 //           Get interface methods
114 // --------------------------------------------------------------------------------
115 
getMessageType(void)116 XKMSMessageAbstractType::messageType XKMSResultImpl::getMessageType(void) {
117 
118 	return XKMSMessageAbstractTypeImpl::Result;
119 
120 }
121 
122 #endif /* XSEC_XKMS_ENABLED */
123