1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VUser.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
35 #include "connectivity/sdbcx/VUser.hxx"
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <com/sun/star/sdbcx/Privilege.hpp>
38 #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
39 #include "TConnection.hxx"
40 #include "connectivity/sdbcx/VCollection.hxx"
41 #include <connectivity/dbexception.hxx>
42 #include <comphelper/sequence.hxx>
44 // -------------------------------------------------------------------------
45 using namespace connectivity
;
46 using namespace connectivity::sdbcx
;
47 using namespace ::com::sun::star::sdbc
;
48 using namespace ::com::sun::star::beans
;
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::container
;
51 using namespace ::com::sun::star::lang
;
53 IMPLEMENT_SERVICE_INFO(OUser
,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
54 // -------------------------------------------------------------------------
55 OUser::OUser(sal_Bool _bCase
) : OUser_BASE(m_aMutex
)
56 , ODescriptor(OUser_BASE::rBHelper
,_bCase
,sal_True
)
60 // -------------------------------------------------------------------------
61 OUser::OUser(const ::rtl::OUString
& _Name
,sal_Bool _bCase
) : OUser_BASE(m_aMutex
)
62 ,ODescriptor(OUser_BASE::rBHelper
,_bCase
)
67 // -------------------------------------------------------------------------
72 // -------------------------------------------------------------------------
73 void OUser::disposing(void)
75 OPropertySetHelper::disposing();
76 ::osl::MutexGuard
aGuard(m_aMutex
);
78 m_pGroups
->disposing();
80 // -------------------------------------------------------------------------
81 Any SAL_CALL
OUser::queryInterface( const Type
& rType
) throw(RuntimeException
)
83 Any aRet
= ODescriptor::queryInterface( rType
);
84 return aRet
.hasValue() ? aRet
: OUser_BASE::queryInterface( rType
);
86 // -------------------------------------------------------------------------
87 Sequence
< Type
> SAL_CALL
OUser::getTypes( ) throw(RuntimeException
)
89 return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
91 // -------------------------------------------------------------------------
92 ::cppu::IPropertyArrayHelper
* OUser::createArrayHelper( ) const
94 Sequence
< Property
> aProps
;
95 describeProperties(aProps
);
96 return new ::cppu::OPropertyArrayHelper(aProps
);
99 // -------------------------------------------------------------------------
100 ::cppu::IPropertyArrayHelper
& OUser::getInfoHelper()
102 return *const_cast<OUser
*>(this)->getArrayHelper();
104 // -------------------------------------------------------------------------
106 void SAL_CALL
OUser::changePassword( const ::rtl::OUString
& /*objPassword*/, const ::rtl::OUString
& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException
, RuntimeException
)
108 ::osl::MutexGuard
aGuard(m_aMutex
);
109 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
110 ::dbtools::throwFeatureNotImplementedException( "XUser::changePassword", *this );
112 // -------------------------------------------------------------------------
114 Reference
< XNameAccess
> SAL_CALL
OUser::getGroups( ) throw(RuntimeException
)
116 ::osl::MutexGuard
aGuard(m_aMutex
);
117 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
124 catch( const RuntimeException
& )
126 // allowed to leave this method
129 catch( const Exception
& )
134 return const_cast<OUser
*>(this)->m_pGroups
;
136 // -------------------------------------------------------------------------
137 // -------------------------------------------------------------------------
139 sal_Int32 SAL_CALL
OUser::getPrivileges( const ::rtl::OUString
& /*objName*/, sal_Int32
/*objType*/ ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
141 ::osl::MutexGuard
aGuard(m_aMutex
);
142 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
143 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::changePassword", *this );
146 // -------------------------------------------------------------------------
147 sal_Int32 SAL_CALL
OUser::getGrantablePrivileges( const ::rtl::OUString
& /*objName*/, sal_Int32
/*objType*/ ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
149 ::osl::MutexGuard
aGuard(m_aMutex
);
150 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
151 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::getGrantablePrivileges", *this );
154 // -------------------------------------------------------------------------
155 void SAL_CALL
OUser::grantPrivileges( const ::rtl::OUString
& /*objName*/, sal_Int32
/*objType*/, sal_Int32
/*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
157 ::osl::MutexGuard
aGuard(m_aMutex
);
158 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
159 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::grantPrivileges", *this );
161 // -------------------------------------------------------------------------
162 void SAL_CALL
OUser::revokePrivileges( const ::rtl::OUString
& /*objName*/, sal_Int32
/*objType*/, sal_Int32
/*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
164 ::osl::MutexGuard
aGuard(m_aMutex
);
165 checkDisposed(OUser_BASE::rBHelper
.bDisposed
);
166 ::dbtools::throwFeatureNotImplementedException( "XAuthorizable::revokePrivileges", *this );
168 // -----------------------------------------------------------------------------
169 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
171 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
173 // -----------------------------------------------------------------------------
174 ::rtl::OUString SAL_CALL
OUser::getName( ) throw(::com::sun::star::uno::RuntimeException
)
178 // -----------------------------------------------------------------------------
179 void SAL_CALL
OUser::setName( const ::rtl::OUString
& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException
)
181 OSL_ENSURE( false, "OUser::setName: not implemented!" );
182 // not allowed to throw an SQLException here ...
184 // -----------------------------------------------------------------------------
186 void SAL_CALL
OUser::acquire() throw()
188 OUser_BASE::acquire();
190 // -----------------------------------------------------------------------------
191 void SAL_CALL
OUser::release() throw()
193 OUser_BASE::release();
195 // -----------------------------------------------------------------------------