1*9b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9b5730f6SAndrew Rist * distributed with this work for additional information
6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance
9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at
10*9b5730f6SAndrew Rist *
11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9b5730f6SAndrew Rist *
13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an
15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the
17*9b5730f6SAndrew Rist * specific language governing permissions and limitations
18*9b5730f6SAndrew Rist * under the License.
19*9b5730f6SAndrew Rist *
20*9b5730f6SAndrew Rist *************************************************************/
21*9b5730f6SAndrew Rist
22*9b5730f6SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <stdio.h>
28cdf0e10cSrcweir #include "connectivity/sdbcx/VUser.hxx"
29cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
32cdf0e10cSrcweir #include "TConnection.hxx"
33cdf0e10cSrcweir #include "connectivity/sdbcx/VCollection.hxx"
34cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
35cdf0e10cSrcweir #include <comphelper/sequence.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir // -------------------------------------------------------------------------
38cdf0e10cSrcweir using namespace connectivity;
39cdf0e10cSrcweir using namespace connectivity::sdbcx;
40cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
41cdf0e10cSrcweir using namespace ::com::sun::star::beans;
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir using namespace ::com::sun::star::container;
44cdf0e10cSrcweir using namespace ::com::sun::star::lang;
45cdf0e10cSrcweir
46cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
47cdf0e10cSrcweir // -------------------------------------------------------------------------
OUser(sal_Bool _bCase)48cdf0e10cSrcweir OUser::OUser(sal_Bool _bCase) : OUser_BASE(m_aMutex)
49cdf0e10cSrcweir , ODescriptor(OUser_BASE::rBHelper,_bCase,sal_True)
50cdf0e10cSrcweir , m_pGroups(NULL)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
53cdf0e10cSrcweir // -------------------------------------------------------------------------
OUser(const::rtl::OUString & _Name,sal_Bool _bCase)54cdf0e10cSrcweir OUser::OUser(const ::rtl::OUString& _Name,sal_Bool _bCase) : OUser_BASE(m_aMutex)
55cdf0e10cSrcweir ,ODescriptor(OUser_BASE::rBHelper,_bCase)
56cdf0e10cSrcweir ,m_pGroups(NULL)
57cdf0e10cSrcweir {
58cdf0e10cSrcweir m_Name = _Name;
59cdf0e10cSrcweir }
60cdf0e10cSrcweir // -------------------------------------------------------------------------
~OUser()61cdf0e10cSrcweir OUser::~OUser( )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir delete m_pGroups;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir // -------------------------------------------------------------------------
disposing(void)66cdf0e10cSrcweir void OUser::disposing(void)
67cdf0e10cSrcweir {
68cdf0e10cSrcweir OPropertySetHelper::disposing();
69cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
70cdf0e10cSrcweir if(m_pGroups)
71cdf0e10cSrcweir m_pGroups->disposing();
72cdf0e10cSrcweir }
73cdf0e10cSrcweir // -------------------------------------------------------------------------
queryInterface(const Type & rType)74cdf0e10cSrcweir Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException)
75cdf0e10cSrcweir {
76cdf0e10cSrcweir Any aRet = ODescriptor::queryInterface( rType);
77cdf0e10cSrcweir return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
78cdf0e10cSrcweir }
79cdf0e10cSrcweir // -------------------------------------------------------------------------
getTypes()80cdf0e10cSrcweir Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException)
81cdf0e10cSrcweir {
82cdf0e10cSrcweir return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -------------------------------------------------------------------------
createArrayHelper() const85cdf0e10cSrcweir ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir Sequence< Property > aProps;
88cdf0e10cSrcweir describeProperties(aProps);
89cdf0e10cSrcweir return new ::cppu::OPropertyArrayHelper(aProps);
90cdf0e10cSrcweir
91cdf0e10cSrcweir }
92cdf0e10cSrcweir // -------------------------------------------------------------------------
getInfoHelper()93cdf0e10cSrcweir ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
94cdf0e10cSrcweir {
95cdf0e10cSrcweir return *const_cast<OUser*>(this)->getArrayHelper();
96cdf0e10cSrcweir }
97cdf0e10cSrcweir // -------------------------------------------------------------------------
98cdf0e10cSrcweir // XUser
changePassword(const::rtl::OUString &,const::rtl::OUString &)99cdf0e10cSrcweir void SAL_CALL OUser::changePassword( const ::rtl::OUString& /*objPassword*/, const ::rtl::OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
102cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
103cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XUser::changePassword", *this );
104cdf0e10cSrcweir }
105cdf0e10cSrcweir // -------------------------------------------------------------------------
106cdf0e10cSrcweir // XGroupsSupplier
getGroups()107cdf0e10cSrcweir Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException)
108cdf0e10cSrcweir {
109cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
110cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
111cdf0e10cSrcweir
112cdf0e10cSrcweir try
113cdf0e10cSrcweir {
114cdf0e10cSrcweir if ( !m_pGroups )
115cdf0e10cSrcweir refreshGroups();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir catch( const RuntimeException& )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir // allowed to leave this method
120cdf0e10cSrcweir throw;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir catch( const Exception& )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir // allowed
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir return const_cast<OUser*>(this)->m_pGroups;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir // -------------------------------------------------------------------------
130cdf0e10cSrcweir // -------------------------------------------------------------------------
131cdf0e10cSrcweir
getPrivileges(const::rtl::OUString &,sal_Int32)132cdf0e10cSrcweir sal_Int32 SAL_CALL OUser::getPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
135cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
136cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
137cdf0e10cSrcweir return 0;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -------------------------------------------------------------------------
getGrantablePrivileges(const::rtl::OUString &,sal_Int32)140cdf0e10cSrcweir sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
143cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
144cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
145cdf0e10cSrcweir return 0;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir // -------------------------------------------------------------------------
grantPrivileges(const::rtl::OUString &,sal_Int32,sal_Int32)148cdf0e10cSrcweir void SAL_CALL OUser::grantPrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
151cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
152cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // -------------------------------------------------------------------------
revokePrivileges(const::rtl::OUString &,sal_Int32,sal_Int32)155cdf0e10cSrcweir void SAL_CALL OUser::revokePrivileges( const ::rtl::OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
156cdf0e10cSrcweir {
157cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex);
158cdf0e10cSrcweir checkDisposed(OUser_BASE::rBHelper.bDisposed);
159cdf0e10cSrcweir ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
160cdf0e10cSrcweir }
161cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPropertySetInfo()162cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
165cdf0e10cSrcweir }
166cdf0e10cSrcweir // -----------------------------------------------------------------------------
getName()167cdf0e10cSrcweir ::rtl::OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException)
168cdf0e10cSrcweir {
169cdf0e10cSrcweir return m_Name;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // -----------------------------------------------------------------------------
setName(const::rtl::OUString &)172cdf0e10cSrcweir void SAL_CALL OUser::setName( const ::rtl::OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException)
173cdf0e10cSrcweir {
174cdf0e10cSrcweir OSL_ENSURE( false, "OUser::setName: not implemented!" );
175cdf0e10cSrcweir // not allowed to throw an SQLException here ...
176cdf0e10cSrcweir }
177cdf0e10cSrcweir // -----------------------------------------------------------------------------
178cdf0e10cSrcweir // XInterface
acquire()179cdf0e10cSrcweir void SAL_CALL OUser::acquire() throw()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir OUser_BASE::acquire();
182cdf0e10cSrcweir }
183cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()184cdf0e10cSrcweir void SAL_CALL OUser::release() throw()
185cdf0e10cSrcweir {
186cdf0e10cSrcweir OUser_BASE::release();
187cdf0e10cSrcweir }
188cdf0e10cSrcweir // -----------------------------------------------------------------------------
189cdf0e10cSrcweir
190cdf0e10cSrcweir
191