xref: /AOO41X/main/xmlsecurity/source/xmlsec/xmlelementwrapper_xmlsecimpl.cxx (revision 06b3ce531745799678cf4bb887ef37436d81238b) !
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmlsecurity.hxx"
26 
27 #include "xmlelementwrapper_xmlsecimpl.hxx"
28 #include <cppuhelper/typeprovider.hxx>
29 
30 namespace cssu = com::sun::star::uno;
31 namespace cssl = com::sun::star::lang;
32 
33 #define SERVICE_NAME "com.sun.star.xml.wrapper.XMLElementWrapper"
34 #define IMPLEMENTATION_NAME "com.sun.star.xml.security.bridge.xmlsec.XMLElementWrapper_XmlSecImpl"
35 
XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode)36 XMLElementWrapper_XmlSecImpl::XMLElementWrapper_XmlSecImpl(const xmlNodePtr pNode)
37     : m_pElement( pNode )
38 {
39 }
40 
41 /* XXMLElementWrapper */
42 
43 
44 /* XUnoTunnel */
getUnoTunnelImplementationId(void)45 cssu::Sequence< sal_Int8 > XMLElementWrapper_XmlSecImpl::getUnoTunnelImplementationId( void )
46     throw (cssu::RuntimeException)
47 {
48     static ::cppu::OImplementationId* pId = 0;
49     if (! pId)
50     {
51         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
52         if (! pId)
53         {
54             static ::cppu::OImplementationId aId;
55             pId = &aId;
56         }
57     }
58     return pId->getImplementationId();
59 }
60 
getSomething(const cssu::Sequence<sal_Int8> & aIdentifier)61 sal_Int64 SAL_CALL XMLElementWrapper_XmlSecImpl::getSomething( const cssu::Sequence< sal_Int8 >& aIdentifier )
62     throw (cssu::RuntimeException)
63 {
64     if (aIdentifier.getLength() == 16 &&
65         0 == rtl_compareMemory(
66             getUnoTunnelImplementationId().getConstArray(),
67             aIdentifier.getConstArray(),
68             16 ))
69     {
70         return reinterpret_cast < sal_Int64 > ( this );
71     }
72     else
73     {
74         return 0;
75     }
76 }
77 
78 
XMLElementWrapper_XmlSecImpl_getImplementationName()79 rtl::OUString XMLElementWrapper_XmlSecImpl_getImplementationName ()
80     throw (cssu::RuntimeException)
81 {
82     return rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) );
83 }
84 
XMLElementWrapper_XmlSecImpl_supportsService(const rtl::OUString & ServiceName)85 sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl_supportsService( const rtl::OUString& ServiceName )
86     throw (cssu::RuntimeException)
87 {
88     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ));
89 }
90 
XMLElementWrapper_XmlSecImpl_getSupportedServiceNames()91 cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl_getSupportedServiceNames(  )
92     throw (cssu::RuntimeException)
93 {
94     cssu::Sequence < rtl::OUString > aRet(1);
95     rtl::OUString* pArray = aRet.getArray();
96     pArray[0] =  rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
97     return aRet;
98 }
99 #undef SERVICE_NAME
100 
101 cssu::Reference< cssu::XInterface > SAL_CALL
XMLElementWrapper_XmlSecImpl_createInstance(const cssu::Reference<cssl::XMultiServiceFactory> &)102     XMLElementWrapper_XmlSecImpl_createInstance(
103         const cssu::Reference< cssl::XMultiServiceFactory > &)
104     throw( cssu::Exception )
105 {
106     return (cppu::OWeakObject*) new XMLElementWrapper_XmlSecImpl(NULL);
107 }
108 
109 /* XServiceInfo */
getImplementationName()110 rtl::OUString SAL_CALL XMLElementWrapper_XmlSecImpl::getImplementationName(  )
111     throw (cssu::RuntimeException)
112 {
113     return XMLElementWrapper_XmlSecImpl_getImplementationName();
114 }
supportsService(const rtl::OUString & rServiceName)115 sal_Bool SAL_CALL XMLElementWrapper_XmlSecImpl::supportsService( const rtl::OUString& rServiceName )
116     throw (cssu::RuntimeException)
117 {
118     return XMLElementWrapper_XmlSecImpl_supportsService( rServiceName );
119 }
getSupportedServiceNames()120 cssu::Sequence< rtl::OUString > SAL_CALL XMLElementWrapper_XmlSecImpl::getSupportedServiceNames(  )
121     throw (cssu::RuntimeException)
122 {
123     return XMLElementWrapper_XmlSecImpl_getSupportedServiceNames();
124 }
125 
getNativeElement() const126 xmlNodePtr XMLElementWrapper_XmlSecImpl::getNativeElement(  ) const
127 /****** XMLElementWrapper_XmlSecImpl/getNativeElement *************************
128  *
129  *   NAME
130  *  getNativeElement -- Retrieves the libxml2 node wrapped by this object
131  *
132  *   SYNOPSIS
133  *  pNode = getNativeElement();
134  *
135  *   FUNCTION
136  *  see NAME
137  *
138  *   INPUTS
139  *  empty
140  *
141  *   RESULT
142  *  pNode - the libxml2 node wrapped by this object
143  *
144  *   HISTORY
145  *  05.01.2004 -    implemented
146  *
147  *   AUTHOR
148  *  Michael Mi
149  *  Email: michael.mi@sun.com
150  ******************************************************************************/
151 {
152     return m_pElement;
153 }
154 
setNativeElement(const xmlNodePtr pNode)155 void XMLElementWrapper_XmlSecImpl::setNativeElement(const xmlNodePtr pNode)
156 /****** XMLElementWrapper_XmlSecImpl/setNativeElement *************************
157  *
158  *   NAME
159  *  setNativeElement -- Configures the libxml2 node wrapped by this object
160  *
161  *   SYNOPSIS
162  *  setNativeElement( pNode );
163  *
164  *   FUNCTION
165  *  see NAME
166  *
167  *   INPUTS
168  *  pNode - the new libxml2 node to be wrapped by this object
169  *
170  *   RESULT
171  *  empty
172  *
173  *   HISTORY
174  *  05.01.2004 -    implemented
175  *
176  *   AUTHOR
177  *  Michael Mi
178  *  Email: michael.mi@sun.com
179  ******************************************************************************/
180 {
181     m_pElement = pNode;
182 }
183 
184