LibreOffice Module connectivity (master) 1
VUser.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
21#include <sdbcx/VUser.hxx>
25#include <o3tl/unreachable.hxx>
26
27
28using namespace connectivity;
29using namespace connectivity::sdbcx;
30using namespace ::com::sun::star::sdbc;
31using namespace ::com::sun::star::beans;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::container;
34using namespace ::com::sun::star::lang;
35
36IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
37
38OUser::OUser(bool _bCase) : OUser_BASE(m_aMutex)
39 , ODescriptor(OUser_BASE::rBHelper,_bCase,true)
40{
41}
42
43OUser::OUser(const OUString& Name, bool _bCase) : OUser_BASE(m_aMutex)
44 ,ODescriptor(OUser_BASE::rBHelper,_bCase)
45{
46 m_Name = Name;
47}
48
50{
51}
52
54{
56 ::osl::MutexGuard aGuard(m_aMutex);
57 if(m_pGroups)
58 m_pGroups->disposing();
59}
60
61Any SAL_CALL OUser::queryInterface( const Type & rType )
62{
63 Any aRet = ODescriptor::queryInterface( rType);
64 return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
65}
66
67Sequence< Type > SAL_CALL OUser::getTypes( )
68{
69 return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
70}
71
73{
74 Sequence< Property > aProps;
75 describeProperties(aProps);
76 return new ::cppu::OPropertyArrayHelper(aProps);
77
78}
79
81{
82 return *getArrayHelper();
83}
84
85// XUser
86void SAL_CALL OUser::changePassword( const OUString& /*objPassword*/, const OUString& /*newPassword*/ )
87{
88 ::osl::MutexGuard aGuard(m_aMutex);
89 checkDisposed(OUser_BASE::rBHelper.bDisposed);
90 ::dbtools::throwFeatureNotImplementedSQLException( "XUser::changePassword", *this );
91}
92
93// XGroupsSupplier
94Reference< XNameAccess > SAL_CALL OUser::getGroups( )
95{
96 ::osl::MutexGuard aGuard(m_aMutex);
97 checkDisposed(OUser_BASE::rBHelper.bDisposed);
98
99 try
100 {
101 if ( !m_pGroups )
103 }
104 catch( const RuntimeException& )
105 {
106 // allowed to leave this method
107 throw;
108 }
109 catch( const Exception& )
110 {
111 // allowed
112 }
113
114 return m_pGroups.get();
115}
116
117sal_Int32 SAL_CALL OUser::getPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ )
118{
119 ::osl::MutexGuard aGuard(m_aMutex);
120 checkDisposed(OUser_BASE::rBHelper.bDisposed);
121 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::changePassword", *this );
123}
124
125sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ )
126{
127 ::osl::MutexGuard aGuard(m_aMutex);
128 checkDisposed(OUser_BASE::rBHelper.bDisposed);
129 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::getGrantablePrivileges", *this );
131}
132
133void SAL_CALL OUser::grantPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ )
134{
135 ::osl::MutexGuard aGuard(m_aMutex);
136 checkDisposed(OUser_BASE::rBHelper.bDisposed);
137 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::grantPrivileges", *this );
138}
139
140void SAL_CALL OUser::revokePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ )
141{
142 ::osl::MutexGuard aGuard(m_aMutex);
143 checkDisposed(OUser_BASE::rBHelper.bDisposed);
144 ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::revokePrivileges", *this );
145}
146
147css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( )
148{
149 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
150}
151
152OUString SAL_CALL OUser::getName( )
153{
154 return m_Name;
155}
156
157void SAL_CALL OUser::setName( const OUString& /*aName*/ )
158{
159 OSL_FAIL( "OUser::setName: not implemented!" );
160 // not allowed to throw an SQLException here ...
161}
162
163// XInterface
164void SAL_CALL OUser::acquire() noexcept
165{
166 OUser_BASE::acquire();
167}
168
169void SAL_CALL OUser::release() noexcept
170{
171 OUser_BASE::release();
172}
173
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User")
::cppu::IPropertyArrayHelper * getArrayHelper()
void describeProperties(css::uno::Sequence< css::beans::Property > &_rProps) const
void disposing(std::unique_lock< std::mutex > &rGuard)
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes()
Definition: VDescriptor.cxx:94
virtual void SAL_CALL release() noexcept override
Definition: VUser.cxx:169
std::unique_ptr< OGroups > m_pGroups
Definition: VUser.hxx:52
virtual void SAL_CALL setName(const OUString &aName) override
Definition: VUser.cxx:157
virtual sal_Int32 SAL_CALL getGrantablePrivileges(const OUString &objName, sal_Int32 objType) override
Definition: VUser.cxx:125
virtual ::cppu::IPropertyArrayHelper * createArrayHelper() const override
Definition: VUser.cxx:72
virtual ~OUser() override
Definition: VUser.cxx:49
virtual sal_Int32 SAL_CALL getPrivileges(const OUString &objName, sal_Int32 objType) override
Definition: VUser.cxx:117
virtual OUString SAL_CALL getName() override
Definition: VUser.cxx:152
virtual void SAL_CALL acquire() noexcept override
Definition: VUser.cxx:164
virtual void SAL_CALL revokePrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: VUser.cxx:140
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: VUser.cxx:61
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: VUser.cxx:67
virtual void SAL_CALL grantPrivileges(const OUString &objName, sal_Int32 objType, sal_Int32 objPrivileges) override
Definition: VUser.cxx:133
OUser(bool _bCase)
Definition: VUser.cxx:38
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: VUser.cxx:147
virtual css::uno::Reference< css::container::XNameAccess > SAL_CALL getGroups() override
Definition: VUser.cxx:94
virtual void SAL_CALL changePassword(const OUString &objPassword, const OUString &newPassword) override
Definition: VUser.cxx:86
virtual ::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
Definition: VUser.cxx:80
virtual void SAL_CALL disposing() override
Definition: VUser.cxx:53
mutable::osl::Mutex m_aMutex
std::mutex m_aMutex
@ Exception
Type
::cppu::WeakComponentImplHelper< css::sdbcx::XUser, css::sdbcx::XGroupsSupplier, css::container::XNamed, css::lang::XServiceInfo > OUser_BASE
Definition: VUser.hxx:41
void checkDisposed(bool _bThrow)
Definition: dbtools.cxx:1951
void throwFeatureNotImplementedSQLException(const OUString &_rFeatureName, const Reference< XInterface > &_rxContext, const Any &_rNextException)
OUString Name
#define O3TL_UNREACHABLE