xref: /aoo41x/main/sal/inc/osl/security.h (revision 9eab2a37)
1*9eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9eab2a37SAndrew Rist  * distributed with this work for additional information
6*9eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
9*9eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9eab2a37SAndrew Rist  *
11*9eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9eab2a37SAndrew Rist  *
13*9eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9eab2a37SAndrew Rist  * software distributed under the License is distributed on an
15*9eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9eab2a37SAndrew Rist  * specific language governing permissions and limitations
18*9eab2a37SAndrew Rist  * under the License.
19*9eab2a37SAndrew Rist  *
20*9eab2a37SAndrew Rist  *************************************************************/
21*9eab2a37SAndrew Rist 
22*9eab2a37SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _OSL_SECURITY_H_
25cdf0e10cSrcweir #define _OSL_SECURITY_H_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ustring.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifdef __cplusplus
30cdf0e10cSrcweir extern "C" {
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir 
33cdf0e10cSrcweir typedef enum {
34cdf0e10cSrcweir 	osl_Security_E_None,
35cdf0e10cSrcweir 	osl_Security_E_UserUnknown,
36cdf0e10cSrcweir     osl_Security_E_WrongPassword,
37cdf0e10cSrcweir     osl_Security_E_Unknown,
38cdf0e10cSrcweir 	osl_Security_E_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
39cdf0e10cSrcweir } oslSecurityError;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /** Process handle
42cdf0e10cSrcweir 	@see osl_loginUser
43cdf0e10cSrcweir 	@see osl_freeSecurityHandle
44cdf0e10cSrcweir 	@see osl_executeProcess
45cdf0e10cSrcweir */
46cdf0e10cSrcweir typedef void* oslSecurity;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir /** Create a security handle for the current user.
49cdf0e10cSrcweir 	@return a security handle or NULL on failure.
50cdf0e10cSrcweir 	@see osl_freeSecurityHandle
51cdf0e10cSrcweir 	@see osl_executeProcess
52cdf0e10cSrcweir 	@see osl_executeApplication
53cdf0e10cSrcweir */
54cdf0e10cSrcweir oslSecurity SAL_CALL osl_getCurrentSecurity(void);
55cdf0e10cSrcweir 
56cdf0e10cSrcweir /** Create a security handle for the denoted user.
57cdf0e10cSrcweir 	Try to log in the user on the local system.
58cdf0e10cSrcweir 	@param strzUserName [in] denotes the name of the user to logg in.
59cdf0e10cSrcweir 	@param strPasswd [in] the password for this user.
60cdf0e10cSrcweir 	@param pSecurity [out] returns the security handle if user could be logged in.
61cdf0e10cSrcweir 	@return osl_Security_E_None if user could be logged in, otherwise an error-code.
62cdf0e10cSrcweir 	@see osl_freeSecurityHandle
63cdf0e10cSrcweir 	@see osl_executeProcess
64cdf0e10cSrcweir 	@see osl_executeApplication
65cdf0e10cSrcweir */
66cdf0e10cSrcweir oslSecurityError SAL_CALL osl_loginUser(
67cdf0e10cSrcweir     rtl_uString *strUserName,
68cdf0e10cSrcweir 	rtl_uString *strPasswd,
69cdf0e10cSrcweir 	oslSecurity *pSecurity
70cdf0e10cSrcweir 	);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /** Create a security handle for the denoted user.
73cdf0e10cSrcweir 	Try to log in the user on the denoted file server. On success the homedir will be
74cdf0e10cSrcweir 	the maped drive on this server.
75cdf0e10cSrcweir 	@param strUserName [in] denotes the name of the user to logg in.
76cdf0e10cSrcweir 	@param strPasswd [in] the password for this user.
77cdf0e10cSrcweir 	@param strFileServer [in] denotes the file server on wich the user is logged in.
78cdf0e10cSrcweir 	@param pSecurity [out] returns the security handle if user could be logged in.
79cdf0e10cSrcweir 	@return osl_Security_E_None if user could be logged in, otherwise an error-code.
80cdf0e10cSrcweir 	@see osl_freeSecurityHandle
81cdf0e10cSrcweir 	@see osl_executeProcess
82cdf0e10cSrcweir 	@see osl_executeApplication
83cdf0e10cSrcweir */
84cdf0e10cSrcweir oslSecurityError SAL_CALL osl_loginUserOnFileServer(
85cdf0e10cSrcweir     rtl_uString *strUserName,
86cdf0e10cSrcweir 	rtl_uString *strPasswd,
87cdf0e10cSrcweir 	rtl_uString *strFileServer,
88cdf0e10cSrcweir 	oslSecurity *pSecurity
89cdf0e10cSrcweir 	);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir /** Query if the user who is denotes by this security has administrator rigths.
92cdf0e10cSrcweir 	@param Security [in] the security handle for th user.
93cdf0e10cSrcweir 	@return True, if the user has adminsitrator rights, otherwise false.
94cdf0e10cSrcweir */
95cdf0e10cSrcweir sal_Bool SAL_CALL osl_isAdministrator(oslSecurity Security);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir /** Free the security handle, created by osl_loginUser or osl_getCurrentSecurity.
98cdf0e10cSrcweir 	@param Security [in] the security handle.
99cdf0e10cSrcweir 	@see osl_loginUser
100cdf0e10cSrcweir */
101cdf0e10cSrcweir void SAL_CALL osl_freeSecurityHandle(oslSecurity Security);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir /** Get the login ident for the user of this security handle.
104cdf0e10cSrcweir 	@param Security [in] the security handle.
105cdf0e10cSrcweir 	@param strIdent [out] the string that receives the ident on success.
106cdf0e10cSrcweir 	@return True, if the security handle is valid, otherwise False.
107cdf0e10cSrcweir */
108cdf0e10cSrcweir sal_Bool SAL_CALL osl_getUserIdent(oslSecurity Security, rtl_uString **strIdent);
109cdf0e10cSrcweir 
110cdf0e10cSrcweir /** Get the login name for the user of this security handle.
111cdf0e10cSrcweir 	@param Security [in] the security handle.
112cdf0e10cSrcweir 	@param pszName [out] the string that receives the user name on success.
113cdf0e10cSrcweir 	@return True, if the security handle is valid, otherwise False.
114cdf0e10cSrcweir */
115cdf0e10cSrcweir sal_Bool SAL_CALL osl_getUserName(oslSecurity Security, rtl_uString **strName);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir /** Get the home directory of the user of this security handle.
118cdf0e10cSrcweir 	@param Security [in] the security handle.
119cdf0e10cSrcweir 	@param strDirectory [out] the string that receives the directory path on success.
120cdf0e10cSrcweir 	@return True, if the security handle is valid, otherwise False.
121cdf0e10cSrcweir */
122cdf0e10cSrcweir sal_Bool SAL_CALL osl_getHomeDir(oslSecurity Security, rtl_uString **strDirectory);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir /** Get the directory for configuration data of the user of this security handle.
125cdf0e10cSrcweir 	@param Security [in] the security handle.
126cdf0e10cSrcweir 	@param strDirectory [out] the string that receives the directory path on success.
127cdf0e10cSrcweir 	@return True, if the security handle is valid, otherwise False.
128cdf0e10cSrcweir */
129cdf0e10cSrcweir sal_Bool SAL_CALL osl_getConfigDir(oslSecurity Security, rtl_uString **strDirectory);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir /** Load Profile of the User
133cdf0e10cSrcweir     Implemented just for Windows
134cdf0e10cSrcweir 	@param oslSecurity Security [in] previously fetch Security of the User
135cdf0e10cSrcweir 	@return True if the Profile could successfully loaded, False otherwise.
136cdf0e10cSrcweir */
137cdf0e10cSrcweir 
138cdf0e10cSrcweir sal_Bool SAL_CALL osl_loadUserProfile(oslSecurity Security);
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 
141cdf0e10cSrcweir /** Unload a User Profile
142cdf0e10cSrcweir 	Implemented just for Windows
143cdf0e10cSrcweir 	@param oslSecurity Security [in] previously fetch Security of the User
144cdf0e10cSrcweir 	@return nothing is returned!
145cdf0e10cSrcweir */
146cdf0e10cSrcweir 
147cdf0e10cSrcweir void SAL_CALL osl_unloadUserProfile(oslSecurity Security);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir #ifdef __cplusplus
150cdf0e10cSrcweir }
151cdf0e10cSrcweir #endif
152cdf0e10cSrcweir 
153cdf0e10cSrcweir #endif	/* _OSL_SECURITY_H_ */
154cdf0e10cSrcweir 
155