merge the formfield patch from ooo-build
[ooovba.git] / extensions / source / config / ldap / ldapuserprofilebe.hxx
blob352d499471c87a8e0263661f3da4227f8512268d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ldapuserprofilebe.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
32 #define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
34 #include "ldapuserprof.hxx"
35 #include "ldapaccess.hxx"
36 #include "ldapuserprofilelayer.hxx"
37 #include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
42 #include <com/sun/star/configuration/backend/CannotConnectException.hpp>
43 #include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
44 #include <com/sun/star/configuration/backend/ConnectionLostException.hpp>
45 #include <com/sun/star/container/XNameAccess.hpp>
46 #include <com/sun/star/lang/IllegalArgumentException.hpp>
47 #include <cppuhelper/compbase2.hxx>
50 #define CONTEXT_ITEM_PREFIX_ "/modules/com.sun.star.configuration/bootstrap/"
51 namespace extensions { namespace config { namespace ldap {
53 namespace css = com::sun::star ;
54 namespace uno = css::uno ;
55 namespace lang = css::lang ;
56 namespace ldap= css::ldap ;
57 namespace backend = css::configuration::backend ;
58 namespace container = css::container;
59 //------------------------------------------------------------------------------
61 //------------------------------------------------------------------------------
62 typedef cppu::WeakComponentImplHelper2<backend::XSingleLayerStratum,
63 lang::XServiceInfo> BackendBase ;
65 struct LdapProfileMutexHolder { osl::Mutex mMutex; };
66 /**
67 Implements the PlatformBackend service, a specialization of the
68 SingleLayerStratum service for retreiving LDAP user profile
69 configuration settings from a LDAP repsoitory.
71 class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase
73 public :
75 LdapUserProfileBe(const uno::Reference<uno::XComponentContext>& xContext);
76 // throw(backend::BackendAccessException, backend::BackendSetupException, RuntimeException);
77 ~LdapUserProfileBe(void) ;
79 // XServiceInfo
80 virtual rtl::OUString SAL_CALL
81 getImplementationName( )
82 throw (uno::RuntimeException) ;
84 virtual sal_Bool SAL_CALL
85 supportsService( const rtl::OUString& aServiceName )
86 throw (uno::RuntimeException) ;
88 virtual uno::Sequence<rtl::OUString> SAL_CALL
89 getSupportedServiceNames( )
90 throw (uno::RuntimeException) ;
92 //XSingleLayerStratum
93 virtual uno::Reference<backend::XLayer> SAL_CALL
94 getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
95 throw (backend::BackendAccessException,
96 lang::IllegalArgumentException,
97 uno::RuntimeException) ;
99 virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL
100 getUpdatableLayer( const rtl::OUString& aLayerId )
101 throw (backend::BackendAccessException,
102 lang::NoSupportException,
103 lang::IllegalArgumentException,
104 uno::RuntimeException) ;
106 Provides the implementation name.
107 @return implementation name
109 static rtl::OUString SAL_CALL getLdapUserProfileBeName(void) ;
111 Provides the supported services names
112 @return service names
114 static uno::Sequence<rtl::OUString> SAL_CALL
115 getLdapUserProfileBeServiceNames(void) ;
117 private:
118 /** Build OO/LDAP attribute mapping table */
119 void initializeMappingTable (const rtl::OUString& aFileMapName);
120 /** Check if LDAP is configured */
121 bool readLdapConfiguration(LdapDefinition& aDefinition);
123 bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess,
124 const rtl::OUString& aLdapSetting,
125 rtl::OString& aServerParameter);
127 void mapGenericException(ldap::LdapGenericException& aException)
128 throw (backend::InsufficientAccessRightsException,
129 backend::ConnectionLostException,
130 backend::BackendAccessException);
131 /** Connect to LDAP server */
132 void connectToLdapServer(const LdapDefinition& aDefinition );
133 /** Get URL of OO-to-LDAP Mapping File */
134 rtl::OUString getMappingFileUrl(const rtl::OUString& aFileMapName) const;
136 /** Service Factory object */
137 uno::Reference<lang::XMultiServiceFactory> mFactory;
138 /** Component Context */
139 uno::Reference<uno::XComponentContext> mContext ;
140 /** Object for LDAP functionality */
141 LdapUserProfileSourceRef mLdapSource;
142 /**Currently logged in user */
143 rtl::OUString mLoggedOnUser ;
144 /** DN of currently logged in user */
145 rtl::OString mUserDN;
148 //------------------------------------------------------------------------------
151 #endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_