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 67 virtual sal_Bool SAL_CALL 68 supportsService( const rtl::OUString& aServiceName ) ; 69 70 virtual uno::Sequence<rtl::OUString> SAL_CALL 71 getSupportedServiceNames( ) ; 72 73 // XPropertySet 74 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()75 getPropertySetInfo() 76 { return css::uno::Reference< css::beans::XPropertySetInfo >(); } 77 78 virtual void SAL_CALL setPropertyValue( 79 rtl::OUString const &, css::uno::Any const &); 80 81 virtual css::uno::Any SAL_CALL getPropertyValue( 82 rtl::OUString const & PropertyName); 83 addPropertyChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XPropertyChangeListener> const &)84 virtual void SAL_CALL addPropertyChangeListener( 85 rtl::OUString const &, 86 css::uno::Reference< css::beans::XPropertyChangeListener > const &) 87 {} 88 removePropertyChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XPropertyChangeListener> const &)89 virtual void SAL_CALL removePropertyChangeListener( 90 rtl::OUString const &, 91 css::uno::Reference< css::beans::XPropertyChangeListener > const &) 92 {} 93 addVetoableChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XVetoableChangeListener> const &)94 virtual void SAL_CALL addVetoableChangeListener( 95 rtl::OUString const &, 96 css::uno::Reference< css::beans::XVetoableChangeListener > const &) 97 {} 98 removeVetoableChangeListener(rtl::OUString const &,css::uno::Reference<css::beans::XVetoableChangeListener> const &)99 virtual void SAL_CALL removeVetoableChangeListener( 100 rtl::OUString const &, 101 css::uno::Reference< css::beans::XVetoableChangeListener > const &) 102 {} 103 104 /** 105 Provides the implementation name. 106 @return implementation name 107 */ 108 static rtl::OUString SAL_CALL getLdapUserProfileBeName(void) ; 109 /** 110 Provides the supported services names 111 @return service names 112 */ 113 static uno::Sequence<rtl::OUString> SAL_CALL 114 getLdapUserProfileBeServiceNames(void) ; 115 116 private: 117 /** Check if LDAP is configured */ 118 bool readLdapConfiguration( 119 uno::Reference<lang::XMultiServiceFactory> const & factory, 120 LdapDefinition * definition, rtl::OUString * loggedOnUser); 121 122 bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess, 123 const rtl::OUString& aLdapSetting, 124 rtl::OString& aServerParameter); 125 126 LdapData data_; 127 } ; 128 //------------------------------------------------------------------------------ 129 }}} 130 131 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_ 132