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 * XKMSReissueKeyBindingImpl := Implementation for ReissueKeyBinding
24 *
25 * $Id$
26 *
27 */
28
29 // XSEC Includes
30
31 #include <xsec/framework/XSECDefs.hpp>
32 #include <xsec/framework/XSECError.hpp>
33 #include <xsec/framework/XSECEnv.hpp>
34
35
36 #ifdef XSEC_XKMS_ENABLED
37
38 #include "XKMSReissueKeyBindingImpl.hpp"
39 #include "XKMSStatusImpl.hpp"
40
41 #include <xsec/xkms/XKMSConstants.hpp>
42
43 #include <xercesc/dom/DOM.hpp>
44
45 XERCES_CPP_NAMESPACE_USE
46
47 // --------------------------------------------------------------------------------
48 // Construct/Destruct
49 // --------------------------------------------------------------------------------
50
XKMSReissueKeyBindingImpl(const XSECEnv * env)51 XKMSReissueKeyBindingImpl::XKMSReissueKeyBindingImpl(
52 const XSECEnv * env
53 ) :
54 XKMSKeyBindingAbstractTypeImpl(env) {
55 mp_status = NULL;
56 }
57
XKMSReissueKeyBindingImpl(const XSECEnv * env,XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node)58 XKMSReissueKeyBindingImpl::XKMSReissueKeyBindingImpl(
59 const XSECEnv * env,
60 XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * node
61 ) :
62 XKMSKeyBindingAbstractTypeImpl(env, node) {
63
64 mp_status = NULL;
65 }
66
~XKMSReissueKeyBindingImpl()67 XKMSReissueKeyBindingImpl::~XKMSReissueKeyBindingImpl() {
68
69 if (mp_status != NULL)
70 delete mp_status;
71
72 }
73
74 // --------------------------------------------------------------------------------
75 // Load from DOM
76 // --------------------------------------------------------------------------------
77
load(void)78 void XKMSReissueKeyBindingImpl::load(void) {
79
80 if (mp_keyBindingAbstractTypeElement == NULL) {
81 throw XSECException(XSECException::ExpectedXKMSChildNotFound,
82 "XKMSReissueKeyBindingImpl::load - called on empty DOM");
83 }
84
85 XKMSKeyBindingAbstractTypeImpl::load();
86
87 /* Find the status element */
88 DOMNodeList * nl = mp_keyBindingAbstractTypeElement->getElementsByTagNameNS(
89 XKMSConstants::s_unicodeStrURIXKMS,
90 XKMSConstants::s_tagStatus);
91
92 if (nl == NULL || nl->getLength() != 1) {
93 throw XSECException(XSECException::ExpectedXKMSChildNotFound,
94 "XKMSReissueKeyBinding::load - Status value not found");
95 }
96
97 XSECnew(mp_status, XKMSStatusImpl(mp_env, (DOMElement*) nl->item(0)));
98 mp_status->load();
99
100 }
101
102 // --------------------------------------------------------------------------------
103 // Create
104 // --------------------------------------------------------------------------------
105
createBlankReissueKeyBinding(XKMSStatus::StatusValue status)106 DOMElement * XKMSReissueKeyBindingImpl::createBlankReissueKeyBinding(XKMSStatus::StatusValue status) {
107
108 DOMElement * ret = XKMSKeyBindingAbstractTypeImpl::
109 createBlankKeyBindingAbstractType(XKMSConstants::s_tagReissueKeyBinding);
110
111 mp_env->doPrettyPrint(ret);
112
113 // Create the status element
114 XSECnew(mp_status, XKMSStatusImpl(mp_env));
115 ret->appendChild(mp_status->createBlankStatus(status));
116 mp_env->doPrettyPrint(ret);
117
118 // Must have an Id
119 XKMSKeyBindingAbstractTypeImpl::setId();
120
121 return ret;
122
123 }
124
125 // --------------------------------------------------------------------------------
126 // Status handling
127 // --------------------------------------------------------------------------------
128
getStatus(void) const129 XKMSStatus * XKMSReissueKeyBindingImpl::getStatus(void) const {
130
131 return mp_status;
132
133 }
134
135 #endif /* XSEC_XKMS_ENABLED */
136