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