SecurityAgentPlugin not working anymore on Yosemite (SFAuthorizationPluginView)

大兔子大兔子 提交于 2019-12-09 13:18:55

问题


We have developed an Authorization Plug-in that uses an SFAuthorizationPluginView to present UI to the user. This example is based on the "old" NameAndPassword example provided by Apple.

We are using this Authorization Plug-in to unlock the session (we have updated the "system.login.screensaver" authorization in the authorizationdb) using a custom view. This worked well until the last update to Yosemite. Since Yosemite, the SFAuthorizationPluginView is not closing anymore after the user logged into the session. We could update the example to force closing the window, by doing something like:

// confirm that we have authorized the user
[self callbacks]->SetResult ([self engineRef], kAuthorizationResultAllow);

// close the window
NSView* v = [self viewForType:SFViewTypeCredentials]; 
NSWindow* w = [v window]; 
[w close];

Now the SFAuthorizationPluginView is well closed once the user is logged in (after we have authorized the user), but something remains active in the background and the user has no focus in the session (the user cannot select something or write in a text edit for example). We have to manually kill the SecurityAgent in order to get the focus again. (note that the system seems to automatically kill the SecurityAgent after 30 seconds).

We have found a fixed 2014 version of Apple's NameAndPassword auth plugin sample at the following page, but we face the same issue on Yosemite: A fixed 2014 version of Apple's NameAndPassword auth plugin sample

This code was working fine for us until the Yosemite release.

Anyone experimenting a similar issue? Any idea or advice to fix this issue?


回答1:


Instead of close to the window you should overwrite didDeactivate method AND add call:

[self didDeactivate];

in the SFAuthorizationPluginView class AFTER you set the result to ALLOW.

Apple updated their documentation, you could re-read it, there are some good guidelines that would save me A LOT of time and effort one year ago.



来源:https://stackoverflow.com/questions/26543149/securityagentplugin-not-working-anymore-on-yosemite-sfauthorizationpluginview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!