2 * Copyright (c) 2000-2001,2003-2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
29 * Created by michael on Fri Oct 20 2000.
32 #include <Security/Authorization.h>
34 #include <Security/AuthorizationEngine.h>
36 using namespace Authorization
;
38 static const AuthorizationItem gItems
[] =
40 {"login", 0, NULL
, NULL
},
41 {"reboot", 0, NULL
, NULL
},
42 {"shutdown", 0, NULL
, NULL
},
43 {"mount", 0, NULL
, NULL
},
44 {"login.reboot", 0, NULL
, NULL
},
45 {"login.shutdown", 0, NULL
, NULL
},
46 {"unmount", 0, NULL
, NULL
}
49 static const AuthorizationRights gRights
=
52 const_cast<AuthorizationItem
*>(gItems
)
56 printRights(const RightSet
&rightSet
)
58 for(RightSet::const_iterator it
= rightSet
.begin(); it
!= rightSet
.end(); ++it
)
60 printf("right: \"%s\"\n", it
->rightName());
65 main(int argc
, char **argv
)
67 Engine
engine("/tmp/config.plist");
69 const RightSet
inputRights(&gRights
);
70 MutableRightSet outputRights
;
71 printf("InputRights:\n");
72 printRights(inputRights
);
73 printf("Authorizing:\n");
74 OSStatus result
= engine
.authorize(inputRights
, NULL
,
75 kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagExtendRights
| kAuthorizationFlagPartialRights
,
76 NULL
, NULL
, &outputRights
);
77 printf("Result: %ld\n", result
);
78 printf("OutputRights:\n");
79 printRights(outputRights
);