diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-06-20 06:16:56 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-06-20 06:16:56 +0000 |
commit | 99d22677dbc58726b1684dc5d17930b52f1e6f85 (patch) | |
tree | d151fe4cb2b7dcd96f3868334bce78b57cfedcad /connectivity | |
parent | 9b316f673f54170e0a4a76730622dd9ca47e0709 (diff) |
#88434# implement user access rights
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/adabas/BUser.cxx | 181 | ||||
-rw-r--r-- | connectivity/source/drivers/adabas/BUsers.cxx | 9 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ACatalog.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AGroup.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AGroups.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/ATable.cxx | 20 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AUser.cxx | 78 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/AUsers.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/drivers/ado/adoimp.cxx | 96 | ||||
-rw-r--r-- | connectivity/source/inc/adabas/BUser.hxx | 13 | ||||
-rw-r--r-- | connectivity/source/inc/ado/AGroup.hxx | 10 | ||||
-rw-r--r-- | connectivity/source/inc/ado/AGroups.hxx | 13 | ||||
-rw-r--r-- | connectivity/source/inc/ado/AUser.hxx | 24 | ||||
-rw-r--r-- | connectivity/source/inc/ado/AUsers.hxx | 13 | ||||
-rw-r--r-- | connectivity/source/inc/ado/adoimp.hxx | 13 |
15 files changed, 442 insertions, 64 deletions
diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx index f6cdcc7b4462..58259a0c3c2f 100644 --- a/connectivity/source/drivers/adabas/BUser.cxx +++ b/connectivity/source/drivers/adabas/BUser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BUser.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:41:57 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:12:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,11 +74,20 @@ #ifndef _CONNECTIVITY_ADABAS_BCONNECTION_HXX_ #include "adabas/BConnection.hxx" #endif +#ifndef _CONNECTIVITY_DBTOOLS_HXX_ +#include "connectivity/dbtools.hxx" +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ +#include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_ +#include <com/sun/star/sdbcx/PrivilegeObject.hpp> +#endif using namespace connectivity::adabas; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -// using namespace ::com::sun::star::sdbcx; +using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; @@ -158,4 +167,170 @@ cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper() return *OUserExtend_PROP::getArrayHelper(); } // ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdabasUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + + sal_Int32 nRights = 0; + // first we need to create the sql stmt to select the privs + Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData(); + ::rtl::OUString sCatalog,sSchema,sTable; + ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable); + Reference<XStatement> xStmt = m_pConnection->createStatement(); + ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("SELECT REFTABLENAME,PRIVILEGES FROM DOMAIN.USR_USES_TAB WHERE REFOBJTYPE <> 'SYSTEM' AND DEFUSERNAME = '"); + sSql += m_Name; + sSql += ::rtl::OUString::createFromAscii("' AND REFTABLENAME = '"); + sSql += sTable; + sSql += ::rtl::OUString::createFromAscii("'"); + if(xStmt.is()) + { + Reference<XResultSet> xRes = xStmt->executeQuery(sSql); + if(xRes.is()) + { + Reference<XRow> xRow(xRes,UNO_QUERY); + if(xRow.is() && xRes->next()) + { + ::rtl::OUString sPrivs = xRow->getString(2); + static const ::rtl::OUString sInsert = ::rtl::OUString::createFromAscii("INS"); + static const ::rtl::OUString sDelete = ::rtl::OUString::createFromAscii("DEL"); + static const ::rtl::OUString sUpdate = ::rtl::OUString::createFromAscii("UPD"); + static const ::rtl::OUString sAlter = ::rtl::OUString::createFromAscii("ALT"); + static const ::rtl::OUString sSelect = ::rtl::OUString::createFromAscii("SEL"); + static const ::rtl::OUString sReference = ::rtl::OUString::createFromAscii("REF"); + if(sPrivs.indexOf(sInsert) != -1) + nRights |= Privilege::INSERT; + if(sPrivs.indexOf(sDelete) != -1) + nRights |= Privilege::DELETE; + if(sPrivs.indexOf(sUpdate) != -1) + nRights |= Privilege::UPDATE; + if(sPrivs.indexOf(sAlter) != -1) + nRights |= Privilege::ALTER; + if(sPrivs.indexOf(sSelect) != -1) + nRights |= Privilege::SELECT; + if(sPrivs.indexOf(sReference) != -1) + nRights |= Privilege::REFERENCE; + } + } + } + + return nRights; +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdabasUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + + sal_Int32 nRights = 0; + + return nRights; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdabasUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + + ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges); + if(sPrivs.getLength()) + { + ::rtl::OUString sGrant; + sGrant += ::rtl::OUString::createFromAscii("GRANT "); + sGrant += sPrivs; + sGrant += ::rtl::OUString::createFromAscii(" ON "); + Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData(); + sGrant += ::dbtools::quoteTableName(xMeta,objName); + sGrant += ::rtl::OUString::createFromAscii(" TO "); + sGrant += m_Name; + + Reference<XStatement> xStmt = m_pConnection->createStatement(); + if(xStmt.is()) + xStmt->execute(sGrant); + } +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdabasUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges); + if(sPrivs.getLength()) + { + ::rtl::OUString sGrant; + sGrant += ::rtl::OUString::createFromAscii("GRANT "); + sGrant += sPrivs; + sGrant += ::rtl::OUString::createFromAscii(" ON "); + Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData(); + sGrant += ::dbtools::quoteTableName(xMeta,objName); + sGrant += ::rtl::OUString::createFromAscii(" FROM "); + sGrant += m_Name; + + Reference<XStatement> xStmt = m_pConnection->createStatement(); + if(xStmt.is()) + xStmt->execute(sGrant); + } +} +// ----------------------------------------------------------------------------- +// XUser +void SAL_CALL OAdabasUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + ::rtl::OUString sAlterPwd; + sAlterPwd = ::rtl::OUString::createFromAscii("ALTER PASSWORD "); + sAlterPwd += m_Name; + sAlterPwd += ::rtl::OUString::createFromAscii(" ") ; + sAlterPwd += objPassword; + sAlterPwd += ::rtl::OUString::createFromAscii(" TO ") ; + sAlterPwd += newPassword; + Reference<XStatement> xStmt = m_pConnection->createStatement(); + if(xStmt.is()) + xStmt->execute(sAlterPwd); +} +// ----------------------------------------------------------------------------- +::rtl::OUString OAdabasUser::getPrivilegeString(sal_Int32 nRights) const +{ + ::rtl::OUString sPrivs; + if((nRights & Privilege::INSERT) == Privilege::INSERT) + sPrivs += ::rtl::OUString::createFromAscii("INSERT"); + + if((nRights & Privilege::DELETE) == Privilege::DELETE) + { + if(sPrivs.getLength()) + sPrivs += ::rtl::OUString::createFromAscii(","); + sPrivs += ::rtl::OUString::createFromAscii("DELETE"); + } + + if((nRights & Privilege::UPDATE) == Privilege::UPDATE) + { + if(sPrivs.getLength()) + sPrivs += ::rtl::OUString::createFromAscii(","); + sPrivs += ::rtl::OUString::createFromAscii("UPDATE"); + } + + if((nRights & Privilege::ALTER) == Privilege::ALTER) + { + if(sPrivs.getLength()) + sPrivs += ::rtl::OUString::createFromAscii(","); + sPrivs += ::rtl::OUString::createFromAscii("ALTER"); + } + + if((nRights & Privilege::SELECT) == Privilege::SELECT) + { + if(sPrivs.getLength()) + sPrivs += ::rtl::OUString::createFromAscii(","); + sPrivs += ::rtl::OUString::createFromAscii("SELECT"); + } + + if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE) + { + if(sPrivs.getLength()) + sPrivs += ::rtl::OUString::createFromAscii(","); + sPrivs += ::rtl::OUString::createFromAscii("REFERENCES"); + } + + return sPrivs; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/adabas/BUsers.cxx b/connectivity/source/drivers/adabas/BUsers.cxx index 02e25ac41756..a2f832640b43 100644 --- a/connectivity/source/drivers/adabas/BUsers.cxx +++ b/connectivity/source/drivers/adabas/BUsers.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BUsers.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:06 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:12:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -125,8 +125,9 @@ void SAL_CALL OUsers::appendByDescriptor( const Reference< XPropertySet >& descr aSql = aSql + aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote + ::rtl::OUString::createFromAscii(" PASSWORD ") + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD))); + aSql += ::rtl::OUString::createFromAscii(" RESOURCE NOT EXCLUSIVE"); - Reference< XStatement > xStmt = m_pConnection->createStatement( ); + Reference< XStatement > xStmt = m_pConnection->createStatement( ); xStmt->execute(aSql); OCollection_TYPE::appendByDescriptor(descriptor); @@ -160,4 +161,6 @@ void SAL_CALL OUsers::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOu dropByName(m_aElements[index]->first); } +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx index 1b1d59034f3a..40a0f36798e5 100644 --- a/connectivity/source/drivers/ado/ACatalog.cxx +++ b/connectivity/source/drivers/ado/ACatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ACatalog.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:41:55 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -182,7 +182,7 @@ void OCatalog::refreshGroups() if(m_pGroups) delete m_pGroups; - m_pGroups = new OGroups(*this,m_aMutex,aVector,pGroups,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + m_pGroups = new OGroups(this,m_aMutex,aVector,pGroups,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); } // ------------------------------------------------------------------------- void OCatalog::refreshUsers() @@ -210,7 +210,7 @@ void OCatalog::refreshUsers() if(m_pUsers) delete m_pUsers; - m_pUsers = new OUsers(*this,m_aMutex,aVector,pUsers,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + m_pUsers = new OUsers(this,m_aMutex,aVector,pUsers,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx index dd9e8aa55265..897011d72b32 100644 --- a/connectivity/source/drivers/ado/AGroup.cxx +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroup.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,7 +110,7 @@ void WpADOGroup::Create() operator=(pCommand); } // ------------------------------------------------------------------------- -OAdoGroup::OAdoGroup(sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase) +OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent) { construct(); if(_pGroup) @@ -121,7 +121,7 @@ OAdoGroup::OAdoGroup(sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase) refreshUsers(); } // ------------------------------------------------------------------------- -OAdoGroup::OAdoGroup(sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase) +OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase),m_pCatalog(_pParent) { construct(); m_aGroup.Create(); @@ -155,7 +155,7 @@ void OAdoGroup::refreshUsers() if(m_pUsers) m_pUsers->reFill(aVector); else - m_pUsers = new OUsers(*this,m_aMutex,aVector,pUsers,isCaseSensitive()); + m_pUsers = new OUsers(m_pCatalog,m_aMutex,aVector,pUsers,isCaseSensitive()); } //-------------------------------------------------------------------------- Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/ado/AGroups.cxx b/connectivity/source/drivers/ado/AGroups.cxx index 63a835402253..d999d6dc1494 100644 --- a/connectivity/source/drivers/ado/AGroups.cxx +++ b/connectivity/source/drivers/ado/AGroups.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroups.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:40:04 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,7 +94,7 @@ typedef connectivity::sdbcx::OCollection OCollection_TYPE; Reference< XNamed > OGroups::createObject(const ::rtl::OUString& _rName) { Reference< XNamed > xRet = NULL; - OAdoGroup* pRet = new OAdoGroup(isCaseSensitive(),_rName); + OAdoGroup* pRet = new OAdoGroup(m_pCatalog,isCaseSensitive(),_rName); xRet = pRet; return xRet; } @@ -106,7 +106,7 @@ void OGroups::impl_refresh() throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > OGroups::createEmptyObject() { - OAdoGroup* pNew = new OAdoGroup(isCaseSensitive()); + OAdoGroup* pNew = new OAdoGroup(m_pCatalog,isCaseSensitive()); return pNew; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx index 3f6d5b8961c9..3178f124217a 100644 --- a/connectivity/source/drivers/ado/ATable.cxx +++ b/connectivity/source/drivers/ado/ATable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ATable.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-05-25 13:09:28 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -168,7 +168,10 @@ void OAdoTable::refreshColumns() } } - m_pColumns = new OColumns(*this,m_aMutex,aVector,pColumns,isCaseSensitive(),m_pCatalog->getConnection()); + if(m_pColumns) + m_pColumns->reFill(aVector); + else + m_pColumns = new OColumns(*this,m_aMutex,aVector,pColumns,isCaseSensitive(),m_pCatalog->getConnection()); } // ------------------------------------------------------------------------- void OAdoTable::refreshKeys() @@ -194,7 +197,10 @@ void OAdoTable::refreshKeys() } } - m_pKeys = new OKeys(*this,m_aMutex,aVector,pKeys,isCaseSensitive(),m_pCatalog->getConnection()); + if(m_pKeys) + m_pKeys->reFill(aVector); + else + m_pKeys = new OKeys(*this,m_aMutex,aVector,pKeys,isCaseSensitive(),m_pCatalog->getConnection()); } // ------------------------------------------------------------------------- void OAdoTable::refreshIndexes() @@ -219,8 +225,10 @@ void OAdoTable::refreshIndexes() } } } - - m_pIndexes = new OIndexes(*this,m_aMutex,aVector,pIndexes,isCaseSensitive(),m_pCatalog->getConnection()); + if(m_pIndexes) + m_pIndexes->reFill(aVector); + else + m_pIndexes = new OIndexes(*this,m_aMutex,aVector,pIndexes,isCaseSensitive(),m_pCatalog->getConnection()); } //-------------------------------------------------------------------------- Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx index 2138adea9d93..7750a8713b9d 100644 --- a/connectivity/source/drivers/ado/AUser.cxx +++ b/connectivity/source/drivers/ado/AUser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AUser.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,6 +80,12 @@ #ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_ #include "ado/AConnection.hxx" #endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif +#ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ +#include "ado/Awrapado.hxx" +#endif using namespace connectivity::ado; using namespace com::sun::star::uno; @@ -88,7 +94,9 @@ using namespace com::sun::star::beans; using namespace com::sun::star::sdbc; // ------------------------------------------------------------------------- -OAdoUser::OAdoUser(sal_Bool _bCase, ADOUser* _pUser) : OUser_TYPEDEF(_bCase) +OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser) + : OUser_TYPEDEF(_bCase) + ,m_pCatalog(_pParent) { construct(); @@ -99,7 +107,9 @@ OAdoUser::OAdoUser(sal_Bool _bCase, ADOUser* _pUser) : OUser_TYPEDEF(_bCase) refreshGroups(); } // ------------------------------------------------------------------------- -OAdoUser::OAdoUser(sal_Bool _bCase, const ::rtl::OUString& _Name) : OUser_TYPEDEF(_Name,_bCase) +OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) + : OUser_TYPEDEF(_Name,_bCase) + , m_pCatalog(_pParent) { construct(); m_aUser.Create(); @@ -134,7 +144,7 @@ void OAdoUser::refreshGroups() if(m_pGroups) m_pGroups->reFill(aVector); else - m_pGroups = new OGroups(*this,m_aMutex,aVector,pGroups,isCaseSensitive()); + m_pGroups = new OGroups(m_pCatalog,m_aMutex,aVector,pGroups,isCaseSensitive()); } //-------------------------------------------------------------------------- Sequence< sal_Int8 > OAdoUser::getUnoTunnelImplementationId() @@ -194,11 +204,13 @@ void OAdoUser::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const } } // ------------------------------------------------------------------------- -OUserExtend::OUserExtend(sal_Bool _bCase, ADOUser* _pUser) : OAdoUser(_bCase,_pUser) +OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser) + : OAdoUser(_pParent,_bCase,_pUser) { } // ------------------------------------------------------------------------- -OUserExtend::OUserExtend(sal_Bool _bCase, const ::rtl::OUString& _Name) : OAdoUser(_bCase,_Name) +OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) + : OAdoUser(_pParent,_bCase,_Name) { } @@ -221,16 +233,64 @@ cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper() } // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- -void SAL_CALL OAdoUser::acquire() throw(::com::sun::star::uno::RuntimeException) +void SAL_CALL OAdoUser::acquire() throw(RuntimeException) { OUser_TYPEDEF::acquire(); } // ----------------------------------------------------------------------------- -void SAL_CALL OAdoUser::release() throw(::com::sun::star::uno::RuntimeException) +void SAL_CALL OAdoUser::release() throw(RuntimeException) { OUser_TYPEDEF::release(); } // ----------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + + return ADOS::mapAdoRights2Sdbc(m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType))); +} +// ------------------------------------------------------------------------- +sal_Int32 SAL_CALL OAdoUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + + sal_Int32 nRights = 0; + RightsEnum eRights = m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType)); + if((eRights & adRightWithGrant) == adRightWithGrant) + nRights = ADOS::mapAdoRights2Sdbc(eRights); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); + return nRights; +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessGrant,RightsEnum(ADOS::mapRights2Ado(objPrivileges))); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ------------------------------------------------------------------------- +void SAL_CALL OAdoUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessRevoke,RightsEnum(ADOS::mapRights2Ado(objPrivileges))); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ----------------------------------------------------------------------------- +// XUser +void SAL_CALL OAdoUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException) +{ + ::osl::MutexGuard aGuard(m_aMutex); + checkDisposed(OUser_TYPEDEF::rBHelper.bDisposed); + m_aUser.ChangePassword(objPassword,newPassword); + ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this); +} +// ----------------------------------------------------------------------------- + + diff --git a/connectivity/source/drivers/ado/AUsers.cxx b/connectivity/source/drivers/ado/AUsers.cxx index c717b2387f7b..484550afd3f0 100644 --- a/connectivity/source/drivers/ado/AUsers.cxx +++ b/connectivity/source/drivers/ado/AUsers.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AUsers.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-04-12 12:33:30 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,8 +90,8 @@ typedef connectivity::sdbcx::OCollection OCollection_TYPE; Reference< XNamed > OUsers::createObject(const ::rtl::OUString& _rName) { - OAdoUser* pRet = new OAdoUser(isCaseSensitive(),_rName); - Reference< XNamed > xRet = pRet; + OAdoUser* pRet = new OAdoUser(m_pCatalog,isCaseSensitive(),_rName); + Reference< XNamed > xRet = pRet; return xRet; } // ------------------------------------------------------------------------- @@ -102,7 +102,7 @@ void OUsers::impl_refresh() throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > OUsers::createEmptyObject() { - OUserExtend* pNew = new OUserExtend(isCaseSensitive()); + OUserExtend* pNew = new OUserExtend(m_pCatalog,isCaseSensitive()); return pNew; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx index c6169c10d214..d6171cd87526 100644 --- a/connectivity/source/drivers/ado/adoimp.cxx +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: adoimp.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-29 06:31:06 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:16:56 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,13 @@ * ************************************************************************/ +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGE_HPP_ +#include <com/sun/star/sdbcx/Privilege.hpp> +#endif +#ifndef _COM_SUN_STAR_SDBCX_PRIVILEGEOBJECT_HPP_ +#include <com/sun/star/sdbcx/PrivilegeObject.hpp> +#endif + #ifndef _CONNECTIVITY_ADO_AWRAPADO_HXX_ #include "ado/Awrapado.hxx" #endif @@ -74,9 +81,11 @@ #include <com/sun/star/sdbc/DataType.hpp> #endif + using namespace connectivity::ado; using namespace com::sun::star::uno; using namespace com::sun::star::sdbc; +using namespace com::sun::star::sdbcx; #define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4}; @@ -256,6 +265,89 @@ sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType) } return bRet; } +// ----------------------------------------------------------------------------- +ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType) +{ + ObjectTypeEnum eType = adPermObjTable; + switch(objType) + { + case PrivilegeObject::TABLE: + eType = adPermObjTable; + break; + case PrivilegeObject::VIEW: + eType = adPermObjView; + break; + case PrivilegeObject::COLUMN: + eType = adPermObjColumn; + break; + } + return eType; +} +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType) +{ + sal_Int32 nType = PrivilegeObject::TABLE; + switch(objType) + { + case adPermObjTable: + nType = PrivilegeObject::TABLE; + break; + case adPermObjView: + nType = PrivilegeObject::VIEW; + break; + case adPermObjColumn: + nType = PrivilegeObject::COLUMN; + break; + } + return nType; +} +#ifdef DELETE +#undef DELETE +#endif +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights) +{ + sal_Int32 nRights = 0; + if((eRights & adRightInsert) == adRightInsert) + nRights |= Privilege::INSERT; + if((eRights & adRightDelete) == adRightDelete) + nRights |= ::com::sun::star::sdbcx::Privilege::DELETE; + if((eRights & adRightUpdate) == adRightUpdate) + nRights |= Privilege::UPDATE; + if((eRights & adRightWriteDesign) == adRightWriteDesign) + nRights |= Privilege::ALTER; + if((eRights & adRightRead) == adRightRead) + nRights |= Privilege::SELECT; + if((eRights & adRightReference) == adRightReference) + nRights |= Privilege::REFERENCE; + if((eRights & adRightDrop) == adRightDrop) + nRights |= Privilege::DROP; + + return nRights; +} +// ----------------------------------------------------------------------------- +sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights) +{ + sal_Int32 eRights = adRightNone; + + if((nRights & Privilege::INSERT) == Privilege::INSERT) + eRights |= adRightInsert; + if((nRights & Privilege::DELETE) == Privilege::DELETE) + eRights |= adRightDelete; + if((nRights & Privilege::UPDATE) == Privilege::UPDATE) + eRights |= adRightUpdate; + if((nRights & Privilege::ALTER) == Privilege::ALTER) + eRights |= adRightWriteDesign; + if((nRights & Privilege::SELECT) == Privilege::SELECT) + eRights |= adRightRead; + if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE) + eRights |= adRightReference; + if((nRights & Privilege::DROP) == Privilege::DROP) + eRights |= adRightDrop; + + return eRights; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/inc/adabas/BUser.hxx b/connectivity/source/inc/adabas/BUser.hxx index 51fc4b6e50d8..1d98392c1dba 100644 --- a/connectivity/source/inc/adabas/BUser.hxx +++ b/connectivity/source/inc/adabas/BUser.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BUser.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2000-11-03 13:40:10 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:13:17 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,8 @@ namespace connectivity class OAdabasUser : public OUser_TYPEDEF { OAdabasConnection* m_pConnection; + + ::rtl::OUString getPrivilegeString(sal_Int32 nRights) const; public: virtual void refreshGroups(); public: @@ -84,6 +86,13 @@ namespace connectivity // XInterface virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); + // XUser + virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XAuthorizable + virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); }; class OUserExtend; diff --git a/connectivity/source/inc/ado/AGroup.hxx b/connectivity/source/inc/ado/AGroup.hxx index 417ef14cf2b1..389897640440 100644 --- a/connectivity/source/inc/ado/AGroup.hxx +++ b/connectivity/source/inc/ado/AGroup.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroup.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:09:04 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:14:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,10 +74,12 @@ namespace connectivity namespace ado { typedef sdbcx::OGroup OGroup_ADO; + class OCatalog; class OAdoGroup : public OGroup_ADO { WpADOGroup m_aGroup; + OCatalog* m_pCatalog; sal_Int32 MapRight(RightsEnum _eNum); RightsEnum Map2Right(sal_Int32 _eNum); @@ -89,8 +91,8 @@ namespace connectivity public: virtual void refreshUsers(); public: - OAdoGroup(sal_Bool _bCase, ADOGroup* _pGroup=NULL); - OAdoGroup(sal_Bool _bCase, const ::rtl::OUString& _Name); + OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup=NULL); + OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name); virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); diff --git a/connectivity/source/inc/ado/AGroups.hxx b/connectivity/source/inc/ado/AGroups.hxx index c4d61339b5f5..b7c0b0b833e0 100644 --- a/connectivity/source/inc/ado/AGroups.hxx +++ b/connectivity/source/inc/ado/AGroups.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroups.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-02 12:52:32 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:14:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,9 @@ #ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ #include "ado/Awrapadox.hxx" #endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif namespace connectivity { @@ -81,17 +84,19 @@ namespace connectivity class OGroups : public sdbcx::OCollection { ADOGroups* m_pCollection; + OCatalog* m_pCatalog; protected: virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); public: - OGroups(::cppu::OWeakObject& _rParent, + OGroups(OCatalog* _pParent, ::osl::Mutex& _rMutex, const TStringVector &_rVector, - ADOGroups* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ADOGroups* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector) ,m_pCollection(_pCollection) + ,m_pCatalog(_pParent) { if(m_pCollection) m_pCollection->AddRef(); diff --git a/connectivity/source/inc/ado/AUser.hxx b/connectivity/source/inc/ado/AUser.hxx index 356d13bcabd9..541ec02c7134 100644 --- a/connectivity/source/inc/ado/AUser.hxx +++ b/connectivity/source/inc/ado/AUser.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AUser.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:09:04 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:14:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,12 +73,14 @@ namespace connectivity { namespace ado { + class OCatalog; typedef connectivity::sdbcx::OUser OUser_TYPEDEF; class OAdoUser : public OUser_TYPEDEF { protected: - WpADOUser m_aUser; + WpADOUser m_aUser; + OCatalog* m_pCatalog; virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, @@ -92,8 +94,8 @@ namespace connectivity public: virtual void refreshGroups(); public: - OAdoUser(sal_Bool _bCase, ADOUser* _pUser=NULL); - OAdoUser(sal_Bool _bCase, const ::rtl::OUString& _Name); + OAdoUser(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser=NULL); + OAdoUser(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name); // com::sun::star::lang::XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); @@ -101,6 +103,14 @@ namespace connectivity virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); + // XUser + virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XAuthorizable + virtual sal_Int32 SAL_CALL getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + WpADOUser getImpl() const { return m_aUser;} }; @@ -117,8 +127,8 @@ namespace connectivity // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); public: - OUserExtend(sal_Bool _bCase,ADOUser* _pUser=NULL); - OUserExtend(sal_Bool _bCase,const ::rtl::OUString& _Name); + OUserExtend(OCatalog* _pParent,sal_Bool _bCase,ADOUser* _pUser=NULL); + OUserExtend(OCatalog* _pParent,sal_Bool _bCase,const ::rtl::OUString& _Name); virtual void construct(); ::rtl::OUString getPassword() const { return m_Password;} diff --git a/connectivity/source/inc/ado/AUsers.hxx b/connectivity/source/inc/ado/AUsers.hxx index 28571d9691a5..239b788ef8be 100644 --- a/connectivity/source/inc/ado/AUsers.hxx +++ b/connectivity/source/inc/ado/AUsers.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AUsers.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-02 12:52:32 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:14:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -68,6 +68,9 @@ #ifndef _CONNECTIVITY_ADO_AWRAPADOX_HXX_ #include "ado/Awrapadox.hxx" #endif +#ifndef _CONNECTIVITY_ADO_CATALOG_HXX_ +#include "ado/ACatalog.hxx" +#endif namespace connectivity { @@ -81,16 +84,18 @@ namespace connectivity class OUsers : public sdbcx::OCollection { ADOUsers* m_pCollection; + OCatalog* m_pCatalog; public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); public: - OUsers( ::cppu::OWeakObject& _rParent, + OUsers( OCatalog* _pParent, ::osl::Mutex& _rMutex, const TStringVector &_rVector, - ADOUsers* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) + ADOUsers* _pCollection,sal_Bool _bCase) : sdbcx::OCollection(*_pParent,_bCase,_rMutex,_rVector) ,m_pCollection(_pCollection) + ,m_pCatalog(_pParent) { if(m_pCollection) m_pCollection->AddRef(); diff --git a/connectivity/source/inc/ado/adoimp.hxx b/connectivity/source/inc/ado/adoimp.hxx index e02d3a47e3d0..6c940bcab856 100644 --- a/connectivity/source/inc/ado/adoimp.hxx +++ b/connectivity/source/inc/ado/adoimp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: adoimp.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ + * last change: $Author: oj $ $Date: 2001-06-20 07:14:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,10 @@ #include <com/sun/star/sdbc/SQLException.hpp> #endif +#ifndef _ADOCTINT_H_ +#include <ado/ADOCTINT.H> +#endif + struct ADOConnection; enum DataTypeEnum; namespace connectivity @@ -118,6 +122,11 @@ namespace connectivity static sal_Int32 MapADOType2Jdbc(DataTypeEnum eType); static DataTypeEnum MapJdbc2ADOType(sal_Int32 _nType); static sal_Bool isJetEngine(sal_Int32 _nEngineType); + + static ObjectTypeEnum mapObjectType2Ado(sal_Int32 objType); + static sal_Int32 mapAdoType2Object(ObjectTypeEnum objType); + static sal_Int32 mapAdoRights2Sdbc(RightsEnum eRights); + static sal_Int32 mapRights2Ado(sal_Int32 nRights); }; |