xref: /trunk/main/sal/inc/osl/security_decl.hxx (revision 30acf5e8)
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
10565d668cSAndrew Rist  *
11565d668cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12565d668cSAndrew Rist  *
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.
19565d668cSAndrew Rist  *
20565d668cSAndrew Rist  *************************************************************/
21565d668cSAndrew Rist 
22565d668cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _OSL_SECURITY_DECL_HXX_
25cdf0e10cSrcweir #define _OSL_SECURITY_DECL_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #	include <osl/security.h>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace osl
31cdf0e10cSrcweir {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /** capsulate security informations for one user.
34cdf0e10cSrcweir 	A object of this class is used to execute a process with the rights an
35cdf0e10cSrcweir 	security options of a scecified user.
36cdf0e10cSrcweir 	@see Process::executeProcess
37cdf0e10cSrcweir */
38cdf0e10cSrcweir class Security
39cdf0e10cSrcweir {
40cdf0e10cSrcweir protected:
41cdf0e10cSrcweir 	oslSecurity m_handle;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir public:
44cdf0e10cSrcweir 	/// constructor
45cdf0e10cSrcweir     inline Security();
46cdf0e10cSrcweir 	/// destructor
47cdf0e10cSrcweir     inline ~Security();
48cdf0e10cSrcweir 	/** get the security information for one user.
49cdf0e10cSrcweir 		The underlying operating system is asked for this information.
50cdf0e10cSrcweir 		@param strName [in] denotes the name of the user
51cdf0e10cSrcweir 		@param strPasswd [in] denotes the password of this user
52cdf0e10cSrcweir 		@return True, if the specified user is known by the underlying operating system,
53cdf0e10cSrcweir 		otherwise False
54cdf0e10cSrcweir 	*/
55cdf0e10cSrcweir 	inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
56cdf0e10cSrcweir 									   const ::rtl::OUString& strPasswd);
57cdf0e10cSrcweir 	/** get the security information for one user.
58cdf0e10cSrcweir 		This method will try to login the user at the denoted file server.
59cdf0e10cSrcweir 		If a network resource named \\server\username exists and this resource
60cdf0e10cSrcweir 		could be connected by this user, the methos will return true and getHomeDir
61cdf0e10cSrcweir 		will return \\server\username.
62cdf0e10cSrcweir 		@param strName [in] denotes the name of the user
63cdf0e10cSrcweir 		@param strPasswd [in] denotes the password of this user
64cdf0e10cSrcweir 		@return True, if the specified user is known by file server and the
65cdf0e10cSrcweir 		could be connected,	otherwise False
66cdf0e10cSrcweir 	*/
67cdf0e10cSrcweir 	inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString & strName,
68cdf0e10cSrcweir 									   const ::rtl::OUString & strPasswd,
69cdf0e10cSrcweir 									   const ::rtl::OUString & strFileServer);
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	/** get the ident of the logged in user.
72cdf0e10cSrcweir 		@param strName [out] is the buffer which returns the name
73cdf0e10cSrcweir 		@param max [in] is the size of this buffer
74*30acf5e8Spfg 		@return True, if any user is successfully logged in, otherwise False
75cdf0e10cSrcweir 	*/
76cdf0e10cSrcweir     inline sal_Bool  SAL_CALL getUserIdent( ::rtl::OUString& strIdent) const;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	/** get the name of the logged in user.
79cdf0e10cSrcweir 		@param strName [out] is the buffer which returns the name
80cdf0e10cSrcweir 		@param max [in] is the size of this buffer
81*30acf5e8Spfg 		@return True, if any user is successfully logged in, otherwise False
82cdf0e10cSrcweir 	*/
83cdf0e10cSrcweir     inline sal_Bool SAL_CALL getUserName( ::rtl::OUString& strName) const;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	/** get the home directory of the logged in user.
86cdf0e10cSrcweir 		@param strDirectory [out] is the buffer which returns the directory name
87cdf0e10cSrcweir 		@param max [in] is the size of this buffer
88*30acf5e8Spfg 		@return True, if any user is successfully logged in, otherwise False
89cdf0e10cSrcweir 	*/
90cdf0e10cSrcweir     inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	/** get the directory for configuration data of the logged in user.
93cdf0e10cSrcweir 		@param strDirectory [out] is the buffer which returns the directory name
94cdf0e10cSrcweir 		@param max [in] is the size of this buffer
95*30acf5e8Spfg 		@return True, if any user is successfully logged in, otherwise False
96cdf0e10cSrcweir 	*/
97cdf0e10cSrcweir     inline sal_Bool SAL_CALL getConfigDir( ::rtl::OUString & strDirectory) const;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	/** Query if the user who is logged inhas administrator rigths.
100cdf0e10cSrcweir 		@return True, if the user has administrator rights, otherwise false.
101cdf0e10cSrcweir 	*/
102cdf0e10cSrcweir 	inline sal_Bool SAL_CALL isAdministrator() const;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	/** Returns the underlying oslSecurity handle
105cdf0e10cSrcweir 	 */
106cdf0e10cSrcweir     inline oslSecurity getHandle() const;
107cdf0e10cSrcweir 
108cdf0e10cSrcweir };
109cdf0e10cSrcweir 
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir #endif	// _OSL_SECURITY_HXX_
113cdf0e10cSrcweir 
114