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 #ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
25 #define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
26 
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/lang/XInitialization.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/container/XNameAccess.hpp>
33 #include <com/sun/star/lang/IllegalArgumentException.hpp>
34 #include <cppuhelper/compbase2.hxx>
35 
36 #include "ldapaccess.hxx"
37 
38 namespace extensions { namespace config { namespace ldap {
39 
40 namespace css = com::sun::star ;
41 namespace uno = css::uno ;
42 namespace lang = css::lang ;
43 namespace container = css::container;
44 
45 struct LdapDefinition;
46 
47 typedef cppu::WeakComponentImplHelper2<css::beans::XPropertySet,
48                                        lang::XServiceInfo> BackendBase ;
49 
50 struct LdapProfileMutexHolder { osl::Mutex mMutex; };
51 /**
52   Implements the PlatformBackend service, a specialization of the
53   XPropertySet service for retrieving LDAP user profile
54   configuration settings from a LDAP repository.
55   */
56 class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase
57 {
58     public :
59 
60         LdapUserProfileBe(const uno::Reference<uno::XComponentContext>& xContext);
61 		~LdapUserProfileBe(void) ;
62 
63         // XServiceInfo
64         virtual rtl::OUString SAL_CALL
65             getImplementationName(  )
66                 throw (uno::RuntimeException) ;
67 
68         virtual sal_Bool SAL_CALL
69             supportsService( const rtl::OUString& aServiceName )
70                 throw (uno::RuntimeException) ;
71 
72         virtual uno::Sequence<rtl::OUString> SAL_CALL
73             getSupportedServiceNames(  )
74                 throw (uno::RuntimeException) ;
75 
76         // XPropertySet
77         virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
getPropertySetInfo()78         getPropertySetInfo() throw (css::uno::RuntimeException)
79         { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
80 
81         virtual void SAL_CALL setPropertyValue(
82             rtl::OUString const &, css::uno::Any const &)
83             throw (
84                 css::beans::UnknownPropertyException,
85                 css::beans::PropertyVetoException,
86                 css::lang::IllegalArgumentException,
87                 css::lang::WrappedTargetException, css::uno::RuntimeException);
88 
89         virtual css::uno::Any SAL_CALL getPropertyValue(
90             rtl::OUString const & PropertyName)
91             throw (
92                 css::beans::UnknownPropertyException,
93                 css::lang::WrappedTargetException, css::uno::RuntimeException);
94 
addPropertyChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XPropertyChangeListener> const &)95         virtual void SAL_CALL addPropertyChangeListener(
96             rtl::OUString const &,
97             css::uno::Reference< css::beans::XPropertyChangeListener > const &)
98             throw (
99                 css::beans::UnknownPropertyException,
100                 css::lang::WrappedTargetException, css::uno::RuntimeException)
101         {}
102 
removePropertyChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XPropertyChangeListener> const &)103         virtual void SAL_CALL removePropertyChangeListener(
104             rtl::OUString const &,
105             css::uno::Reference< css::beans::XPropertyChangeListener > const &)
106             throw (
107                 css::beans::UnknownPropertyException,
108                 css::lang::WrappedTargetException, css::uno::RuntimeException)
109         {}
110 
addVetoableChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XVetoableChangeListener> const &)111         virtual void SAL_CALL addVetoableChangeListener(
112             rtl::OUString const &,
113             css::uno::Reference< css::beans::XVetoableChangeListener > const &)
114             throw (
115                 css::beans::UnknownPropertyException,
116                 css::lang::WrappedTargetException, css::uno::RuntimeException)
117         {}
118 
removeVetoableChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XVetoableChangeListener> const &)119         virtual void SAL_CALL removeVetoableChangeListener(
120             rtl::OUString const &,
121             css::uno::Reference< css::beans::XVetoableChangeListener > const &)
122             throw (
123                 css::beans::UnknownPropertyException,
124                 css::lang::WrappedTargetException, css::uno::RuntimeException)
125         {}
126 
127 		 /**
128           Provides the implementation name.
129 		  @return   implementation name
130           */
131         static rtl::OUString SAL_CALL getLdapUserProfileBeName(void) ;
132         /**
133           Provides the supported services names
134 		  @return   service names
135           */
136         static uno::Sequence<rtl::OUString> SAL_CALL
137 			getLdapUserProfileBeServiceNames(void) ;
138 
139     private:
140 		/** Check if LDAP is configured */
141         bool readLdapConfiguration(
142             uno::Reference<lang::XMultiServiceFactory> const & factory,
143             LdapDefinition * definition, rtl::OUString * loggedOnUser);
144 
145         bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess,
146 								const rtl::OUString& aLdapSetting,
147 								rtl::OString& aServerParameter);
148 
149     LdapData data_;
150 } ;
151 //------------------------------------------------------------------------------
152 }}}
153 
154 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_
155