Re: Authorization Samples for Cocoa?
Re: Authorization Samples for Cocoa?
- Subject: Re: Authorization Samples for Cocoa?
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 16 Nov 2009 10:37:26 -0700
On Nov 15, 2009, at 7:09 PM, Laurent Daudelin wrote:
> The BLAuthentication class uses "AuthorizationExecuteWithPrivileges" which doesn't seem to allow to pass a description like "AuthorizationRightSet" seems to allow. I've searched for some samples but they are all very outdated (from 2005 (AuthForAll) and 2007 (BetterAuthorizationSample)) and are way too complex to understand in like one hour. I can't imagine that all that crap hasn't been encapsulated under some Objective-C classes. Anyone has any idea or pointer to something basic I don't need to take a few hours to figure it out?
Typed in Mail, untested, use at your own risk but it ought to work, and all that:
#import <SecurityFoundation/SFAuthorization.h>
const char *myFancyMessage = "We humbly ask for your password so we can do this and that.";
AuthorizationItem promptItem = {kAuthorizationEnvironmentPrompt, strlen(myFancyMessage), myFancyMessage, 0};
AuthorizationEnvironment myEnvironment = {1, &promptItem};
AuthorizationItem myRight = {kAuthorizationRightExecute, 0, NULL, 0};
AuthorizationRights myRights = {1, &myRight};
SFAuthorization *sfAuthorization = [SFAuthorization authorizationWithFlags:kAuthorizationFlagInterationAllowed|kAuthorizationFlagPreAuthorize rights:myRights environment:myEnvironment];
At that last line, the security server ought to pre-authorize with the message in myFancyMessage instead of the default message. Then you use AEWP() with the AuthorizationRef obtained from the SFAuthorization to do whatever it is you need to do.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden