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/ref.hxx>
39 #include <rtl/ustrbuf.hxx>
41 #include <cppuhelper/typeprovider.hxx>
42 #include <cppuhelper/queryinterface.hxx>
44 #include <com/sun/star/sdbc/SQLException.hpp>
46 #include "pq_xuser.hxx"
47 #include "pq_tools.hxx"
48 #include "pq_statics.hxx"
50 using com::sun::star::uno::Reference
;
51 using com::sun::star::uno::Sequence
;
52 using com::sun::star::uno::Any
;
53 using com::sun::star::uno::Type
;
55 using com::sun::star::beans::XPropertySet
;
57 using com::sun::star::sdbc::XStatement
;
58 using com::sun::star::sdbc::SQLException
;
60 namespace pq_sdbc_driver
63 User::User( const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
64 const Reference
< css::sdbc::XConnection
> & connection
,
65 ConnectionSettings
*pSettings
)
67 getStatics().refl
.user
.implName
,
68 getStatics().refl
.user
.serviceNames
,
72 * getStatics().refl
.user
.pProps
)
75 Reference
< XPropertySet
> User::createDataDescriptor( )
77 rtl::Reference
<UserDescriptor
> pUser
= new UserDescriptor( m_xMutex
, m_conn
, m_pSettings
);
78 pUser
->copyValuesFrom( this );
80 return Reference
< XPropertySet
> ( pUser
);
84 Sequence
<Type
> User::getTypes()
86 static cppu::OTypeCollection
collection(
87 cppu::UnoType
<css::sdbcx::XUser
>::get(),
88 ReflectionBase::getTypes());
90 return collection
.getTypes();
93 Sequence
< sal_Int8
> User::getImplementationId()
95 return css::uno::Sequence
<sal_Int8
>();
98 Any
User::queryInterface( const Type
& reqType
)
100 Any ret
= ReflectionBase::queryInterface( reqType
);
101 if( ! ret
.hasValue() )
102 ret
= ::cppu::queryInterface(
104 static_cast< css::sdbcx::XUser
* > ( this ) );
109 void User::changePassword(
110 const OUString
&, const OUString
& newPassword
)
112 OUStringBuffer
buf(128);
113 buf
.append( "ALTER USER " );
114 bufferQuoteIdentifier( buf
, extractStringProperty( this, getStatics().NAME
), m_pSettings
);
115 buf
.append( " PASSWORD " );
116 bufferQuoteConstant( buf
, newPassword
, m_pSettings
);
117 Reference
< XStatement
> stmt
= m_conn
->createStatement();
118 DisposeGuard
guard( stmt
);
119 stmt
->executeUpdate( buf
.makeStringAndClear() );
122 sal_Int32
User::getPrivileges( const OUString
& objName
, sal_Int32 objType
)
124 SAL_INFO("connectivity.postgresql", "User::getPrivileges[\"Name\"] got called for " << objName
<< "(type=" << objType
<< ")");
129 sal_Int32
User::getGrantablePrivileges( const OUString
&, sal_Int32
)
135 void User::grantPrivileges( const OUString
&, sal_Int32
, sal_Int32
)
137 throw css::sdbc::SQLException(u
"pq_driver: privilege change not implemented yet"_ustr
,
138 *this, OUString(), 1, Any() );
141 void User::revokePrivileges( const OUString
&, sal_Int32
, sal_Int32
)
143 throw css::sdbc::SQLException(u
"pq_driver: privilege change not implemented yet"_ustr
,
144 *this, OUString(), 1, Any() );
148 UserDescriptor::UserDescriptor(
149 const ::rtl::Reference
< comphelper::RefCountedMutex
> & refMutex
,
150 const Reference
< css::sdbc::XConnection
> & connection
,
151 ConnectionSettings
*pSettings
)
153 getStatics().refl
.userDescriptor
.implName
,
154 getStatics().refl
.userDescriptor
.serviceNames
,
158 * getStatics().refl
.userDescriptor
.pProps
)
161 Reference
< XPropertySet
> UserDescriptor::createDataDescriptor( )
163 rtl::Reference
<UserDescriptor
> pUser
= new UserDescriptor( m_xMutex
, m_conn
, m_pSettings
);
164 pUser
->copyValuesFrom( this );
166 return Reference
< XPropertySet
> ( pUser
);
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */