LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_xuser.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 62 0.0 %
Date: 2014-11-03 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  Effective License of whole file:
       5             :  *
       6             :  *    This library is free software; you can redistribute it and/or
       7             :  *    modify it under the terms of the GNU Lesser General Public
       8             :  *    License version 2.1, as published by the Free Software Foundation.
       9             :  *
      10             :  *    This library is distributed in the hope that it will be useful,
      11             :  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :  *    Lesser General Public License for more details.
      14             :  *
      15             :  *    You should have received a copy of the GNU Lesser General Public
      16             :  *    License along with this library; if not, write to the Free Software
      17             :  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      18             :  *    MA  02111-1307  USA
      19             :  *
      20             :  *  Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
      21             :  *
      22             :  *    The Contents of this file are made available subject to the terms of
      23             :  *    the GNU Lesser General Public License Version 2.1
      24             :  *
      25             :  *    Copyright: 2000 by Sun Microsystems, Inc.
      26             :  *
      27             :  *    Contributor(s): Joerg Budischewski
      28             :  *
      29             :  *  All parts contributed on or after August 2011:
      30             :  *
      31             :  *    This Source Code Form is subject to the terms of the Mozilla Public
      32             :  *    License, v. 2.0. If a copy of the MPL was not distributed with this
      33             :  *    file, You can obtain one at http://mozilla.org/MPL/2.0/.
      34             :  *
      35             :  ************************************************************************/
      36             : 
      37             : #include <rtl/ustrbuf.hxx>
      38             : 
      39             : #include <cppuhelper/typeprovider.hxx>
      40             : #include <cppuhelper/queryinterface.hxx>
      41             : 
      42             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      43             : 
      44             : #include <com/sun/star/sdbc/XRow.hpp>
      45             : #include <com/sun/star/sdbc/XParameters.hpp>
      46             : 
      47             : #include "pq_xuser.hxx"
      48             : #include "pq_tools.hxx"
      49             : #include "pq_statics.hxx"
      50             : 
      51             : using osl::MutexGuard;
      52             : using osl::Mutex;
      53             : 
      54             : using com::sun::star::container::XNameAccess;
      55             : using com::sun::star::container::XIndexAccess;
      56             : using com::sun::star::container::ElementExistException;
      57             : using com::sun::star::container::NoSuchElementException;
      58             : 
      59             : using com::sun::star::uno::Reference;
      60             : using com::sun::star::uno::Exception;
      61             : using com::sun::star::uno::UNO_QUERY;
      62             : using com::sun::star::uno::XInterface;
      63             : using com::sun::star::uno::Sequence;
      64             : using com::sun::star::uno::Any;
      65             : using com::sun::star::uno::makeAny;
      66             : using com::sun::star::uno::Type;
      67             : using com::sun::star::uno::RuntimeException;
      68             : 
      69             : using com::sun::star::lang::IllegalArgumentException;
      70             : using com::sun::star::lang::IndexOutOfBoundsException;
      71             : 
      72             : using com::sun::star::beans::XPropertySetInfo;
      73             : using com::sun::star::beans::XFastPropertySet;
      74             : using com::sun::star::beans::XMultiPropertySet;
      75             : using com::sun::star::beans::XPropertySet;
      76             : using com::sun::star::beans::Property;
      77             : 
      78             : using com::sun::star::sdbc::XResultSet;
      79             : using com::sun::star::sdbc::XPreparedStatement;
      80             : using com::sun::star::sdbc::XStatement;
      81             : using com::sun::star::sdbc::XParameters;
      82             : using com::sun::star::sdbc::XRow;
      83             : using com::sun::star::sdbc::SQLException;
      84             : 
      85             : namespace pq_sdbc_driver
      86             : {
      87             : 
      88           0 : User::User( const ::rtl::Reference< RefCountedMutex > & refMutex,
      89             :             const Reference< com::sun::star::sdbc::XConnection > & connection,
      90             :             ConnectionSettings *pSettings )
      91             :     : ReflectionBase(
      92           0 :         getStatics().refl.user.implName,
      93           0 :         getStatics().refl.user.serviceNames,
      94             :         refMutex,
      95             :         connection,
      96             :         pSettings,
      97           0 :         * getStatics().refl.user.pProps )
      98           0 : {}
      99             : 
     100           0 : Reference< XPropertySet > User::createDataDescriptor(  ) throw (RuntimeException, std::exception)
     101             : {
     102           0 :     UserDescriptor * pUser = new UserDescriptor( m_refMutex, m_conn, m_pSettings );
     103           0 :     pUser->copyValuesFrom( this );
     104             : 
     105           0 :     return Reference< XPropertySet > ( pUser );
     106             : }
     107             : 
     108             : 
     109           0 : Sequence<Type > User::getTypes() throw( RuntimeException, std::exception )
     110             : {
     111             :     static cppu::OTypeCollection *pCollection;
     112           0 :     if( ! pCollection )
     113             :     {
     114           0 :         MutexGuard guard( osl::Mutex::getGlobalMutex() );
     115           0 :         if( !pCollection )
     116             :         {
     117             :             static cppu::OTypeCollection collection(
     118           0 :                 cppu::UnoType<com::sun::star::sdbcx::XUser>::get(),
     119           0 :                 ReflectionBase::getTypes());
     120           0 :             pCollection = &collection;
     121           0 :         }
     122             :     }
     123           0 :     return pCollection->getTypes();
     124             : }
     125             : 
     126           0 : Sequence< sal_Int8> User::getImplementationId() throw( RuntimeException, std::exception )
     127             : {
     128           0 :     return css::uno::Sequence<sal_Int8>();
     129             : }
     130             : 
     131           0 : Any User::queryInterface( const Type & reqType ) throw (RuntimeException, std::exception)
     132             : {
     133           0 :     Any ret;
     134             : 
     135           0 :     ret = ReflectionBase::queryInterface( reqType );
     136           0 :     if( ! ret.hasValue() )
     137           0 :         ret = ::cppu::queryInterface(
     138             :             reqType,
     139           0 :             static_cast< com::sun::star::sdbcx::XUser * > ( this ) );
     140           0 :     return ret;
     141             : }
     142             : 
     143             : 
     144           0 : void User::changePassword(
     145             :     const OUString& oldPassword, const OUString& newPassword )
     146             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     147             : {
     148             :     (void) oldPassword;
     149           0 :     OUStringBuffer buf(128);
     150           0 :     buf.append( "ALTER USER " );
     151           0 :     bufferQuoteIdentifier( buf, extractStringProperty( this, getStatics().NAME ), m_pSettings );
     152           0 :     buf.append( " PASSWORD " );
     153           0 :     bufferQuoteConstant( buf, newPassword, m_pSettings );
     154           0 :     Reference< XStatement > stmt = m_conn->createStatement();
     155           0 :     DisposeGuard guard( stmt );
     156           0 :     stmt->executeUpdate( buf.makeStringAndClear() );
     157           0 : }
     158             : 
     159           0 : sal_Int32 User::getPrivileges( const OUString& objName, sal_Int32 objType )
     160             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     161             : {
     162           0 :     sal_Int32 ret = 0xffffffff;
     163           0 :     if( isLog( m_pSettings, LogLevel::INFO ) )
     164             :     {
     165           0 :         Statics & st = getStatics();
     166             : 
     167           0 :         OUStringBuffer buf( 128 );
     168           0 :         buf.append( "User::getPrivileges[" + extractStringProperty( this, st.NAME ) +
     169           0 :                     "] got called for " + objName + "(type=" +
     170           0 :                     OUString::number(objType) + ")");
     171           0 :         log( m_pSettings, LogLevel::INFO, buf.makeStringAndClear() );
     172             :     }
     173             :     // all privileges
     174           0 :     return ret;
     175             : }
     176             : 
     177           0 : sal_Int32 User::getGrantablePrivileges( const OUString& objName, sal_Int32 objType )
     178             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     179             : {
     180             :     (void) objName; (void) objType;
     181             :     // all privileges
     182           0 :     return 0xffffffff;
     183             : }
     184             : 
     185           0 : void User::grantPrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
     186             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     187             : {
     188             :     (void) objName; (void) objType; (void) objPrivileges;
     189             :     throw com::sun::star::sdbc::SQLException("pq_driver: privilege change not implemented yet",
     190           0 :                                              *this, OUString(), 1, Any() );
     191             : }
     192             : 
     193           0 : void User::revokePrivileges( const OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges )
     194             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
     195             : {
     196             :     (void) objName; (void) objType; (void) objPrivileges;
     197             :     throw com::sun::star::sdbc::SQLException("pq_driver: privilege change not implemented yet",
     198           0 :                                              *this, OUString(), 1, Any() );
     199             : }
     200             : 
     201             : 
     202           0 : UserDescriptor::UserDescriptor(
     203             :     const ::rtl::Reference< RefCountedMutex > & refMutex,
     204             :     const Reference< com::sun::star::sdbc::XConnection > & connection,
     205             :     ConnectionSettings *pSettings )
     206             :     : ReflectionBase(
     207           0 :         getStatics().refl.userDescriptor.implName,
     208           0 :         getStatics().refl.userDescriptor.serviceNames,
     209             :         refMutex,
     210             :         connection,
     211             :         pSettings,
     212           0 :         * getStatics().refl.userDescriptor.pProps )
     213           0 : {}
     214             : 
     215           0 : Reference< XPropertySet > UserDescriptor::createDataDescriptor(  ) throw (RuntimeException, std::exception)
     216             : {
     217           0 :     UserDescriptor * pUser = new UserDescriptor( m_refMutex, m_conn, m_pSettings );
     218           0 :     pUser->copyValuesFrom( this );
     219             : 
     220           0 :     return Reference< XPropertySet > ( pUser );
     221             : }
     222             : 
     223             : 
     224             : }
     225             : 
     226             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10