xref: /trunk/main/connectivity/source/drivers/mysql/YUser.cxx (revision bccc15720f18c5c38dc8be638980e527a5e06ef0)
19b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59b5730f6SAndrew Rist  * distributed with this work for additional information
69b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
99b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149b5730f6SAndrew Rist  * software distributed under the License is distributed on an
159b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
179b5730f6SAndrew Rist  * specific language governing permissions and limitations
189b5730f6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209b5730f6SAndrew Rist  *************************************************************/
219b5730f6SAndrew Rist 
229b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include "mysql/YUser.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/common_res.hrc"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace connectivity;
37cdf0e10cSrcweir using namespace connectivity::mysql;
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 // -------------------------------------------------------------------------
45cdf0e10cSrcweir OMySQLUser::OMySQLUser( 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 // -------------------------------------------------------------------------
51cdf0e10cSrcweir OMySQLUser::OMySQLUser(   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 // -------------------------------------------------------------------------
59cdf0e10cSrcweir void OMySQLUser::refreshGroups()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir // -------------------------------------------------------------------------
63cdf0e10cSrcweir OUserExtend::OUserExtend(   const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : OMySQLUser(_xConnection)
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     construct();
66cdf0e10cSrcweir }
67cdf0e10cSrcweir // -------------------------------------------------------------------------
68cdf0e10cSrcweir typedef connectivity::sdbcx::OUser  OUser_TYPEDEF;
69cdf0e10cSrcweir void OUserExtend::construct()
70cdf0e10cSrcweir {
71*bccc1572SDon Lewis     registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD),    PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(static_cast< ::rtl::OUString*>(NULL)));
72cdf0e10cSrcweir }
73cdf0e10cSrcweir // -----------------------------------------------------------------------------
74cdf0e10cSrcweir cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     Sequence< Property > aProps;
77cdf0e10cSrcweir     describeProperties(aProps);
78cdf0e10cSrcweir     return new cppu::OPropertyArrayHelper(aProps);
79cdf0e10cSrcweir }
80cdf0e10cSrcweir // -------------------------------------------------------------------------
81cdf0e10cSrcweir cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     return *OUserExtend_PROP::getArrayHelper();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
86cdf0e10cSrcweir // -----------------------------------------------------------------------------
87cdf0e10cSrcweir sal_Int32 SAL_CALL OMySQLUser::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 // -----------------------------------------------------------------------------
97cdf0e10cSrcweir void OMySQLUser::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 // -------------------------------------------------------------------------
211cdf0e10cSrcweir sal_Int32 SAL_CALL OMySQLUser::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 // -------------------------------------------------------------------------
221cdf0e10cSrcweir void SAL_CALL OMySQLUser::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     ::osl::MutexGuard aGuard(m_aMutex);
231cdf0e10cSrcweir 
232cdf0e10cSrcweir     ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
233cdf0e10cSrcweir     if(sPrivs.getLength())
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir         ::rtl::OUString sGrant;
236cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii("GRANT ");
237cdf0e10cSrcweir         sGrant += sPrivs;
238cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii(" ON ");
239cdf0e10cSrcweir         Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
240cdf0e10cSrcweir         sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
241cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii(" TO ");
242cdf0e10cSrcweir         sGrant += m_Name;
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         Reference<XStatement> xStmt = m_xConnection->createStatement();
245cdf0e10cSrcweir         if(xStmt.is())
246cdf0e10cSrcweir             xStmt->execute(sGrant);
247cdf0e10cSrcweir         ::comphelper::disposeComponent(xStmt);
248cdf0e10cSrcweir     }
249cdf0e10cSrcweir }
250cdf0e10cSrcweir // -------------------------------------------------------------------------
251cdf0e10cSrcweir void SAL_CALL OMySQLUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
252cdf0e10cSrcweir {
253cdf0e10cSrcweir     if ( objType != PrivilegeObject::TABLE )
254cdf0e10cSrcweir     {
255cdf0e10cSrcweir         ::connectivity::SharedResources aResources;
256cdf0e10cSrcweir         const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
257cdf0e10cSrcweir         ::dbtools::throwGenericSQLException(sError,*this);
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
261cdf0e10cSrcweir     checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
262cdf0e10cSrcweir     ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
263cdf0e10cSrcweir     if(sPrivs.getLength())
264cdf0e10cSrcweir     {
265cdf0e10cSrcweir         ::rtl::OUString sGrant;
266cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
267cdf0e10cSrcweir         sGrant += sPrivs;
268cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii(" ON ");
269cdf0e10cSrcweir         Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
270cdf0e10cSrcweir         sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
271cdf0e10cSrcweir         sGrant += ::rtl::OUString::createFromAscii(" FROM ");
272cdf0e10cSrcweir         sGrant += m_Name;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir         Reference<XStatement> xStmt = m_xConnection->createStatement();
275cdf0e10cSrcweir         if(xStmt.is())
276cdf0e10cSrcweir             xStmt->execute(sGrant);
277cdf0e10cSrcweir         ::comphelper::disposeComponent(xStmt);
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir // -----------------------------------------------------------------------------
281cdf0e10cSrcweir // XUser
282cdf0e10cSrcweir void SAL_CALL OMySQLUser::changePassword( const ::rtl::OUString& /*oldPassword*/, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
285cdf0e10cSrcweir     checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
286cdf0e10cSrcweir     ::rtl::OUString sAlterPwd;
287cdf0e10cSrcweir     sAlterPwd = ::rtl::OUString::createFromAscii("SET PASSWORD FOR ");
288cdf0e10cSrcweir     sAlterPwd += m_Name;
289cdf0e10cSrcweir     sAlterPwd += ::rtl::OUString::createFromAscii("@\"%\" = PASSWORD('") ;
290cdf0e10cSrcweir     sAlterPwd += newPassword;
291cdf0e10cSrcweir     sAlterPwd += ::rtl::OUString::createFromAscii("')") ;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
294cdf0e10cSrcweir     Reference<XStatement> xStmt = m_xConnection->createStatement();
295cdf0e10cSrcweir     if ( xStmt.is() )
296cdf0e10cSrcweir     {
297cdf0e10cSrcweir         xStmt->execute(sAlterPwd);
298cdf0e10cSrcweir         ::comphelper::disposeComponent(xStmt);
299cdf0e10cSrcweir     }
300cdf0e10cSrcweir }
301cdf0e10cSrcweir // -----------------------------------------------------------------------------
302cdf0e10cSrcweir ::rtl::OUString OMySQLUser::getPrivilegeString(sal_Int32 nRights) const
303cdf0e10cSrcweir {
304cdf0e10cSrcweir     ::rtl::OUString sPrivs;
305cdf0e10cSrcweir     if((nRights & Privilege::INSERT) == Privilege::INSERT)
306cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("INSERT");
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     if((nRights & Privilege::DELETE) == Privilege::DELETE)
309cdf0e10cSrcweir     {
310cdf0e10cSrcweir         if(sPrivs.getLength())
311cdf0e10cSrcweir             sPrivs += ::rtl::OUString::createFromAscii(",");
312cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("DELETE");
313cdf0e10cSrcweir     }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         if(sPrivs.getLength())
318cdf0e10cSrcweir             sPrivs += ::rtl::OUString::createFromAscii(",");
319cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
320cdf0e10cSrcweir     }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir     if((nRights & Privilege::ALTER) == Privilege::ALTER)
323cdf0e10cSrcweir     {
324cdf0e10cSrcweir         if(sPrivs.getLength())
325cdf0e10cSrcweir             sPrivs += ::rtl::OUString::createFromAscii(",");
326cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("ALTER");
327cdf0e10cSrcweir     }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     if((nRights & Privilege::SELECT) == Privilege::SELECT)
330cdf0e10cSrcweir     {
331cdf0e10cSrcweir         if(sPrivs.getLength())
332cdf0e10cSrcweir             sPrivs += ::rtl::OUString::createFromAscii(",");
333cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("SELECT");
334cdf0e10cSrcweir     }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir     if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
337cdf0e10cSrcweir     {
338cdf0e10cSrcweir         if(sPrivs.getLength())
339cdf0e10cSrcweir             sPrivs += ::rtl::OUString::createFromAscii(",");
340cdf0e10cSrcweir         sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
341cdf0e10cSrcweir     }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir     return sPrivs;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir // -----------------------------------------------------------------------------
346cdf0e10cSrcweir 
347