#ifndef _OSXSIGNING
#define _OSXSIGNING
#include <Security/codesigning.h>
#include <Security/cspclient.h>
#include <limits.h>
#include <string>
#include <CoreFoundation/CFBundle.h>
#ifdef _CPP_OSXSIGNING
#pragma export on
#endif
namespace Security
{
namespace CodeSigning
{
class OSXCode : public Signable {
public:
virtual string encode() const = 0;
static OSXCode *decode(const char *extForm);
public:
static OSXCode *main();
static OSXCode *at(const char *path);
public:
virtual string canonicalPath() const = 0;
protected:
OSXCode() { } static void scanFile(const char *pathname, Signer::State &state); static string getPath(CFURLRef url);
};
class ExecutableTool : public OSXCode {
public:
ExecutableTool(const char *path) : mPath(path) { }
string encode() const;
string path() const { return mPath; }
string canonicalPath() const;
protected:
void scanContents(Signer::State &state) const;
private:
string mPath; };
class GenericBundle : public OSXCode {
public:
GenericBundle(const char *path);
~GenericBundle();
string encode() const;
string canonicalPath() const;
string path() const { return mPath; }
string executablePath() const { return getPath(CFBundleCopyExecutableURL(mBundle)); }
virtual void *lookupSymbol(const char *name);
protected:
void scanContents(Signer::State &state) const;
protected:
string mPath; CFBundleRef mBundle; };
class ApplicationBundle : public GenericBundle {
public:
ApplicationBundle(const char *pathname) : GenericBundle(pathname) { }
};
class LoadableBundle : public GenericBundle {
public:
LoadableBundle(const char *pathname) : GenericBundle(pathname) { }
virtual bool isLoaded() const;
virtual void load();
virtual void unload();
};
}
}
#ifdef _CPP_OSXSIGNING
#pragma export off
#endif
#endif //_OSXSIGNING