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 <stdio.h>
22 : #include <connectivity/sdbcx/VUser.hxx>
23 : #include <com/sun/star/lang/DisposedException.hpp>
24 : #include <com/sun/star/sdbcx/Privilege.hpp>
25 : #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
26 : #include "TConnection.hxx"
27 : #include <connectivity/sdbcx/VCollection.hxx>
28 : #include <connectivity/dbexception.hxx>
29 : #include <comphelper/sequence.hxx>
30 :
31 :
32 : using namespace connectivity;
33 : using namespace connectivity::sdbcx;
34 : using namespace ::com::sun::star::sdbc;
35 : using namespace ::com::sun::star::beans;
36 : using namespace ::com::sun::star::uno;
37 : using namespace ::com::sun::star::container;
38 : using namespace ::com::sun::star::lang;
39 :
40 0 : IMPLEMENT_SERVICE_INFO(OUser,"com.sun.star.sdbcx.VUser","com.sun.star.sdbcx.User");
41 :
42 0 : OUser::OUser(bool _bCase) : OUser_BASE(m_aMutex)
43 : , ODescriptor(OUser_BASE::rBHelper,_bCase,true)
44 0 : , m_pGroups(NULL)
45 : {
46 0 : }
47 :
48 0 : OUser::OUser(const OUString& _Name, bool _bCase) : OUser_BASE(m_aMutex)
49 : ,ODescriptor(OUser_BASE::rBHelper,_bCase)
50 0 : ,m_pGroups(NULL)
51 : {
52 0 : m_Name = _Name;
53 0 : }
54 :
55 0 : OUser::~OUser( )
56 : {
57 0 : delete m_pGroups;
58 0 : }
59 :
60 0 : void OUser::disposing(void)
61 : {
62 0 : OPropertySetHelper::disposing();
63 0 : ::osl::MutexGuard aGuard(m_aMutex);
64 0 : if(m_pGroups)
65 0 : m_pGroups->disposing();
66 0 : }
67 :
68 0 : Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
69 : {
70 0 : Any aRet = ODescriptor::queryInterface( rType);
71 0 : return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType);
72 : }
73 :
74 0 : Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException, std::exception)
75 : {
76 0 : return ::comphelper::concatSequences(ODescriptor::getTypes(),OUser_BASE::getTypes());
77 : }
78 :
79 0 : ::cppu::IPropertyArrayHelper* OUser::createArrayHelper( ) const
80 : {
81 0 : Sequence< Property > aProps;
82 0 : describeProperties(aProps);
83 0 : return new ::cppu::OPropertyArrayHelper(aProps);
84 :
85 : }
86 :
87 0 : ::cppu::IPropertyArrayHelper & OUser::getInfoHelper()
88 : {
89 0 : return *const_cast<OUser*>(this)->getArrayHelper();
90 : }
91 :
92 : // XUser
93 0 : void SAL_CALL OUser::changePassword( const OUString& /*objPassword*/, const OUString& /*newPassword*/ ) throw(::com::sun::star::sdbc::SQLException, RuntimeException, std::exception)
94 : {
95 0 : ::osl::MutexGuard aGuard(m_aMutex);
96 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
97 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XUser::changePassword", *this );
98 0 : }
99 :
100 : // XGroupsSupplier
101 0 : Reference< XNameAccess > SAL_CALL OUser::getGroups( ) throw(RuntimeException, std::exception)
102 : {
103 0 : ::osl::MutexGuard aGuard(m_aMutex);
104 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
105 :
106 : try
107 : {
108 0 : if ( !m_pGroups )
109 0 : refreshGroups();
110 : }
111 0 : catch( const RuntimeException& )
112 : {
113 : // allowed to leave this method
114 0 : throw;
115 : }
116 0 : catch( const Exception& )
117 : {
118 : // allowed
119 : }
120 :
121 0 : return const_cast<OUser*>(this)->m_pGroups;
122 : }
123 :
124 :
125 : SAL_WNOUNREACHABLE_CODE_PUSH
126 :
127 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)
128 : {
129 0 : ::osl::MutexGuard aGuard(m_aMutex);
130 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
131 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::changePassword", *this );
132 0 : return 0;
133 : }
134 :
135 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)
136 : {
137 0 : ::osl::MutexGuard aGuard(m_aMutex);
138 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
139 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::getGrantablePrivileges", *this );
140 0 : return 0;
141 : }
142 :
143 : SAL_WNOUNREACHABLE_CODE_POP
144 :
145 :
146 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)
147 : {
148 0 : ::osl::MutexGuard aGuard(m_aMutex);
149 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
150 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::grantPrivileges", *this );
151 0 : }
152 :
153 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)
154 : {
155 0 : ::osl::MutexGuard aGuard(m_aMutex);
156 0 : checkDisposed(OUser_BASE::rBHelper.bDisposed);
157 0 : ::dbtools::throwFeatureNotImplementedSQLException( "XAuthorizable::revokePrivileges", *this );
158 0 : }
159 :
160 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUser::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
161 : {
162 0 : return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
163 : }
164 :
165 0 : OUString SAL_CALL OUser::getName( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
166 : {
167 0 : return m_Name;
168 : }
169 :
170 0 : void SAL_CALL OUser::setName( const OUString& /*aName*/ ) throw(::com::sun::star::uno::RuntimeException, std::exception)
171 : {
172 : OSL_FAIL( "OUser::setName: not implemented!" );
173 : // not allowed to throw an SQLException here ...
174 0 : }
175 :
176 : // XInterface
177 0 : void SAL_CALL OUser::acquire() throw()
178 : {
179 0 : OUser_BASE::acquire();
180 0 : }
181 :
182 0 : void SAL_CALL OUser::release() throw()
183 : {
184 0 : OUser_BASE::release();
185 0 : }
186 :
187 :
188 :
189 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|