LibreOffice Module connectivity (master) 1
AUser.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <ado/AUser.hxx>
21#include <ado/ACatalog.hxx>
22#include <ado/AGroups.hxx>
24#include <com/sun/star/sdbc/XRow.hpp>
25#include <com/sun/star/sdbc/XResultSet.hpp>
26#include <ado/AConnection.hxx>
27#include <ado/Awrapado.hxx>
28
29using namespace connectivity::ado;
30using namespace com::sun::star::uno;
31using namespace com::sun::star::lang;
32using namespace com::sun::star::beans;
33using namespace com::sun::star::sdbc;
34
35
36OAdoUser::OAdoUser(OCatalog* _pParent,bool _bCase, ADOUser* _pUser)
37 : OUser_TYPEDEF(_bCase)
38 ,m_pCatalog(_pParent)
39{
40 construct();
41
42 if(_pUser)
43 m_aUser.set(_pUser);
44 else
46}
47
48OAdoUser::OAdoUser(OCatalog* _pParent,bool _bCase, const OUString& Name)
49 : OUser_TYPEDEF(Name,_bCase)
50 , m_pCatalog(_pParent)
51{
52 construct();
55}
56
58{
59 ::std::vector< OUString> aVector;
61 aGroups.fillElementNames(aVector);
62 if(m_pGroups)
63 m_pGroups->reFill(aVector);
64 else
65 m_pGroups.reset(new OGroups(m_pCatalog, m_aMutex, aVector, aGroups, isCaseSensitive()));
66}
67
68void OAdoUser::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
69{
70 if(m_aUser.IsValid())
71 {
72
73 switch(nHandle)
74 {
76 {
77 OUString aVal;
78 rValue >>= aVal;
79 m_aUser.put_Name(aVal);
80 }
81 break;
82 }
83 }
84}
85
86void OAdoUser::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
87{
88 if(m_aUser.IsValid())
89 {
90 switch(nHandle)
91 {
93 rValue <<= m_aUser.get_Name();
94 break;
95 }
96 }
97}
98
99OUserExtend::OUserExtend(OCatalog* _pParent,bool _bCase, ADOUser* _pUser)
100 : OAdoUser(_pParent,_bCase,_pUser)
101{
102}
103
104OUserExtend::OUserExtend(OCatalog* _pParent,bool _bCase, const OUString& Name)
105 : OAdoUser(_pParent,_bCase,Name)
106{
107}
108
109
111{
114}
115
117{
119 describeProperties(aProps);
120 return new cppu::OPropertyArrayHelper(aProps);
121}
122
124{
126}
127
128sal_Int32 SAL_CALL OAdoUser::getPrivileges( const OUString& objName, sal_Int32 objType )
129{
130 ::osl::MutexGuard aGuard(m_aMutex);
131 checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
132
134}
135
136sal_Int32 SAL_CALL OAdoUser::getGrantablePrivileges( const OUString& objName, sal_Int32 objType )
137{
138 ::osl::MutexGuard aGuard(m_aMutex);
139 checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
140
141 sal_Int32 nRights = 0;
142 RightsEnum eRights = m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType));
143 if((eRights & adRightWithGrant) == adRightWithGrant)
144 nRights = ADOS::mapAdoRights2Sdbc(eRights);
146 return nRights;
147}
148
149void SAL_CALL OAdoUser::grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
150{
151 ::osl::MutexGuard aGuard(m_aMutex);
152 checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
153 m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessGrant,RightsEnum(ADOS::mapRights2Ado(objPrivileges)));
155}
156
157void SAL_CALL OAdoUser::revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
158{
159 ::osl::MutexGuard aGuard(m_aMutex);
160 checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
161 m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessRevoke,RightsEnum(ADOS::mapRights2Ado(objPrivileges)));
163}
164
165// XUser
166void SAL_CALL OAdoUser::changePassword( const OUString& objPassword, const OUString& newPassword )
167{
168 ::osl::MutexGuard aGuard(m_aMutex);
169 checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
170 m_aUser.ChangePassword(objPassword,newPassword);
172}
173
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void registerProperty(const OUString &_rName, sal_Int32 _nHandle, sal_Int32 _nAttributes, void *_pPointerToMember, const css::uno::Type &_rMemberType)
::dbtools::OPropertyMap & getPropMap()
Definition: TConnection.cxx:68
static void ThrowException(ADOConnection *_pAdoCon, const css::uno::Reference< css::uno::XInterface > &_xInterface)
Definition: ADriver.cxx:207
static ObjectTypeEnum mapObjectType2Ado(sal_Int32 objType)
Definition: adoimp.cxx:224
static sal_Int32 mapRights2Ado(sal_Int32 nRights)
Definition: adoimp.cxx:287
static sal_Int32 mapAdoRights2Sdbc(RightsEnum eRights)
Definition: adoimp.cxx:266
virtual void SAL_CALL grantPrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: AUser.cxx:149
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
Definition: AUser.cxx:68
OAdoUser(OCatalog *_pParent, bool _bCase, ADOUser *_pUser=nullptr)
Definition: AUser.cxx:36
virtual sal_Int32 SAL_CALL getGrantablePrivileges(const OUString &objName, sal_Int32 objType) override
Definition: AUser.cxx:136
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
Definition: AUser.cxx:86
virtual void SAL_CALL revokePrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: AUser.cxx:157
virtual void SAL_CALL changePassword(const OUString &objPassword, const OUString &newPassword) override
Definition: AUser.cxx:166
virtual void refreshGroups() override
Definition: AUser.cxx:57
virtual sal_Int32 SAL_CALL getPrivileges(const OUString &objName, sal_Int32 objType) override
Definition: AUser.cxx:128
OConnection * getConnection() const
Definition: ACatalog.hxx:43
WpADOConnection & getConnection()
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: AUser.cxx:116
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: AUser.cxx:123
OUserExtend(OCatalog *_pParent, bool _bCase, ADOUser *_pUser=nullptr)
Definition: AUser.cxx:99
virtual void construct() override
Definition: AUser.cxx:110
bool ChangePassword(std::u16string_view _rPwd, std::u16string_view _rNewPwd)
Definition: Awrapado.cxx:1421
OUString get_Name() const
Definition: Awrapado.cxx:1408
bool SetPermissions(const OLEVariant &Name, ObjectTypeEnum ObjectType, ActionEnum Action, RightsEnum Rights)
Definition: Awrapado.cxx:1447
RightsEnum GetPermissions(const OLEVariant &Name, ObjectTypeEnum ObjectType)
Definition: Awrapado.cxx:1436
void put_Name(std::u16string_view _rName)
Definition: Awrapado.cxx:1415
void fillElementNames(::std::vector< OUString > &_rVector)
Definition: Aolewrap.hxx:129
std::unique_ptr< OGroups > m_pGroups
Definition: VUser.hxx:52
mutable::osl::Mutex m_aMutex
OCollection OGroups
Definition: VUser.hxx:36
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
#define PROPERTY_ID_NAME
Definition: propertyids.hxx:50
#define PROPERTY_ID_PASSWORD
Definition: propertyids.hxx:74
sal_Int32 nHandle
OUString Name