xref: /aoo41x/main/sal/inc/osl/security_decl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _OSL_SECURITY_DECL_HXX_
29 #define _OSL_SECURITY_DECL_HXX_
30 
31 #include <rtl/ustring.hxx>
32 #	include <osl/security.h>
33 
34 namespace osl
35 {
36 
37 /** capsulate security informations for one user.
38 	A object of this class is used to execute a process with the rights an
39 	security options of a scecified user.
40 	@see Process::executeProcess
41 */
42 class Security
43 {
44 protected:
45 	oslSecurity m_handle;
46 
47 public:
48 	/// constructor
49     inline Security();
50 	/// destructor
51     inline ~Security();
52 	/** get the security information for one user.
53 		The underlying operating system is asked for this information.
54 		@param strName [in] denotes the name of the user
55 		@param strPasswd [in] denotes the password of this user
56 		@return True, if the specified user is known by the underlying operating system,
57 		otherwise False
58 	*/
59 	inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString& strName,
60 									   const ::rtl::OUString& strPasswd);
61 	/** get the security information for one user.
62 		This method will try to login the user at the denoted file server.
63 		If a network resource named \\server\username exists and this resource
64 		could be connected by this user, the methos will return true and getHomeDir
65 		will return \\server\username.
66 		@param strName [in] denotes the name of the user
67 		@param strPasswd [in] denotes the password of this user
68 		@return True, if the specified user is known by file server and the
69 		could be connected,	otherwise False
70 	*/
71 	inline sal_Bool SAL_CALL logonUser(const ::rtl::OUString & strName,
72 									   const ::rtl::OUString & strPasswd,
73 									   const ::rtl::OUString & strFileServer);
74 
75 	/** get the ident of the logged in user.
76 		@param strName [out] is the buffer which returns the name
77 		@param max [in] is the size of this buffer
78 		@return True, if any user is successfuly logged in, otherwise False
79 	*/
80     inline sal_Bool  SAL_CALL getUserIdent( ::rtl::OUString& strIdent) const;
81 
82 	/** get the name of the logged in user.
83 		@param strName [out] is the buffer which returns the name
84 		@param max [in] is the size of this buffer
85 		@return True, if any user is successfuly logged in, otherwise False
86 	*/
87     inline sal_Bool SAL_CALL getUserName( ::rtl::OUString& strName) const;
88 
89 	/** get the home directory of the logged in user.
90 		@param strDirectory [out] is the buffer which returns the directory name
91 		@param max [in] is the size of this buffer
92 		@return True, if any user is successfuly logged in, otherwise False
93 	*/
94     inline sal_Bool SAL_CALL getHomeDir( ::rtl::OUString& strDirectory) const;
95 
96 	/** get the directory for configuration data of the logged in user.
97 		@param strDirectory [out] is the buffer which returns the directory name
98 		@param max [in] is the size of this buffer
99 		@return True, if any user is successfuly logged in, otherwise False
100 	*/
101     inline sal_Bool SAL_CALL getConfigDir( ::rtl::OUString & strDirectory) const;
102 
103 	/** Query if the user who is logged inhas administrator rigths.
104 		@return True, if the user has administrator rights, otherwise false.
105 	*/
106 	inline sal_Bool SAL_CALL isAdministrator() const;
107 
108 	/** Returns the underlying oslSecurity handle
109 	 */
110     inline oslSecurity getHandle() const;
111 
112 };
113 
114 }
115 
116 #endif	// _OSL_SECURITY_HXX_
117 
118