diff options
author | sb <sb@openoffice.org> | 2010-03-04 23:05:27 +0100 |
---|---|---|
committer | sb <sb@openoffice.org> | 2010-03-04 23:05:27 +0100 |
commit | d11e7c65afe7eb24f8c696b5bd18898ae095f382 (patch) | |
tree | b8fe110f9c1c918d69579e38e176c4e8c9804e13 /extensions | |
parent | 8213de345f24af0c55b587802d5738e611b7009c (diff) | |
parent | 60c0e59fd450e39902d85918d2243fb83c02a21d (diff) |
merged in re/DEV300_next towards DEV300_m74
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/config/ldap/componentdef.cxx | 51 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapaccess.cxx | 76 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapaccess.hxx | 37 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapbe2.uno.xml | 45 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprof.cxx | 226 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprof.hxx | 163 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.cxx | 321 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.hxx | 112 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilelayer.cxx | 244 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilelayer.hxx | 121 | ||||
-rw-r--r-- | extensions/source/config/ldap/makefile.mk | 4 | ||||
-rw-r--r-- | extensions/source/config/ldap/propertysethelper.cxx | 150 | ||||
-rw-r--r-- | extensions/source/config/ldap/propertysethelper.hxx | 134 | ||||
-rw-r--r-- | extensions/source/oooimprovement/Jobs.xcu | 1 |
14 files changed, 172 insertions, 1513 deletions
diff --git a/extensions/source/config/ldap/componentdef.cxx b/extensions/source/config/ldap/componentdef.cxx index 986866939466..0fd917d2ff9e 100644 --- a/extensions/source/config/ldap/componentdef.cxx +++ b/extensions/source/config/ldap/componentdef.cxx @@ -28,14 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_extensions.hxx" -#ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_ #include "ldapuserprofilebe.hxx" -#endif //CONFIGMGR_BACKEND_LDAPUSERPROFILE_HXX_ -#include <com/sun/star/registry/XRegistryKey.hpp> -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ #include <cppuhelper/implementationentry.hxx> -#endif // _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ -#include <rtl/ustrbuf.hxx> using namespace extensions::config::ldap ; @@ -70,49 +64,8 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( extern "C" sal_Bool SAL_CALL component_writeInfo(void *aServiceManager, void *aRegistryKey) { - using namespace ::com::sun::star::registry; - if (aRegistryKey) - { - - /** Service factory */ - uno::Reference<lang::XMultiServiceFactory> xFactory - (reinterpret_cast<lang::XMultiServiceFactory*> (aServiceManager), - uno::UNO_QUERY); - - rtl::OUStringBuffer aImplKeyName; - aImplKeyName.appendAscii("/"); - aImplKeyName.append(LdapUserProfileBe::getLdapUserProfileBeName()); - - rtl::OUString aMainKeyName(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - - uno::Reference<XRegistryKey> xNewImplKey( - reinterpret_cast<XRegistryKey*> - (aRegistryKey)->createKey(aImplKeyName.makeStringAndClear())); - - uno::Reference<XRegistryKey> xNewKey( - xNewImplKey->createKey(aMainKeyName)); - - //Now register associated service names - uno::Sequence<rtl::OUString> sServiceNames = - LdapUserProfileBe::getLdapUserProfileBeServiceNames(); - for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i) - { - xNewKey->createKey(sServiceNames[i]); - } - //Now register associated org.openoffice.UserProfile component - //that this backend supports under xNewImplKey - uno::Reference<XRegistryKey> xComponentKey( - xNewImplKey->createKey(rtl::OUString::createFromAscii - ("/DATA/SupportedComponents"))); - - uno::Sequence<rtl::OUString> aComponentList(1); - aComponentList[0]= rtl::OUString::createFromAscii - ("org.openoffice.UserProfile"); - - xComponentKey->setAsciiListValue(aComponentList); - return sal_True; - } - return sal_False; + return cppu::component_writeInfoHelper( + aServiceManager, aRegistryKey, kImplementations_entries); } //------------------------------------------------------------------------------ diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx index 8e049df2d660..c518dc37e94c 100644 --- a/extensions/source/config/ldap/ldapaccess.cxx +++ b/extensions/source/config/ldap/ldapaccess.cxx @@ -30,7 +30,6 @@ #include "ldapaccess.hxx" -#include "ldapuserprof.hxx" #include <rtl/ustrbuf.hxx> #include <rtl/strbuf.hxx> @@ -46,6 +45,8 @@ t_ldap_init LdapConnection::s_p_init = NULL; t_ldap_msgfree LdapConnection::s_p_msgfree = NULL; t_ldap_get_dn LdapConnection::s_p_get_dn = NULL; t_ldap_first_entry LdapConnection::s_p_first_entry = NULL; +t_ldap_first_attribute LdapConnection::s_p_first_attribute = NULL; +t_ldap_next_attribute LdapConnection::s_p_next_attribute = NULL; t_ldap_search_s LdapConnection::s_p_search_s = NULL; t_ldap_value_free LdapConnection::s_p_value_free = NULL; t_ldap_get_values LdapConnection::s_p_get_values = NULL; @@ -188,12 +189,12 @@ void LdapConnection::initConnection() } } //------------------------------------------------------------------------------ - void LdapConnection::getUserProfile(const rtl::OUString& aUser, - const LdapUserProfileMap& aUserProfileMap, - LdapUserProfile& aUserProfile) + void LdapConnection::getUserProfile( + const rtl::OUString& aUser, LdapData * data) throw (lang::IllegalArgumentException, ldap::LdapConnectionException, ldap::LdapGenericException) - { +{ + OSL_ASSERT(data != 0); if (!isValid()) { connectSimple(); } rtl::OString aUserDn =findUserDn( rtl::OUStringToOString(aUser, RTL_TEXTENCODING_ASCII_US)); @@ -203,18 +204,26 @@ void LdapConnection::initConnection() aUserDn, LDAP_SCOPE_BASE, "(objectclass=*)", - const_cast<sal_Char **>(aUserProfileMap.getLdapAttributes()), + 0, 0, // Attributes + values &result.msg) ; checkLdapReturnCode("getUserProfile", retCode,mConnection) ; - - aUserProfileMap.ldapToUserProfile(mConnection, - result.msg, - aUserProfile) ; - - } + void * ptr; + char * attr = (*s_p_first_attribute)(mConnection, result.msg, &ptr); + while (attr != 0) { + char ** values = (*s_p_get_values)(mConnection, result.msg, attr); + if (values != 0) { + data->insert( + LdapData::value_type( + rtl::OStringToOUString(attr, RTL_TEXTENCODING_ASCII_US), + rtl::OStringToOUString(*values, RTL_TEXTENCODING_UTF8))); + (*s_p_value_free)(values); + } + attr = (*s_p_next_attribute)(mConnection, result.msg, ptr); + } +} //------------------------------------------------------------------------------ rtl::OString LdapConnection::findUserDn(const rtl::OString& aUser) throw (lang::IllegalArgumentException, @@ -264,47 +273,6 @@ void LdapConnection::initConnection() return userDn ; } -//------------------------------------------------------------------------------ -rtl::OString LdapConnection::getSingleAttribute( - const rtl::OString& aDn, - const rtl::OString& aAttribute) - throw (ldap::LdapConnectionException, ldap::LdapGenericException) -{ - if (!isValid()) { connectSimple(); } - const sal_Char *attributes [2] ; - rtl::OString value ; - - attributes [0] = aAttribute ; - attributes [1] = 0 ; - LdapMessageHolder result ; - LdapErrCode retCode = (*s_p_search_s)(mConnection, - aDn, - LDAP_SCOPE_BASE, - "(objectclass=*)", - const_cast<sal_Char **>(attributes), - 0, // Attributes + values - &result.msg) ; - - if (retCode == LDAP_NO_SUCH_OBJECT) - { - return value ; - } - checkLdapReturnCode("GetSingleAttribute", retCode, mConnection) ; - LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ; - - if (entry != NULL) - { - sal_Char **values = (*s_p_get_values)(mConnection, entry, - aAttribute) ; - - if (values != NULL) - { - if (*values != NULL) { value = *values ; } - (*s_p_value_free)(values) ; - } - } - return value ; -} extern "C" { static void SAL_CALL thisModule() {} } void LdapConnection::loadModule() @@ -336,6 +304,8 @@ void LdapConnection::loadModule() s_p_msgfree = (t_ldap_msgfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_msgfree").pData)); s_p_get_dn = (t_ldap_get_dn)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_dn").pData)); s_p_first_entry = (t_ldap_first_entry)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_entry").pData)); + s_p_first_attribute = (t_ldap_first_attribute)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_attribute").pData)); + s_p_next_attribute = (t_ldap_next_attribute)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_next_attribute").pData)); s_p_search_s = (t_ldap_search_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_search_s").pData)); s_p_value_free = (t_ldap_value_free)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_value_free").pData)); s_p_get_values = (t_ldap_get_values)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_values").pData)); diff --git a/extensions/source/config/ldap/ldapaccess.hxx b/extensions/source/config/ldap/ldapaccess.hxx index d5f4e0606864..b2ea7970952e 100644 --- a/extensions/source/config/ldap/ldapaccess.hxx +++ b/extensions/source/config/ldap/ldapaccess.hxx @@ -28,6 +28,10 @@ #ifndef EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_ #define EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_ +#include "sal/config.h" + +#include <map> + #include "wrapldapinclude.hxx" #include <com/sun/star/ldap/LdapGenericException.hpp> @@ -54,6 +58,8 @@ typedef LDAP_API(LDAP *) (LDAP_CALL *t_ldap_init)( const char *defhost, int defp typedef LDAP_API(int) (LDAP_CALL *t_ldap_msgfree)( LDAPMessage *lm ); typedef LDAP_API(char *) (LDAP_CALL *t_ldap_get_dn)( LDAP *ld, LDAPMessage *entry ); typedef LDAP_API(LDAPMessage *) (LDAP_CALL *t_ldap_first_entry)( LDAP *ld, LDAPMessage *chain ); +typedef LDAP_API(char *) (LDAP_CALL *t_ldap_first_attribute)( LDAP *ld, LDAPMessage *entry, void **ptr ); +typedef LDAP_API(char *) (LDAP_CALL *t_ldap_next_attribute)( LDAP *ld, LDAPMessage *entry, void *ptr ); typedef LDAP_API(int) (LDAP_CALL *t_ldap_search_s)( LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPMessage **res ); typedef LDAP_API(void) (LDAP_CALL *t_ldap_value_free)( char **vals ); typedef LDAP_API(char **) (LDAP_CALL *t_ldap_get_values)( LDAP *ld, LDAPMessage *entry, const char *target ); @@ -76,10 +82,10 @@ struct LdapDefinition rtl::OString mUserObjectClass; /** User Entity Unique Attribute */ rtl::OString mUserUniqueAttr; - /** Mapping File */ - rtl::OString mMapping; } ; +typedef std::map< rtl::OUString, rtl::OUString > LdapData; // key/value pairs + /** Class encapulating all LDAP functionality */ class LdapConnection { @@ -95,36 +101,19 @@ public: throw (ldap::LdapConnectionException, ldap::LdapGenericException); - /** query connection status */ - bool isConnected() const { return isValid(); } - /** Gets LdapUserProfile from LDAP repository for specified user @param aUser name of logged on user @param aUserProfileMap Map containing LDAP->00o mapping - @param aUserProfile struct for holding OOo values + @param aUserProfile struct for holding OOo values @throws com::sun::star::ldap::LdapGenericException if an LDAP error occurs. */ - void getUserProfile(const rtl::OUString& aUser, - const LdapUserProfileMap& aUserProfileMap, - LdapUserProfile& aUserProfile) + void getUserProfile(const rtl::OUString& aUser, LdapData * data) throw (lang::IllegalArgumentException, ldap::LdapConnectionException, ldap::LdapGenericException); - /** - Retrieves a single attribute from a single entry. - @param aDn entry DN - @param aAttribute attribute name - - @throws com::sun::star::ldap::LdapGenericException - if an LDAP error occurs. - */ - rtl::OString getSingleAttribute(const rtl::OString& aDn, - const rtl::OString& aAttribute) - throw (ldap::LdapConnectionException, - ldap::LdapGenericException); /** finds DN of user @return DN of User @@ -137,8 +126,6 @@ public: void loadModule(); static t_ldap_err2string s_p_err2string; - static t_ldap_value_free s_p_value_free; - static t_ldap_get_values s_p_get_values; private: void initConnection() @@ -159,6 +146,8 @@ private: LdapDefinition mLdapDefinition; static oslModule s_Ldap_Module; + static t_ldap_value_free s_p_value_free; + static t_ldap_get_values s_p_get_values; static t_ldap_unbind_s s_p_unbind_s; static t_ldap_simple_bind_s s_p_simple_bind_s; static t_ldap_set_option s_p_set_option; @@ -166,6 +155,8 @@ private: static t_ldap_msgfree s_p_msgfree; static t_ldap_get_dn s_p_get_dn; static t_ldap_first_entry s_p_first_entry; + static t_ldap_first_attribute s_p_first_attribute; + static t_ldap_next_attribute s_p_next_attribute; static t_ldap_search_s s_p_search_s; static t_ldap_memfree s_p_memfree; diff --git a/extensions/source/config/ldap/ldapbe2.uno.xml b/extensions/source/config/ldap/ldapbe2.uno.xml deleted file mode 100644 index e365e20f48aa..000000000000 --- a/extensions/source/config/ldap/ldapbe2.uno.xml +++ /dev/null @@ -1,45 +0,0 @@ -c<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice/DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name>ldapbe2.uno</module-name> - <component-description> - <author>Sarah Smith</author> - <name>com.sun.star.comp.configuration.backend.LdapUserProfileBe</name> - <description>The LdapUserProfileBe accesses User Profile settings form a configured LDAP repository</description> - <loader-name>com.sun.star.loader.SharedLibrary</loader-name> - <language>C++</language> - <status value="final"/> - <supported-service>com.sun.star.configuration.backend.LdapUserProfileBe</supported-service> - <supported-service>com.sun.star.configuration.backend.PlatformBackend</supported-service> - <supported-service>com.sun.star.configuration.backend.SingleLayerStratum</supported-service> - <service-dependency>com.sun.star.configuration.backend.LayerDescriber</service-dependency> - <type>com.sun.star.configuration.CannotLoadConfigurationException</type> - <type>com.sun.star.configuration.backend.BackendAccessException</type> - <type>com.sun.star.configuration.backend.XLayer</type> - <type>com.sun.star.configuration.backend.XUpdateHandler</type> - <type>com.sun.star.configuration.backend.XSingleLayerStratum</type> - <type>com.sun.star.uno.XComponentContext</type> - <type>com.sun.star.lang.IllegalArgumentException</type> - <type>com.sun.star.lang.XInitialization</type> - <type>com.sun.star.lang.XMultiServiceFactory</type> - <type>com.sun.star.lang.XServiceInfo</type> - <type>com.sun.star.lang.XSingleServiceFactory</type> - <type>com.sun.star.lang.XSingleComponentFactory</type> - <type>com.sun.star.lang.XTypeProvider</type> - <type>com.sun.star.registry.XRegistryKey</type> - <type>com.sun.star.uno.Any</type> - <type>com.sun.star.uno.Sequence</type> - </component-description> - <project-build-dependency> comphelper </project-build-dependency> - <project-build-dependency> vos </project-build-dependency> - <project-build-dependency> cppuhelper </project-build-dependency> - <project-build-dependency> salhelper </project-build-dependency> - <project-build-dependency> cppu </project-build-dependency> - <project-build-dependency> sal </project-build-dependency> - <runtime-module-dependency> comphelp2$(COM) </runtime-module-dependency> - <runtime-module-dependency> vos2$(COM) </runtime-module-dependency> - <runtime-module-dependency> cppuhelper3$(COM) </runtime-module-dependency> - <runtime-module-dependency> salhelper3$(COM) </runtime-module-dependency> - <runtime-module-dependency> cppu3 </runtime-module-dependency> - <runtime-module-dependency> sal3 </runtime-module-dependency> -</module-description> diff --git a/extensions/source/config/ldap/ldapuserprof.cxx b/extensions/source/config/ldap/ldapuserprof.cxx deleted file mode 100644 index a75a1b0d1447..000000000000 --- a/extensions/source/config/ldap/ldapuserprof.cxx +++ /dev/null @@ -1,226 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#include "ldapuserprof.hxx" -#include "ldapaccess.hxx" -namespace extensions { namespace config { namespace ldap { -//============================================================================== - -//------------------------------------------------------------------------------ - -/** - Finds the next line in a buffer and returns it, along with a - modified version of the buffer with the line removed. - - @param aString string to extract the next line from - @param aLine next line - @return sal_True if a line has been extracted, sal_False otherwise - */ -static sal_Bool getNextLine(rtl::OString& aString, - rtl::OString& aLine) -{ - aString = aString.trim() ; - const sal_Char *currentChar = aString ; - const sal_Char *endChar = currentChar + aString.getLength() ; - sal_Int32 lineThreshold = 0 ; - - while (currentChar < endChar && - *currentChar != '\r' && *currentChar != '\n') { ++ currentChar ; } - lineThreshold = currentChar - static_cast<const sal_Char *>(aString) ; - if (lineThreshold == 0) { return sal_False ; } - aLine = aString.copy(0, lineThreshold) ; - aString = aString.copy(lineThreshold) ; - return sal_True ; -} -//------------------------------------------------------------------------------ - -LdapUserProfileMap::~LdapUserProfileMap(void) -{ - // No need to delete the contents of the mAttributes array, - // since they refer to rtl::OStrings stored in the mLdapAttributes - // array. - if (mAttributes != NULL) - { - delete [] mAttributes ; - } -} -//------------------------------------------------------------------------------ - -void LdapUserProfileMap::source(const rtl::OString& aMap) -{ - if (mAttributes != NULL) - { - delete [] mAttributes ; mAttributes = NULL ; - mMapping.clear() ; - } - rtl::OString currentLine ; - rtl::OString buffer = aMap ; - std::set<rtl::OString> attributes ; - rtl::OString prefix ; - - // First, parse the buffer to find all the mapping definitions. - // While we're at it, we collect the list of unique LDAP attributes - // involved in the mapping. - while (getNextLine(buffer, currentLine)) - { - addNewMapping(currentLine, attributes, prefix) ; - } - // Now we use the list of attributes to build mAttributes - mAttributes = new const sal_Char * [attributes.size() + 1] ; - std::set<rtl::OString>::const_iterator attribute ; - sal_Int32 i = 0 ; - - for (attribute = attributes.begin() ; - attribute != attributes.end() ; ++ attribute) - { - mAttributes [i ++] = static_cast<const sal_Char *>(*attribute) ; - } - mAttributes [i] = NULL ; -} -//------------------------------------------------------------------------------ - -void LdapUserProfileMap::ldapToUserProfile(LDAP *aConnection, - LDAPMessage *aEntry, - LdapUserProfile& aProfile) const -{ - if (aEntry == NULL) { return ; } - // Ensure return value has proper size - aProfile.mProfile.resize(mMapping.size()) ; - sal_Char **values = NULL ; - - for (sal_uInt32 i = 0 ; i < mMapping.size() ; ++ i) - { - aProfile.mProfile [i].mAttribute = rtl::OStringToOUString( - mMapping [i].mProfileElement, - RTL_TEXTENCODING_ASCII_US); - rtl::OUString debugStr = aProfile.mProfile [i].mAttribute; - - for (sal_uInt32 j = 0 ; - j < mMapping [i].mLdapAttributes.size() ; ++ j) - { - values = (*LdapConnection::s_p_get_values)(aConnection, aEntry, - mMapping [i].mLdapAttributes [j]) ; - - if (values != NULL) - { - aProfile.mProfile[i].mValue = rtl::OStringToOUString( - *values, RTL_TEXTENCODING_UTF8); - (*LdapConnection::s_p_value_free)(values); - break; - } - } - } -} -//------------------------------------------------------------------------------ -void LdapUserProfileMap::addNewMapping(const rtl::OString& aLine, - std::set<rtl::OString>& aLdapAttributes, - rtl::OString& aPrefix) -{ - if (aLine.getStr() [0] == '#') { return ; } - sal_Int32 prefixLength = aPrefix.getLength() ; - - if (prefixLength == 0) - { - sal_Int32 firstSlash = aLine.indexOf('/') ; - - if (firstSlash == -1) { return ; } - sal_Int32 secondSlash = aLine.indexOf('/', firstSlash + 1) ; - - if (secondSlash == -1){ return; } - - - mComponentName = - rtl::OUString::createFromAscii(aLine.copy(0, firstSlash)) ; - mGroupName = - rtl::OUString::createFromAscii(aLine.copy(firstSlash + 1, - secondSlash - firstSlash - 1)) ; - aPrefix = aLine.copy(0, secondSlash + 1) ; - prefixLength = secondSlash + 1 ; - - } - else if (aLine.compareTo(aPrefix, prefixLength) != 0) - { - return ; - } - mMapping.push_back(Mapping()) ; - if (!mMapping.back().parse(aLine.copy(prefixLength))) - { - mMapping.pop_back() ; - } - else - { - const std::vector<rtl::OString>& attributes = - mMapping.back().mLdapAttributes ; - std::vector<rtl::OString>::const_iterator ldapAttribute ; - - for (ldapAttribute = attributes.begin() ; - ldapAttribute != attributes.end() ; ++ ldapAttribute) - { - aLdapAttributes.insert(*ldapAttribute) ; - } - } -} -//------------------------------------------------------------------------------ - -static sal_Char kMappingSeparator = '=' ; -static sal_Char kLdapMapSeparator = ',' ; - -sal_Bool LdapUserProfileMap::Mapping::parse(const rtl::OString& aLine) -{ - sal_Int32 index = aLine.indexOf(kMappingSeparator) ; - - if (index == -1) - { - // Imparsable line - return sal_False ; - } - sal_Int32 oldIndex = index + 1 ; - - mProfileElement = aLine.copy(0, index).trim() ; - mLdapAttributes.clear() ; - index = aLine.indexOf(kLdapMapSeparator, oldIndex) ; - while (index != -1) - { - mLdapAttributes.push_back( - aLine.copy(oldIndex, index - oldIndex).trim()) ; - oldIndex = index + 1 ; - index = aLine.indexOf(kLdapMapSeparator, oldIndex) ; - } - rtl::OString endOfLine = aLine.copy(oldIndex).trim() ; - - if (endOfLine.getLength() > 0) - { - mLdapAttributes.push_back(endOfLine) ; - } - return sal_True ; -} -//------------------------------------------------------------------------------ - -} } } // extensiond.config.ldap - diff --git a/extensions/source/config/ldap/ldapuserprof.hxx b/extensions/source/config/ldap/ldapuserprof.hxx deleted file mode 100644 index 36b9d671ea02..000000000000 --- a/extensions/source/config/ldap/ldapuserprof.hxx +++ /dev/null @@ -1,163 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_ -#define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_ - -#include "wrapldapinclude.hxx" -#include <rtl/ustring.hxx> -#include <rtl/string.hxx> - -#ifndef VECTOR_INCLUDED -#define VECTOR_INCLUDED -#include <vector> -#endif // VECTOR_INCLUDED - -#ifndef SET_INCLUDED -#define SET_INCLUDED -#include <set> -#endif // SET_INCLUDED - - -namespace extensions { namespace config { namespace ldap { - -/** Struct containing the data associated to a UserProfile */ -struct LdapUserProfile { - /** Struct defining an entry in the profile */ - struct ProfileEntry { - rtl::OUString mAttribute ; - rtl::OUString mValue ; - } ; - /** List of attribute/value pairs */ - std::vector<ProfileEntry> mProfile ; - - typedef std::vector<ProfileEntry>::const_iterator Iterator; -} ; - -/** Provider of UserProfile mapping services */ -class LdapUserProfileMap -{ - public : - /** Default constructor, doesn't do much. */ - LdapUserProfileMap() : mAttributes(NULL) {} - /** Destructor */ - ~LdapUserProfileMap() ; - - /** - Fills the map using a string description of the mapping. - Each possible UserProfile attribute is mapped to a list - of LDAP attributes, in order of priority. - The entry is formatted as: - <UP Attribute>=<LDAP Attr1>,...,<LDAP AttrN> - - @param aMap string description of the mapping - */ - void source(const rtl::OString& aMap) ; - /** - Returns an array of all the LDAP attribute names that may - be relevant for UserProfile mapping. - - @return array of LDAP attribute names - */ - const sal_Char **getLdapAttributes(void) const { return mAttributes ; } - /** - Returns the component name that holds the data - when presented to the outside. - - @return component name - */ - const rtl::OUString& getComponentName(void) const { - return mComponentName ; - } - /** - Returns the group name that holds the data when - presented to the outside world. - - @return group name - */ - const rtl::OUString& getGroupName(void) const { - return mGroupName ; - } - /** - Struct defining the mapping between UserProfile attributes - and LDAP ones. It also serves as a crude "schema" of the - UserProfile component, as the list of profile elements - is the list of properties in the component and the presence - or absence of LDAP mapping indicates whether the property - should be made writable or kept read-only. - */ - struct Mapping { - /** Name of the UserProfile element */ - rtl::OString mProfileElement ; - /** Corresponding LDAP attributes in order of priority */ - std::vector<rtl::OString> mLdapAttributes ; - - /** Utility to fill the mapping from a <Prof>=<Ldap1>;...;<LdapN> - description */ - sal_Bool parse(const rtl::OString& aDescription) ; - } ; - - - /** - Maps an LDAP entry to a UserProfile. - - @param aConnection LDAP connection to the repository - @param aEntry entry containing the data - @param aProfile user profile struct to fill up - */ - void ldapToUserProfile(LDAP *aConnection, - LDAPMessage *aEntry, - LdapUserProfile& aProfile) const ; - - private : - /** Contains the mapping entries */ - std::vector<Mapping> mMapping ; - /** Contains the LDAP attributes used in a NULL terminated array */ - const sal_Char **mAttributes ; - /** User profile component name */ - rtl::OUString mComponentName ; - /** User profile storage group name */ - rtl::OUString mGroupName ; - - /** - Adds a new mapping entry to the list, and collects the - LDAP attributes involved in the mapping. - - @param aMappingDescription string describing the mapping - @param aLdapAttributes collection of LDAP attributes - @param aPrefix common prefix to the attributes - containing the component and group - name, used for validation - */ - void addNewMapping(const rtl::OString& aMappingDescription, - std::set<rtl::OString>& aLdapAttributes, - rtl::OString& aPrefix) ; -} ; - -} } } // extensions.config.ldap - -#endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_ diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx index 9466dfb1371f..5826188c564d 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.cxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx @@ -28,8 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_extensions.hxx" +#include "ldapaccess.hxx" #include "ldapuserprofilebe.hxx" -#include "ldapuserprofilelayer.hxx" #include <osl/file.hxx> #include <osl/module.hxx> #include <osl/process.h> @@ -40,63 +40,18 @@ #include <rtl/instance.hxx> #endif #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/Optional.hpp> #include <osl/security.hxx> //============================================================================== namespace extensions { namespace config { namespace ldap { - -static void checkIOError( - osl::File::RC aErrorCode, - const rtl::OUString& aFileUrl) -{ - switch (aErrorCode) - { - case osl::File::E_None: // got it - { - - } - break; - default: - { - rtl::OUStringBuffer sMsg; - sMsg.appendAscii("LdapUserProfileBe: Cannot Read Meta-Configuration file:"); - sMsg.append(aFileUrl); - throw backend::BackendSetupException(sMsg.makeStringAndClear(), - NULL, uno::Any()); - } - } -} - -//------------------------------------------------------------------------------ -#if 0 -static rtl::OUString getCurrentModuleDirectory() // URL excluding terminating slash -{ - rtl::OUString aFileURL; - if ( !osl::Module::getUrlFromAddress((void*)&getCurrentModuleDirectory,aFileURL) ) - { - OSL_TRACE(false, "Cannot locate current module - using executable instead"); - - OSL_VERIFY(osl_Process_E_None == osl_getExecutableFile(&aFileURL.pData)); - } - - OSL_ENSURE(0 < aFileURL.lastIndexOf('/'), "Cannot find directory for module URL"); - - return aFileURL.copy(0, aFileURL.lastIndexOf('/') ); -} -#endif -//------------------------------------------------------------------------------ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContext>& xContext) -// throw (backend::BackendAccessException, backend::BackendSetupException, RuntimeException) : LdapProfileMutexHolder(), - BackendBase(mMutex), - mFactory(xContext->getServiceManager(),uno::UNO_QUERY_THROW), - mContext(xContext), - mLdapSource( new LdapUserProfileSource ), - mLoggedOnUser(), - mUserDN() + BackendBase(mMutex) { LdapDefinition aDefinition; + rtl::OUString loggedOnUser; // This whole rigmarole is to prevent an infinite recursion where reading // the configuration for the backend would create another instance of the @@ -113,16 +68,20 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex try { bReentrantCall = true ; - if (! readLdapConfiguration(aDefinition) ) + if (!readLdapConfiguration( + css::uno::Reference< css::lang::XMultiServiceFactory >( + xContext->getServiceManager(), + css::uno::UNO_QUERY_THROW), + &aDefinition, &loggedOnUser)) { - throw backend::BackendSetupException( + throw css::uno::RuntimeException( rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"), - NULL, uno::Any()); + NULL); } bReentrantCall = false ; } - catch (uno::Exception&) + catch (...) { bReentrantCall = false; throw; @@ -130,34 +89,10 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex } } - try - { - mLdapSource->mConnection.loadModule(); - mLdapSource->mConnection.connectSimple(aDefinition); - //Set the UserDN - mUserDN = mLdapSource->mConnection.findUserDn( - rtl::OUStringToOString(mLoggedOnUser, RTL_TEXTENCODING_ASCII_US)); - } - catch (lang::IllegalArgumentException& exception) - { - throw backend::BackendSetupException(exception.Message, NULL, - uno::makeAny(exception)) ; - } - catch (ldap::LdapConnectionException& exception) - { - throw backend::CannotConnectException(exception.Message, NULL, - uno::makeAny(exception)) ; - } - catch(ldap::LdapGenericException& exception) - { - mapGenericException(exception) ; - } - - initializeMappingTable( - rtl::OStringToOUString(aDefinition.mMapping, - RTL_TEXTENCODING_ASCII_US)); - - OSL_POSTCOND(mLdapSource->mConnection.isConnected(),"Erroneously constructed a LdapUserProfileBackend without a LDAP connection"); + LdapConnection connection; + connection.loadModule(); + connection.connectSimple(aDefinition); + connection.getUserProfile(loggedOnUser, &data_); } //------------------------------------------------------------------------------ LdapUserProfileBe::~LdapUserProfileBe() @@ -165,129 +100,11 @@ LdapUserProfileBe::~LdapUserProfileBe() } //------------------------------------------------------------------------------ -void LdapUserProfileBe::initializeMappingTable(const rtl::OUString& aFileMapName) -{ - rtl::OUString aMappingFileUrl = getMappingFileUrl(aFileMapName ); - - osl::File aFile (aMappingFileUrl); - checkIOError( aFile.open(OpenFlag_Read), aMappingFileUrl); - - sal_uInt64 nFileLength = 0; - checkIOError( aFile.getSize(nFileLength), aMappingFileUrl); - - sal_uInt32 nDataLength = sal_uInt32(nFileLength); - if (nDataLength != nFileLength) - { - throw backend::BackendSetupException(rtl::OUString::createFromAscii - ("LdapUserProfileBe - can not read entire Mapping File: too big"), - NULL, uno::Any()); - } - - struct RawBuffer - { - RawBuffer(sal_Size size) : data(rtl_allocateMemory(size)) {} - ~RawBuffer() { rtl_freeMemory(data); } - - void * data; - }; - RawBuffer buffer( nDataLength ); - - sal_uInt64 nRead = 0; - osl::File::RC result = aFile.read (static_cast<sal_uInt8*>(buffer.data), nDataLength, nRead); - if (result != osl::File::E_None) - { - checkIOError( result, aMappingFileUrl ); - OSL_ASSERT(!"unreached"); - } - - if (nRead != nDataLength) - { - throw backend::BackendSetupException(rtl::OUString::createFromAscii - ("LdapUserProfileBe - can not read entire Mapping File"), - NULL, uno::Any()); - } - - rtl::OString aStrBuffer ( static_cast<char*>(buffer.data), sal_uInt32(nDataLength) ); - mLdapSource->mProfileMap.source(aStrBuffer); - -} -//------------------------------------------------------------------------------ - -static const rtl::OUString kMappingFileSuffix(RTL_CONSTASCII_USTRINGPARAM( - "-attr.map")); - -static const rtl::OUString kMappingUrl( - RTL_CONSTASCII_USTRINGPARAM("/modules/com.sun.star.configuration/bootstrap/LdapMappingUrl")); - - -static const sal_Unicode kPathSeparator = '/' ; -static const rtl::OUString kBootstrapContextSingletonName( - RTL_CONSTASCII_USTRINGPARAM( - "/singletons/com.sun.star.configuration.bootstrap.theBootstrapContext")); - -rtl::OUString LdapUserProfileBe::getMappingFileUrl(const rtl::OUString& aFileMapName) const -{ - uno::Any aContext = mContext->getValueByName(kBootstrapContextSingletonName); - uno::Reference<uno::XComponentContext> aBootStrapContext; - - rtl::OUString aFileUrl; - if (aContext >>= aBootStrapContext) - aBootStrapContext->getValueByName(kMappingUrl) >>= aFileUrl; - - if (aFileUrl.getLength() == 0 ) - { -#if 0 - static const rtl::OUString kMappingDirectory(RTL_CONSTASCII_USTRINGPARAM( "/share/registry/ldap")); - - rtl::OUString aModuleUrl = getCurrentModuleDirectory(); - sal_Int32 nIndex = aModuleUrl.lastIndexOf('/'); - if (nIndex == 0) - { - throw backend::BackendSetupException(rtl::OUString::createFromAscii - ("LdapUserProfileBe - can not access Mapping File"), - NULL, uno::Any()); - } - rtl::OUString aMappingFileUrl = aModuleUrl.copy(0, nIndex); - aMappingFileUrl += kMappingDirectory; - aFileUrl = aMappingFileUrl; -#else - throw backend::BackendSetupException(rtl::OUString::createFromAscii - ("LdapUserProfileBe - can not locate Mapping File"), - NULL, uno::Any()); -#endif - } - - rtl::OUStringBuffer sFileBuffer(aFileUrl); - sFileBuffer.append(kPathSeparator); - sFileBuffer.append (aFileMapName); - sFileBuffer.append(kMappingFileSuffix); - return sFileBuffer.makeStringAndClear(); -} -//------------------------------------------------------------------------------ -void LdapUserProfileBe::mapGenericException(ldap::LdapGenericException& aException) - throw (backend::InsufficientAccessRightsException, - backend::ConnectionLostException, - backend::BackendAccessException) -{ - switch (aException.ErrorCode) - { - case LDAP_INSUFFICIENT_ACCESS: - throw backend::InsufficientAccessRightsException(aException.Message, - NULL, uno::makeAny(aException)) ; - - case LDAP_SERVER_DOWN: - case LDAP_CONNECT_ERROR: - throw backend::ConnectionLostException(aException.Message, NULL, - uno::makeAny(aException)) ; - default: - throw backend::BackendAccessException(aException.Message, NULL, - uno::makeAny(aException)) ; - } -} -//------------------------------------------------------------------------------ - -bool LdapUserProfileBe::readLdapConfiguration(LdapDefinition& aDefinition) +bool LdapUserProfileBe::readLdapConfiguration( + css::uno::Reference< css::lang::XMultiServiceFactory > const & factory, + LdapDefinition * definition, rtl::OUString * loggedOnUser) { + OSL_ASSERT(factory.is() && definition != 0 && loggedOnUser != 0); const rtl::OUString kConfigurationProviderService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")) ; const rtl::OUString kReadOnlyViewService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ; const rtl::OUString kComponent( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.LDAP/UserDirectory")); @@ -299,14 +116,12 @@ bool LdapUserProfileBe::readLdapConfiguration(LdapDefinition& aDefinition) const rtl::OUString kPassword(RTL_CONSTASCII_USTRINGPARAM("SearchPassword")); const rtl::OUString kUserObjectClass(RTL_CONSTASCII_USTRINGPARAM("UserObjectClass")); const rtl::OUString kUserUniqueAttr(RTL_CONSTASCII_USTRINGPARAM("UserUniqueAttribute")); - const rtl::OUString kMapping(RTL_CONSTASCII_USTRINGPARAM("Mapping")); - const rtl::OString kDefaultMappingFile("oo-ldap"); uno::Reference< XInterface > xIface; try { uno::Reference< lang::XMultiServiceFactory > xCfgProvider( - mFactory->createInstance(kConfigurationProviderService), + factory->createInstance(kConfigurationProviderService), uno::UNO_QUERY); OSL_ENSURE(xCfgProvider.is(),"LdapUserProfileBe: could not create the configuration provider"); if (!xCfgProvider.is()) @@ -324,26 +139,23 @@ bool LdapUserProfileBe::readLdapConfiguration(LdapDefinition& aDefinition) uno::Reference<container::XNameAccess > xChildAccess(xIface, uno::UNO_QUERY_THROW); - if (!getLdapStringParam(xChildAccess, kServer, aDefinition.mServer)) + if (!getLdapStringParam(xChildAccess, kServer, definition->mServer)) return false; - if (!getLdapStringParam(xChildAccess, kBaseDN, aDefinition.mBaseDN)) + if (!getLdapStringParam(xChildAccess, kBaseDN, definition->mBaseDN)) return false; - aDefinition.mPort=0; - xChildAccess->getByName(kPort) >>= aDefinition.mPort ; - if (aDefinition.mPort == 0) + definition->mPort=0; + xChildAccess->getByName(kPort) >>= definition->mPort ; + if (definition->mPort == 0) return false; - if (!getLdapStringParam(xAccess, kUserObjectClass, aDefinition.mUserObjectClass)) + if (!getLdapStringParam(xAccess, kUserObjectClass, definition->mUserObjectClass)) return false; - if (!getLdapStringParam(xAccess, kUserUniqueAttr, aDefinition.mUserUniqueAttr)) + if (!getLdapStringParam(xAccess, kUserUniqueAttr, definition->mUserUniqueAttr)) return false; - getLdapStringParam(xAccess, kUser, aDefinition.mAnonUser); - getLdapStringParam(xAccess, kPassword, aDefinition.mAnonCredentials); - - if (!getLdapStringParam(xAccess, kMapping, aDefinition.mMapping)) - aDefinition.mMapping = kDefaultMappingFile; + getLdapStringParam(xAccess, kUser, definition->mAnonUser); + getLdapStringParam(xAccess, kPassword, definition->mAnonCredentials); } catch (uno::Exception & e) { @@ -353,15 +165,15 @@ bool LdapUserProfileBe::readLdapConfiguration(LdapDefinition& aDefinition) } osl::Security aSecurityContext; - if (!aSecurityContext.getUserName(mLoggedOnUser)) + if (!aSecurityContext.getUserName(*loggedOnUser)) OSL_TRACE("LdapUserProfileBackend - could not get Logged on user from system"); - sal_Int32 nIndex = mLoggedOnUser.indexOf('/'); + sal_Int32 nIndex = loggedOnUser->indexOf('/'); if (nIndex > 0) - mLoggedOnUser = mLoggedOnUser.copy(nIndex+1); + *loggedOnUser = loggedOnUser->copy(nIndex+1); //Remember to remove - OSL_TRACE("Logged on user is %s", rtl::OUStringToOString(mLoggedOnUser,RTL_TEXTENCODING_ASCII_US).getStr()); + OSL_TRACE("Logged on user is %s", rtl::OUStringToOString(*loggedOnUser,RTL_TEXTENCODING_ASCII_US).getStr()); return true; } @@ -379,35 +191,48 @@ bool LdapUserProfileBe::getLdapStringParam( return aServerParameter.getLength() != 0; } //------------------------------------------------------------------------------ -uno::Reference<backend::XLayer> SAL_CALL LdapUserProfileBe::getLayer( - const rtl::OUString& /*aComponent*/, const rtl::OUString& /*aTimestamp*/) - throw (backend::BackendAccessException, lang::IllegalArgumentException,uno::RuntimeException) +void LdapUserProfileBe::setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - OSL_PRECOND(mLdapSource->mConnection.isConnected(), "LdapUserProfileBackend invoked without a connection"); - if (!mLdapSource->mConnection.isConnected()) - return NULL; - - const rtl::OString kModificationAttribute = "modifyTimeStamp"; - - rtl::OString aTimeStamp = mLdapSource->mConnection. - getSingleAttribute( mUserDN, kModificationAttribute); - - return new LdapUserProfileLayer( - mFactory, mLoggedOnUser, mLdapSource, - rtl::OStringToOUString(aTimeStamp, RTL_TEXTENCODING_ASCII_US)); + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")), + static_cast< cppu::OWeakObject * >(this), -1); } -//------------------------------------------------------------------------------ -uno::Reference<backend::XUpdatableLayer> SAL_CALL -LdapUserProfileBe::getUpdatableLayer(const rtl::OUString& /*aComponent*/) - throw (backend::BackendAccessException,lang::NoSupportException, - lang::IllegalArgumentException,uno::RuntimeException) +css::uno::Any LdapUserProfileBe::getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) { - throw lang::NoSupportException( - rtl::OUString::createFromAscii( - "LdapUserProfileBe: No Update Operation allowed, Read Only access"), - *this) ; + for (sal_Int32 i = 0;;) { + sal_Int32 j = PropertyName.indexOf(',', i); + if (j == -1) { + j = PropertyName.getLength(); + } + if (j == i) { + throw css::beans::UnknownPropertyException( + PropertyName, static_cast< cppu::OWeakObject * >(this)); + } + LdapData::iterator k(data_.find(PropertyName.copy(i, j - i))); + if (k != data_.end()) { + return css::uno::makeAny( + css::beans::Optional< css::uno::Any >( + true, css::uno::makeAny(k->second))); + } + if (j == PropertyName.getLength()) { + break; + } + i = j + 1; + } + return css::uno::makeAny(css::beans::Optional< css::uno::Any >()); } + //------------------------------------------------------------------------------ rtl::OUString SAL_CALL LdapUserProfileBe::getLdapUserProfileBeName(void) { return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.LdapUserProfileBe") ; @@ -423,10 +248,8 @@ rtl::OUString SAL_CALL LdapUserProfileBe::getImplementationName(void) uno::Sequence<rtl::OUString> SAL_CALL LdapUserProfileBe::getLdapUserProfileBeServiceNames(void) { - uno::Sequence<rtl::OUString> aServices(2) ; + uno::Sequence<rtl::OUString> aServices(1) ; aServices[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.LdapUserProfileBe")) ; - aServices[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.PlatformBackend")) ; - return aServices ; } //------------------------------------------------------------------------------ diff --git a/extensions/source/config/ldap/ldapuserprofilebe.hxx b/extensions/source/config/ldap/ldapuserprofilebe.hxx index 240a7b364e24..f19e9e275a55 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.hxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.hxx @@ -28,41 +28,33 @@ #ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_ #define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_ -#include "ldapuserprof.hxx" -#include "ldapaccess.hxx" -#include "ldapuserprofilelayer.hxx" -#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/configuration/backend/CannotConnectException.hpp> -#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp> -#include <com/sun/star/configuration/backend/ConnectionLostException.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <cppuhelper/compbase2.hxx> +#include "ldapaccess.hxx" -#define CONTEXT_ITEM_PREFIX_ "/modules/com.sun.star.configuration/bootstrap/" namespace extensions { namespace config { namespace ldap { namespace css = com::sun::star ; namespace uno = css::uno ; namespace lang = css::lang ; -namespace ldap= css::ldap ; -namespace backend = css::configuration::backend ; namespace container = css::container; -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ -typedef cppu::WeakComponentImplHelper2<backend::XSingleLayerStratum, +struct LdapDefinition; + +typedef cppu::WeakComponentImplHelper2<css::beans::XPropertySet, lang::XServiceInfo> BackendBase ; struct LdapProfileMutexHolder { osl::Mutex mMutex; }; /** Implements the PlatformBackend service, a specialization of the - SingleLayerStratum service for retreiving LDAP user profile + XPropertySet service for retreiving LDAP user profile configuration settings from a LDAP repsoitory. */ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase @@ -70,7 +62,6 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase public : LdapUserProfileBe(const uno::Reference<uno::XComponentContext>& xContext); - // throw(backend::BackendAccessException, backend::BackendSetupException, RuntimeException); ~LdapUserProfileBe(void) ; // XServiceInfo @@ -86,19 +77,57 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase getSupportedServiceNames( ) throw (uno::RuntimeException) ; - //XSingleLayerStratum - virtual uno::Reference<backend::XLayer> SAL_CALL - getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp ) - throw (backend::BackendAccessException, - lang::IllegalArgumentException, - uno::RuntimeException) ; - - virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL - getUpdatableLayer( const rtl::OUString& aLayerId ) - throw (backend::BackendAccessException, - lang::NoSupportException, - lang::IllegalArgumentException, - uno::RuntimeException) ; + // XPropertySet + virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (css::uno::RuntimeException) + { return css::uno::Reference< css::beans::XPropertySetInfo >(); } + + virtual void SAL_CALL setPropertyValue( + rtl::OUString const &, css::uno::Any const &) + throw ( + css::beans::UnknownPropertyException, + css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual css::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & PropertyName) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XPropertyChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const &, + css::uno::Reference< css::beans::XVetoableChangeListener > const &) + throw ( + css::beans::UnknownPropertyException, + css::lang::WrappedTargetException, css::uno::RuntimeException) + {} + /** Provides the implementation name. @return implementation name @@ -112,35 +141,16 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase getLdapUserProfileBeServiceNames(void) ; private: - /** Build OO/LDAP attribute mapping table */ - void initializeMappingTable (const rtl::OUString& aFileMapName); /** Check if LDAP is configured */ - bool readLdapConfiguration(LdapDefinition& aDefinition); + bool readLdapConfiguration( + uno::Reference<lang::XMultiServiceFactory> const & factory, + LdapDefinition * definition, rtl::OUString * loggedOnUser); bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess, const rtl::OUString& aLdapSetting, rtl::OString& aServerParameter); - void mapGenericException(ldap::LdapGenericException& aException) - throw (backend::InsufficientAccessRightsException, - backend::ConnectionLostException, - backend::BackendAccessException); - /** Connect to LDAP server */ - void connectToLdapServer(const LdapDefinition& aDefinition ); - /** Get URL of OO-to-LDAP Mapping File */ - rtl::OUString getMappingFileUrl(const rtl::OUString& aFileMapName) const; - - /** Service Factory object */ - uno::Reference<lang::XMultiServiceFactory> mFactory; - /** Component Context */ - uno::Reference<uno::XComponentContext> mContext ; - /** Object for LDAP functionality */ - LdapUserProfileSourceRef mLdapSource; - /**Currently logged in user */ - rtl::OUString mLoggedOnUser ; - /** DN of currently logged in user */ - rtl::OString mUserDN; - + LdapData data_; } ; //------------------------------------------------------------------------------ }}} diff --git a/extensions/source/config/ldap/ldapuserprofilelayer.cxx b/extensions/source/config/ldap/ldapuserprofilelayer.cxx deleted file mode 100644 index 9c9afbe8989c..000000000000 --- a/extensions/source/config/ldap/ldapuserprofilelayer.cxx +++ /dev/null @@ -1,244 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" -#include "ldapuserprofilelayer.hxx" -#include <com/sun/star/configuration/backend/PropertyInfo.hpp> -#include <com/sun/star/configuration/backend/ConnectionLostException.hpp> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ -// on windows this is defined indirectly by <ldap.h> -#undef OPTIONAL -#include <com/sun/star/beans/PropertyAttribute.hpp> -#endif -#include <rtl/ustrbuf.hxx> -#include <com/sun/star/uno/Sequence.hxx> - -//============================================================================== -namespace extensions { namespace config { namespace ldap { - -static const sal_Unicode kPathSeparator = '/' ; - -static -uno::Reference<backend::XLayerContentDescriber> - newLayerDescriber(const uno::Reference<lang::XMultiServiceFactory>& xFactory) -{ - typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber; - - rtl::OUString const k_sLayerDescriberService ( - RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.backend.LayerDescriber")); - - LayerDescriber xResult(xFactory->createInstance(k_sLayerDescriberService), uno::UNO_QUERY_THROW); - return xResult; -} -//------------------------------------------------------------------------------ - -void LdapUserProfileSource::getUserProfile(const rtl::OUString & aUser, LdapUserProfile & aProfile) -{ - mConnection.getUserProfile(aUser, - mProfileMap, - aProfile); -} - -rtl::OUString LdapUserProfileSource::getComponentName() const -{ - return mProfileMap.getComponentName(); -} - -rtl::OUString LdapUserProfileSource::getConfigurationBasePath() const -{ - rtl::OUStringBuffer sComponentNameBuffer(mProfileMap.getComponentName()); - sComponentNameBuffer.append(kPathSeparator); - sComponentNameBuffer.append (mProfileMap.getGroupName()); - sComponentNameBuffer.append(kPathSeparator); - - return sComponentNameBuffer.makeStringAndClear(); -} -//------------------------------------------------------------------------------ - -struct LdapUserProfileLayer::ProfileData -{ - LdapUserProfile mProfile; - rtl::OUString mBasePath; - - explicit ProfileData(LdapUserProfileSource & aSource, const rtl::OUString & aUser) - { - aSource.getUserProfile(aUser, mProfile); - mBasePath = aSource.getConfigurationBasePath(); - } -}; -//------------------------------------------------------------------------------ - -LdapUserProfileLayer::LdapUserProfileLayer( - const uno::Reference<lang::XMultiServiceFactory>& xFactory, - const rtl::OUString& aUser, - const LdapUserProfileSourceRef & aUserProfileSource, - const rtl::OUString& aTimestamp) -: mLayerDescriber( newLayerDescriber(xFactory) ) -, mSource( aUserProfileSource ) -, mUser(aUser) -, mTimestamp(aTimestamp) -, mProfile( 0 ) -{ - OSL_ASSERT(mSource.is()); -} - -//------------------------------------------------------------------------------ -LdapUserProfileLayer::~LdapUserProfileLayer() -{ - delete mProfile; -} -//------------------------------------------------------------------------------ - -#define PROPNAME( name ) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) ) -#define PROPTYPE( type ) getCppuType( static_cast< type const *>( 0 ) ) - -const sal_Int32 LAYER_PROPERTY_URL = 1; - -cppu::IPropertyArrayHelper * SAL_CALL LdapUserProfileLayer::newInfoHelper() -{ - using com::sun::star::beans::Property; - using namespace com::sun::star::beans::PropertyAttribute; - - Property properties[] = - { - Property(PROPNAME("URL"), LAYER_PROPERTY_URL, PROPTYPE(rtl::OUString), READONLY) - }; - - return new cppu::OPropertyArrayHelper(properties, sizeof(properties)/sizeof(properties[0])); -} -//------------------------------------------------------------------------------ - -void SAL_CALL LdapUserProfileLayer::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const -{ - switch (nHandle) - { - case LAYER_PROPERTY_URL: - { - rtl::OUStringBuffer aURL; - aURL.appendAscii("ldap-user-profile:"); - aURL.append(mUser); - aURL.append(sal_Unicode('@')); - if (mSource.is()) - aURL.append(mSource->getComponentName()); - else - aURL.appendAscii("<NULL>"); - - rValue <<= aURL.makeStringAndClear(); - } - break; - - default: - OSL_ENSURE(false, "Error: trying to get an UNKNOWN property"); - break; - } -} -//------------------------------------------------------------------------------ - -bool LdapUserProfileLayer::readProfile() -{ - if (mSource.is()) - try - { - OSL_ASSERT(!mProfile); - mProfile = new ProfileData(*mSource,mUser); - - mSource.clear(); - } - catch (ldap::LdapConnectionException & e) - { - // without existing Ldap Connection we should never have gotten a timestamp - OSL_ENSURE(false, "Unexpected: Have Ldap Backedn Layer but no vaild LDAP connection ?!"); - throw backend::ConnectionLostException(e.Message, *this, uno::makeAny(e) ); - } - catch (ldap::LdapGenericException & e) - { - throw backend::BackendAccessException(e.Message, *this, uno::makeAny(e) ); - } - OSL_ASSERT( !mSource.is() ); - OSL_ASSERT( mProfile != 0 ); - return mProfile != 0; -} -//------------------------------------------------------------------------------ - -void SAL_CALL LdapUserProfileLayer::readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) -{ - std::vector<backend::PropertyInfo> aPropList; -#ifdef SUPPRESS_BACKEND_ERRORS - try -#endif - if ( readProfile() ) - { - // initialize PropInfo members that are the same for all settings - const rtl::OUString k_sTypeString(RTL_CONSTASCII_USTRINGPARAM("string")); - - backend::PropertyInfo aPropInfo; - aPropInfo.Type = k_sTypeString; - aPropInfo.Protected = sal_False; - - LdapUserProfile * pProfile = &mProfile->mProfile; - aPropList.reserve(pProfile->mProfile.size()); - - for (LdapUserProfile::Iterator entry = pProfile->mProfile.begin() ; - entry != pProfile->mProfile.end() ; ++ entry) - { - if (entry->mAttribute.getLength()==0) { continue ; } - if (entry->mValue.getLength()==0) { continue ; } - - aPropInfo.Name = mProfile->mBasePath + entry->mAttribute; - aPropInfo.Value <<= entry->mValue; - - aPropList.push_back(aPropInfo); - } - } -#ifdef SUPPRESS_BACKEND_ERRORS - catch (uno::Exception & e) - { - OSL_TRACE("LDAP Backend - Reading data from LDAP failed: %s\n", - rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); - } -#endif - - if ( !aPropList.empty()) - { - //Describe UserProfileLayer (the list of properties) to the XHandler - //Object using com.sun.star.comp.backend.LayerContentDescriber Service - uno::Sequence<backend::PropertyInfo> aPropInfoList(&aPropList.front(),aPropList.size()); - - mLayerDescriber->describeLayer(xHandler, aPropInfoList); - } - // else { check handler not NULL; xHandler->startLayer(); xHandler->endLayer(); } -} -//------------------------------------------------------------------------------ -}}} -//------------------------------------------------------------------------------ - diff --git a/extensions/source/config/ldap/ldapuserprofilelayer.hxx b/extensions/source/config/ldap/ldapuserprofilelayer.hxx deleted file mode 100644 index c87bccc02d38..000000000000 --- a/extensions/source/config/ldap/ldapuserprofilelayer.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ -#define EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ - -#include "ldapuserprof.hxx" -#include "ldapaccess.hxx" - -#include "propertysethelper.hxx" -#include <com/sun/star/configuration/backend/XLayer.hpp> -#include <com/sun/star/configuration/backend/BackendAccessException.hpp> - -#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ -#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> -#endif -#include <com/sun/star/util/XTimeStamped.hpp> -#include <cppuhelper/implbase2.hxx> -#include <salhelper/simplereferenceobject.hxx> -#include <rtl/ref.hxx> - - -namespace extensions { namespace config { namespace ldap { - -namespace css = com::sun::star ; -namespace uno = css::uno ; -namespace lang = css::lang ; -namespace backend = css::configuration::backend ; -namespace util = css::util ; - -//------------------------------------------------------------------------------ -struct LdapUserProfileSource : public salhelper::SimpleReferenceObject -{ - LdapConnection mConnection; - LdapUserProfileMap mProfileMap; - - rtl::OUString getComponentName() const; - rtl::OUString getConfigurationBasePath() const; - void getUserProfile(rtl::OUString const & aUser, LdapUserProfile & aProfile); -}; -typedef rtl::Reference< LdapUserProfileSource > LdapUserProfileSourceRef; -//------------------------------------------------------------------------------ - -/** - Implementation of the XLayer interfaces for LdapUserProfileBe. - Class reads UserProfile setting form LDAP. - The timestamp indicates the last modification time - */ - class LdapUserProfileLayer : public cppu::ImplInheritanceHelper2< - apihelper::ReadOnlyPropertySetHelper, - backend::XLayer, - util::XTimeStamped> -{ - public : - /** Constructor */ - LdapUserProfileLayer( - const uno::Reference<lang::XMultiServiceFactory>& xFactory, - const rtl::OUString& aUser, - const LdapUserProfileSourceRef & aUserProfileSource, - const rtl::OUString& aTimestamp); - // throw (uno::RuntimeException - - /** Destructor */ - ~LdapUserProfileLayer(); - - // XLayer - virtual void SAL_CALL readData( - const uno::Reference<backend::XLayerHandler>& xHandler) - throw ( backend::MalformedDataException, - lang::NullPointerException, - lang::WrappedTargetException, - uno::RuntimeException) ; - - // XTimeStamped - virtual rtl::OUString SAL_CALL getTimestamp(void) - throw (uno::RuntimeException) - { return mTimestamp; } - - protected: - // PropertySetHelper - virtual cppu::IPropertyArrayHelper * SAL_CALL newInfoHelper(); - - virtual void SAL_CALL getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const; - private : - struct ProfileData; - bool readProfile(); - - uno::Reference<backend::XLayerContentDescriber> mLayerDescriber; - LdapUserProfileSourceRef mSource; - rtl::OUString mUser; - rtl::OUString mTimestamp; - ProfileData * mProfile; - private: - using cppu::OPropertySetHelper::getFastPropertyValue; - } ; -}}} -#endif // EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ diff --git a/extensions/source/config/ldap/makefile.mk b/extensions/source/config/ldap/makefile.mk index 58fea69cd309..a27cb39b6225 100644 --- a/extensions/source/config/ldap/makefile.mk +++ b/extensions/source/config/ldap/makefile.mk @@ -27,7 +27,6 @@ PRJ=..$/..$/.. -PRJINC=$(PRJ)$/source PRJNAME=extensions TARGET=ldapbe ENABLE_EXCEPTIONS=TRUE @@ -64,10 +63,7 @@ SOLARINC+= $(LDAPSDKINCLUDES) SLOFILES=\ $(SLO)$/ldapuserprofilebe.obj \ - $(SLO)$/ldapuserprof.obj \ $(SLO)$/ldapaccess.obj \ - $(SLO)$/ldapuserprofilelayer.obj \ - $(SLO)$/propertysethelper.obj \ $(SLO)$/componentdef.obj LIB1TARGET=$(SLB)$/_$(TARGET).lib diff --git a/extensions/source/config/ldap/propertysethelper.cxx b/extensions/source/config/ldap/propertysethelper.cxx deleted file mode 100644 index 6bdf17ccf0e8..000000000000 --- a/extensions/source/config/ldap/propertysethelper.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_extensions.hxx" - -#include "propertysethelper.hxx" -#include <com/sun/star/lang/XTypeProvider.hpp> - -#include <cppuhelper/typeprovider.hxx> - -//.......................................................................... -namespace extensions { - namespace apihelper { -//.......................................................................... - namespace uno = com::sun::star::uno; - namespace lang = com::sun::star::lang; - namespace beans = com::sun::star::beans; -//.......................................................................... -PropertySetHelper::PropertySetHelper() -: BroadcasterBase() -, cppu::OWeakObject() -, cppu::OPropertySetHelper( BroadcasterBase::getBroadcastHelper() ) -, m_pHelper(0) -{ -} - -//.......................................................................... -PropertySetHelper::~PropertySetHelper() -{ - delete m_pHelper; -} - -//.......................................................................... -// XInterface -uno::Any SAL_CALL PropertySetHelper::queryInterface( uno::Type const & rType ) throw (uno::RuntimeException) -{ - uno::Any aResult = cppu::OPropertySetHelper::queryInterface(rType); - if (!aResult.hasValue()) - aResult = OWeakObject::queryInterface(rType); - return aResult; -} - -void SAL_CALL PropertySetHelper::acquire() throw () -{ - OWeakObject::acquire(); -} - -void SAL_CALL PropertySetHelper::release() throw () -{ - if (m_refCount == 1) - this->disposing(); - - OWeakObject::release(); -} - -//.......................................................................... -// XTypeProvider -uno::Sequence< uno::Type > SAL_CALL PropertySetHelper::getTypes() throw (uno::RuntimeException) -{ - // could be static instance - cppu::OTypeCollection aTypes( - ::getCppuType( static_cast< uno::Reference< beans::XPropertySet > const * >(0) ), - ::getCppuType( static_cast< uno::Reference< beans::XMultiPropertySet > const * >(0) ), - ::getCppuType( static_cast< uno::Reference< beans::XFastPropertySet > const * >(0) ), - ::getCppuType( static_cast< uno::Reference< lang::XTypeProvider > const * >(0) ) ); - - return aTypes.getTypes(); -} - -//.......................................................................... -// cppu::OPropertySetHelper -uno::Reference< beans::XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo( ) - throw (uno::RuntimeException) -{ - return createPropertySetInfo(getInfoHelper()); -} - -//.......................................................................... -cppu::IPropertyArrayHelper & SAL_CALL PropertySetHelper::getInfoHelper() -{ - osl::MutexGuard aGuard( getBroadcastMutex() ); - if (!m_pHelper) - m_pHelper = newInfoHelper(); - - OSL_ENSURE(m_pHelper,"Derived class did not create new PropertyInfoHelper"); - if (!m_pHelper) - throw uno::RuntimeException(rtl::OUString::createFromAscii("No PropertyArrayHelper available"),*this); - - return *m_pHelper; -} - -//.......................................................................... -sal_Bool SAL_CALL PropertySetHelper::convertFastPropertyValue( - uno::Any & rConvertedValue, uno::Any & rOldValue, sal_Int32 nHandle, const uno::Any& rValue ) - throw (lang::IllegalArgumentException) -{ - this->getFastPropertyValue(rOldValue, nHandle); - rConvertedValue = rValue; - return rValue.isExtractableTo( rOldValue.getValueType() ); -} - -//.......................................................................... -void SAL_CALL ReadOnlyPropertySetHelper::setFastPropertyValue_NoBroadcast( - sal_Int32 /*nHandle*/, const uno::Any& /*rValue*/ ) - throw (uno::Exception) -{ - OSL_ENSURE(false, "Attempt to set value in read-only property set"); - throw beans::PropertyVetoException(rtl::OUString::createFromAscii("Attempt to set value in Read-Only property set"),*this); -} - -//.......................................................................... -sal_Bool SAL_CALL ReadOnlyPropertySetHelper::convertFastPropertyValue( - uno::Any & /*rConvertedValue*/, uno::Any & /*rOldValue*/, sal_Int32 /*nHandle*/, const uno::Any& /*rValue*/ ) - throw (lang::IllegalArgumentException) -{ - OSL_ENSURE(false, "Attempt to convert value in read-only property set"); - return false; -} -//.......................................................................... -//.......................................................................... - } // namespace apihelper -} // namespace extensions -//.......................................................................... - - diff --git a/extensions/source/config/ldap/propertysethelper.hxx b/extensions/source/config/ldap/propertysethelper.hxx deleted file mode 100644 index 1a6dd9867d06..000000000000 --- a/extensions/source/config/ldap/propertysethelper.hxx +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef EXTENSIONS_MISC_PROPERTYSETHELPER_HXX -#define EXTENSIONS_MISC_PROPERTYSETHELPER_HXX - -#include <cppuhelper/propshlp.hxx> -#include <cppuhelper/weak.hxx> - -//.......................................................................... -namespace extensions { - namespace apihelper { -//.......................................................................... - namespace uno = com::sun::star::uno; - namespace lang = com::sun::star::lang; - namespace beans = com::sun::star::beans; -//.......................................................................... -class BroadcasterBase -{ - osl::Mutex m_aMutex; - cppu::OBroadcastHelper m_aBroadcastHelper; - -protected: - BroadcasterBase() : m_aMutex(), m_aBroadcastHelper(m_aMutex) {} - ~BroadcasterBase() {} - - osl::Mutex & getBroadcastMutex() { return m_aMutex; } - cppu::OBroadcastHelper & getBroadcastHelper() { return m_aBroadcastHelper; } -}; - -//.......................................................................... - -class PropertySetHelper : protected BroadcasterBase // must be first - , public cppu::OWeakObject - , public cppu::OPropertySetHelper // not copyable -{ -public: - PropertySetHelper(); - ~PropertySetHelper(); - - // XInterface - virtual uno::Any SAL_CALL queryInterface( uno::Type const & rType ) throw (uno::RuntimeException); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); - // XTypeProvider - virtual uno::Sequence< uno::Type > SAL_CALL getTypes() throw (uno::RuntimeException); - - // to be provided by derived classes - // virtual uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (uno::RuntimeException) = 0; - - // XPropertySet - virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL - getPropertySetInfo( ) throw (uno::RuntimeException); - - -protected: -// new methods still to be overridden - virtual cppu::IPropertyArrayHelper * SAL_CALL newInfoHelper() = 0; - -// cppu::OPropertySetHelper interface -#if 0 // these methods still must be overridden - virtual cppu::IPropertyArrayHelper * SAL_CALL newInfoHelper() = 0; - - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) - throw (uno::Exception) = 0; - - virtual void SAL_CALL getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const = 0; -#endif - virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - // default implementation: does not do any conversion - virtual sal_Bool SAL_CALL convertFastPropertyValue( - uno::Any & rConvertedValue, uno::Any & rOldValue, - sal_Int32 nHandle, const uno::Any& rValue ) - throw (lang::IllegalArgumentException); -private: - cppu::IPropertyArrayHelper * m_pHelper; -}; -//.......................................................................... - -class ReadOnlyPropertySetHelper : public PropertySetHelper -{ -public: - ReadOnlyPropertySetHelper() {} - ~ReadOnlyPropertySetHelper() {} - -protected: -#if 0 // these methods still must be overridden - virtual cppu::IPropertyArrayHelper * SAL_CALL newInfoHelper() = 0; - - virtual void SAL_CALL getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const = 0; -#endif - // default implementation: rejects any attempt to set a value - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) - throw (uno::Exception); - - // default implementation: rejects any attempt to do a conversion - virtual sal_Bool SAL_CALL convertFastPropertyValue( - uno::Any & rConvertedValue, uno::Any & rOldValue, - sal_Int32 nHandle, const uno::Any& rValue ) - throw (lang::IllegalArgumentException); -}; -//.......................................................................... - } // namespace apihelper -} // namespace extensions -//.......................................................................... - -#endif - - diff --git a/extensions/source/oooimprovement/Jobs.xcu b/extensions/source/oooimprovement/Jobs.xcu index 438ab2d23e8e..206d83dd7eb2 100644 --- a/extensions/source/oooimprovement/Jobs.xcu +++ b/extensions/source/oooimprovement/Jobs.xcu @@ -1,5 +1,4 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd"> <oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <node oor:name="Jobs"> <node oor:name="OOoImprovement.OnLogRotateJob" oor:op="replace"> |