OS X Keychain integration Keychain.h

From CDOT Wiki
Jump to: navigation, search
//Authors: Mohammad Tirtashi mo3b.com
//		   Phillip Vitorino philv.com
//Last changed: December 9th 2006
//keychain.h
#ifndef _keychain_h
#define _keychain_h

#include "keychain.h"
#include <CoreFoundation/CoreFoundation.h>
#include <Security/Security.h>
#include <CoreServices/CoreServices.h>

class keychain {
	private:
		keychain();
		static keychain* inst;
		
	public:
		// adds an internet keychain entry to the keychain database. 
		int AddInternetPassword (SecKeychainRef keychain, int serverNameLength, const char *serverName, int securityDomainLength, 
						const char *securityDomain, int accountNameLength, const char *accountName, int pathLength,
						const char *path, int port, SecProtocolType protocol, SecAuthenticationType authenticationType,
						int passwordLength, const void *passwordData, SecKeychainItemRef *itemRef);
		// retrieves a keychain item from the keychain database. 						
		int RetrieveInternetPassword (SecKeychainRef keychain, int serverNameLength, const char *serverName, int securityDomainLength,
								const char *securityDomain,int pathLength, 
								const char *path, int port, SecProtocolType protocol, SecAuthenticationType authenticationType, 
								UInt32 *passwordLength, void **passwordData,SecKeychainItemRef *itemRef);
		// modifies an existing keychain entry's password attribute						
		int ChangeInternetPassword (SecKeychainItemRef itemRef, int accountNameLength, const char *accountName, 
								int passwordLength, const void *passwordData);
		// returns an instance of the curret keychain object in memory. If none exist then one is created.
		static keychain* getInstance();
		~keychain();
};

#endif