diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-08-03 13:39:19 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-08-03 13:39:19 +0000 |
commit | aefe7dfb971c4b96940fc7179a83212049993986 (patch) | |
tree | 83f8f37ef6eda1544f52a30620b59546e0ea423e /extensions/source/config | |
parent | 8c8fa4fb63d94e2d2f31819a61539319c95f250e (diff) |
INTEGRATION: CWS scmtoapoc (1.1.2); FILE ADDED
2004/04/22 09:10:40 ssmith 1.1.2.1: #115692# ldap user profile backend
Diffstat (limited to 'extensions/source/config')
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilelayer.cxx | 171 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilelayer.hxx | 76 |
2 files changed, 247 insertions, 0 deletions
diff --git a/extensions/source/config/ldap/ldapuserprofilelayer.cxx b/extensions/source/config/ldap/ldapuserprofilelayer.cxx new file mode 100644 index 000000000000..622b39a34c57 --- /dev/null +++ b/extensions/source/config/ldap/ldapuserprofilelayer.cxx @@ -0,0 +1,171 @@ +/************************************************************************* + * + * $RCSfile: ldapuserprofilelayer.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: hr $ $Date: 2004-08-03 14:39:07 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards OOurce License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free OOftware; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free OOftware Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free OOftware + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards OOurce License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * OOurce License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * OOftware provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE OOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the OOftware. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ +#include "ldapuserprofilelayer.hxx" +#endif +#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_PROPERTYINFO_HPP_ +#include <com/sun/star/configuration/backend/PropertyInfo.hpp> +#endif +#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYERCONTENTDESCIBER_HPP_ +#include <com/sun/star/configuration/backend/XLayerContentDescriber.hpp> +#endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif // _RTL_USTRBUF_HXX_ +#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_ +#include <com/sun/star/uno/Sequence.hxx> +#endif + +//============================================================================== +namespace extensions { namespace config { namespace ldap { + + +LdapUserProfileLayer::LdapUserProfileLayer( + const uno::Reference<lang::XMultiServiceFactory>& xFactory, + const rtl::OUString& aUser, + const LdapUserProfileMap& aUserProfileMap, + LdapConnection& aConnection, + const rtl::OUString& aTimeStamp) + : mFactory(xFactory), + mUserName(aUser), + mConnection(aConnection), + mUserProfileMap(aUserProfileMap), + mTimeStamp(aTimeStamp) +{ + + +} +//------------------------------------------------------------------------------ +static const sal_Unicode kPathSeparator = '/' ; + +void SAL_CALL LdapUserProfileLayer::readData( + const uno::Reference<backend::XLayerHandler>& xHandler) + throw ( backend::MalformedDataException, + lang::NullPointerException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + try + { + LdapUserProfile aUserProfile; + mConnection.getUserProfile(mUserName, + mUserProfileMap, + aUserProfile); + + + std::vector<LdapUserProfile::ProfileEntry>::const_iterator entry ; + + + rtl::OUStringBuffer sComponentNameBuffer(mUserProfileMap.getComponentName()); + sComponentNameBuffer.append(kPathSeparator); + sComponentNameBuffer.append (mUserProfileMap.getGroupName()); + sComponentNameBuffer.append(kPathSeparator); + rtl::OUString sComponentName = sComponentNameBuffer.makeStringAndClear(); + + std::vector<backend::PropertyInfo> aPropList; + backend::PropertyInfo aPropInfo; + for (entry = aUserProfile.mProfile.begin() ; + entry != aUserProfile.mProfile.end() ; ++ entry) + { + if ((*entry).mAttribute.getLength()==0) { continue ; } + if ((*entry).mValue.getLength()==0) { continue ; } + aPropInfo.Name = sComponentName + entry->mAttribute; + aPropInfo.Type = rtl::OUString::createFromAscii("string"); + aPropInfo.Value <<= entry->mValue; + aPropInfo.Protected = sal_False; + aPropList.push_back(aPropInfo); + } + 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.size()); + for( sal_uInt32 i = 0; i < aPropList.size(); i++) + { + aPropInfoList[i] = aPropList[i]; + } + rtl::OUString const k_sLayerDescriberService ( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.configuration.backend.LayerDescriber")); + + typedef uno::Reference<backend::XLayerContentDescriber> LayerDescriber; + LayerDescriber xLayerDescriber = LayerDescriber::query( + mFactory->createInstance(k_sLayerDescriberService)); + + if (xLayerDescriber.is()) + { + xLayerDescriber->describeLayer(xHandler, aPropInfoList); + } + else + { + OSL_TRACE("LdapUserProfileLayer::readData- cannot create com.sun.star.configuration.backend.LayerContentDescriber Service"); + } + } + } + catch(uno::Exception e) + { + OSL_TRACE("LdapUserProfileLayer::readData- cannot read LDAP User Profile Layer"); + } +} +//------------------------------------------------------------------------------ +}}} +//------------------------------------------------------------------------------ diff --git a/extensions/source/config/ldap/ldapuserprofilelayer.hxx b/extensions/source/config/ldap/ldapuserprofilelayer.hxx new file mode 100644 index 000000000000..28232adac138 --- /dev/null +++ b/extensions/source/config/ldap/ldapuserprofilelayer.hxx @@ -0,0 +1,76 @@ +#ifndef EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ +#define EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ + +#ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROF_HXX_ +#include "ldapuserprof.hxx" +#endif +#ifndef EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_ +#include "ldapaccess.hxx" +#endif // EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_ + +#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYER_HPP_ +#include <com/sun/star/configuration/backend/XLayer.hpp> +#endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_XLAYER_HPP_ + +#ifndef _COM_SUN_STAR_CONFIGURATION_BACKEND_BACKENDACCESSEXCEPTION_HPP_ +#include <com/sun/star/configuration/backend/BackendAccessException.hpp> +#endif // _COM_SUN_STAR_CONFIGURATION_BACKEND_BACKENDACCESSEXCEPTION_HPP_ + +#ifndef _COM_SUN_STAR_UTIL_XTIMESTAMPED_HPP_ +#include <com/sun/star/util/XTimeStamped.hpp> +#endif // _COM_SUN_STAR_UTIL_XTIMESTAMPED_HPP_ + +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> +#endif // _CPPUHELPER_IMPLBASE2_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 ; + +/** + Implementation of the XLayer interfaces for LdapUserProfileBe. + Class reads UserProfile setting form LDAP. + The timestamp indicates the last modification time + */ + class LdapUserProfileLayer : public cppu::WeakImplHelper2<backend::XLayer, + util::XTimeStamped> +{ + public : + /** Constructor */ + LdapUserProfileLayer( + const uno::Reference<lang::XMultiServiceFactory>& xFactory, + const rtl::OUString& aUser, + const LdapUserProfileMap& aUserProfileMap, + LdapConnection& aConnection, + const rtl::OUString& aTimeStamp); + + /** Destructor */ + ~LdapUserProfileLayer(void) {} + + // 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;} + private : + uno::Reference<lang::XMultiServiceFactory> mFactory; + LdapConnection& mConnection; + const LdapUserProfileMap& mUserProfileMap; + rtl::OUString mUserName; + rtl::OUString mTimeStamp; + } ; +}}} +#endif // EXTENSIONS_CONFIG_LDAP_LADPUSERPROFILELAYER_HXX_ |