1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * Effective License of whole file:
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.
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.
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,
20 * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
22 * The Contents of this file are made available subject to the terms of
23 * the GNU Lesser General Public License Version 2.1
25 * Copyright: 2000 by Sun Microsystems, Inc.
27 * Contributor(s): Joerg Budischewski
29 * All parts contributed on or after August 2011:
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/.
35 ************************************************************************/
37 #include <sal/log.hxx>
38 #include <rtl/ustrbuf.hxx>
40 #include <cppuhelper/typeprovider.hxx>
41 #include <cppuhelper/queryinterface.hxx>
43 #include <com/sun/star/sdbc/SQLException.hpp>
45 #include "pq_xuser.hxx"
46 #include "pq_tools.hxx"
47 #include "pq_statics.hxx"
49 using com::sun::star::uno::Reference
;
50 using com::sun::star::uno::Sequence
;
51 using com::sun::star::uno::Any
;
52 using com::sun::star::uno::Type
;
54 using com::sun::star::beans::XPropertySet
;
56 using com::sun::star::sdbc::XStatement
;
57 using com::sun::star::sdbc::SQLException
;
59 namespace pq_sdbc_driver
62 User::User( const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
63 const Reference
< css::sdbc::XConnection
> & connection
,
64 ConnectionSettings
*pSettings
)
66 getStatics().refl
.user
.implName
,
67 getStatics().refl
.user
.serviceNames
,
71 * getStatics().refl
.user
.pProps
)
74 Reference
< XPropertySet
> User::createDataDescriptor( )
76 UserDescriptor
* pUser
= new UserDescriptor( m_xMutex
, m_conn
, m_pSettings
);
77 pUser
->copyValuesFrom( this );
79 return Reference
< XPropertySet
> ( pUser
);
83 Sequence
<Type
> User::getTypes()
85 static cppu::OTypeCollection
collection(
86 cppu::UnoType
<css::sdbcx::XUser
>::get(),
87 ReflectionBase::getTypes());
89 return collection
.getTypes();
92 Sequence
< sal_Int8
> User::getImplementationId()
94 return css::uno::Sequence
<sal_Int8
>();
97 Any
User::queryInterface( const Type
& reqType
)
99 Any ret
= ReflectionBase::queryInterface( reqType
);
100 if( ! ret
.hasValue() )
101 ret
= ::cppu::queryInterface(
103 static_cast< css::sdbcx::XUser
* > ( this ) );
108 void User::changePassword(
109 const OUString
&, const OUString
& newPassword
)
111 OUStringBuffer
buf(128);
112 buf
.append( "ALTER USER " );
113 bufferQuoteIdentifier( buf
, extractStringProperty( this, getStatics().NAME
), m_pSettings
);
114 buf
.append( " PASSWORD " );
115 bufferQuoteConstant( buf
, newPassword
, m_pSettings
);
116 Reference
< XStatement
> stmt
= m_conn
->createStatement();
117 DisposeGuard
guard( stmt
);
118 stmt
->executeUpdate( buf
.makeStringAndClear() );
121 sal_Int32
User::getPrivileges( const OUString
& objName
, sal_Int32 objType
)
123 SAL_INFO("connectivity.postgresql", "User::getPrivileges[\"Name\"] got called for " << objName
<< "(type=" << objType
<< ")");
128 sal_Int32
User::getGrantablePrivileges( const OUString
&, sal_Int32
)
134 void User::grantPrivileges( const OUString
&, sal_Int32
, sal_Int32
)
136 throw css::sdbc::SQLException("pq_driver: privilege change not implemented yet",
137 *this, OUString(), 1, Any() );
140 void User::revokePrivileges( const OUString
&, sal_Int32
, sal_Int32
)
142 throw css::sdbc::SQLException("pq_driver: privilege change not implemented yet",
143 *this, OUString(), 1, Any() );
147 UserDescriptor::UserDescriptor(
148 const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
149 const Reference
< css::sdbc::XConnection
> & connection
,
150 ConnectionSettings
*pSettings
)
152 getStatics().refl
.userDescriptor
.implName
,
153 getStatics().refl
.userDescriptor
.serviceNames
,
157 * getStatics().refl
.userDescriptor
.pProps
)
160 Reference
< XPropertySet
> UserDescriptor::createDataDescriptor( )
162 UserDescriptor
* pUser
= new UserDescriptor( m_xMutex
, m_conn
, m_pSettings
);
163 pUser
->copyValuesFrom( this );
165 return Reference
< XPropertySet
> ( pUser
);
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */