• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   The header file for User identify Manager driver.
3 
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef _USER_IDENTIFY_MANAGER_H_
16 #define _USER_IDENTIFY_MANAGER_H_
17 
18 #include <Uefi.h>
19 
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/MdeModuleHii.h>
22 
23 #include <Protocol/FormBrowser2.h>
24 #include <Protocol/HiiDatabase.h>
25 #include <Protocol/HiiConfigAccess.h>
26 #include <Protocol/HiiString.h>
27 #include <Protocol/HiiConfigRouting.h>
28 #include <Protocol/UserCredential2.h>
29 #include <Protocol/UserManager.h>
30 #include <Protocol/DeferredImageLoad.h>
31 #include <Protocol/SimpleTextOut.h>
32 #include <Protocol/SimpleTextIn.h>
33 #include <Protocol/SimpleTextInEx.h>
34 
35 #include <Library/UefiRuntimeServicesTableLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/MemoryAllocationLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/DevicePathLib.h>
40 #include <Library/DebugLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/PrintLib.h>
43 #include <Library/HiiLib.h>
44 
45 #include "UserIdentifyManagerData.h"
46 
47 //
48 // This is the generated IFR binary data for each formset defined in VFR.
49 // This data array is ready to be used as input of HiiAddPackages() to
50 // create a packagelist.
51 //
52 extern UINT8                UserIdentifyManagerVfrBin[];
53 
54 //
55 // This is the generated String package data for all .UNI files.
56 // This data array is ready to be used as input of HiiAddPackages() to
57 // create a packagelist.
58 //
59 extern UINT8                UserIdentifyManagerStrings[];
60 
61 #define   USER_NUMBER_INC           32
62 #define   DEFAULT_PROFILE_SIZE      512
63 #define   INFO_PAYLOAD_SIZE         64
64 
65 //
66 // Credential Provider Information.
67 //
68 typedef struct {
69   UINTN                         Count;
70   EFI_USER_CREDENTIAL2_PROTOCOL *Provider[1];
71 } CREDENTIAL_PROVIDER_INFO;
72 
73 //
74 // Internal user profile entry.
75 //
76 typedef struct {
77   UINTN   MaxProfileSize;
78   UINTN   UserProfileSize;
79   CHAR16  UserVarName[9];
80   UINT8   *ProfileInfo;
81 } USER_PROFILE_ENTRY;
82 
83 //
84 // Internal user profile database.
85 //
86 typedef struct {
87   UINTN                   UserProfileNum;
88   UINTN                   MaxProfileNum;
89   EFI_USER_PROFILE_HANDLE UserProfile[1];
90 } USER_PROFILE_DB;
91 
92 #define USER_MANAGER_SIGNATURE  SIGNATURE_32 ('U', 'I', 'M', 'S')
93 
94 typedef struct {
95   UINTN                           Signature;
96   EFI_HANDLE                      DriverHandle;
97   EFI_HII_HANDLE                  HiiHandle;
98 
99   //
100   // Consumed protocol.
101   //
102   EFI_HII_DATABASE_PROTOCOL       *HiiDatabase;
103   EFI_HII_STRING_PROTOCOL         *HiiString;
104   EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
105   EFI_FORM_BROWSER2_PROTOCOL      *FormBrowser2;
106 
107   //
108   // Produced protocol.
109   //
110   EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;
111 } USER_MANAGER_CALLBACK_INFO;
112 
113 ///
114 /// HII specific Vendor Device Path definition.
115 ///
116 typedef struct {
117   VENDOR_DEVICE_PATH        VendorDevicePath;
118   EFI_DEVICE_PATH_PROTOCOL  End;
119 } HII_VENDOR_DEVICE_PATH;
120 
121 /**
122   Register an event notification function for the user profile changed.
123 
124   @param[in]  ImageHandle     Image handle this driver.
125 
126 **/
127 VOID
128 LoadDeferredImageInit (
129   IN EFI_HANDLE        ImageHandle
130   );
131 
132 
133 /**
134   This function creates a new user profile with only
135   a new user identifier attached and returns its handle.
136   The user profile is non-volatile, but the handle User
137   can change across reboots.
138 
139   @param[in]   This               Protocol EFI_USER_MANAGER_PROTOCOL instance
140                                   pointer.
141   @param[out]  User               Handle of a new user profile.
142 
143   @retval EFI_SUCCESS             User profile was successfully created.
144   @retval EFI_ACCESS_DENIED       Current user does not have sufficient permissions
145                                   to create a user profile.
146   @retval EFI_UNSUPPORTED         Creation of new user profiles is not supported.
147   @retval EFI_INVALID_PARAMETER   User is NULL.
148 
149 **/
150 EFI_STATUS
151 EFIAPI
152 UserProfileCreate (
153   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
154   OUT       EFI_USER_PROFILE_HANDLE             *User
155   );
156 
157 
158 /**
159   Delete an existing user profile.
160 
161   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
162                                   pointer.
163   @param  User                    User profile handle.
164 
165   @retval EFI_SUCCESS             User profile was successfully deleted.
166   @retval EFI_ACCESS_DENIED       Current user does not have sufficient permissions
167                                   to delete a user profile or there is only one
168                                   user profile.
169   @retval EFI_UNSUPPORTED         Deletion of new user profiles is not supported.
170   @retval EFI_INVALID_PARAMETER   User does not refer to a valid user profile.
171 
172 **/
173 EFI_STATUS
174 EFIAPI
175 UserProfileDelete (
176   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
177   IN        EFI_USER_PROFILE_HANDLE             User
178   );
179 
180 
181 /**
182   Get next user profile from the user profile database.
183 
184   @param[in]       This           Protocol EFI_USER_MANAGER_PROTOCOL instance
185                                   pointer.
186   @param[in, out]  User           User profile handle.
187 
188   @retval EFI_SUCCESS             Next enrolled user profile successfully returned.
189   @retval EFI_INVALID_PARAMETER   User is NULL.
190 
191 **/
192 EFI_STATUS
193 EFIAPI
194 UserProfileGetNext (
195   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
196   IN OUT    EFI_USER_PROFILE_HANDLE             *User
197   );
198 
199 
200 /**
201   This function returns the current user profile handle.
202 
203   @param[in]  This                Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
204   @param[out]  CurrentUser        User profile handle.
205 
206   @retval EFI_SUCCESS             Current user profile handle returned successfully.
207   @retval EFI_INVALID_PARAMETER   CurrentUser is NULL.
208 
209 **/
210 EFI_STATUS
211 EFIAPI
212 UserProfileCurrent (
213   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
214   OUT       EFI_USER_PROFILE_HANDLE             *CurrentUser
215   );
216 
217 
218 /**
219   Identify the user and, if authenticated, returns the user handle and changes
220   the current user profile.
221 
222   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
223   @param  CurrentUser             User profile handle.
224 
225   @retval EFI_SUCCESS             User was successfully identified.
226   @retval EFI_INVALID_PARAMETER   User is NULL.
227   @retval EFI_ACCESS_DENIED       User was not successfully identified.
228 
229 **/
230 EFI_STATUS
231 EFIAPI
232 UserProfileIdentify (
233   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
234   OUT       EFI_USER_PROFILE_HANDLE             *User
235   );
236 
237 
238 /**
239   Find a user using a user information record.
240 
241   This function searches all user profiles for the specified user information record.
242   The search starts with the user information record handle following UserInfo and
243   continues until either the information is found or there are no more user profiles.
244   A match occurs when the Info.InfoType field matches the user information record
245   type and the user information record data matches the portion of Info passed the
246   EFI_USER_INFO header.
247 
248   @param[in]      This     Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
249   @param[in, out] User     On entry, points to the previously returned user profile
250                            handle, or NULL to start searching with the first user profile.
251                            On return, points to the user profile handle, or NULL if not
252                            found.
253   @param[in, out] UserInfo On entry, points to the previously returned user information
254                            handle, or NULL to start searching with the first. On return,
255                            points to the user information handle of the user information
256                            record, or NULL if not found. Can be NULL, in which case only
257                            one user information record per user can be returned.
258   @param[in]      Info     Points to the buffer containing the user information to be
259                            compared to the user information record. If NULL, then only
260                            the user information record type is compared. If InfoSize is 0,
261                            then the user information record must be empty.
262 
263   @param[in]      InfoSize The size of Info, in bytes.
264 
265   @retval EFI_SUCCESS      User information was found. User points to the user profile handle,
266                            and UserInfo points to the user information handle.
267   @retval EFI_NOT_FOUND    User information was not found. User points to NULL and UserInfo
268                            points to NULL.
269 
270 **/
271 EFI_STATUS
272 EFIAPI
273 UserProfileFind (
274   IN     CONST EFI_USER_MANAGER_PROTOCOL        *This,
275   IN OUT EFI_USER_PROFILE_HANDLE                *User,
276   IN OUT EFI_USER_INFO_HANDLE                   *UserInfo OPTIONAL,
277   IN     CONST EFI_USER_INFO                    *Info,
278   IN     UINTN                                  InfoSize
279   );
280 
281 
282 /**
283   This function returns user information.
284 
285   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
286                                   pointer.
287   @param  User                    Handle of the user whose profile will be
288                                   retrieved.
289   @param  UserInfo                Handle of the user information data record.
290   @param  Info                    On entry, points to a buffer of at least
291                                   *InfoSize bytes.  On exit, holds the user
292                                   information.
293   @param  InfoSize                On entry, points to the size of Info. On return,
294                                   points to the size of the user information.
295 
296   @retval EFI_SUCCESS             Information returned successfully.
297   @retval EFI_ACCESS_DENIED       The information about the specified user cannot
298                                   be accessed  by the current user.
299                                   EFI_BUFFER_TOO_SMALL- The number of bytes
300                                   specified by *InfoSize is too small to hold the
301                                   returned data.
302 
303 **/
304 EFI_STATUS
305 EFIAPI
306 UserProfileGetInfo (
307   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
308   IN        EFI_USER_PROFILE_HANDLE             User,
309   IN        EFI_USER_INFO_HANDLE                UserInfo,
310   OUT       EFI_USER_INFO                       *Info,
311   IN OUT    UINTN                               *InfoSize
312   );
313 
314 
315 /**
316   This function changes user information.
317 
318   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
319                                   pointer.
320   @param  User                    Handle of the user whose profile will be
321                                   retrieved.
322   @param  UserInfo                Handle of the user information data record.
323   @param  Info                    Points to the user information.
324   @param  InfoSize                The size of Info, in bytes.
325 
326   @retval EFI_SUCCESS             User profile information was successfully
327                                   changed/added.
328   @retval EFI_ACCESS_DENIED       The record is exclusive.
329   @retval EFI_SECURITY_VIOLATION  The current user does not have permission to
330                                   change  the specified user profile or user
331                                   information record.
332 
333 **/
334 EFI_STATUS
335 EFIAPI
336 UserProfileSetInfo (
337   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
338   IN        EFI_USER_PROFILE_HANDLE             User,
339   IN OUT    EFI_USER_INFO_HANDLE                *UserInfo,
340   IN CONST  EFI_USER_INFO                       *Info,
341   IN        UINTN                               InfoSize
342   );
343 
344 
345 /**
346   This function allows the credential provider to notify the User Identity Manager
347   when user status has changed while deselected.
348 
349   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
350                                   pointer.
351   @param  Changed                 Points to the instance of the
352                                   EFI_USER_CREDENTIAL_PROTOCOL  where the user has
353                                   changed.
354 
355   @retval EFI_SUCCESS             The User Identity Manager has handled the
356                                   notification.
357   @retval EFI_NOT_READY           The function was called while the specified
358                                   credential  provider was not selected.
359   @retval EFI_UNSUPPORTED         The User Identity Manager doesn't support
360                                   asynchronous  notifications.
361 
362 **/
363 EFI_STATUS
364 EFIAPI
365 UserProfileNotify (
366   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
367   IN        EFI_HANDLE                          Changed
368   );
369 
370 
371 /**
372   Delete the user information attached to the user profile specified by the UserInfo.
373 
374   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
375   @param  User                    Handle of the user whose profile will be retrieved.
376   @param  UserInfo                Handle of the user information data record.
377 
378   @retval EFI_SUCCESS             User information deleted successfully.
379   @retval EFI_ACCESS_DENIED       The current user does not have permission to
380                                   delete this user in-formation.
381   @retval EFI_NOT_FOUND           User information record UserInfo does not exist
382                                   in the user pro-file.
383 
384 **/
385 EFI_STATUS
386 EFIAPI
387 UserProfileDeleteInfo (
388   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
389   IN        EFI_USER_PROFILE_HANDLE             User,
390   IN        EFI_USER_INFO_HANDLE                UserInfo
391   );
392 
393 
394 /**
395   This function returns the next user information record.
396 
397   @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
398   @param  User                    Handle of the user whose profile will be retrieved.
399   @param  UserInfo                Handle of the user information data record.
400 
401   @retval EFI_SUCCESS             User information returned.
402   @retval EFI_NOT_FOUND           No more user information found.
403 
404 **/
405 EFI_STATUS
406 EFIAPI
407 UserProfileGetNextInfo (
408   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
409   IN        EFI_USER_PROFILE_HANDLE             User,
410   IN OUT    EFI_USER_INFO_HANDLE                *UserInfo
411   );
412 
413 #endif
414