1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
29 #define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
30 
31 #include <com/sun/star/beans/XPropertySet.hpp>
32 #include <com/sun/star/lang/XInitialization.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/container/XNameAccess.hpp>
37 #include <com/sun/star/lang/IllegalArgumentException.hpp>
38 #include <cppuhelper/compbase2.hxx>
39 
40 #include "ldapaccess.hxx"
41 
42 namespace extensions { namespace config { namespace ldap {
43 
44 namespace css = com::sun::star ;
45 namespace uno = css::uno ;
46 namespace lang = css::lang ;
47 namespace container = css::container;
48 
49 struct LdapDefinition;
50 
51 typedef cppu::WeakComponentImplHelper2<css::beans::XPropertySet,
52                                        lang::XServiceInfo> BackendBase ;
53 
54 struct LdapProfileMutexHolder { osl::Mutex mMutex; };
55 /**
56   Implements the PlatformBackend service, a specialization of the
57   XPropertySet service for retreiving LDAP user profile
58   configuration settings from a LDAP repsoitory.
59   */
60 class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase
61 {
62     public :
63 
64         LdapUserProfileBe(const uno::Reference<uno::XComponentContext>& xContext);
65 		~LdapUserProfileBe(void) ;
66 
67         // XServiceInfo
68         virtual rtl::OUString SAL_CALL
69             getImplementationName(  )
70                 throw (uno::RuntimeException) ;
71 
72         virtual sal_Bool SAL_CALL
73             supportsService( const rtl::OUString& aServiceName )
74                 throw (uno::RuntimeException) ;
75 
76         virtual uno::Sequence<rtl::OUString> SAL_CALL
77             getSupportedServiceNames(  )
78                 throw (uno::RuntimeException) ;
79 
80         // XPropertySet
81         virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
82         getPropertySetInfo() throw (css::uno::RuntimeException)
83         { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
84 
85         virtual void SAL_CALL setPropertyValue(
86             rtl::OUString const &, css::uno::Any const &)
87             throw (
88                 css::beans::UnknownPropertyException,
89                 css::beans::PropertyVetoException,
90                 css::lang::IllegalArgumentException,
91                 css::lang::WrappedTargetException, css::uno::RuntimeException);
92 
93         virtual css::uno::Any SAL_CALL getPropertyValue(
94             rtl::OUString const & PropertyName)
95             throw (
96                 css::beans::UnknownPropertyException,
97                 css::lang::WrappedTargetException, css::uno::RuntimeException);
98 
99         virtual void SAL_CALL addPropertyChangeListener(
100             rtl::OUString const &,
101             css::uno::Reference< css::beans::XPropertyChangeListener > const &)
102             throw (
103                 css::beans::UnknownPropertyException,
104                 css::lang::WrappedTargetException, css::uno::RuntimeException)
105         {}
106 
107         virtual void SAL_CALL removePropertyChangeListener(
108             rtl::OUString const &,
109             css::uno::Reference< css::beans::XPropertyChangeListener > const &)
110             throw (
111                 css::beans::UnknownPropertyException,
112                 css::lang::WrappedTargetException, css::uno::RuntimeException)
113         {}
114 
115         virtual void SAL_CALL addVetoableChangeListener(
116             rtl::OUString const &,
117             css::uno::Reference< css::beans::XVetoableChangeListener > const &)
118             throw (
119                 css::beans::UnknownPropertyException,
120                 css::lang::WrappedTargetException, css::uno::RuntimeException)
121         {}
122 
123         virtual void SAL_CALL removeVetoableChangeListener(
124             rtl::OUString const &,
125             css::uno::Reference< css::beans::XVetoableChangeListener > const &)
126             throw (
127                 css::beans::UnknownPropertyException,
128                 css::lang::WrappedTargetException, css::uno::RuntimeException)
129         {}
130 
131 		 /**
132           Provides the implementation name.
133 		  @return   implementation name
134           */
135         static rtl::OUString SAL_CALL getLdapUserProfileBeName(void) ;
136         /**
137           Provides the supported services names
138 		  @return   service names
139           */
140         static uno::Sequence<rtl::OUString> SAL_CALL
141 			getLdapUserProfileBeServiceNames(void) ;
142 
143     private:
144 		/** Check if LDAP is configured */
145         bool readLdapConfiguration(
146             uno::Reference<lang::XMultiServiceFactory> const & factory,
147             LdapDefinition * definition, rtl::OUString * loggedOnUser);
148 
149         bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess,
150 								const rtl::OUString& aLdapSetting,
151 								rtl::OString& aServerParameter);
152 
153     LdapData data_;
154 } ;
155 //------------------------------------------------------------------------------
156 }}}
157 
158 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_
159