1//
2//  AppDelegate.m
3//  GSSSampleOSX
4//
5//  Created by Love Hörnquist Åstrand on 2011-11-13.
6//
7
8#import "AppDelegate.h"
9#import <GSS/GSSItem.h>
10
11@implementation AppDelegate
12
13@synthesize window = _window;
14@synthesize tableview = _tableview;
15@synthesize credentials = _credentials;
16@synthesize arrayController = _arrayController;
17
18- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
19{
20	[self refreshCredentials:nil];
21}
22
23- (IBAction)refreshCredentials:(id)sender
24{
25	_credentials = [[NSMutableArray alloc] init];
26	
27	CFMutableDictionaryRef attrs = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
28	
29	CFDictionaryAddValue(attrs, kGSSAttrClass, kGSSAttrClassKerberos);
30	
31	CFErrorRef error = NULL;
32	
33	CFArrayRef items = GSSItemCopyMatching(attrs, &error);
34	if (items) {
35		CFIndex n, count = CFArrayGetCount(items);
36		for (n = 0; n < count; n++) {
37			CFTypeRef item = CFArrayGetValueAtIndex(items, n);
38			NSLog(@"item %d = %@", (int)n, item);
39			
40			NSDictionary *i;
41			
42			i = [(__bridge NSDictionary *)item mutableCopy];
43			[i setValue:@"expire1" forKey:@"kGSSAttrTransientExpire"];
44			NSLog(@"%@ %@", i, [i className]);
45			[_credentials addObject:i];
46		}
47		CFRelease(items);
48	}
49	CFRelease(attrs);
50	
51	[_credentials addObject:@{ @"kGSSAttrNameDisplay" : @"foo", @"kGSSAttrTransientExpire" : @"expire"}];
52	
53	NSLog(@"%@", _credentials);
54	
55	[_arrayController setContent:_credentials];
56	
57	NSLog(@"item %@", [_arrayController valueForKeyPath:@"arrangedObjects.kGSSAttrNameDisplay"]);
58	NSLog(@"item %@", [_arrayController valueForKeyPath:@"arrangedObjects.kGSSAttrTransientExpire"]);
59	
60	[_tableview reloadData];
61	
62	
63}
64@end
65