Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <connectivity/sdbcx/VUser.hxx>
22 : #include <com/sun/star/lang/DisposedException.hpp>
23 : #include <com/sun/star/sdbcx/Privilege.hpp>
24 : #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
25 : #include "TConnection.hxx"
26 : #include <connectivity/sdbcx/VCollection.hxx>
27 : #include <connectivity/dbexception.hxx>
28 : #include <comphelper/sequence.hxx>
29 :
30 :
31 : using namespace connectivity;
32 : using namespace connectivity::sdbcx;
33 : using namespace ::com::sun::star::sdbc;
34 : using namespace ::com::sun::star::beans;
35 : using namespace ::com::sun::star::uno;
36 : using namespace ::com::sun::star::container;
37 : using namespace ::com::sun::star::lang;
38 :
39 0 : IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
40 :
41 0 : OUser::OUser(bool _bCase) : OUser_BASE(m_aMutex)
42 : , ODescriptor(OUser_BASE::rBHelper,_bCase,true)
43 0 : , m_pGroups(NULL)
44 : {
45 0 : }
46 :
47 0 : OUser::OUser(const OUString& _Name, bool _bCase) : OUser_BASE(m_aMutex)
48 : ,ODescriptor(OUser_BASE::rBHelper,_bCase)
49 0 : ,m_pGroups(NULL)
50 : {
51 0 : m_Name = _Name;
52 0 : }
53 :
54 0 : OUser::~OUser( )
55 : {
56 0 : delete m_pGroups;
57 0 : }
58 :
59 0 : void OUser::disposing()
60 : {
61 0 : OPropertySetHelper::disposing();
62 0 : ::osl::MutexGuard aGuard(m_aMutex);
63 0 : if(m_pGroups)
64 0 : m_pGroups->disposing();
65 0 : }
66 :
67 0 : Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
68 : {
69 0 : Any aRet = ODescriptor::queryInterface( rType);
70 0 : return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
71 : }
72 :
73 0 : Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException, std::exception)
74 : {
75 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
76 : }
77 :
78 0 : ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
79 : {
80 0 : Sequence< Property > aProps;
81 0 : describeProperties(aProps);
82 0 : return new ::cppu::OPropertyArrayHelper(aProps);
83 :
84 : }
85 :
86 0 : ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
87 : {
88 0 : return *getArrayHelper();
89 : }
90 :
91 : // XUser
92 0 : void SAL_CALL OUser::changePassword( const OUString& /*objPassword*/, const OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
93 : {
94 0 : ::osl::MutexGuard aGuard(m_aMutex);
95 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
96 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XUser::changePassword", *this );
97 0 : }
98 :
99 : // XGroupsSupplier
100 0 : Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException, std::exception)
101 : {
102 0 : ::osl::MutexGuard aGuard(m_aMutex);
103 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
104 :
105 : try
106 : {
107 0 : if ( !m_pGroups )
108 0 : refreshGroups();
109 : }
110 0 : catch( const RuntimeException& )
111 : {
112 : // allowed to leave this method
113 0 : throw;
114 : }
115 0 : catch( const Exception& )
116 : {
117 : // allowed
118 : }
119 :
120 0 : return m_pGroups;
121 : }
122 :
123 :
124 : SAL_WNOUNREACHABLE_CODE_PUSH
125 :
126 0 : sal_Int32 SAL_CALL OUser::getPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
127 : {
128 0 : ::osl::MutexGuard aGuard(m_aMutex);
129 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
130 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::changePassword", *this );
131 0 : return 0;
132 : }
133 :
134 0 : sal_Int32 SAL_CALL OUser::getGrantablePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
135 : {
136 0 : ::osl::MutexGuard aGuard(m_aMutex);
137 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
138 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::getGrantablePrivileges", *this );
139 0 : return 0;
140 : }
141 :
142 : SAL_WNOUNREACHABLE_CODE_POP
143 :
144 :
145 0 : void SAL_CALL OUser::grantPrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
146 : {
147 0 : ::osl::MutexGuard aGuard(m_aMutex);
148 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
149 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::grantPrivileges", *this );
150 0 : }
151 :
152 0 : void SAL_CALL OUser::revokePrivileges( const OUString& /*objName*/, sal_Int32 /*objType*/, sal_Int32 /*objPrivileges*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
153 : {
154 0 : ::osl::MutexGuard aGuard(m_aMutex);
155 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
156 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::revokePrivileges", *this );
157 0 : }
158 :
159 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
160 : {
161 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
162 : }
163 :
164 0 : OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
165 : {
166 0 : return m_Name;
167 : }
168 :
169 0 : void SAL_CALL OUser::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
170 : {
171 : OSL_FAIL( "OUser::setName: not implemented!" );
172 : // not allowed to throw an SQLException here ...
173 0 : }
174 :
175 : // XInterface
176 0 : void SAL_CALL OUser::acquire() throw()
177 : {
178 0 : OUser_BASE::acquire();
179 0 : }
180 :
181 0 : void SAL_CALL OUser::release() throw()
182 : {
183 0 : OUser_BASE::release();
184 0 : }
185 :
186 :
187 :
188 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|