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