Permalink
Browse files

importing

  • Loading branch information...
0 parents commit 2d29c36d766f10dc508157f1e0e1479b8af10360 @gabriel committed Aug 7, 2008
Showing with 9,316 additions and 0 deletions.
  1. +1 −0 .gitattributes
  2. +4 −0 .gitignore
  3. +70 −0 Classes/EMKeychainItem.h
  4. +213 −0 Classes/EMKeychainItem.m
  5. +45 −0 Classes/EMKeychainProxy.h
  6. +171 −0 Classes/EMKeychainProxy.m
  7. +183 −0 Classes/External/GTM/GTMBase64.h
  8. +697 −0 Classes/External/GTM/GTMBase64.m
  9. +166 −0 Classes/External/GTM/GTMDefines.h
  10. +381 −0 Classes/External/GTM/GTMRegex.h
  11. +812 −0 Classes/External/GTM/GTMRegex.m
  12. +17 −0 Classes/External/NSInvocation+ForwardedConstruction.h
  13. +369 −0 Classes/External/NSInvocation+ForwardedConstruction.m
  14. +37 −0 Classes/External/NSString+RegEx.h
  15. +94 −0 Classes/External/NSString+RegEx.m
  16. +49 −0 Classes/GHKit.h
  17. +44 −0 Classes/GHNSDate+Parsing.h
  18. +174 −0 Classes/GHNSDate+Parsing.m
  19. +15 −0 Classes/GHNSFileManager+Utils.h
  20. +88 −0 Classes/GHNSFileManager+Utils.m
  21. +39 −0 Classes/GHNSNumber+Utils.h
  22. +92 −0 Classes/GHNSNumber+Utils.m
  23. +33 −0 Classes/GHNSString+HMAC.h
  24. +95 −0 Classes/GHNSString+HMAC.m
  25. +34 −0 Classes/GHNSString+TimeInterval.h
  26. +69 −0 Classes/GHNSString+TimeInterval.m
  27. +52 −0 Classes/GHNSString+Utils.h
  28. +200 −0 Classes/GHNSString+Utils.m
  29. +16 −0 Classes/GHNSString+Validation.h
  30. +22 −0 Classes/GHNSString+Validation.m
  31. +44 −0 Classes/GHNSURL+Utils.h
  32. +115 −0 Classes/GHNSURL+Utils.m
  33. +36 −0 Classes/GHNSXMLElement+Utils.h
  34. +57 −0 Classes/GHNSXMLElement+Utils.m
  35. +34 −0 Classes/GHNSXMLNode+Utils.h
  36. +53 −0 Classes/GHNSXMLNode+Utils.m
  37. +40 −0 Classes/GHViewAnimation.h
  38. +208 −0 Classes/GHViewAnimation.m
  39. +54 −0 Classes/hmac.c
  40. +10 −0 Classes/hmac.h
  41. +168 −0 Classes/sha1.c
  42. +24 −0 Classes/sha1.h
  43. BIN English.lproj/InfoPlist.strings
  44. BIN GHKit.xcodeproj/TemplateIcon.icns
  45. +1,578 −0 GHKit.xcodeproj/gabe.perspectivev3
  46. +1,683 −0 GHKit.xcodeproj/ghandford.perspectivev3
  47. +666 −0 GHKit.xcodeproj/project.pbxproj
  48. +7 −0 GHKit_Prefix.pch
  49. +26 −0 Info.plist
  50. +20 −0 Tests-Info.plist
  51. +16 −0 Tests/NSDate+ParsingTest.h
  52. +41 −0 Tests/NSDate+ParsingTest.m
  53. +16 −0 Tests/NSString+HMACTest.h
  54. +27 −0 Tests/NSString+HMACTest.m
  55. +15 −0 Tests/NSString+TimeIntervalTest.h
  56. +45 −0 Tests/NSString+TimeIntervalTest.m
  57. +16 −0 Tests/NSString+UtilsTest.h
  58. +35 −0 Tests/NSString+UtilsTest.m
@@ -0,0 +1 @@
+*.pbxproj -crlf -diff -merge
@@ -0,0 +1,4 @@
+build
+.DS_Store
+*.pbxuser
+*.move1v3
@@ -0,0 +1,70 @@
+/*Copyright (c) 2007 Extendmac, LLC. <support@extendmac.com>
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#import <Security/Security.h>
+
+@interface EMKeychainItem : NSObject {
+ NSString *myPassword;
+ NSString *myUsername;
+ NSString *myLabel;
+ SecKeychainItemRef coreKeychainItem;
+}
+- (NSString *)password;
+- (NSString *)username;
+- (NSString *)label;
+- (BOOL)setPassword:(NSString *)newPassword;
+- (BOOL)setUsername:(NSString *)newUsername;
+- (BOOL)setLabel:(NSString *)newLabel;
+@end
+
+@interface EMKeychainItem (Private)
+- (BOOL)modifyAttributeWithTag:(SecItemAttr)attributeTag toBeString:(NSString *)newStringValue;
+@end
+
+@interface EMGenericKeychainItem : EMKeychainItem
+{
+ NSString *myServiceName;
+}
++ (id)genericKeychainItem:(SecKeychainItemRef)item forServiceName:(NSString *)serviceName username:(NSString *)username password:(NSString *)password;
+- (NSString *)serviceName;
+- (BOOL)setServiceName:(NSString *)newServiceName;
+@end
+
+@interface EMInternetKeychainItem : EMKeychainItem
+{
+ NSString *myServer;
+ NSString *myPath;
+ int myPort;
+ SecProtocolType myProtocol;
+}
++ (id)internetKeychainItem:(SecKeychainItemRef)item forServer:(NSString *)server username:(NSString *)username password:(NSString *)password path:(NSString *)path port:(int)port protocol:(SecProtocolType)protocol;
+- (NSString *)server;
+- (NSString *)path;
+- (int)port;
+- (SecProtocolType)protocol;
+- (BOOL)setServer:(NSString *)newServer;
+- (BOOL)setPath:(NSString *)newPath;
+- (BOOL)setPort:(int)newPort;
+- (BOOL)setProtocol:(SecProtocolType)newProtocol;
+@end
@@ -0,0 +1,213 @@
+/*Copyright (c) 2007 Extendmac, LLC. <support@extendmac.com>
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#import "EMKeychainItem.h"
+
+@implementation EMKeychainItem
+- (id)initWithCoreKeychainItem:(SecKeychainItemRef)item username:(NSString *)username password:(NSString *)password
+{
+ if ((self = [super init]))
+ {
+ coreKeychainItem = item;
+ [self setValue:username forKey:@"myUsername"];
+ [self setValue:password forKey:@"myPassword"];
+ return self;
+ }
+ return nil;
+}
+- (NSString *)password
+{
+ return myPassword;
+}
+- (NSString *)username
+{
+ return myUsername;
+}
+- (NSString *)label
+{
+ return myLabel;
+}
+
+- (BOOL)setPassword:(NSString *)newPasswordString
+{
+ if (!newPasswordString)
+ {
+ return NO;
+ }
+ [self willChangeValueForKey:@"password"];
+ [myPassword autorelease];
+ myPassword = [newPasswordString copy];
+ [self didChangeValueForKey:@"password"];
+
+ const char *newPassword = [newPasswordString UTF8String];
+ OSStatus returnStatus = SecKeychainItemModifyAttributesAndData(coreKeychainItem, NULL, strlen(newPassword), (void *)newPassword);
+ return (returnStatus == noErr);
+}
+- (BOOL)setUsername:(NSString *)newUsername
+{
+ [self willChangeValueForKey:@"username"];
+ [myUsername autorelease];
+ myUsername = [newUsername copy];
+ [self didChangeValueForKey:@"username"];
+
+ return [self modifyAttributeWithTag:kSecAccountItemAttr toBeString:newUsername];
+}
+- (BOOL)setLabel:(NSString *)newLabel
+{
+ [self willChangeValueForKey:@"label"];
+ [myLabel autorelease];
+ myLabel = [newLabel copy];
+ [self didChangeValueForKey:@"label"];
+
+ return [self modifyAttributeWithTag:kSecLabelItemAttr toBeString:newLabel];
+}
+@end
+
+@implementation EMKeychainItem (Private)
+- (BOOL)modifyAttributeWithTag:(SecItemAttr)attributeTag toBeString:(NSString *)newStringValue
+{
+ const char *newValue = [newStringValue UTF8String];
+ SecKeychainAttribute attributes[1];
+ attributes[0].tag = attributeTag;
+ attributes[0].length = strlen(newValue);
+ attributes[0].data = (void *)newValue;
+
+ SecKeychainAttributeList list;
+ list.count = 1;
+ list.attr = attributes;
+
+ OSStatus returnStatus = SecKeychainItemModifyAttributesAndData(coreKeychainItem, &list, 0, NULL);
+ return (returnStatus == noErr);
+}
+@end
+
+@implementation EMGenericKeychainItem
+- (id)initWithCoreKeychainItem:(SecKeychainItemRef)item serviceName:(NSString *)serviceName username:(NSString *)username password:(NSString *)password
+{
+ if ((self = [super initWithCoreKeychainItem:item username:username password:password]))
+ {
+ [self setValue:serviceName forKey:@"myServiceName"];
+ return self;
+ }
+ return nil;
+}
++ (id)genericKeychainItem:(SecKeychainItemRef)item forServiceName:(NSString *)serviceName username:(NSString *)username password:(NSString *)password
+{
+ return [[[EMGenericKeychainItem alloc] initWithCoreKeychainItem:item serviceName:serviceName username:username password:password] autorelease];
+}
+- (NSString *)serviceName
+{
+ return myServiceName;
+}
+
+- (BOOL)setServiceName:(NSString *)newServiceName
+{
+ [self willChangeValueForKey:@"serviceName"];
+ [myServiceName autorelease];
+ myServiceName = [newServiceName copy];
+ [self didChangeValueForKey:@"serviceName"];
+
+ return [self modifyAttributeWithTag:kSecServiceItemAttr toBeString:newServiceName];
+}
+@end
+
+@implementation EMInternetKeychainItem
+- (id)initWithCoreKeychainItem:(SecKeychainItemRef)item server:(NSString *)server username:(NSString *)username password:(NSString *)password path:(NSString *)path port:(int)port protocol:(SecProtocolType)protocol
+{
+ if ((self = [super initWithCoreKeychainItem:item username:username password:password]))
+ {
+ [self setValue:server forKey:@"myServer"];
+ [self setValue:path forKey:@"myPath"];
+ [self setValue:[NSNumber numberWithInt:port] forKey:@"myPort"];
+ [self setValue:[NSNumber numberWithInt:protocol] forKey:@"myProtocol"];
+ return self;
+ }
+ return nil;
+}
++ (id)internetKeychainItem:(SecKeychainItemRef)item forServer:(NSString *)server username:(NSString *)username password:(NSString *)password path:(NSString *)path port:(int)port protocol:(SecProtocolType)protocol
+{
+ return [[[EMInternetKeychainItem alloc] initWithCoreKeychainItem:item server:server username:username password:password path:path port:port protocol:protocol] autorelease];
+}
+- (NSString *)server
+{
+ return myServer;
+}
+- (NSString *)path
+{
+ return myPath;
+}
+- (int)port
+{
+ return myPort;
+}
+- (SecProtocolType)protocol
+{
+ return myProtocol;
+}
+
+- (BOOL)setServer:(NSString *)newServer
+{
+ [self willChangeValueForKey:@"server"];
+ [myServer autorelease];
+ myServer = [newServer copy];
+ [self didChangeValueForKey:@"server"];
+
+ return [self modifyAttributeWithTag:kSecServerItemAttr toBeString:newServer];
+}
+- (BOOL)setPath:(NSString *)newPath
+{
+ [self willChangeValueForKey:@"path"];
+ [myPath autorelease];
+ myPath = [newPath copy];
+ [self didChangeValueForKey:@"path"];
+
+ return [self modifyAttributeWithTag:kSecPathItemAttr toBeString:newPath];
+}
+- (BOOL)setPort:(int)newPort
+{
+ [self willChangeValueForKey:@"port"];
+ myPort = newPort;
+ [self didChangeValueForKey:@"port"];
+
+ return [self modifyAttributeWithTag:kSecPortItemAttr toBeString:[NSString stringWithFormat:@"%i", newPort]];
+}
+- (BOOL)setProtocol:(SecProtocolType)newProtocol
+{
+ [self willChangeValueForKey:@"protocol"];
+ myProtocol = newProtocol;
+ [self didChangeValueForKey:@"protocol"];
+
+ SecKeychainAttribute attributes[1];
+ attributes[0].tag = kSecProtocolItemAttr;
+ attributes[0].length = sizeof(newProtocol);
+ attributes[0].data = (void *)newProtocol;
+
+ SecKeychainAttributeList list;
+ list.count = 1;
+ list.attr = attributes;
+
+ OSStatus returnStatus = SecKeychainItemModifyAttributesAndData(coreKeychainItem, &list, 0, NULL);
+ return (returnStatus == noErr);
+}
+@end
@@ -0,0 +1,45 @@
+/*Copyright (c) 2007 Extendmac, LLC. <support@extendmac.com>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+//Last Changed on 2/07/08. Version 0.14
+
+#import <Security/Security.h>
+
+#import "EMKeychainItem.h"
+
+@interface EMKeychainProxy : NSObject {
+ BOOL _logErrors;
+}
++ (id)sharedProxy;
+- (void)lockKeychain;
+- (void)unlockKeychain;
+- (void)setLogsErrors:(BOOL)flag;
+
+- (EMGenericKeychainItem *)genericKeychainItemForService:(NSString *)serviceNameString withUsername:(NSString *)usernameString;
+- (EMInternetKeychainItem *)internetKeychainItemForServer:(NSString *)serverString withUsername:(NSString *)usernameString path:(NSString *)pathString port:(int)port protocol:(SecProtocolType)protocol;
+
+- (EMGenericKeychainItem *)addGenericKeychainItemForService:(NSString *)serviceNameString withUsername:(NSString *)usernameString password:(NSString *)passwordString;
+- (EMInternetKeychainItem *)addInternetKeychainItemForServer:(NSString *)serverString withUsername:(NSString *)usernameString password:(NSString *)passwordString path:(NSString *)pathString port:(int)port protocol:(SecProtocolType)protocol;
+
+@end
Oops, something went wrong.

0 comments on commit 2d29c36

Please sign in to comment.