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 #include "hsqldb/HUser.hxx"
27cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
28cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
29cdf0e10cSrcweir #include "connectivity/dbtools.hxx"
30cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
31cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
32cdf0e10cSrcweir #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
33cdf0e10cSrcweir #include "TConnection.hxx"
34cdf0e10cSrcweir #include "resource/hsqldb_res.hrc"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace connectivity;
37cdf0e10cSrcweir using namespace connectivity::hsqldb;
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir using namespace ::com::sun::star::beans;
40cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx;
41cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
42cdf0e10cSrcweir using namespace ::com::sun::star::container;
43cdf0e10cSrcweir using namespace ::com::sun::star::lang;
44cdf0e10cSrcweir // -------------------------------------------------------------------------
OHSQLUser(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XConnection> & _xConnection)45cdf0e10cSrcweir OHSQLUser::OHSQLUser(	const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : connectivity::sdbcx::OUser(sal_True)
46cdf0e10cSrcweir 				,m_xConnection(_xConnection)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	construct();
49cdf0e10cSrcweir }
50cdf0e10cSrcweir // -------------------------------------------------------------------------
OHSQLUser(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XConnection> & _xConnection,const::rtl::OUString & _Name)51cdf0e10cSrcweir OHSQLUser::OHSQLUser(   const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
52cdf0e10cSrcweir 				const ::rtl::OUString& _Name
53cdf0e10cSrcweir 			) : connectivity::sdbcx::OUser(_Name,sal_True)
54cdf0e10cSrcweir 				,m_xConnection(_xConnection)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir 	construct();
57cdf0e10cSrcweir }
58cdf0e10cSrcweir // -------------------------------------------------------------------------
refreshGroups()59cdf0e10cSrcweir void OHSQLUser::refreshGroups()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir // -------------------------------------------------------------------------
OUserExtend(const::com::sun::star::uno::Reference<::com::sun::star::sdbc::XConnection> & _xConnection)63cdf0e10cSrcweir OUserExtend::OUserExtend(	const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : OHSQLUser(_xConnection)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	construct();
66cdf0e10cSrcweir }
67cdf0e10cSrcweir // -------------------------------------------------------------------------
68cdf0e10cSrcweir typedef connectivity::sdbcx::OUser	OUser_TYPEDEF;
construct()69cdf0e10cSrcweir void OUserExtend::construct()
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD),	PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
72cdf0e10cSrcweir }
73cdf0e10cSrcweir // -----------------------------------------------------------------------------
createArrayHelper() const74cdf0e10cSrcweir cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	Sequence< Property > aProps;
77cdf0e10cSrcweir 	describeProperties(aProps);
78cdf0e10cSrcweir 	return new cppu::OPropertyArrayHelper(aProps);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir // -------------------------------------------------------------------------
getInfoHelper()81cdf0e10cSrcweir cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	return *OUserExtend_PROP::getArrayHelper();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
86cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPrivileges(const::rtl::OUString & objName,sal_Int32 objType)87cdf0e10cSrcweir sal_Int32 SAL_CALL OHSQLUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
90cdf0e10cSrcweir 	checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	sal_Int32 nRights,nRightsWithGrant;
93cdf0e10cSrcweir 	findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
94cdf0e10cSrcweir 	return nRights;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir // -----------------------------------------------------------------------------
findPrivilegesAndGrantPrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 & nRights,sal_Int32 & nRightsWithGrant)97cdf0e10cSrcweir void OHSQLUser::findPrivilegesAndGrantPrivileges(const ::rtl::OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	nRightsWithGrant = nRights = 0;
100cdf0e10cSrcweir 	// first we need to create the sql stmt to select the privs
101cdf0e10cSrcweir 	Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
102cdf0e10cSrcweir 	::rtl::OUString sCatalog,sSchema,sTable;
103cdf0e10cSrcweir 	::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
104cdf0e10cSrcweir 	Reference<XResultSet> xRes;
105cdf0e10cSrcweir 	switch(objType)
106cdf0e10cSrcweir 	{
107cdf0e10cSrcweir 		case PrivilegeObject::TABLE:
108cdf0e10cSrcweir 		case PrivilegeObject::VIEW:
109cdf0e10cSrcweir 			{
110cdf0e10cSrcweir 				Any aCatalog;
111cdf0e10cSrcweir 				if ( sCatalog.getLength() )
112cdf0e10cSrcweir 					aCatalog <<= sCatalog;
113cdf0e10cSrcweir 				xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
114cdf0e10cSrcweir 			}
115cdf0e10cSrcweir 			break;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		case PrivilegeObject::COLUMN:
118cdf0e10cSrcweir 			{
119cdf0e10cSrcweir 				Any aCatalog;
120cdf0e10cSrcweir 				if ( sCatalog.getLength() )
121cdf0e10cSrcweir 					aCatalog <<= sCatalog;
122cdf0e10cSrcweir 				xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
123cdf0e10cSrcweir 			}
124cdf0e10cSrcweir 			break;
125cdf0e10cSrcweir 	}
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	if ( xRes.is() )
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		static const ::rtl::OUString sSELECT	= ::rtl::OUString::createFromAscii("SELECT");
130cdf0e10cSrcweir 		static const ::rtl::OUString sINSERT	= ::rtl::OUString::createFromAscii("INSERT");
131cdf0e10cSrcweir 		static const ::rtl::OUString sUPDATE	= ::rtl::OUString::createFromAscii("UPDATE");
132cdf0e10cSrcweir 		static const ::rtl::OUString sDELETE	= ::rtl::OUString::createFromAscii("DELETE");
133cdf0e10cSrcweir 		static const ::rtl::OUString sREAD		= ::rtl::OUString::createFromAscii("READ");
134cdf0e10cSrcweir 		static const ::rtl::OUString sCREATE	= ::rtl::OUString::createFromAscii("CREATE");
135cdf0e10cSrcweir 		static const ::rtl::OUString sALTER		= ::rtl::OUString::createFromAscii("ALTER");
136cdf0e10cSrcweir 		static const ::rtl::OUString sREFERENCE = ::rtl::OUString::createFromAscii("REFERENCE");
137cdf0e10cSrcweir 		static const ::rtl::OUString sDROP		= ::rtl::OUString::createFromAscii("DROP");
138cdf0e10cSrcweir 		static const ::rtl::OUString sYes		= ::rtl::OUString::createFromAscii("YES");
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 		nRightsWithGrant = nRights = 0;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 		Reference<XRow> xCurrentRow(xRes,UNO_QUERY);
143cdf0e10cSrcweir 		while( xCurrentRow.is() && xRes->next() )
144cdf0e10cSrcweir 		{
145cdf0e10cSrcweir 			::rtl::OUString sGrantee	= xCurrentRow->getString(5);
146cdf0e10cSrcweir 			::rtl::OUString sPrivilege	= xCurrentRow->getString(6);
147cdf0e10cSrcweir 			::rtl::OUString sGrantable	= xCurrentRow->getString(7);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir 			if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
150cdf0e10cSrcweir 				continue;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 			if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
153cdf0e10cSrcweir 			{
154cdf0e10cSrcweir 				nRights |= Privilege::SELECT;
155cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
156cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::SELECT;
157cdf0e10cSrcweir 			}
158cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
159cdf0e10cSrcweir 			{
160cdf0e10cSrcweir 				nRights |= Privilege::INSERT;
161cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
162cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::INSERT;
163cdf0e10cSrcweir 			}
164cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
165cdf0e10cSrcweir 			{
166cdf0e10cSrcweir 				nRights |= Privilege::UPDATE;
167cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
168cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::UPDATE;
169cdf0e10cSrcweir 			}
170cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
171cdf0e10cSrcweir 			{
172cdf0e10cSrcweir 				nRights |= Privilege::DELETE;
173cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
174cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::DELETE;
175cdf0e10cSrcweir 			}
176cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
177cdf0e10cSrcweir 			{
178cdf0e10cSrcweir 				nRights |= Privilege::READ;
179cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
180cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::READ;
181cdf0e10cSrcweir 			}
182cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
183cdf0e10cSrcweir 			{
184cdf0e10cSrcweir 				nRights |= Privilege::CREATE;
185cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
186cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::CREATE;
187cdf0e10cSrcweir 			}
188cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
189cdf0e10cSrcweir 			{
190cdf0e10cSrcweir 				nRights |= Privilege::ALTER;
191cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
192cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::ALTER;
193cdf0e10cSrcweir 			}
194cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
195cdf0e10cSrcweir 			{
196cdf0e10cSrcweir 				nRights |= Privilege::REFERENCE;
197cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
198cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::REFERENCE;
199cdf0e10cSrcweir 			}
200cdf0e10cSrcweir 			else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
201cdf0e10cSrcweir 			{
202cdf0e10cSrcweir 				nRights |= Privilege::DROP;
203cdf0e10cSrcweir 				if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
204cdf0e10cSrcweir 					nRightsWithGrant |= Privilege::DROP;
205cdf0e10cSrcweir 			}
206cdf0e10cSrcweir 		}
207cdf0e10cSrcweir 		::comphelper::disposeComponent(xRes);
208cdf0e10cSrcweir 	}
209cdf0e10cSrcweir }
210cdf0e10cSrcweir // -------------------------------------------------------------------------
getGrantablePrivileges(const::rtl::OUString & objName,sal_Int32 objType)211cdf0e10cSrcweir sal_Int32 SAL_CALL OHSQLUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
214cdf0e10cSrcweir 	checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 	sal_Int32 nRights,nRightsWithGrant;
217cdf0e10cSrcweir 	findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
218cdf0e10cSrcweir 	return nRightsWithGrant;
219cdf0e10cSrcweir }
220cdf0e10cSrcweir // -------------------------------------------------------------------------
grantPrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)221cdf0e10cSrcweir void SAL_CALL OHSQLUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir     if ( objType != PrivilegeObject::TABLE )
224cdf0e10cSrcweir     {
225cdf0e10cSrcweir         ::connectivity::SharedResources aResources;
226cdf0e10cSrcweir         const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
227cdf0e10cSrcweir         ::dbtools::throwGenericSQLException(sError,*this);
228cdf0e10cSrcweir     } // if ( objType != PrivilegeObject::TABLE )
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
234cdf0e10cSrcweir 	if(sPrivs.getLength())
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		::rtl::OUString sGrant;
237cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii("GRANT ");
238cdf0e10cSrcweir 		sGrant += sPrivs;
239cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii(" ON ");
240cdf0e10cSrcweir 		Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
241cdf0e10cSrcweir 		sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
242cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii(" TO ");
243cdf0e10cSrcweir 		sGrant += m_Name;
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 		Reference<XStatement> xStmt = m_xConnection->createStatement();
246cdf0e10cSrcweir 		if(xStmt.is())
247cdf0e10cSrcweir 			xStmt->execute(sGrant);
248cdf0e10cSrcweir 		::comphelper::disposeComponent(xStmt);
249cdf0e10cSrcweir 	}
250cdf0e10cSrcweir }
251cdf0e10cSrcweir // -------------------------------------------------------------------------
revokePrivileges(const::rtl::OUString & objName,sal_Int32 objType,sal_Int32 objPrivileges)252cdf0e10cSrcweir void SAL_CALL OHSQLUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     if ( objType != PrivilegeObject::TABLE )
255cdf0e10cSrcweir     {
256cdf0e10cSrcweir         ::connectivity::SharedResources aResources;
257cdf0e10cSrcweir         const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
258cdf0e10cSrcweir         ::dbtools::throwGenericSQLException(sError,*this);
259cdf0e10cSrcweir     } // if ( objType != PrivilegeObject::TABLE )
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
262cdf0e10cSrcweir 	checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
263cdf0e10cSrcweir     ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
264cdf0e10cSrcweir 	if(sPrivs.getLength())
265cdf0e10cSrcweir 	{
266cdf0e10cSrcweir 		::rtl::OUString sGrant;
267cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
268cdf0e10cSrcweir 		sGrant += sPrivs;
269cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii(" ON ");
270cdf0e10cSrcweir 		Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
271cdf0e10cSrcweir 		sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
272cdf0e10cSrcweir 		sGrant += ::rtl::OUString::createFromAscii(" FROM ");
273cdf0e10cSrcweir 		sGrant += m_Name;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 		Reference<XStatement> xStmt = m_xConnection->createStatement();
276cdf0e10cSrcweir 		if(xStmt.is())
277cdf0e10cSrcweir 			xStmt->execute(sGrant);
278cdf0e10cSrcweir 		::comphelper::disposeComponent(xStmt);
279cdf0e10cSrcweir 	}
280cdf0e10cSrcweir }
281cdf0e10cSrcweir // -----------------------------------------------------------------------------
282cdf0e10cSrcweir // XUser
changePassword(const::rtl::OUString &,const::rtl::OUString & newPassword)283cdf0e10cSrcweir void SAL_CALL OHSQLUser::changePassword( const ::rtl::OUString& /*oldPassword*/, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
286cdf0e10cSrcweir 	checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
287cdf0e10cSrcweir 	::rtl::OUString sAlterPwd;
288cdf0e10cSrcweir 	sAlterPwd = ::rtl::OUString::createFromAscii("SET PASSWORD FOR ");
289cdf0e10cSrcweir 	sAlterPwd += m_Name;
290cdf0e10cSrcweir 	sAlterPwd += ::rtl::OUString::createFromAscii("@\"%\" = PASSWORD('") ;
291cdf0e10cSrcweir 	sAlterPwd += newPassword;
292cdf0e10cSrcweir 	sAlterPwd += ::rtl::OUString::createFromAscii("')") ;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	Reference<XStatement> xStmt = m_xConnection->createStatement();
296cdf0e10cSrcweir 	if ( xStmt.is() )
297cdf0e10cSrcweir 	{
298cdf0e10cSrcweir 		xStmt->execute(sAlterPwd);
299cdf0e10cSrcweir 		::comphelper::disposeComponent(xStmt);
300cdf0e10cSrcweir 	}
301cdf0e10cSrcweir }
302cdf0e10cSrcweir // -----------------------------------------------------------------------------
getPrivilegeString(sal_Int32 nRights) const303cdf0e10cSrcweir ::rtl::OUString OHSQLUser::getPrivilegeString(sal_Int32 nRights) const
304cdf0e10cSrcweir {
305cdf0e10cSrcweir 	::rtl::OUString sPrivs;
306cdf0e10cSrcweir 	if((nRights & Privilege::INSERT) == Privilege::INSERT)
307cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("INSERT");
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 	if((nRights & Privilege::DELETE) == Privilege::DELETE)
310cdf0e10cSrcweir 	{
311cdf0e10cSrcweir 		if(sPrivs.getLength())
312cdf0e10cSrcweir 			sPrivs += ::rtl::OUString::createFromAscii(",");
313cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("DELETE");
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 	if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
317cdf0e10cSrcweir 	{
318cdf0e10cSrcweir 		if(sPrivs.getLength())
319cdf0e10cSrcweir 			sPrivs += ::rtl::OUString::createFromAscii(",");
320cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
321cdf0e10cSrcweir 	}
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	if((nRights & Privilege::ALTER) == Privilege::ALTER)
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir 		if(sPrivs.getLength())
326cdf0e10cSrcweir 			sPrivs += ::rtl::OUString::createFromAscii(",");
327cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("ALTER");
328cdf0e10cSrcweir 	}
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 	if((nRights & Privilege::SELECT) == Privilege::SELECT)
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir 		if(sPrivs.getLength())
333cdf0e10cSrcweir 			sPrivs += ::rtl::OUString::createFromAscii(",");
334cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("SELECT");
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir 
337cdf0e10cSrcweir 	if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
338cdf0e10cSrcweir 	{
339cdf0e10cSrcweir 		if(sPrivs.getLength())
340cdf0e10cSrcweir 			sPrivs += ::rtl::OUString::createFromAscii(",");
341cdf0e10cSrcweir 		sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
342cdf0e10cSrcweir 	}
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 	return sPrivs;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir // -----------------------------------------------------------------------------
347cdf0e10cSrcweir 
348