MeVisLab Toolbox Reference
macAuthorization.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef MAC_AUTHORIZATION_H
14 #define MAC_AUTHORIZATION_H
15 
17 
18 #if defined(__APPLE__)
19 
21 #include <string>
22 #include <list>
23 
24 namespace macos { namespace internal {
25 
26  class AuthorizationPrivate;
27 
30  {
31  public:
32 
35  ErrAuthorizationUnknown = -1,
36  ErrAuthorizationSuccess = 0,
37  ErrAuthorizationCanceled = 1,
38  ErrAuthorizationDenied = 2,
39  ErrAuthorizationToolExecuteFailure = 3,
40  ErrAuthorizationToolEnvironmentError = 4
41  };
42 
44  Authorization(const std::string &prompt = std::string());
45 
48 
50 
52  void setPrompt(const std::string &prompt);
53 
55 
60  bool executeWithPrivileges(const std::string &cmd, const std::list<std::string> &argv, const std::string &prompt = std::string(), AuthorizationError *error = NULL);
61 
63  const std::string &getCommandOutput() const;
64 
65  private:
66 
67  OSXSUPPORT_PRIVATE_API AuthorizationPrivate *_priv;
68  };
69 
70 } }
71 
72 #endif // __APPLE__
73 #endif // __macAuthorization_H
Authorization framework encapsulation.
void setPrompt(const std::string &prompt)
Set prompt used when no prompt is provided with a function call (UTF8)
bool executeWithPrivileges(const std::string &cmd, const std::list< std::string > &argv, const std::string &prompt=std::string(), AuthorizationError *error=NULL)
execute cmd including arguments with privileges (UTF8)
const std::string & getCommandOutput() const
return a reference to the stdout output string of the command last executed
AuthorizationError
Authorization error codes.
Authorization(const std::string &prompt=std::string())
C-tor (Optionally set a prompt used when no prompt is provided with a function call)
#define OSXSUPPORT_PUBLIC_API
Symbol visibility macros.
#define OSXSUPPORT_PRIVATE_API
AppleScript support.