xref: /trunk/main/sal/inc/osl/security_decl.hxx (revision db0736c4a34c0bd2edac2045e23a88f8195c6c5b)
1565d668cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3565d668cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4565d668cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5565d668cSAndrew Rist  * distributed with this work for additional information
6565d668cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7565d668cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8565d668cSAndrew Rist  * "License"); you may not use this file except in compliance
9565d668cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11565d668cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13565d668cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14565d668cSAndrew Rist  * software distributed under the License is distributed on an
15565d668cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16565d668cSAndrew Rist  * KIND, either express or implied.  See the License for the
17565d668cSAndrew Rist  * specific language governing permissions and limitations
18565d668cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20565d668cSAndrew Rist  *************************************************************/
21565d668cSAndrew Rist 
22cdf0e10cSrcweir #ifndef _OSL_SECURITY_DECL_HXX_
23cdf0e10cSrcweir #define _OSL_SECURITY_DECL_HXX_
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #include <rtl/ustring.hxx>
26cdf0e10cSrcweir #   include <osl/security.h>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir namespace osl
29cdf0e10cSrcweir {
30cdf0e10cSrcweir 
31cdf0e10cSrcweir /** capsulate security informations for one user.
32cdf0e10cSrcweir     A object of this class is used to execute a process with the rights an
33cdf0e10cSrcweir     security options of a scecified user.
34cdf0e10cSrcweir     @see Process::executeProcess
35cdf0e10cSrcweir */
36cdf0e10cSrcweir class Security
37cdf0e10cSrcweir {
38cdf0e10cSrcweir protected:
39cdf0e10cSrcweir     oslSecurity m_handle;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir public:
42*db0736c4Smseidel     // constructor
43cdf0e10cSrcweir     inline Security();
44*db0736c4Smseidel     // destructor
45cdf0e10cSrcweir     inline ~Security();
46cdf0e10cSrcweir     /** get the security information for one user.
47cdf0e10cSrcweir         The underlying operating system is asked for this information.
48cdf0e10cSrcweir         @param strName [in] denotes the name of the user
49cdf0e10cSrcweir         @param strPasswd [in] denotes the password of this user
50cdf0e10cSrcweir         @return True, if the specified user is known by the underlying operating system,
51cdf0e10cSrcweir         otherwise False
52cdf0e10cSrcweir     */
53cdf0e10cSrcweir     inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
54cdf0e10cSrcweir                                        const ::rtl::OUString& strPasswd);
55cdf0e10cSrcweir     /** get the security information for one user.
56cdf0e10cSrcweir         This method will try to login the user at the denoted file server.
57cdf0e10cSrcweir         If a network resource named \\server\username exists and this resource
58*db0736c4Smseidel         could be connected by this user, the method will return true and getHomeDir
59cdf0e10cSrcweir         will return \\server\username.
60cdf0e10cSrcweir         @param strName [in] denotes the name of the user
61cdf0e10cSrcweir         @param strPasswd [in] denotes the password of this user
62cdf0e10cSrcweir         @return True, if the specified user is known by file server and the
63cdf0e10cSrcweir         could be connected, otherwise False
64cdf0e10cSrcweir     */
65cdf0e10cSrcweir     inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString & strName,
66cdf0e10cSrcweir                                        const ::rtl::OUString & strPasswd,
67cdf0e10cSrcweir                                        const ::rtl::OUString & strFileServer);
68cdf0e10cSrcweir 
69cdf0e10cSrcweir     /** get the ident of the logged in user.
70cdf0e10cSrcweir         @param strName [out] is the buffer which returns the name
71cdf0e10cSrcweir         @param max [in] is the size of this buffer
7230acf5e8Spfg         @return True, if any user is successfully logged in, otherwise False
73cdf0e10cSrcweir     */
74cdf0e10cSrcweir     inline sal_Bool  SAL_CALL getUserIdent( ::rtl::OUString& strIdent) const;
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     /** get the name of the logged in user.
77cdf0e10cSrcweir         @param strName [out] is the buffer which returns the name
78cdf0e10cSrcweir         @param max [in] is the size of this buffer
7930acf5e8Spfg         @return True, if any user is successfully logged in, otherwise False
80cdf0e10cSrcweir     */
81cdf0e10cSrcweir     inline sal_Bool SAL_CALL getUserName( ::rtl::OUString& strName) const;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /** get the home directory of the logged in user.
84cdf0e10cSrcweir         @param strDirectory [out] is the buffer which returns the directory name
85cdf0e10cSrcweir         @param max [in] is the size of this buffer
8630acf5e8Spfg         @return True, if any user is successfully logged in, otherwise False
87cdf0e10cSrcweir     */
88cdf0e10cSrcweir     inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir     /** get the directory for configuration data of the logged in user.
91cdf0e10cSrcweir         @param strDirectory [out] is the buffer which returns the directory name
92cdf0e10cSrcweir         @param max [in] is the size of this buffer
9330acf5e8Spfg         @return True, if any user is successfully logged in, otherwise False
94cdf0e10cSrcweir     */
95cdf0e10cSrcweir     inline sal_Bool SAL_CALL getConfigDir( ::rtl::OUString & strDirectory) const;
96cdf0e10cSrcweir 
97*db0736c4Smseidel     /** Query if the user who is logged in has administrator rights.
98cdf0e10cSrcweir         @return True, if the user has administrator rights, otherwise false.
99cdf0e10cSrcweir     */
100cdf0e10cSrcweir     inline sal_Bool SAL_CALL isAdministrator() const;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     /** Returns the underlying oslSecurity handle
103cdf0e10cSrcweir      */
104cdf0e10cSrcweir     inline oslSecurity getHandle() const;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir #endif  // _OSL_SECURITY_HXX_
111