--- /dev/null
+//
+// AFSCommanderPref.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 10/05/07.
+// Copyright (c) 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <PreferencePanes/PreferencePanes.h>
+#import "AFSPropertyManager.h"
+#import "global.h"
+#import "ViewUtility.h"
+#import "LynkCreationController.h"
+
+// the way to load and unload the menuextra was inspired by MenuMeters developed by Alex Harper
+// Routines to handle adding and remove menu extras in HIServices (from ASM source)
+int CoreMenuExtraGetMenuExtra(CFStringRef identifier, void *menuExtra);
+int CoreMenuExtraAddMenuExtra(CFURLRef path, int position, int whoCares, int whoCares2, int whoCares3, int whoCares4);
+int CoreMenuExtraRemoveMenuExtra(void *menuExtra, int whoCares);
+
+
+
+@interface AFSCommanderPref : NSPreferencePane
+{
+ //for check system version
+ int prefStartUp;
+ // Main View
+ IBOutlet NSView *afsCommanderView;
+ IBOutlet NSSearchField *textSearchField;
+ IBOutlet NSTextField *afsDefaultCellLabel;
+ IBOutlet NSButton *tokensButton;
+ IBOutlet NSButton *unlogButton;
+ IBOutlet NSButton *aklogCredentialAtLoginTime;
+ IBOutlet NSButton *installKRB5AuthAtLoginButton;
+ IBOutlet NSButton *useAklogCheck;
+ IBOutlet NSTextField *afsVersionLabel;
+ BOOL startAFSAtLogin;
+ IBOutlet NSButton *checkButtonAfsAtBootTime;
+ IBOutlet NSTextField *textFieldDevInfoLabel;
+
+ //NSString *appID;
+ //id installationPathTextField;
+ id startStopButton;
+ id cellList;
+ //id cellNameTextEdit;
+ id cellIpButton;
+ id addCellButton;
+ id removeCellButton;
+ //id refreshConfigurationButton;
+ id saveConfigurationButton;
+ id labelSaveResult;
+ id tokensTable;
+ id afsMenucheckBox;
+
+ //cache manager IBOutlet
+ IBOutlet NSTextField *statCacheEntry;
+ IBOutlet NSTextField *dCacheDim;
+ IBOutlet NSTextField *cacheDimension;
+ IBOutlet NSTextField *daemonNumber;
+ IBOutlet NSTextField *afsRootMountPoint;
+ IBOutlet NSTextField *nVolEntry;
+ IBOutlet NSButton *dynRoot;
+ IBOutlet NSButton *afsDB;
+ IBOutlet NSButton *verbose;
+ IBOutlet NSBox *groupsBox;
+
+ //Configuration sheet
+ id ipConfigurationSheet;
+ id ipConfControllerCommander;
+
+ //Token sheet
+ id credentialSheet;
+ id credentialCommander;
+
+
+ //Info Sheet
+ id infoSheet;
+ id infoController;
+
+ //lynk creation
+ id lyncCreationSheet;
+ IBOutlet LynkCreationController *lynkCreationController;
+
+ //manage link
+ IBOutlet NSButton *checkEnableLink;
+ IBOutlet NSButton *buttonAddLink;
+ IBOutlet NSButton *buttonRemoveLink;
+ bool enableLink;
+
+ AFSPropertyManager *afsProperty; //AFS Property managment class
+ NSMutableArray *filteredCellDB; //Filtered CellServDB
+ NSArray *tokenList;
+ NSTimer *timerForCheckTokensList;
+ NSLock *tokensLock;
+}
+
+- (void) mainViewDidLoad;
+- (void) willUnselect;
+- (void) didSelect;
+- (id) initWithBundle:(NSBundle *)bundle;
+- (void)startTimer;
+- (void)stopTimer;
+//View Action
+- (IBAction) refreshConfiguration:(id) sender;
+- (void) fillCacheParamView;
+- (void) updateCacheParamFromView;
+- (IBAction) showCellIP:(id) sender;
+- (IBAction) addRemoveCell:(id) sender;
+- (IBAction) addLink:(id) sender;
+- (IBAction) removeLink:(id) sender;
+- (IBAction) enableLink:(id) sender;
+- (IBAction) saveConfiguration:(id) sender;
+- (IBAction) saveCacheManagerParam:(id) sender;
+- (IBAction) startStopAfs:(id) sender;
+- (IBAction) info:(id) sender;
+- (IBAction) tableDoubleAction:(id) sender;
+- (IBAction) getNewToken:(id) sender;
+- (IBAction) unlog:(id) sender;
+- (IBAction) afsMenuActivationEvent:(id) sender;
+- (IBAction) aklogSwitchEvent:(id) sender;
+- (IBAction) credentialAtLoginTimeEvent:(id) sender;
+- (IBAction) afsStartupSwitchEvent:(id) sender;
+- (void) credentialAtLoginTimeEventCreationLaunchAgentDir:(NSWindow*)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
+- (IBAction) krb5KredentialAtLoginTimeEvent:(id) sender;
+- (IBAction) searchCellTextEvent:(id) sender;
+- (void) clearCellServDBFiltering;
+- (void) filterCellServDB:(NSString*)textToFilter;
+- (DBCellElement*) getCurrentCellInDB;
+- (DBCellElement*) getCellByIDX:(int) idx;
+- (void) modifyCell:(DBCellElement*) cellElement;
+- (void) modifyCellByIDX:(int) idx;
+- (void) showMessage:(NSString*) message;
+- (void) manageButtonState:(int) rowSelected;
+- (void) setAfsStatus;
+- (void) refreshTokens:(NSTimer*)theTimer;
+- (BOOL) isAFSMenuExtraLoaded;
+- (void) addAFSMenuExtra;
+- (void) removeAFSMenuExtra;
+- (void) repairHelperTool;
+- (void) writePreferenceFile;
+- (void) readPreferenceFile;
+- (void) mextraChangeActivation:(NSNotification *)notification;
+- (void) refreshGui:(NSNotification *)notification;
+- (void) afsVolumeMountChange:(NSNotification *)notification;
+@end
\ No newline at end of file
--- /dev/null
+//
+// AFSCommanderPref.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 10/05/07.
+// Copyright (c) 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "AFSCommanderPref.h"
+#import "IpConfiguratorCommander.h"
+#import "TokenCredentialController.h"
+#import "InfoController.h"
+#import "TaskUtil.h"
+#import "PListManager.h"
+#import "DialogUtility.h"
+#import "NSString+search.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#import <CoreServices/CoreServices.h>
+
+
+#define ADD_CELL_CONTROL_TAG 1
+#define REMOVE_CELL_CONTROL_TAG 2
+
+#define TABLE_TOKENS_LIST 1
+#define TABLE_CELL_LIST 2
+
+#define TAB_TOKENS 1
+#define TAB_CELL_SERV_DB 2
+#define TAB_CACHE 3
+#define TAB_GROUP 4
+
+//CellServDB table id
+#define CELLSRVDB_TABLE_USR_DFLT_CHECK_COLUMN 0
+#define CELLSRVDB_TABLE_DFLT_CHECK_COLUMN 1
+#define CELLSRVDB_TABLE_NAME_COLUMN 2
+#define CELLSRVDB_TABLE_DESCRIPTION_COLUMN 3
+
+@implementation AFSCommanderPref
+
+// -------------------------------------------------------------------------------
+// initWithBundle:
+// -------------------------------------------------------------------------------
+- (id)initWithBundle:(NSBundle *)bundle
+{
+ if ( ( self = [super initWithBundle:bundle] ) != nil ) {
+ //appID = afsCommanderID;
+ prefStartUp = 1;
+ }
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// mainView:
+// -------------------------------------------------------------------------------
+- (NSView *) mainView {
+ if (prefStartUp == 1){
+ SInt32 osxMJVers = 0;
+ SInt32 osxMnVers = 0;
+ if (Gestalt(gestaltSystemVersionMajor, &osxMJVers) == noErr && Gestalt(gestaltSystemVersionMinor, &osxMnVers) == noErr) {
+ if (osxMJVers == 10 && osxMnVers>= 5) {
+ // we are working on leopard
+ NSLog(@"Leopard AFSCommander adapting");
+ [afsCommanderView setFrameSize:NSMakeSize(668, [afsCommanderView frame].size.height)];
+ prefStartUp = 0;
+ }
+ }
+ }
+
+ return afsCommanderView;
+}
+
+// -------------------------------------------------------------------------------
+// mainViewDidLoad:
+// -------------------------------------------------------------------------------
+- (void) mainViewDidLoad
+{
+ //CellServDB Table
+ [((NSTableView*)cellList) setDelegate:self];
+ [((NSTableView*)cellList) setTarget:self];
+ [((NSTableView*)cellList) setDoubleAction:@selector(tableDoubleAction:)];
+
+
+}
+
+// -------------------------------------------------------------------------------
+// didSelect:
+// -------------------------------------------------------------------------------
+- (void) didSelect
+{
+ // Set Developer info
+ [textFieldDevInfoLabel setStringValue:kDevelopInfo];
+ // creating the lock
+ tokensLock = [[NSLock alloc] init];
+
+ //Initialization cellservdb and token list
+ filteredCellDB = nil;
+ tokenList = nil;
+
+ [self readPreferenceFile];
+
+ // alloc the afs property mananger
+ afsProperty = [[AFSPropertyManager alloc] init];
+
+ // register preference pane to detect menuextra killed by user
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(mextraChangeActivation:)
+ name:afsCommanderID
+ object:kMExtraClosedNotification];
+
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(refreshGui:)
+ name:afsCommanderID
+ object:kMenuExtraEventOccured];
+
+ //Register for mount/unmount afs volume
+ [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
+ selector:@selector(afsVolumeMountChange:)
+ name:NSWorkspaceDidMountNotification object:nil];
+
+ [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
+ selector:@selector(afsVolumeMountChange:)
+ name:NSWorkspaceDidUnmountNotification object:nil];
+
+ // set self as table data source
+ [((NSTableView*)cellList) setDataSource:self];
+ [((NSTableView*)tokensTable) setDataSource:self];
+
+ //check the afs state
+ [self setAfsStatus];
+
+ // check the MenuExtra state
+ [self mextraChangeActivation:nil];
+
+ // let show the configuration after prefpane is open
+ [self refreshConfiguration:nil];
+
+ // refresh the token list
+ //[self refreshTokens:nil];
+
+ //refresh table to reflect the NSSearchField contained text
+ [self searchCellTextEvent:nil];
+}
+
+// -------------------------------------------------------------------------------
+// willUnselect:
+// -------------------------------------------------------------------------------
+- (void)willUnselect
+{
+ NSLog(@"willUnselect");
+ // remove self as datasource
+ [((NSTableView*)cellList) setDataSource:nil];
+ [((NSTableView*)tokensTable) setDataSource:nil];
+
+ //release the afs property manager
+ if(afsProperty) [afsProperty release];
+ //release tokens list
+ if(tokenList) [tokenList release];
+ //Remove the cell temp array
+ if(filteredCellDB) [filteredCellDB release];
+
+ [self writePreferenceFile];
+
+ // unregister preference pane to detect menuextra killed by user
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self
+ name:afsCommanderID
+ object:kMExtraClosedNotification];
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self
+ name:afsCommanderID
+ object:kMenuExtraEventOccured];
+ [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self
+ name:NSWorkspaceDidMountNotification object:nil];
+ [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self
+ name:NSWorkspaceDidUnmountNotification object:nil];
+
+ [self stopTimer];
+ [tokensLock release];
+}
+
+
+// -------------------------------------------------------------------------------
+// startTimer:
+// -------------------------------------------------------------------------------
+- (void)startTimer{
+ //start the time for check tokens validity
+ if(timerForCheckTokensList) return;
+ timerForCheckTokensList = [NSTimer scheduledTimerWithTimeInterval:TOKENS_REFRESH_TIME_IN_SEC
+ target:self
+ selector:@selector(refreshTokens:)
+ userInfo:nil
+ repeats:YES];
+ [timerForCheckTokensList fire];
+}
+
+// -------------------------------------------------------------------------------
+// stopTimer:
+// -------------------------------------------------------------------------------
+- (void)stopTimer{
+ if(!timerForCheckTokensList) return;
+ [timerForCheckTokensList invalidate];
+ timerForCheckTokensList = nil;
+}
+
+
+// -------------------------------------------------------------------------------
+// readPreferenceFile:
+// -------------------------------------------------------------------------------
+- (void) readPreferenceFile
+{
+
+ // read the preference for afs path
+ //NSString *afsSysPath = PREFERENCE_AFS_SYS_PAT_STATIC;/*(NSString*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_AFS_SYS_PAT, (CFStringRef)afsCommanderID,
+ // kCFPreferencesAnyUser, kCFPreferencesAnyHost);*/
+ /*if(afsSysPath){
+ [((NSTextField*) installationPathTextField ) setStringValue:afsSysPath];
+ }*/
+
+ // read the preference for aklog use
+ NSNumber *useAklogPrefValue = (NSNumber*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_USE_AKLOG, (CFStringRef)afsCommanderID,
+ kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+ if(useAklogPrefValue){
+ [useAklogCheck setState:[useAklogPrefValue intValue]];
+ [aklogCredentialAtLoginTime setEnabled:[useAklogPrefValue intValue]];
+ } else {
+ [useAklogCheck setState:NSOffState];
+ [aklogCredentialAtLoginTime setEnabled:NSOffState];
+ [aklogCredentialAtLoginTime setState:NSOffState];
+ [PListManager installLaunchdFile:NO
+ resourcePath:nil];
+ }
+
+ //check if krb5 at startup is enable at system level
+ [installKRB5AuthAtLoginButton setState:[PListManager checkKrb5AtLoginTimeLaunchdEnable]];
+
+ //check if the user has installed and enabled the afs agent
+ [aklogCredentialAtLoginTime setState:[PListManager checkAklogAtLoginTimeLaunchdEnable]];
+
+ //check for AFS enable at startup
+ NSNumber *afsEnableStartupTime = (NSNumber*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_START_AFS_AT_STARTUP,
+ (CFStringRef)afsCommanderID, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+ if(afsEnableStartupTime)
+ startAFSAtLogin = [afsEnableStartupTime boolValue];
+ else
+ startAFSAtLogin = false;
+ //set the check button state
+ [checkButtonAfsAtBootTime setState:startAFSAtLogin];
+}
+
+// -------------------------------------------------------------------------------
+// willUnselect:
+// -------------------------------------------------------------------------------
+- (void) writePreferenceFile
+{
+ //Set the preference for afs path
+ /*CFPreferencesSetValue((CFStringRef)PREFERENCE_AFS_SYS_PAT,
+ (CFStringRef)[((NSTextField*) installationPathTextField ) stringValue],
+ (CFStringRef)afsCommanderID, kCFPreferencesAnyUser, kCFPreferencesAnyHost);*/
+
+ //Set the preference for aklog use
+ CFPreferencesSetValue((CFStringRef)PREFERENCE_USE_AKLOG,
+ (CFNumberRef)[NSNumber numberWithInt:[useAklogCheck state]],
+ (CFStringRef)afsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+
+ // Notify
+ if ([self isAFSMenuExtraLoaded]) [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kPrefChangeNotification];
+
+ //set AFS enable state at startup
+ CFPreferencesSetValue((CFStringRef)PREFERENCE_START_AFS_AT_STARTUP,
+ (CFNumberRef)[NSNumber numberWithBool:startAFSAtLogin],
+ (CFStringRef)afsCommanderID, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+
+ CFPreferencesSynchronize((CFStringRef)afsCommanderID, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+ CFPreferencesSynchronize((CFStringRef)afsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+}
+
+// -------------------------------------------------------------------------------
+// saveConfiguration:
+// -------------------------------------------------------------------------------
+- (IBAction) saveConfiguration:(id) sender
+{
+ @try{
+
+ //[afsProperty setCellName:[cellNameTextEdit stringValue]];
+ [afsProperty setCellName:[afsProperty getDefaultCellName]];
+
+ //save configurations
+ [afsProperty saveConfigurationFiles:YES];
+
+
+ //Reload all configuration
+ [self refreshConfiguration:nil];
+
+ //refresh table to reflect the NSSearchField contained text
+ [self searchCellTextEvent:nil];
+
+ //Show dialog for notifity al saving process ar gone ell
+ [self showMessage:kConfigurationSaved];
+ }@catch(NSException *e){
+ [self showMessage:[e reason]];
+ } @finally {
+ [((NSTableView*)cellList) reloadData];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// saveCacheManagerParam:
+// -------------------------------------------------------------------------------
+- (IBAction) saveCacheManagerParam:(id) sender
+{
+ @try{
+ NSLog(@"Backing up the cache configuration file");
+ //Update the value form view to afs property manager class
+ [self updateCacheParamFromView];
+ [afsProperty saveCacheConfigurationFiles:YES];
+ NSLog(@"Cache configuration file backuped");
+ [self showMessage:kSavedCacheConfiguration];
+ }@catch(NSException *e){
+ [self showMessage:[e reason]];
+ } @finally {
+ [((NSTableView*)cellList) reloadData];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// refreshConfiguration:
+// -------------------------------------------------------------------------------
+- (IBAction) refreshConfiguration:(id) sender
+{
+ NSLog(@"refreshConfiguration");
+ NSString *afsBasePath = PREFERENCE_AFS_SYS_PAT_STATIC;
+
+ @try{
+ // set the afs path
+ [afsProperty setPath:afsBasePath];
+
+ // load configuration
+ [afsProperty loadConfiguration];
+
+ //set the afs version label
+ [afsVersionLabel setStringValue:[afsProperty getAfsVersion]];
+
+ //set the current default cell
+ [afsDefaultCellLabel setStringValue:[afsProperty getDefaultCellName]];
+
+ // Update cache view
+ [self fillCacheParamView];
+
+ //Filter the cellServDb and allocate filtered array
+ [self filterCellServDB:nil];
+
+ }@catch(NSException *e){
+ [self showMessage:[e reason]];
+ } @finally {
+ [((NSTableView*)cellList) reloadData];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// fillCacheParamView:
+// -------------------------------------------------------------------------------
+-(void) fillCacheParamView
+{
+ [dynRoot setState:[afsProperty dynRoot]?NSOnState:NSOffState];
+ [afsDB setState:[afsProperty afsDB]?NSOnState:NSOffState];
+ [statCacheEntry setIntValue:[afsProperty statCacheEntry]];
+ [dCacheDim setIntValue:[afsProperty dCacheDim]];
+ [cacheDimension setIntValue:[afsProperty cacheDimension]];
+ [daemonNumber setIntValue:[afsProperty daemonNumber]];
+ [afsRootMountPoint setStringValue:[afsProperty afsRootMountPoint]];
+ [nVolEntry setIntValue:[afsProperty nVolEntry]];
+
+ //new version property
+ //[verbose setEnabled:[afsProperty useAfsdConfConfigFile]];
+ [verbose setState:[afsProperty verbose]?NSOnState:NSOffState];
+
+}
+
+// -------------------------------------------------------------------------------
+// updateCacheParamFromView:
+// -------------------------------------------------------------------------------
+-(void) updateCacheParamFromView
+{
+ NSString *tmpAfsPath = [afsRootMountPoint stringValue];
+ if(!tmpAfsPath || ([tmpAfsPath length] == 0) || ([tmpAfsPath characterAtIndex:0] != '/'))
+ @throw [NSException exceptionWithName:@"updateCacheParamFromView"
+ reason:kBadAfsRootMountPoint
+ userInfo:nil];
+
+
+ [afsProperty setDynRoot:[dynRoot state]==NSOnState];
+ [afsProperty setAfsDB:[afsDB state]==NSOnState];
+ [afsProperty setStatCacheEntry:[statCacheEntry intValue]];
+ [afsProperty setDCacheDim:[dCacheDim intValue]];
+ [afsProperty setCacheDimension:[cacheDimension intValue]];
+ [afsProperty setDaemonNumber:[daemonNumber intValue]];
+ [afsProperty setAfsRootMountPoint:tmpAfsPath];
+ [afsProperty setNVolEntry:[nVolEntry intValue]];
+ [afsProperty setVerbose:[verbose state]==NSOnState];
+}
+
+
+// -------------------------------------------------------------------------------
+// showCellIP:
+// -------------------------------------------------------------------------------
+- (IBAction) showCellIP:(id) sender
+{
+ int rowSelected = [((NSTableView *) cellList) selectedRow];
+ [self modifyCellByIDX:rowSelected];
+}
+
+// -------------------------------------------------------------------------------
+// modifyCellByIDX:
+// -------------------------------------------------------------------------------
+-(void) modifyCellByIDX:(int) idx
+{
+ [self modifyCell:[self getCellByIDX:idx]];
+}
+
+// -------------------------------------------------------------------------------
+// modifyCellByIDX:
+// -------------------------------------------------------------------------------
+-(void) modifyCell:(DBCellElement*) cellElement
+{
+ [NSBundle loadNibNamed:@"IpPanel" owner:self];
+ [((IpConfiguratorCommander*) ipConfControllerCommander) setWorkCell:cellElement];
+ [NSApp beginSheet: ipConfigurationSheet
+ modalForWindow: [[self mainView] window]
+ modalDelegate: self
+ didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
+ contextInfo: nil];
+}
+
+// -------------------------------------------------------------------------------
+// addMoifyCell:
+// -------------------------------------------------------------------------------
+- (IBAction) addRemoveCell:(id) sender
+{
+ switch([((NSControl*) sender) tag]){
+ case ADD_CELL_CONTROL_TAG:
+ {
+ DBCellElement *newCell = [[DBCellElement alloc] init];
+ if(!newCell) break;
+
+ [newCell setCellName:kNewCellName];
+ [newCell setCellComment:kNewCellComment];
+ //cellArray = ;
+ [[afsProperty getCellList] addObject:newCell];
+ [newCell release];
+
+ //Modify new cell
+ [self modifyCell:newCell];
+ }
+ break;
+
+ case REMOVE_CELL_CONTROL_TAG:
+ {
+ int index = 0;
+ NSIndexSet *selectedIndex = [(NSTableView*)cellList selectedRowIndexes];
+ if( [selectedIndex count] > 0) {
+ index = [selectedIndex firstIndex];
+ do {
+ DBCellElement *cellElement = (DBCellElement*)[filteredCellDB objectAtIndex:index];
+ [[afsProperty getCellList] removeObject:cellElement];
+ } while ((index = [selectedIndex indexGreaterThanIndex: index]) != NSNotFound);
+ }
+ }
+ break;
+ }
+ //Filter the cellServDb and allocate filtered array
+ [self searchCellTextEvent:nil];
+ [(NSTableView*)cellList deselectAll:nil];
+ [(NSTableView*)cellList reloadData];
+}
+
+// -------------------------------------------------------------------------------
+// repairHelperTool:
+// -------------------------------------------------------------------------------
+- (void) repairHelperTool
+{
+ struct stat st;
+ int fdTool;
+ int status = 0;
+ NSLog(@"repairHelperTool");
+ NSString *afshlpPath = [[self bundle] pathForResource:@"afshlp" ofType:nil];
+
+
+
+ // Open tool exclusively, so nobody can change it while we bless it.
+ fdTool = open([afshlpPath UTF8String], O_NONBLOCK | O_RDONLY | O_EXLOCK, 0);
+
+ if(fdTool == -1)
+ {
+ NSLog(@"Exclusive open while repairing tool failed: %d.", errno);
+ exit(-1);
+ }
+
+ if(fstat(fdTool, &st))
+ {
+ NSLog(@"fstat failed.");
+ exit(-1);
+ }
+
+ if(st.st_uid != 0)
+ {
+ status = [[AuthUtil shared] autorize];
+ if(status == noErr){
+ fchown(fdTool, 0, st.st_gid);
+
+ // Disable group and world writability and make setuid root.
+ fchmod(fdTool, (st.st_mode & (~(S_IWGRP | S_IWOTH)))/* | S_ISUID*/);
+ const char *args[] = {"root", [afshlpPath UTF8String],0L};
+ [[AuthUtil shared] execUnixCommand:"/usr/sbin/chown"
+ args:args
+ output:nil];
+ [[AuthUtil shared] deautorize];
+ }
+ } else NSLog(@"st_uid = 0");
+
+
+
+ close(fdTool);
+
+ NSLog(@"Self-repair done.");
+
+}
+
+
+// -------------------------------------------------------------------------------
+// startStopAfs:
+// -------------------------------------------------------------------------------
+- (IBAction) startStopAfs:(id) sender
+{
+ OSStatus status = noErr;
+ NSString *afsdPath = [TaskUtil searchExecutablePath:@"afsd"];
+ //NSString *startStopScript = nil;
+ NSString *rootHelperApp = nil;
+ BOOL currentAfsState = NO;
+
+ @try {
+ if(afsdPath == nil) return;
+ currentAfsState = [afsProperty checkAfsStatus];
+ rootHelperApp = [[self bundle] pathForResource:@"afshlp" ofType:@""];
+
+ //[startStopScript setString: resourcePath];
+ NSLog(@"Launch repair HelperTool");
+ //Check helper app
+ [self repairHelperTool];
+
+ // make the parameter to call the root helper app
+ status = [[AuthUtil shared] autorize];
+ if(status == noErr){
+ if(currentAfsState){
+ //shutdown afs
+ NSLog(@"Shutting down afs");
+ NSMutableString *afsKextPath = [[NSMutableString alloc] initWithCapacity:256];
+ [afsKextPath setString:[afsProperty path]];
+ [afsKextPath appendString:@"/etc/afs.kext"];
+
+ //Make the array for arguments
+ NSLog(@"executeTaskWithAuth");
+ const char *stopAfsArgs[] = {"stop_afs", [afsKextPath UTF8String], [afsdPath UTF8String], 0L};
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:stopAfsArgs
+ output:nil];
+
+ } else {
+ NSLog(@"Starting up afs");
+ const char *startAfsArgs[] = {[[[self bundle] pathForResource:@"start_afs" ofType:@"sh"] UTF8String], [[afsProperty path] UTF8String], [afsdPath UTF8String], 0L};
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:startAfsArgs
+ output:nil];
+ }
+ }
+ [self refreshGui:nil];
+ }
+ @catch (NSException * e) {
+ [self showMessage:[e reason]];
+ }
+ @finally {
+ [[AuthUtil shared] deautorize];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// info:
+// -------------------------------------------------------------------------------
+- (void) refreshGui:(NSNotification *)notification{
+ BOOL afsIsUp = [afsProperty checkAfsStatus];
+ [self setAfsStatus];
+ //[self refreshTokens:nil];
+ [tokensButton setEnabled:afsIsUp];
+ [unlogButton setEnabled:afsIsUp];
+}
+
+// -------------------------------------------------------------------------------
+// afsVolumeMountChange: Track the afs volume state change
+// -------------------------------------------------------------------------------
+- (void) afsVolumeMountChange:(NSNotification *)notification{
+ // Cehck if is mounted or unmounted afs
+ if([[[notification userInfo] objectForKey:@"NSDevicePath"] isEqualToString:@"/afs"]){
+ [self setAfsStatus];
+ [self refreshTokens:nil];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// info:
+// -------------------------------------------------------------------------------
+- (IBAction) info:(id) sender
+{
+ //NSLog(kDevelopInfo);
+ //[self showMessage:kDevelopInfo];
+ [((InfoController*) infoController) showHtmlResource:[[self bundle] pathForResource:@"licenza" ofType:@"rtf"]];
+
+ [NSApp beginSheet: infoSheet
+ modalForWindow: [[self mainView] window]
+ modalDelegate: self
+ didEndSelector: @selector(didEndInfoSheet:returnCode:contextInfo:)
+ contextInfo: nil];
+}
+
+// -------------------------------------------------------------------------------
+// tableDoubleAction:
+// -------------------------------------------------------------------------------
+- (IBAction) tableDoubleAction:(id) sender
+{
+ [self showCellIP:nil];
+}
+
+// -------------------------------------------------------------------------------
+// getNewToken:
+// -------------------------------------------------------------------------------
+- (IBAction) getNewToken:(id) sender
+{
+ BOOL useAklog = [useAklogCheck state] == NSOnState;
+ if(useAklog){
+ //[AFSPropertyManager aklog];
+ [afsProperty getTokens:false
+ usr:nil
+ pwd:nil];
+ [self refreshTokens:nil];
+ //Inform afs menuextra to updata afs status
+ if ([self isAFSMenuExtraLoaded]) [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kMExtraAFSStateChange];
+
+ } else {
+ [NSBundle loadNibNamed:@"CredentialPanel" owner:self];
+ [NSApp beginSheet: credentialSheet
+ modalForWindow: [[self mainView] window]
+ modalDelegate: self
+ didEndSelector: @selector(didEndCredentialSheet:returnCode:contextInfo:)
+ contextInfo: nil];
+ }
+}
+
+
+// -------------------------------------------------------------------------------
+// getCurrentCellInDB:
+// -------------------------------------------------------------------------------
+- (IBAction) unlog:(id) sender
+{
+ int index = -1;
+ NSIndexSet *selectedIndex = [(NSTableView*)tokensTable selectedRowIndexes];
+ if( [selectedIndex count] > 0) {
+ index = [selectedIndex firstIndex];
+ do {
+ NSString *tokenDesc = [tokenList objectAtIndex:index];
+ NSString *cellToUnlog = [tokenDesc estractTokenByDelimiter:@"afs@"
+ endToken:@" "];
+ [afsProperty unlog:cellToUnlog];
+ } while ((index = [selectedIndex indexGreaterThanIndex: index]) != NSNotFound);
+ } else {
+ [afsProperty unlog:nil];
+ }
+ [self refreshTokens:nil];
+ //Inform afs menuextra to updata afs status
+ if ([self isAFSMenuExtraLoaded]) [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kMExtraAFSStateChange];
+
+}
+
+
+// -------------------------------------------------------------------------------
+// aklogSwitchEvent:
+// -------------------------------------------------------------------------------
+- (IBAction) aklogSwitchEvent:(id) sender
+{
+ //afs menu extra is loaded inform it to read preference
+ @try {
+ if(![useAklogCheck state]) {
+ //Remove launchd ctrl file
+ [PListManager installLaunchdFile:NO resourcePath:[[self bundle] resourcePath]];
+
+ //deselect the checkbox
+ [aklogCredentialAtLoginTime setState:NO];
+ }
+
+ [self writePreferenceFile];
+
+ //Enable disable aklog at login time checkbox according the useAklog checkbox
+ [aklogCredentialAtLoginTime setEnabled:[useAklogCheck state]];
+
+ }
+ @catch (NSException * e) {
+ [self showMessage:[e reason]];
+ }
+
+
+}
+
+
+// -------------------------------------------------------------------------------
+// credentialAtLoginTimeEvent:
+// -------------------------------------------------------------------------------
+- (IBAction) credentialAtLoginTimeEvent:(id) sender {
+ @try {
+ [PListManager installLaunchdFile:[aklogCredentialAtLoginTime state]
+ resourcePath:[[self bundle] resourcePath]];
+
+
+
+ }
+ @catch (NSException * e) {
+ if([e userInfo] != nil && [[e userInfo] isKindOfClass:[NSNumber class]]) {
+ if([((NSNumber*)[e userInfo]) intValue] == 1) {
+ // the dir HOME_LAUNCHD_AGENT_FOLDER (PListManager.h) must be created
+ NSBeginAlertSheet([[NSString stringWithString:kDoYouWantCreateTheDirectory] stringByAppendingString:HOME_LAUNCHD_AGENT_FOLDER],
+ @"Create", @"Cancel", nil,
+ [[self mainView] window], self, @selector(credentialAtLoginTimeEventCreationLaunchAgentDir:returnCode:contextInfo:), NULL,
+ nil, @"", nil);
+ }
+ } else {
+ [self showMessage:[e reason]];
+ }
+ }
+ @finally {
+ [aklogCredentialAtLoginTime setState:[PListManager checkAklogAtLoginTimeLaunchdEnable]];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// afsStartupSwitchEvent:
+// -------------------------------------------------------------------------------
+- (IBAction) afsStartupSwitchEvent:(id) sender {
+ NSString *rootHelperApp = [[self bundle] pathForResource:@"afshlp" ofType:@""];
+ //get the new state
+ NSString *afsdPath = [TaskUtil searchExecutablePath:@"afsd"];
+ NSString *afsStartupScriptPath = [[self bundle] pathForResource:@"start_afs" ofType:@"sh"];
+ startAFSAtLogin = [checkButtonAfsAtBootTime state];
+ const char *startAfsArgs[] = {"load", "-w", [AFS_STARTUP_CONTROL_FILE UTF8String], 0L};
+ const char *stopAfsArgs[] = {"unload", "-w", [AFS_STARTUP_CONTROL_FILE UTF8String], 0L};
+ const char *launchctlExecutable = "/bin/launchctl";
+ /* [PListManager manageAfsStartupLaunchdFile:startAFSAtLogin
+ afsStartupScript:afsStartupScriptPath
+ afsBasePath:[afsProperty path] afsdPath:afsdPath];
+ */
+ const char *startupConfigureOption[] = {"start_afs_at_startup", [afsStartupScriptPath UTF8String], [afsdPath UTF8String], [[afsProperty path] UTF8String], 0L};
+ if([[AuthUtil shared] autorize] == noErr) {
+ if(startAFSAtLogin) {
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:startupConfigureOption
+ output:nil];
+
+ [[AuthUtil shared] execUnixCommand:launchctlExecutable
+ args:startAfsArgs
+ output:nil];
+ } else {
+ //now disable the launchd configuration
+ [[AuthUtil shared] execUnixCommand:launchctlExecutable
+ args:stopAfsArgs
+ output:nil];
+ }
+ }
+}
+
+// -------------------------------------------------------------------------------
+// credentialAtLoginTimeEventCreationLaunchAgentDir:
+// -------------------------------------------------------------------------------
+- (void) credentialAtLoginTimeEventCreationLaunchAgentDir:(NSWindow*)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo {
+ [alert close];
+ switch (returnCode) {
+ case 1:
+ NSLog(@"Yes");
+ if([[NSFileManager defaultManager] createDirectoryAtPath:[HOME_LAUNCHD_AGENT_FOLDER stringByExpandingTildeInPath]
+ attributes:nil]) {
+
+ //Create the file
+ [PListManager installLaunchdFile:YES
+ resourcePath:[[self bundle] resourcePath]];
+
+ //refresh the check box
+ [aklogCredentialAtLoginTime setState:[PListManager checkAklogAtLoginTimeLaunchdEnable]];
+ [self showMessage:kDirectoryCreated];
+ } else {
+ [self showMessage:kErrorCreatingDirectory];
+ }
+ break;
+ case 0:
+ NSLog(@"No");
+
+ break;
+ }
+}
+
+// -------------------------------------------------------------------------------
+// afsMenuActivationEvent:
+// -------------------------------------------------------------------------------
+- (IBAction) krb5KredentialAtLoginTimeEvent:(id) sender {
+ //
+ NSString *rootHelperApp = [[self bundle] pathForResource:@"afshlp" ofType:@""];
+ const char *args[] = {"enable_krb5_startup", [[installKRB5AuthAtLoginButton stringValue] UTF8String], "", 0L};
+
+ //Check helper app
+ [self repairHelperTool];
+ if([[AuthUtil shared] autorize] == noErr) {
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:args
+ output:nil];
+
+ //check if all is gone well
+ [installKRB5AuthAtLoginButton setState:[PListManager checkKrb5AtLoginTimeLaunchdEnable]];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// afsMenuActivationEvent:
+// -------------------------------------------------------------------------------
+-(IBAction) afsMenuActivationEvent:(id) sender
+{
+ if([(NSButton*)afsMenucheckBox state] == NSOffState){
+ // must remove the menu
+ [self removeAFSMenuExtra];
+ } else {
+ // must add the menu
+ [self addAFSMenuExtra];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// searchCellTextEvent:
+// Fileter the CellServDB list according to NSSearch content
+// -------------------------------------------------------------------------------
+- (IBAction) searchCellTextEvent:(id) sender
+{
+
+ NSString *searchText = [[textSearchField stringValue] lowercaseString]; //filter string
+ [self filterCellServDB:searchText];
+ [((NSTableView*)cellList) reloadData];
+}
+
+// -------------------------------------------------------------------------------
+// clearCellServDBFiltering:
+// clear the NSSearchField and showw all CellServDB table
+// -------------------------------------------------------------------------------
+- (void) clearCellServDBFiltering {
+ //Clear the text search
+ [textSearchField setStringValue:@""];
+ //load the temp array with all cell servdb
+ [self searchCellTextEvent:nil];
+}
+// --------------------------------------o-----------------------------------------
+// filterCellServDB:
+// make the NSMutableArray with all cellservdb or filtered element
+// -------------------------------------------------------------------------------
+- (void) filterCellServDB:(NSString*)textToFilter {
+ DBCellElement *cellElement; //Filtered element
+ BOOL doFilter = !(textToFilter == nil || ([textToFilter length] == 0));
+
+ // We can do filtering and make the temp array
+ if(filteredCellDB){
+ [filteredCellDB release];
+ }
+ filteredCellDB = [[NSMutableArray alloc] init];
+ NSEnumerator *e = [[afsProperty getCellList] objectEnumerator];
+ while(cellElement = (DBCellElement*)[e nextObject]) {
+ // check if the element can be get
+ if(doFilter) {
+ //Get the CellServDB array enumerator
+ //NSLog(@"String for filtering: %s", [textToFilter UTF8String]);
+ NSRange rsltRng = [[[cellElement getCellName] lowercaseString] rangeOfString:textToFilter];
+ if(rsltRng.location != NSNotFound) {
+ //we can add this cell to filtered
+ //NSLog(@"Element found during filter: %s", [[cellElement getCellName] UTF8String]);
+ [filteredCellDB addObject:[cellElement retain]];
+ }
+ } else {
+ [filteredCellDB addObject:[cellElement retain]];
+
+ }
+ }
+}
+
+// -------------------------------------------------------------------------------
+// getCurrentCellInDB:
+// -------------------------------------------------------------------------------
+- (DBCellElement*) getCurrentCellInDB
+{
+ int rowSelected = [((NSTableView *) cellList) selectedRow];
+ return [self getCellByIDX:rowSelected];
+}
+
+// -------------------------------------------------------------------------------
+// getCurrentCellInDB:
+// -------------------------------------------------------------------------------
+- (DBCellElement*) getCellByIDX:(int) idx
+{
+ //NSMutableArray *cellArray = [afsProperty getCellList];
+ DBCellElement *cellElement = (DBCellElement*)[filteredCellDB objectAtIndex:idx];
+ return cellElement;
+}
+
+// -------------------------------------------------------------------------------
+// showMessage:
+// -------------------------------------------------------------------------------
+-(void) showMessage:(NSString*) message{
+ NSAlert *alert = [[NSAlert alloc] init];
+
+ [alert setMessageText:message];
+ [alert beginSheetModalForWindow:[[self mainView] window]
+ modalDelegate:nil
+ didEndSelector:nil
+ contextInfo:nil];
+ [alert release];
+}
+
+// -------------------------------------------------------------------------------
+// manageButtonState:
+// -------------------------------------------------------------------------------
+-(void) manageButtonState:(int) rowSelected {
+ [((NSControl*) cellIpButton) setEnabled:rowSelected >= 0];
+ [((NSControl*) removeCellButton) setEnabled:rowSelected >= 0];
+}
+
+// -------------------------------------------------------------------------------
+// setAfsStatus:
+// -------------------------------------------------------------------------------
+-(void) setAfsStatus
+{
+ BOOL afsIsUp = [afsProperty checkAfsStatus];
+ NSLog(@"Afs is: %s", afsIsUp?"Up":"Down");
+ [((NSButton *)startStopButton) setTitle: (afsIsUp?kAfsButtonShutdown:kAfsButtonStartup)];
+
+ NSMutableAttributedString *colorTitle =[[NSMutableAttributedString alloc] initWithAttributedString:[((NSButton *)startStopButton) attributedTitle]];
+ NSRange titleRange = NSMakeRange(0, [colorTitle length]);
+
+ [colorTitle addAttribute:NSForegroundColorAttributeName
+ value:(afsIsUp?[NSColor redColor]:[NSColor blackColor])
+ range:titleRange];
+
+ [((NSButton *)startStopButton) setAttributedTitle:colorTitle];
+
+ if(afsIsUp) {
+ [self startTimer];
+ } else {
+ [self stopTimer];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// refreshToken:
+// -------------------------------------------------------------------------------
+- (void) refreshTokens:(NSTimer*)theTimer;
+{
+ if(![tokensLock tryLock]) return;
+ if(tokenList){
+ [tokenList release];
+ }
+
+ tokenList = [afsProperty getTokenList];
+ [((NSTableView*)tokensTable) reloadData];
+ [tokensLock unlock];
+}
+
+
+// -------------------------------------------------------------------------------
+// isExtraMenuLoaded:
+// -------------------------------------------------------------------------------
+- (BOOL) isAFSMenuExtraLoaded
+{
+ void *menu;
+ if ((CoreMenuExtraGetMenuExtra((CFStringRef)kAFSMenuExtraID, &menu) == 0) && menu) {
+ return YES;
+ }
+ else {
+ return NO;
+ }
+}
+
+// -------------------------------------------------------------------------------
+// isExtraMenuLoaded:
+// -------------------------------------------------------------------------------
+- (void)addAFSMenuExtra {
+
+ void *menuCracker = 0L;
+
+ //Check for MenuCracker
+ if ((CoreMenuExtraGetMenuExtra((CFStringRef)kMenuCrakerMenuExtraID, &menuCracker) != 0) || !menuCracker) {
+ NSLog(@"MenuCracker not present");
+
+ // load the MenuCracker.menu menu extra
+ CoreMenuExtraAddMenuExtra((CFURLRef)kMenuCrakerMenuExtra, 0, 0, 0, 0, 0);
+ } else NSLog(@"MenuCracker alredy loaded");
+
+
+ //Load the AFSCommander menu extra
+ CoreMenuExtraAddMenuExtra((CFURLRef)kAFSMenuExtra, 0, 0, 0, 0, 0);
+}
+
+// -------------------------------------------------------------------------------
+// removeExtra:
+// -------------------------------------------------------------------------------
+- (IBAction) addLink:(id) sender {
+ [NSBundle loadNibNamed:@"SymLinkEdit" owner:self];
+
+ [NSApp beginSheet: lyncCreationSheet
+ modalForWindow: [[self mainView] window]
+ modalDelegate: self
+ didEndSelector: @selector(didEndSymlinkSheet:returnCode:contextInfo:)
+ contextInfo: nil];
+
+}
+
+// -------------------------------------------------------------------------------
+// removeExtra:
+// -------------------------------------------------------------------------------
+- (IBAction) removeLink:(id) sender {
+
+}
+
+// -------------------------------------------------------------------------------
+// removeExtra:
+// -------------------------------------------------------------------------------
+- (IBAction) enableLink:(id) sender {
+
+}
+
+
+// -------------------------------------------------------------------------------
+// removeExtra:
+// -------------------------------------------------------------------------------
+- (void)removeAFSMenuExtra{
+ void *menu;
+ if ((CoreMenuExtraGetMenuExtra((CFStringRef)kAFSMenuExtraID, &menu) == 0) && menu) {
+ CoreMenuExtraRemoveMenuExtra(menu, 0);
+ }
+}
+
+
+// -------------------------------------------------------------------------------
+// mextraChangeActivation:
+// -------------------------------------------------------------------------------
+- (void)mextraChangeActivation:(NSNotification *)notification
+{
+ // set the afsmenu check state
+ [(NSButton*)afsMenucheckBox setState: [self isAFSMenuExtraLoaded]?NSOnState:NSOffState];
+}
+@end
+
+@implementation AFSCommanderPref (NSTableDataSource)
+
+
+// -------------------------------------------------------------------------------
+// tableView:
+// Manage the checkbox of CellServDB Table
+
+// -------------------------------------------------------------------------------
+- (void)tableView:(NSTableView *)table
+ setObjectValue:(id)data
+ forTableColumn:(NSTableColumn *)col
+ row:(int)row
+{
+ NSString *identifier = (NSString*)[col identifier];
+ switch([table tag]){
+ case TABLE_TOKENS_LIST:
+ break;
+
+ case TABLE_CELL_LIST:
+ // we are editing checkbox for cellservdb table
+ if([identifier intValue] == CELLSRVDB_TABLE_USR_DFLT_CHECK_COLUMN) {
+ // set the user default cell
+ DBCellElement *cellElement = (DBCellElement*)[filteredCellDB objectAtIndex:row];
+ [afsProperty setDefaultCellByName:[cellElement getCellName]];
+ //[afsDefaultCellLabel setStringValue:[afsProperty getDefaultCellName]];
+ [((NSTableView*)cellList) reloadData];
+ } else if([identifier intValue] == CELLSRVDB_TABLE_DFLT_CHECK_COLUMN) {
+ // set the cell for wich the user want to get token
+ DBCellElement *cellElement = (DBCellElement*)[filteredCellDB objectAtIndex:row];
+ [cellElement setUserDefaultForToken:![cellElement userDefaultForToken]];
+ }
+ break;
+ }
+
+}
+
+
+// -------------------------------------------------------------------------------
+// tableView:
+// refresh delegate method for two AFSCommander table
+// -------------------------------------------------------------------------------
+- (id) tableView:(NSTableView *) aTableView
+ objectValueForTableColumn:(NSTableColumn *) aTableColumn
+ row:(int) rowIndex
+{
+
+ id result = nil;
+ NSString *identifier = (NSString*)[aTableColumn identifier];
+ switch([aTableView tag]){
+ case TABLE_TOKENS_LIST:
+ //We are refreshing tokens table
+ result = [self getTableTokensListValue:[identifier intValue] row:rowIndex];
+ break;
+
+ case TABLE_CELL_LIST:
+ //We are refreshing cell db table
+ result = [self getTableCelListValue:[identifier intValue] row:rowIndex];
+ break;
+
+ }
+ return result;
+}
+
+
+// -------------------------------------------------------------------------------
+// getTableCelListValue:
+// -------------------------------------------------------------------------------
+- (id)getTableTokensListValue:(int) colId row:(int)row
+{
+ id result = nil;
+ if(!tokenList) return nil;
+ switch(colId){
+ case 0:
+ result = (NSString*)[tokenList objectAtIndex:row];
+ break;
+ }
+ return result;
+}
+
+
+// -------------------------------------------------------------------------------
+// getTableCelListValue:
+// -------------------------------------------------------------------------------
+- (id)getTableCelListValue:(int) colId row:(int)row
+{
+ id result = nil;
+ //NSMutableArray *cellArray = [afsProperty getCellList];
+ DBCellElement *cellElement = (DBCellElement*)[filteredCellDB objectAtIndex:row];
+ switch(colId){
+ case CELLSRVDB_TABLE_USR_DFLT_CHECK_COLUMN:
+ result = [NSNumber numberWithInt:[cellElement userDefaultForCell]];
+ break;
+
+ case CELLSRVDB_TABLE_DFLT_CHECK_COLUMN:
+ result = [NSNumber numberWithInt:[cellElement userDefaultForToken]];
+ break;
+ case CELLSRVDB_TABLE_NAME_COLUMN:
+ result = [cellElement getCellName];
+ break;
+
+ case CELLSRVDB_TABLE_DESCRIPTION_COLUMN:
+ result = [cellElement getCellComment];
+ break;
+ }
+ return result;
+}
+
+// -------------------------------------------------------------------------------
+// numberOfRowsInTableView:
+// -------------------------------------------------------------------------------
+- (int)numberOfRowsInTableView:(NSTableView *)aTableView
+{
+ int rowCount = 0;
+ //NSMutableArray *cellArray = nil;
+ switch([aTableView tag]){
+ case TABLE_TOKENS_LIST:
+ if(tokenList) rowCount = [tokenList count];
+ break;
+
+ case TABLE_CELL_LIST:
+ //cellArray = [afsProperty getCellList];
+ if(filteredCellDB) rowCount = [filteredCellDB count];
+ break;
+
+ }
+ return rowCount;
+}
+
+
+@end
+
+
+@implementation AFSCommanderPref (TableDelegate)
+// -------------------------------------------------------------------------------
+// selectionShouldChangeInTableView:
+// -------------------------------------------------------------------------------
+- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTable
+{
+ [self manageButtonState:[aTable selectedRow]];
+ return YES;
+}
+
+// -------------------------------------------------------------------------------
+// tableView:
+// -------------------------------------------------------------------------------
+- (BOOL)tableView:(NSTableView *)aTable shouldSelectRow:(int)aRow
+{
+ [self manageButtonState:aRow];
+ return YES;
+}
+
+@end
+
+
+@implementation AFSCommanderPref (ModalDelegate)
+// -------------------------------------------------------------------------------
+// didEndSheet:
+// -------------------------------------------------------------------------------
+- (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ NSLog(@"didEndSheet");
+ [sheet orderOut:self];
+ //Filter the cellServDb and allocate filtered array
+ [self searchCellTextEvent:nil];
+ [((NSTableView*)cellList) reloadData];
+ NSLog(@"Has saved %s:", ([((IpConfiguratorCommander*) ipConfControllerCommander) saved])?"YES":"NO");
+}
+
+// -------------------------------------------------------------------------------
+// Klog credential request
+// -------------------------------------------------------------------------------
+- (void)didEndCredentialSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ NSLog(@"didEndCredentialSheet");
+ if([((TokenCredentialController*)credentialCommander) takenToken] == YES){
+ /*[AFSPropertyManager klog:[((TokenCredentialController*)credentialCommander) uName]
+ uPwd:[((TokenCredentialController*)credentialCommander) uPwd] ];*/
+ [afsProperty getTokens:true
+ usr:[((TokenCredentialController*)credentialCommander) uName]
+ pwd:[((TokenCredentialController*)credentialCommander) uPwd]];
+ }
+ [sheet orderOut:self];
+ [self refreshTokens:nil];
+ //Inform afs menuextra to updata afs status
+ if ([self isAFSMenuExtraLoaded]) [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kMExtraAFSStateChange];
+
+}
+
+// -------------------------------------------------------------------------------
+// Klog credential request
+// -------------------------------------------------------------------------------
+- (void)didEndInfoSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ NSLog(@"didEndInfoSheet");
+ [sheet orderOut:self];
+}
+
+// -------------------------------------------------------------------------------
+// symlink edite
+// -------------------------------------------------------------------------------
+- (void)didEndSymlinkSheet:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
+{
+ NSLog(@"didEndSymlinkSheet");
+ [lyncCreationSheet orderOut:self];
+}
+@end
+
+// -------------------------------------------------------------------------------
+// AFSCommanderPref(NSTabViewDelegator) - delegate for nstabview in
+// main preference view
+// -------------------------------------------------------------------------------
+@implementation AFSCommanderPref(NSTabViewDelegator)
+- (void)tabView:(NSTabView *)tabView willSelectTabViewItem: (NSTabViewItem *)tabViewItem
+{
+ //check to see if the cache param tab is the tab that will be selected
+ if([((NSString*)[tabViewItem identifier]) intValue] == TAB_GROUP)
+ {
+ //get
+ NSLog(@"cache param tab");
+ // [groupsBox setHidden:YES];
+ NSLog([groupsBox title]);
+ [ViewUtility enbleDisableControlView:[groupsBox contentView]
+ controlState:NO];
+ }
+}
+@end
\ No newline at end of file
--- /dev/null
+//
+// Prefix header for all source files of the 'AFSCommander' target in the 'AFSCommander' project.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+ #import <AppKit/AppKit.h>
+
+#endif
--- /dev/null
+//
+// AFSMenuCredentialContoller.h
+// AFSCommander
+//
+// Created by Claudio on 14/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "CredentialWindowController.h"
+#import "AFSPropertyManager.h"
+
+@interface AFSMenuCredentialContoller : NSObject {
+ NSRect viewRect;
+ id credentialView;
+ id credentialController;
+ NSPanel *credentialWindow;
+ id credWinController;
+ AFSPropertyManager *afsPropMngr;
+}
+-(id) initWhitRec:(NSRect)rect afsPropManager:(AFSPropertyManager*)afsPropManager;
+-(void) showWindow;
+-(void) closeWindow;
+@end
--- /dev/null
+//
+// AFSMenuCredentialContoller.m
+// AFSCommander
+//
+// Created by Claudio on 14/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "AFSMenuCredentialContoller.h"
+#import "CredentialWindowController.h"
+#import "global.h"
+#import "AFSPropertyManager.h"
+
+@implementation AFSMenuCredentialContoller
+
+-(id) initWhitRec:(NSRect)rect afsPropManager:(AFSPropertyManager*)afsPropManager;
+{
+ viewRect = rect;
+ credentialWindow = nil;
+ afsPropMngr = [afsPropManager retain];
+ NSLog(@"init AFSMenuCredentialContoller");
+ return [self init];
+}
+
+- (void)dealloc {
+ NSLog(@"dealloc AFSMenuCredentialContoller");
+ if(credentialWindow) [credentialWindow release];
+ [super dealloc];
+
+} // dealloc
+
+-(void) showWindow
+{
+ // calculate the point where show the window
+ NSPoint topLeft = {viewRect.origin.x-160,[[NSScreen mainScreen] frame].size.height-kMenuBarHeight};
+ NSLog(@"viewRect.origin.x=%d, topLeft.x=%d", viewRect.origin.x, topLeft.x);
+ // load the bundle for
+ [NSBundle loadNibNamed:@"CredentialWindow.nib" owner:self];
+ NSLog(@"prepare to open window CredentialWindow");
+
+ credentialWindow = [[NSWindow alloc] initWithContentRect:[((NSView*) credentialView) frame]
+ styleMask:NSTitledWindowMask /*| NSUtilityWindowMask*/
+ backing:NSBackingStoreBuffered
+ defer:YES screen:[NSScreen mainScreen]];
+ NSLog(@"Finestra");
+ [credentialWindow setTitle:@"Klog"];
+ [credentialWindow setFrameTopLeftPoint:topLeft];
+ [credentialWindow setContentView:credentialView];
+ [credentialWindow makeKeyAndOrderFront:self];
+ NSLog(@"creata");
+
+}
+
+-(void) closeWindow
+{
+ NSLog(@"closeWindow");
+ if([(CredentialWindowController*)credWinController takenToken] && afsPropMngr) {
+ [afsPropMngr getTokens:true
+ usr:[(CredentialWindowController*)credWinController uName]
+ pwd:[(CredentialWindowController*)credWinController uPwd]];
+ [afsPropMngr release];
+ afsPropMngr = nil;
+ }
+ [credentialWindow close];
+ credentialWindow = nil;
+}
+@end
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>it.infn.lnf.network.AFSMenuExtra</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>INFN</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSPrincipalClass</key>
+ <string>AFSMenuExtra</string>
+</dict>
+</plist>
--- /dev/null
+//
+// AFSMenuExtra.h
+// AFSCommander
+//
+// Created by Claudio on 10/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+
+#import <Cocoa/Cocoa.h>
+#import "SystemUIPlugin.h"
+#import "global.h"
+#import "AFSMenuCredentialContoller.h"
+@class AFSMenuExtraView;
+@interface AFSMenuExtra : NSMenuExtra {
+ @public
+ BOOL afsState; //0-off 1-on
+ BOOL gotToken; //0-no 1-one o more token
+
+ @protected
+ NSString *afsSysPath;
+ NSNumber *useAklogPrefValue;
+ //menu extra
+ NSMenu *theMenu;
+
+ //Menu extra view
+ AFSMenuExtraView *theView;
+ // menu reference
+ NSMenuItem *startStopMenu;
+ NSMenuItem *loginMenu;
+ NSMenuItem *unlogMenu;
+
+ //Icon for state visualization
+ NSImage *hasTokenImage;
+ NSImage *noTokenImage;
+
+ //credential windows mainWindow
+ AFSMenuCredentialContoller *credentialMenuController;
+
+ //NSTimer for tokens refresh
+ NSTimer *timerForCheckTokensList;
+ NSLock *tokensLock;
+}
+- (void)startTimer;
+- (void)stopTimer;
+- (BOOL)useAklogPrefValue;
+- (void)readPreferenceFile:(NSNotification *)notification;
+- (void)getToken:(id)sender;
+- (void)releaseToken:(id)sender;
+- (void)updateAfsStatus:(NSTimer*)timer;
+- (void)klogUserEven:(NSNotification *)notification;
+- (NSImage*)getImageFromBundle:(NSString*)fileName fileExt:(NSString*)ext;
+- (NSImage*)imageToRender;
+- (void)updateMenu;
+- (void)repairHelperTool;
+- (void) afsVolumeMountChange:(NSNotification *)notification;
+@end
--- /dev/null
+//
+// AFSMenuExtra.m
+// AFSCommander
+//
+// Created by Claudio on 10/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "AFSMenuExtra.h"
+#import "AFSMenuExtraView.h"
+#import "AFSPropertyManager.h"
+#import "TaskUtil.h"
+#import "TokenCredentialController.h"
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/fcntl.h>
+#include <sys/errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+@implementation AFSMenuExtra
+// -------------------------------------------------------------------------------
+// -(id) initWithBundle
+// -------------------------------------------------------------------------------
+- (id) initWithBundle:(NSBundle *)bundle
+{
+ self = [super initWithBundle:bundle];
+ if( self == nil )
+ return nil;
+
+ // allocate the lock
+ tokensLock = [[NSLock alloc] init];
+ // inizialize the afspath
+ afsSysPath = nil;
+ credentialMenuController = nil;
+
+ theView = [[AFSMenuExtraView alloc] initWithFrame:[[self view] frame]
+ menuExtra:self];
+ [self setView:theView];
+
+
+ // Get the imge for menu
+ //Load image for menu rappresentation
+ hasTokenImage = [self getImageFromBundle:@"hasToken"
+ fileExt:@"png"];
+
+ noTokenImage = [self getImageFromBundle:@"noToken"
+ fileExt:@"png"];
+
+ theMenu = [[NSMenu alloc] initWithTitle: @""];
+ [theMenu setAutoenablesItems: NO];
+ startStopMenu = [theMenu addItemWithTitle: kAfsOff action: @selector(startStopAfs:) keyEquivalent: @""];
+ [startStopMenu setTarget:self];
+
+ loginMenu = [theMenu addItemWithTitle: kMenuLogin action: @selector(getToken:) keyEquivalent: @""];
+ [loginMenu setTarget:self];
+
+ unlogMenu = [theMenu addItemWithTitle: kMenuUnlog action: @selector(releaseToken:) keyEquivalent: @""];
+ [unlogMenu setTarget:self];
+
+ // Register for preference user change
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(readPreferenceFile:)
+ name:kAFSMenuExtraID object:kPrefChangeNotification];
+
+ // Register for afs state change
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(afsVolumeMountChange:)
+ name:kAFSMenuExtraID object:kMExtraAFSStateChange];
+
+
+ //Register for mount/unmount afs volume
+ [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
+ selector:@selector(afsVolumeMountChange:)
+ name:NSWorkspaceDidMountNotification object:nil];
+
+ [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
+ selector:@selector(afsVolumeMountChange:)
+ name:NSWorkspaceDidUnmountNotification object:nil];
+ //Start to read the afs path
+ [self readPreferenceFile:nil];
+ [self startTimer];
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// -(void) willUnload
+// -------------------------------------------------------------------------------
+- (void) willUnload {
+ //release the lock
+ [self stopTimer];
+
+ if(hasTokenImage) [hasTokenImage release];
+ if(noTokenImage) [noTokenImage release];
+
+ // Unregister for preference change
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kAFSMenuExtraID object:kPrefChangeNotification];
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kAFSMenuExtraID object:kMExtraAFSStateChange];
+ [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceDidMountNotification object:nil];
+ [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceDidUnmountNotification object:nil];
+
+
+ [tokensLock release];
+}
+
+// -------------------------------------------------------------------------------
+// startTimer:
+// -------------------------------------------------------------------------------
+- (void)startTimer{
+ //start the time for check tokens validity
+ if(timerForCheckTokensList) return;
+ timerForCheckTokensList = [NSTimer scheduledTimerWithTimeInterval:TOKENS_REFRESH_TIME_IN_SEC
+ target:self
+ selector:@selector(updateAfsStatus:)
+ userInfo:nil
+ repeats:YES];
+ [timerForCheckTokensList fire];
+}
+
+// -------------------------------------------------------------------------------
+// stopTimer:
+// -------------------------------------------------------------------------------
+- (void)stopTimer{
+ if(!timerForCheckTokensList) return;
+ [timerForCheckTokensList invalidate];
+ timerForCheckTokensList = nil;
+}
+// -------------------------------------------------------------------------------
+// -(void) dealloc
+// -------------------------------------------------------------------------------
+- (void) dealloc
+{
+ [theMenu release];
+ [theView release];
+ if(afsSysPath) [afsSysPath release];
+ // send notify that menuextra has closed
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:afsCommanderID object:kPrefChangeNotification];
+ [super dealloc];
+}
+
+// -------------------------------------------------------------------------------
+// -(NSMenu*) menu
+// -------------------------------------------------------------------------------
+- (NSMenu *) menu
+{
+ return theMenu;
+}
+
+
+// -------------------------------------------------------------------------------
+// -(void) readPreferenceFile
+// -------------------------------------------------------------------------------
+- (void) readPreferenceFile:(NSNotification *)notification
+{
+ NSLog(@"Reading preference file");
+ //CFPreferencesSynchronize((CFStringRef)afsCommanderID, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+ //CFPreferencesSynchronize((CFStringRef)afsCommanderID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+
+ if(afsSysPath) {
+ [afsSysPath release];
+ afsSysPath = nil;
+ }
+
+ afsSysPath = PREFERENCE_AFS_SYS_PAT_STATIC;/*(NSString*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_AFS_SYS_PAT,
+ (CFStringRef)afsCommanderID,
+ kCFPreferencesAnyUser,
+ kCFPreferencesAnyHost);*/
+ //NSLog(@"Path readed %s", (afsSysPath==nil?[afsSysPath UTF8String]:@" no path found "));
+
+ // read the preference for aklog use
+ useAklogPrefValue = (NSNumber*)CFPreferencesCopyValue((CFStringRef)PREFERENCE_USE_AKLOG,
+ (CFStringRef)afsCommanderID,
+ kCFPreferencesCurrentUser,
+ kCFPreferencesAnyHost);
+ //set the menu name
+ //NSLog(@"Preference readed for useAklogPrefValue %d", [useAklogPrefValue intValue]);
+
+ [self updateAfsStatus:nil];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) readPreferenceFile
+// -------------------------------------------------------------------------------
+- (void)startStopAfs:(id)sender
+{
+ NSLog(@"startStopAfs: %s",[afsSysPath UTF8String]);
+ if(!afsSysPath) return;
+
+ OSStatus status = noErr;
+ NSString *afsdPath = [TaskUtil searchExecutablePath:@"afsd"];
+ NSString *rootHelperApp = nil;
+ BOOL currentAfsState = NO;
+
+ @try {
+ if(afsdPath == nil) return;
+ AFSPropertyManager *afsMngr = [[AFSPropertyManager alloc] initWithAfsPath:afsSysPath];
+ currentAfsState = [afsMngr checkAfsStatus];
+ [afsMngr release];
+
+ rootHelperApp = [[self bundle] pathForResource:@"afshlp" ofType:@""];
+
+ //[startStopScript setString: resourcePath];
+ //NSLog(@"LAunch repair HelperTool");
+ //Check helper app
+ [self repairHelperTool];
+
+ // make the parameter to call the root helper app
+ //NSLog(@"Path installazione afs: %s",[afsSysPath UTF8String]);
+ //NSLog(@"Path installazione afsd: %s", [afsdPath UTF8String]);
+ status = [[AuthUtil shared] autorize];
+ if(status == noErr){
+ if(currentAfsState){
+ //shutdown afs
+ //NSLog(@"Shutting down afs");
+ NSMutableString *afsKextPath = [[NSMutableString alloc] initWithCapacity:256];
+ [afsKextPath setString:afsSysPath];
+ [afsKextPath appendString:@"/etc/afs.kext"];
+
+ //NSLog(@"executeTaskWithAuth");
+ const char *stopAfsArgs[] = {"stop_afs", [afsKextPath UTF8String], [afsdPath UTF8String], 0L};
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:stopAfsArgs
+ output:nil];
+ } else {
+ //NSLog(@"Starting up afs");
+ const char *startAfsArgs[] = {[[[self bundle] pathForResource:@"start_afs" ofType:@"sh"] UTF8String], [afsSysPath UTF8String], [afsdPath UTF8String], 0L};
+ [[AuthUtil shared] execUnixCommand:[rootHelperApp UTF8String]
+ args:startAfsArgs
+ output:nil];
+ }
+ }
+ }
+ @catch (NSException * e) {
+ NSLog([e reason]);
+ }
+ @finally {
+ [[AuthUtil shared] deautorize];
+ [self updateAfsStatus:nil];
+ //Send notification to preferencepane
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:afsCommanderID object:kMenuExtraEventOccured];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// -(void) getToken
+// -------------------------------------------------------------------------------
+- (void)getToken:(id)sender
+{
+
+ NSRect globalRect;
+ globalRect.origin = [[[self view] window] convertBaseToScreen:[[self view] frame].origin];
+ globalRect.size = [[self view] frame].size;
+ AFSPropertyManager *afsPropMngr = [[AFSPropertyManager alloc] initWithAfsPath:afsSysPath ];
+ [afsPropMngr loadConfiguration];
+
+
+ if([useAklogPrefValue intValue]==NSOnState ) {
+ NSLog(@"Use Aklog");
+ [afsPropMngr getTokens:false
+ usr:nil
+ pwd:nil];
+ [self klogUserEven:nil];
+ } else {
+ NSLog(@"Use Klog");
+ // register for user event
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(klogUserEven:)
+ name:kAFSMenuExtraID
+ object:kLogWindowClosed];
+
+ credentialMenuController = [[AFSMenuCredentialContoller alloc] initWhitRec:globalRect
+ afsPropManager:afsPropMngr];
+ [credentialMenuController showWindow];
+ }
+
+ //Dispose afs manager
+ [afsPropMngr release];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) releaseToken
+// -------------------------------------------------------------------------------
+- (void)releaseToken:(id)sender
+{
+ AFSPropertyManager *afsMngr = [[AFSPropertyManager alloc] initWithAfsPath:afsSysPath];
+ [afsMngr unlog:nil];
+ [afsMngr release];
+ [self updateAfsStatus:nil];
+}
+
+
+// -------------------------------------------------------------------------------
+// -(void) afsVolumeMountChange - Track for mount unmount afs volume
+// -------------------------------------------------------------------------------
+- (void) afsVolumeMountChange:(NSNotification *)notification{
+ [self updateAfsStatus:nil];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) updateAfsStatus
+// -------------------------------------------------------------------------------
+- (void)updateAfsStatus:(NSTimer*)timer
+{
+ //Try to locking
+ if(![tokensLock tryLock]) return;
+
+ // check the afs state in esclusive mode
+ AFSPropertyManager *afsMngr = [[AFSPropertyManager alloc] initWithAfsPath:afsSysPath];
+ afsState = [afsMngr checkAfsStatus];
+
+ NSArray *tokens = [afsMngr getTokenList];
+ [afsMngr release];
+ gotToken = [tokens count] > 0;
+ [tokens release];
+ // update the menu item title
+ [startStopMenu setTitle:afsState?kAfsButtonShutdown:kAfsButtonStartup];
+
+ [self updateMenu];
+
+ [theView setNeedsDisplay:YES];
+
+ //unlock
+ [tokensLock unlock];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) klogUserEven
+// -------------------------------------------------------------------------------
+-(void) klogUserEven:(NSNotification *)notification
+{
+ if(credentialMenuController) {
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self name:kAFSMenuExtraID object:kLogWindowClosed];
+ [credentialMenuController closeWindow];
+ [credentialMenuController release];
+ credentialMenuController = nil;
+ }
+ //Send notification to PreferencePane
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:afsCommanderID object:kMenuExtraEventOccured];
+
+ [self updateAfsStatus:nil];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) getImageFromBundle
+// -------------------------------------------------------------------------------
+- (NSImage*)getImageFromBundle:(NSString*)fileName fileExt:(NSString*)ext
+{
+ return [[NSImage alloc]initWithContentsOfFile:[[self bundle] pathForResource:fileName
+ ofType:ext]];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) imageToRender
+// -------------------------------------------------------------------------------
+- (NSImage*)imageToRender
+{
+ if(gotToken){
+ return hasTokenImage;
+ } else {
+ return noTokenImage;
+ }
+}
+
+
+// -------------------------------------------------------------------------------
+// -(void) updateMenu
+// -------------------------------------------------------------------------------
+- (void)updateMenu{
+ [loginMenu setEnabled:afsState];
+ [unlogMenu setEnabled:afsState];
+}
+
+
+// -------------------------------------------------------------------------------
+// -(void) useAklogPrefValue
+// -------------------------------------------------------------------------------
+- (BOOL)useAklogPrefValue
+{
+ if(useAklogPrefValue) return [useAklogPrefValue intValue] == NSOnState;
+ else return NSOffState;
+}
+
+// -------------------------------------------------------------------------------
+// repairHelperTool:
+// -------------------------------------------------------------------------------
+- (void) repairHelperTool
+{
+ struct stat st;
+ int fdTool;
+ int status = 0;
+ NSLog(@"repairHelperTool");
+ NSString *afshlpPath = [[self bundle] pathForResource:@"afshlp" ofType:nil];
+
+
+
+ // Open tool exclusively, so nobody can change it while we bless it.
+ fdTool = open([afshlpPath UTF8String], O_NONBLOCK | O_RDONLY | O_EXLOCK, 0);
+
+ if(fdTool == -1)
+ {
+ NSLog(@"Exclusive open while repairing tool failed: %d.", errno);
+ exit(-1);
+ }
+
+ if(fstat(fdTool, &st))
+ {
+ NSLog(@"fstat failed.");
+ exit(-1);
+ }
+
+ if(st.st_uid != 0)
+ {
+ status = [[AuthUtil shared] autorize];
+ if(status == noErr){
+ fchown(fdTool, 0, st.st_gid);
+
+ // Disable group and world writability and make setuid root.
+ fchmod(fdTool, (st.st_mode & (~(S_IWGRP | S_IWOTH)))/* | S_ISUID*/);
+ const char *args[] = {"root", [afshlpPath UTF8String],0L};
+ [[AuthUtil shared] execUnixCommand:"/usr/sbin/chown"
+ args:args
+ output:nil];
+ [[AuthUtil shared] deautorize];
+ }
+ } else NSLog(@"st_uid = 0");
+
+
+
+ close(fdTool);
+
+ NSLog(@"Self-repair done.");
+
+}@end
--- /dev/null
+//
+// AFSMenuExtraView.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 11/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "SystemUIPlugin.h"
+#import "AFSMenuExtra.h"
+
+@interface AFSMenuExtraView : NSMenuExtraView {
+ AFSMenuExtra *theMenuExtra;
+
+}
+- (NSAttributedString*) makeKerberosIndicator:(int*)fontHeight;
+@end
--- /dev/null
+//
+// AFSMenuExtraView.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 11/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "AFSMenuExtraView.h"
+#import "AFSPropertyManager.h"
+@implementation AFSMenuExtraView
+
+- initWithFrame:(NSRect)myRect menuExtra:(AFSMenuExtra*)myExtra {
+
+ // Have super init
+ self = [super initWithFrame:myRect];
+ if(!self) {
+ return nil;
+ }
+
+ // Store our extra
+ theMenuExtra = myExtra;
+
+ // Send it on back
+ return self;
+
+} // initWithFrame
+
+- (void)dealloc {
+
+ [super dealloc];
+
+} // dealloc
+
+- (void)drawRect:(NSRect)rect
+{
+ NSImage *image = nil;
+ int fontHeight = 0;
+ NSAttributedString *kerberosStringIndicator = nil;
+
+ image = [theMenuExtra imageToRender];
+ if (image) {
+ // Live updating even when menu is down handled by making the extra
+ // draw the background if needed.
+ if ([theMenuExtra isMenuDown]) {
+ [theMenuExtra drawMenuBackground:YES];
+ }
+ [image compositeToPoint:NSMakePoint(0, 0) operation:NSCompositeSourceOver];
+ }
+
+ //Draw, if necessary, the kerberos indicator for aklog usage for get token
+ if([theMenuExtra useAklogPrefValue] == NSOnState) {
+ kerberosStringIndicator = [[self makeKerberosIndicator:&fontHeight] autorelease];
+ if(kerberosStringIndicator) [kerberosStringIndicator drawAtPoint:NSMakePoint(0, kMenuBarHeight-fontHeight)];
+ }
+}
+
+/*!
+ @method makeKerberosIndicator
+ @abstract Make the kerberos indicator
+ @discussion Make a letter to render in menu view to inform the user if is enable aklog use
+*/
+- (NSAttributedString*) makeKerberosIndicator:(int*)fontHeight {
+ NSFont *font = [NSFont fontWithName:@"Palatino-Roman" size:9.0];
+ NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObject:font
+ forKey:NSFontAttributeName];
+ NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"K"
+ attributes:attrsDictionary];
+ *fontHeight = [attrString size].height;
+ return attrString;
+}
+@end
--- /dev/null
+//
+// AFSPropertyManager.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 21/05/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "DBCellElement.h"
+#import "FileUtil.h"
+
+/*!
+ @class AFSPropertyManager
+ @abstract AFS Manage Class
+ @discussion This class manage the openafs param for celldbserv, cache param, group creation, get and release token
+*/
+
+@interface AFSPropertyManager : NSObject {
+ NSString *installationPath;
+ NSString *cellName;
+ NSMutableArray *cellList;
+ NSArray *userDefaultCellArray;
+ NSString *afsRootMountPoint;
+ int statCacheEntry;
+ int dCacheDim;
+ int cacheDimension;
+ int daemonNumber;
+ int nVolEntry;
+ bool dynRoot;
+ bool afsDB;
+ bool verbose;
+
+ //-------------------
+ FileUtil *futil;
+ BOOL useAfsdConfVersion;
+}
+
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+*/
+-(id) init;
+
+/*!
+@function initWithAfsPath
+ @abstract (description)
+ @discussion (description)
+ @param path Path di installazione afs
+ @result Istanza della classe di gestione delle propieta' afs
+ */
+- (id)initWithAfsPath:(NSString*)path;
+
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+*/
+-(void) dealloc;
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */
+-(NSMutableArray*) getCellList;
+
+
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */
+-(NSArray*) getAllCellsName;
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */
+-(NSArray*) getUserDefaultForTokenCells;
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */
+-(NSArray*) getDefaultForTokenCellsName;
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */
+-(NSString*) getDefaultCellName;
+
+/*!
+ @method setDefaultCellByName
+ @abstract set the cell named "name" to be se user default
+ @discussion first clean the last one selected as default and then set the cell named "name" as default user cell
+ */
+-(void) setDefaultCellByName:(NSString*)name;
+
+/*!
+ @method
+ @abstract (brief description)
+ @discussion (comprehensive description)
+ */- (void) setCellName:(NSString*)cell;
+
+/*!
+ @method setPath
+ @abstract Imposta Path
+ @discussion Imposta il path dove e' installato afs, in modo da leggere e scrivere le configurazioni
+*/
+-(void) setPath:(NSString*)path;
+
+/*!
+ @method path
+ @abstract Return the afs base
+ @discussion Return the Afs base installation path
+*/
+-(NSString*) path;
+
+/*!
+ @function statCacheEntry
+ @abstract get the afs number of state cache entry
+ @discussion
+ @result Number of stat cache entry
+ */
+-(int) statCacheEntry;
+
+
+/*!
+ @function setStatCacheEntry
+ @abstract Set the afs number of state cache entry
+ @discussion
+ @result Number of stat cache entry
+ */
+-(void) setStatCacheEntry:(int)statEntry;
+
+/*!
+@function dCacheDim
+@abstract return the dCacheDim param value for cache manager
+@result dCacheDim value
+*/
+-(int) dCacheDim;
+
+/*!
+ @function setDCacheDim
+ @abstract set the setDCacheDim value for cache manager param
+ @discussion <#(description)#>
+ @param dcacheDim cache param value
+ */
+-(void) setDCacheDim:(int)dcacheDim;
+
+/*!
+ @function cacheDimension
+ @abstract return the max size of the cache
+ @result Cache dimension
+ */
+-(int) cacheDimension;
+
+/*!
+ @function setCacheDimension
+ @abstract Set the max cache dimension
+ @discussion
+ @param cacheDim MAx Chace dimension
+ */
+-(void) setCacheDimension:(int)cacheDim;
+
+/*!
+ @function daemonNumber
+ @abstract Return the number of daemon for the cache manager
+ @result Number of daemon
+ */
+-(int) daemonNumber;
+
+/*!
+ @function setDaemonNumber
+ @abstract Set the daemon numbero for the cache manager
+ @param dNumber number of daemon
+ */
+-(void) setDaemonNumber:(int)dNumber;
+
+/*!
+ @function afsRootMountPoint
+ @abstract Return the path where afs root volume will be mounted
+ @result AFS mount point
+ */
+-(NSString*) afsRootMountPoint;
+
+/*!
+ @function setAfsRootMountPoint
+ @abstract Set the AFS mount point
+ @param mountPoint AFS mount point
+ */
+-(void) setAfsRootMountPoint:(NSString*)mountPoint;
+
+/*!
+ @function nVolEntry
+ @abstract Return the nVolEntry for cache manager
+ @result value for nVolEntry cache parameter
+ */
+-(int) nVolEntry;
+
+/*!
+ @function setNVolEntry
+ @abstract Set the nVolEntry parameter for cache manager
+ @param entry value for nVolEntry cache manager parameter
+ */
+-(void) setNVolEntry:(int)entry;
+
+/*!
+ @function dynRoot
+ @abstract Return the DynRoot parametr for cache manager
+ @result dynRoot parameter value
+ */
+-(bool) dynRoot;
+
+/*!
+ @function setDynRoot
+ @abstract Set the DynRoot flag value for cache manager
+ @param flag dynRoot state (enable/disable)
+ */
+-(void) setDynRoot:(bool)flag;
+/*!
+ @function afsDB
+ @abstract Get the afsdb flag value for cache manager
+ @result Return the value of the flag
+ */
+-(bool) afsDB;
+
+/*!
+ @function setAfsDB
+ @abstract Set the flag value for afsdb cache manager
+ @param flag AfsDB state (enable/disable)
+ */
+-(void) setAfsDB:(bool)flag;
+/*!
+ @function verbose
+ */
+-(bool) verbose;
+
+/*!
+ @function setVerbose
+ */
+-(void) setVerbose:(bool)flag;
+/*!
+ @function readCacheInfo
+ @abstract Read the cache info
+ @discussion The cache info is read from the file pointed by filePath param
+ @param filePath file location for the CacheInfo
+ */
+-(void) readCacheInfo:(NSString*)filePath;
+
+/*!
+ @function writeCacheInfo
+ @abstract Write the cache info down the file
+ @param filePath where to write the CacheInfo
+ @result return the execution error
+ */
+-(int) writeCacheInfo:(NSString*)filePath;
+
+/*!
+ @function readAfsdOption
+ @abstract Read the afs option
+ @discussion Read the afs option checking firt the afs version so it can read the old afsd.option or afs.conf file. If any error accour an NSException wil be trown
+ @param filePath file where the parameter are store for default afsd.option or afs.conf
+ */
+-(void) readAfsdOption:(NSString*)filePath;
+
+/*!
+ @function readOldAfsdOption
+ @abstract Read the afsd.option file
+ @discussion Read the old afsd.option style afsd option file. If any error accour an NSException wil be trown22
+ @param filePath file path to afsd.option like file
+ @result <#(description)#>
+ */
+-(void) readOldAfsdOption:(NSString*)filePath;
+/*!
+ @function readAFSDParamLineContent
+ @abstract Try to decode one line of afsd.option or afs.conf
+ @param paramLine one line of file afsd.option(the only one that is present) os afs.conf
+ */
+-(void) readAFSDParamLineContent:(NSString*)paramLine;
+/*!
+ @function readNewAfsdOption
+ @abstract Read the new afs.conf file format
+ @discussion Scann every line f the afs.conf file ad for each one call the readAFSDParamLineContent with it's content
+ @param filePath path of the new file with afs.conf file format
+ */
+-(void) readNewAfsdOption:(NSString*)filePath;
+/*!
+ @function writeAfsdOption
+ @abstract <#(description)#>
+ @discussion <#(description)#>
+ @param <#(name) (description)#>
+ @result <#(description)#>
+ */
+-(int) writeAfsdOption:(NSString*)filePath;
+/*!
+ @function writeOldAfsdOption
+ @abstract Write the cache manager parameter to file
+ @discussion First chech the version of afs installed then choice to save old o new file version(afsd.option or afs.conf)
+ @param filePath file path for file to write into
+ @result <#(description)#>
+ */
+-(int) writeOldAfsdOption:(NSString*)filePath;
+/*!
+ @function writeNewAfsdOption
+ @abstract Write the cache parameter to a file with the new format
+ @param filePath file path where write into
+ */
+-(int) writeNewAfsdOption:(NSString*)filePath;
+/*!
+ @function getAfsVersion
+ @abstract Return the string representing the afs version
+ @result The Enteir string returned from the call of fs -version
+ */
+-(NSString*) getAfsVersion;
+/*!
+ @function getAfsMajorVersionVersion
+ @abstract Return the major version of afs Major.x.x
+ @result
+ */
+-(int) getAfsMajorVersionVersion;
+/*!
+ @function getAfsMinorVersionVersion
+ @abstract Return the major version of afs x.Minor.x
+ @result
+ */
+-(int) getAfsMinorVersionVersion;
+
+/*!
+ @function getAfsPatchVersionVersion
+ @abstract Return the major version of afs x.x.Patch
+ @result
+ */
+-(int) getAfsPatchVersionVersion;
+
+/*!
+ @method clearConfiguration
+ @abstract Clear all structure or array that contain value for afs client setting(cells cache param etch)
+ @discussion
+ */
+-(void) clearConfiguration;
+
+/*!
+ @function exceptionOnInvalidPath
+ @abstract Check the validity of afs path
+ @discussion If the installationPath variable don't point to a valid path, will be fired an NSException
+ */
+-(void) exceptionOnInvalidPath;
+
+/*!
+ @method loadConfiguration
+ @abstract load the all afs configuration (ThisCell & CellServDB & cache parameter)
+*/
+-(void) loadConfiguration;
+
+/*!
+ @method readCellInfo
+ @abstract Read the Main Cell Name
+*/
+-(void) readCellInfo:(NSString*) configFile;
+/*!
+ @method readCellDB
+ @abstract Read the CellServDB File
+ @discussion Read the file of all cellservbd ad make the NSArray containing a DBCellElement for aech cell found
+*/
+-(void) readCellDB:(NSString*) configFile;
+/*!
+ @function readTheseCell
+ @abstract Read the "These Cell"
+ @discussion Read the "These Cell" file that contains all the cell from which the user want to get the token
+ @param configFile TheseCell file path
+ @result NSAray with the cells name
+*/
+-(NSArray*) readTheseCell:(NSString*) configFile;
+/*!
+ @method shutdown
+ @abstract Stop The AFS
+*/
+-(void) shutdown;
+
+-(void) scanIpForCell:(DBCellElement*) cellElement allIP:(NSString*)allIP;
+-(void) backupConfigurationFiles;
+-(void) backupFile:(NSString*)localAfsFilePath;
+-(void) saveConfigurationFiles:(BOOL) makeBackup;
+-(void) saveCacheConfigurationFiles:(BOOL) makeBackup;
+-(void) installConfigurationFile:(NSString*)srcConfFile destPath:(NSString*) destPath;
+-(NSArray*) getTokenList;
+-(BOOL) checkAfsStatus;
+-(void) klog:(NSString*)uName uPwd:(NSString*)uPwd cell:(NSString*)theCell;
+-(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable;
+-(void) getTokens:(BOOL)klogAklogFlag usr:(NSString*)usr pwd:(NSString*)pwd;
+-(void) unlog:(NSString*)cell;
+-(NSString*) makeChaceParamString;
+-(BOOL) useAfsdConfConfigFile;
+@end
--- /dev/null
+//
+// AFSPropertyManager.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 21/05/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Kerberos/Kerberos.h>
+#import "AFSPropertyManager.h"
+#import "TaskUtil.h"
+
+#define kKerberosAuthError NSLocalizedStringFromTableInBundle(@"KerberosAuthError",nil,[NSBundle bundleForClass:[self class]],@"KerberosAuthError")
+#define kPathNotEmpty NSLocalizedStringFromTableInBundle(@"PathNotEmpty",nil,[NSBundle bundleForClass:[self class]],@"PathNotEmpty")
+#define kPathDontContainAfsInstallation NSLocalizedStringFromTableInBundle(@"PathDontContainAfsInstallation",nil,[NSBundle bundleForClass:[self class]],@"PathDontContainAfsInstallation")
+#define kThisCellFOError NSLocalizedStringFromTableInBundle(@"ThisCellFOError",nil,[NSBundle bundleForClass:[self class]],@"ThisCellFOError")
+#define kConfFileNotExits NSLocalizedStringFromTableInBundle(@"ConfFileNotExits",nil,[NSBundle bundleForClass:[self class]],@"ConfFileNotExits")
+#define kUserNotAuth NSLocalizedStringFromTableInBundle(@"UserNotAuth",nil,[NSBundle bundleForClass:[self class]],@"UserNotAuth")
+#define kBadAfsPath NSLocalizedStringFromTableInBundle(@"BadAfsPath",nil,[NSBundle bundleForClass:[self class]],@"BadAfsPath")
+
+#define AFS_TOOLS_DIRECTORY /Library/Openafs/
+#define AFS_TOOLS_BIN(x) "/Library/Openafs/bin/"#x
+#define AFS_CACHE_PATH "/var/db/openafs/cache"
+
+#define AFSD_TMP_OLD_PREFERENCE_FILE @"/tmp/afsd.options"
+#define AFSD_TMP_NEW_PREFERENCE_FILE @"/tmp/afs.conf"
+#define AFSD_OLD_PREFERENCE_FILE @"/etc/config/afsd.options"
+#define AFSD_NEW_PREFERENCE_FILE @"/etc/config/afs.conf"
+
+
+//-afsdb -stat 2000 -dcache 800 -daemons 3 -volumes 70 -dynroot -fakestat-all
+#define AFSD_OPTION_AFSDB_KEY "-afsdb"
+#define AFSD_OPTION_VERBOSE_KEY "-verbose"
+#define AFSD_OPTION_STAT_KEY "-stat"
+#define AFSD_OPTION_DCACHE_KEY "-dcache"
+#define AFSD_OPTION_DAEMONS_KEY "-daemons"
+#define AFSD_OPTION_VOLUMES_KEY "-volumes"
+#define AFSD_OPTION_DYNROOT_KEY "-dynroot"
+#define AFSD_OPTION_FKESTAT_ALL "-fakestat-all"
+
+#define AFSD_CONF_VERBOSE @"VERBOSE"
+#define AFSD_CONF_OPTION @"OPTIONS"
+#define AFSD_CONF_SYSNAME @"AFS_SYSNAME"
+#define AFSD_CONF_POST_INI @"AFS_POST_INIT"
+#define AFSD_CONF_PRE_SHUTDOWN @"AFS_PRE_SHUTDOWN"
+
+#define AFS_CONF_CHANGE_FROM_Mj_VERSION 1
+#define AFS_CONF_CHANGE_FROM_Mi_VERSION 4
+#define AFS_DEV_CONF_CHANGE_FROM_Mi_VERSION 5
+#define AFS_CONF_CHANGE_FROM_Pa_VERSION 7
+#define AFS_DEV_CONF_CHANGE_FROM_Pa_VERSION 31
+
+@implementation AFSPropertyManager
+
+
+// -------------------------------------------------------------------------------
+// init:
+// -------------------------------------------------------------------------------
+-(id) init
+{
+ [super init];
+ cellList = [[NSMutableArray alloc] init];
+ cellName = nil;
+ userDefaultCellArray = nil;
+ useAfsdConfVersion = NO;
+ dynRoot = NO;
+ afsDB = NO;
+ verbose = NO;
+ futil = [[FileUtil alloc] init];
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// initWithAfsPath:
+// -------------------------------------------------------------------------------
+- (id)initWithAfsPath:(NSString*)path
+{
+ // avvio la creazione standard dell'oggetto
+ if([self init]){
+ // imposto il path
+ [self setPath:path];
+ }
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// dealloc:
+// -------------------------------------------------------------------------------
+-(void) dealloc
+{
+ if(installationPath){ [installationPath release]; NSLog(@"Released installationPath"); }
+ if(cellList) { NSLog(@"Released cellList");[cellList removeAllObjects];[cellList release];}
+ if(cellName) { NSLog(@"Released cellName");[cellName release];}
+ if(futil) {
+ [futil endAutorization];
+ [futil release];
+ futil = nil;
+ }
+ [super dealloc];
+}
+
+// -------------------------------------------------------------------------------
+// setPath:
+// -------------------------------------------------------------------------------
+- (void) setPath:(NSString*)path {
+ if(installationPath)[installationPath release];
+
+ if(path)
+ installationPath = [path retain];
+}
+
+// -------------------------------------------------------------------------------
+// path:
+// -------------------------------------------------------------------------------
+- (NSString*) path{
+ return installationPath;
+}
+
+// -------------------------------------------------------------------------------
+// statCacheEntry:
+// -------------------------------------------------------------------------------
+-(int) statCacheEntry
+{
+ return statCacheEntry;
+}
+
+// -------------------------------------------------------------------------------
+// setStatCacheEntry:
+// -------------------------------------------------------------------------------
+-(void) setStatCacheEntry:(int)statEntry
+{
+ statCacheEntry = statEntry;
+}
+
+
+// -------------------------------------------------------------------------------
+// dCacheDim:
+// -------------------------------------------------------------------------------
+-(int) dCacheDim
+{
+ return dCacheDim;
+}
+
+// -------------------------------------------------------------------------------
+// setDCacheDim:
+// -------------------------------------------------------------------------------
+-(void) setDCacheDim:(int)dcDim
+{
+ dCacheDim = dcDim;
+}
+
+// -------------------------------------------------------------------------------
+// cacheDimension:
+// -------------------------------------------------------------------------------
+-(int) cacheDimension
+{
+ return cacheDimension;
+}
+
+// -------------------------------------------------------------------------------
+// setCacheDimension:
+// -------------------------------------------------------------------------------
+-(void) setCacheDimension:(int)cacheDim
+{
+ cacheDimension = cacheDim;
+}
+
+// -------------------------------------------------------------------------------
+// daemonNumber:
+// -------------------------------------------------------------------------------
+-(int) daemonNumber
+{
+ return daemonNumber;
+}
+
+// -------------------------------------------------------------------------------
+// setDaemonNumber:
+// -------------------------------------------------------------------------------
+-(void) setDaemonNumber:(int)dNumber
+{
+ daemonNumber = dNumber;
+}
+
+// -------------------------------------------------------------------------------
+// afsRootMountPoint:
+// -------------------------------------------------------------------------------
+-(NSString*) afsRootMountPoint
+{
+ return afsRootMountPoint;
+}
+
+// -------------------------------------------------------------------------------
+// setAfsRootMountPoint:
+// -------------------------------------------------------------------------------
+-(void) setAfsRootMountPoint:(NSString*)mountPoint
+{
+ if(afsRootMountPoint)[afsRootMountPoint release];
+
+ if(mountPoint)
+ afsRootMountPoint = [mountPoint retain];
+}
+
+// -------------------------------------------------------------------------------
+// nVolEntry:
+// -------------------------------------------------------------------------------
+-(int) nVolEntry
+{
+ return nVolEntry;
+}
+
+// -------------------------------------------------------------------------------
+// setNVolEntry:
+// -------------------------------------------------------------------------------
+-(void) setNVolEntry:(int)entry
+{
+ nVolEntry = entry;
+}
+
+// -------------------------------------------------------------------------------
+// dynRoot:
+// -------------------------------------------------------------------------------
+-(bool) dynRoot
+{
+ return dynRoot;
+}
+
+// -------------------------------------------------------------------------------
+// setDynRoot:
+// -------------------------------------------------------------------------------
+-(void) setDynRoot:(bool)flag
+{
+ dynRoot = flag;
+}
+
+// -------------------------------------------------------------------------------
+// dynRoot:
+// -------------------------------------------------------------------------------
+-(bool) afsDB
+{
+ return afsDB;
+}
+
+// -------------------------------------------------------------------------------
+// setDynRoot:
+// -------------------------------------------------------------------------------
+-(void) setAfsDB:(bool)flag
+{
+ afsDB = flag;
+}
+
+// -------------------------------------------------------------------------------
+// setDynRoot:
+// -------------------------------------------------------------------------------
+-(bool) verbose
+{
+ return verbose;
+}
+
+// -------------------------------------------------------------------------------
+// setDynRoot:
+// -------------------------------------------------------------------------------
+-(void) setVerbose:(bool)flag
+{
+ verbose = flag;
+}
+
+// -------------------------------------------------------------------------------
+// useAfsdConfVersion:
+// -------------------------------------------------------------------------------
+-(BOOL) useAfsdConfConfigFile
+{
+ return useAfsdConfVersion;
+}
+
+// -------------------------------------------------------------------------------
+// exceptionOnInvalidPath:
+// -------------------------------------------------------------------------------
+- (void) exceptionOnInvalidPath
+{
+ if(!installationPath || ([installationPath length] == 0)) {
+ @throw [NSException exceptionWithName:@"AFSPropertyManager:exceptionOnInvalidPath"
+ reason:kPathNotEmpty
+ userInfo:nil];
+ }
+ if(![[NSFileManager defaultManager] fileExistsAtPath:installationPath]){
+ @throw [NSException exceptionWithName:@"AFSPropertyManager:exceptionOnInvalidPath"
+ reason:kPathDontContainAfsInstallation
+ userInfo:nil];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// loadConfiguration:
+// -------------------------------------------------------------------------------
+- (void) loadConfiguration {
+ int mjVersion = [self getAfsMajorVersionVersion];
+ int miVersion = [self getAfsMinorVersionVersion];
+ int paVersion = [self getAfsPatchVersionVersion];
+
+ NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256];
+ @try{
+
+ [self exceptionOnInvalidPath];
+ [self clearConfiguration];
+
+ //chech the afs version for chioce wich afsd conf file usage
+ useAfsdConfVersion = mjVersion >= 1 && miVersion>=4 && paVersion>=7;
+ useAfsdConfVersion = useAfsdConfVersion || (mjVersion >= 1 && miVersion>=6 && paVersion>=31);
+
+ // read thiscell config file
+ [filePath setString:installationPath];
+ [filePath appendString: @"/etc/ThisCell"];
+ NSLog(@"Search for cell name.");
+ [self readCellInfo:filePath];
+ if(!cellName){
+ @throw [NSException exceptionWithName:@"readCellInfo"
+ reason:kThisCellFOError
+ userInfo:nil];
+ }
+ NSLog(@"Cell found: %s", [cellName cString]);
+
+ //read TheseCell file
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/TheseCells"];
+ userDefaultCellArray = [self readTheseCell:filePath];
+
+ //read cell serv db
+ NSLog(@"Scan for cell db");
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/CellServDB"];
+ [self readCellDB:filePath];
+ NSLog(@"Server found: %d", [cellList count]);
+
+
+
+ //Read cacheinfo
+ NSLog(@"Scan cacheinfo file");
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/cacheinfo"];
+ [self readCacheInfo:filePath];
+ NSLog(@"End scan cacheinfo file");
+
+ //Read config/afsd.options
+ [filePath setString: installationPath];
+ [filePath appendString: useAfsdConfVersion?AFSD_NEW_PREFERENCE_FILE:AFSD_OLD_PREFERENCE_FILE];
+ [self readAfsdOption:filePath];
+
+ } @catch(NSException * e){
+ @throw e;
+ } @finally {
+ [filePath release];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// readCacheInfo:
+// file template "/afs:/var/db/openafs/cache:30000"
+// -------------------------------------------------------------------------------
+-(void) readCacheInfo:(NSString*)filePath
+{
+ int cicle = 0;
+ NSString *tmpString = nil;
+ NSCharacterSet *fullStopCS = [NSCharacterSet characterSetWithCharactersInString:@":"];
+ NSMutableCharacterSet *chunkStartCS = [[NSMutableCharacterSet alloc] init];
+ [chunkStartCS formUnionWithCharacterSet:[NSCharacterSet alphanumericCharacterSet]];
+ [chunkStartCS formUnionWithCharacterSet:[NSMutableCharacterSet characterSetWithCharactersInString:@"/"]];
+
+ NSCharacterSet *returnCS = [NSCharacterSet characterSetWithCharactersInString:@"\n"];
+ NSFileHandle *fileH = [NSFileHandle fileHandleForReadingAtPath:filePath];
+ NSData *fileHData = [fileH readDataToEndOfFile];
+ NSString *cacheInfoStrData = [[NSString alloc] initWithData:fileHData
+ encoding:NSASCIIStringEncoding];
+ NSScanner *cacheInfoS = [NSScanner scannerWithString:cacheInfoStrData];
+
+ @try{
+ do {
+ cicle++;
+ switch(cicle){
+ case 1:
+ // afs mount path
+ [cacheInfoS scanUpToCharactersFromSet:fullStopCS intoString:&tmpString];
+ [self setAfsRootMountPoint:tmpString];
+ [cacheInfoS scanUpToCharactersFromSet:chunkStartCS intoString:&tmpString];
+ break;
+
+ case 2:
+ //cache path default '/var/db/openafs/cache'
+ [cacheInfoS scanUpToCharactersFromSet:fullStopCS intoString:&tmpString];
+ [cacheInfoS scanUpToCharactersFromSet:chunkStartCS intoString:&tmpString];
+ break;
+
+ case 3:
+ // cache dimension
+ [cacheInfoS scanUpToCharactersFromSet:returnCS intoString:&tmpString];
+ [self setCacheDimension:[tmpString intValue]];
+ break;
+ }
+ }while(cicle < 3 && ![cacheInfoS isAtEnd]);
+ }@catch(NSException *e){
+ @throw e;
+ }@finally{
+ //if(cacheInfoStrData) [cacheInfoStrData release];
+ if(chunkStartCS) [chunkStartCS release];
+ }
+
+}
+
+
+// -------------------------------------------------------------------------------
+// writeCacheInfo:
+// -------------------------------------------------------------------------------
+-(int) writeCacheInfo:(NSString*)filePath
+{
+ NSNumber *tmpNum = nil;
+ NSMutableString *cacheInfoContent = [[NSMutableString alloc] init];
+ if(!cacheInfoContent) return -1;
+
+ //Afs root mount point
+ if([[self afsRootMountPoint] rangeOfString:@"/"].location == NSNotFound || [[self afsRootMountPoint] length] == 0)
+ @throw [NSException exceptionWithName:@"AFSPropertyManager:writeCacheInfo"
+ reason:@"Bad afs path"
+ userInfo:nil];
+ [cacheInfoContent appendString:[self afsRootMountPoint]];
+
+ //standard cache path
+
+ [cacheInfoContent appendString:@":"]; [cacheInfoContent appendString:@AFS_CACHE_PATH]; [cacheInfoContent appendString:@":"];
+
+ //cache dimension
+ tmpNum = [NSNumber numberWithInt:[self cacheDimension]];
+ if([tmpNum intValue] == 0)
+ @throw [NSException exceptionWithName:@"AFSPropertyManager:writeCacheInfo"
+ reason:@"Bad cache dimension"
+ userInfo:nil];
+ [cacheInfoContent appendString:[tmpNum stringValue]];
+
+ [cacheInfoContent writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically: YES
+ encoding: NSASCIIStringEncoding
+ error: nil];
+
+ [cacheInfoContent release];
+ return noErr;
+}
+
+// -------------------------------------------------------------------------------
+// readCacheInfo:
+// file template "/afs:/var/db/openafs/cache:30000"
+// -------------------------------------------------------------------------------
+-(void) readAfsdOption:(NSString*)filePath
+{
+ @try{
+ if(useAfsdConfVersion) {
+ [self readNewAfsdOption:filePath];
+ } else {
+ [self readOldAfsdOption:filePath];
+ }
+
+ }@catch(NSException *e){
+ @throw e;
+ }@finally{
+
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// readOldAfsdOption:
+// -------------------------------------------------------------------------------
+-(void) readOldAfsdOption:(NSString*)filePath
+{
+
+ /*NSFileHandle *fileH = [NSFileHandle fileHandleForReadingAtPath:filePath];
+ NSData *fileHData = [fileH readDataToEndOfFile];
+ NSString *afsdOptionStrData = [[NSString alloc] initWithData:fileHData
+ encoding:NSASCIIStringEncoding];*/
+ if(!filePath) return;
+ [self readAFSDParamLineContent:[[NSString stringWithContentsOfFile:filePath] stringByStandardizingPath]];
+}
+
+// -------------------------------------------------------------------------------
+// readAFSDParamLineContent:
+// -------------------------------------------------------------------------------
+-(void) readAFSDParamLineContent:(NSString*) paramLine{
+ NSString *tmpString = nil;
+ NSCharacterSet *space = [NSCharacterSet characterSetWithCharactersInString:@" "];
+ NSScanner *afsdOptionS = [NSScanner scannerWithString:paramLine];
+
+ do{
+ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString];
+ if(!tmpString) continue;
+
+ NSLog(tmpString);
+ //check parameter type
+ if([tmpString isEqualToString:@AFSD_OPTION_DAEMONS_KEY])
+ {
+ // get number of daemon
+ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString];
+ [self setDaemonNumber:[tmpString intValue]];
+ } else
+ //check parameter type
+ if([tmpString isEqualToString:@AFSD_OPTION_DCACHE_KEY])
+ {
+ //get dcache dimension
+ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString];
+ [self setDCacheDim:[tmpString intValue]];
+ } else
+ //check parameter type
+ if([tmpString isEqualToString:@AFSD_OPTION_DYNROOT_KEY])
+ {
+ [self setDynRoot:true];
+ } else
+ if([tmpString isEqualToString:@AFSD_OPTION_VERBOSE_KEY])
+ {
+ [self setVerbose:true];
+ } else if([tmpString isEqualToString:@AFSD_OPTION_AFSDB_KEY])
+ {
+ [self setAfsDB:true];
+ } else
+ //check parameter type
+ if([tmpString isEqualToString:@AFSD_OPTION_STAT_KEY])
+ {
+ // get fstat entry num
+ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString];
+ [self setStatCacheEntry:[tmpString intValue]];
+ } else
+
+ //check parameter type
+ if([tmpString isEqualToString:@AFSD_OPTION_VOLUMES_KEY])
+ {
+ // get fstat entry num
+ [afsdOptionS scanUpToCharactersFromSet:space intoString:&tmpString];
+ [self setNVolEntry:[tmpString intValue]];
+ }
+
+
+
+ }while(![afsdOptionS isAtEnd]);
+
+}
+
+// -------------------------------------------------------------------------------
+// readNewAfsdOption:
+// -------------------------------------------------------------------------------
+-(void) readNewAfsdOption:(NSString*)filePath
+{
+ if(!filePath) return;
+ NSString *currentLines = nil;
+ NSString *paramValue = nil;
+ NSScanner *lineScanner = nil;
+
+ //Get file content
+ NSString *newAFSDConfContent = [NSString stringWithContentsOfFile:filePath];
+
+ //get lines in array
+ NSArray *confLines = [newAFSDConfContent componentsSeparatedByString:@"\n"];
+
+ //Get the lines enumerator
+ NSEnumerator *lineEnumerator = [confLines objectEnumerator];
+
+ //scann all lines
+ while(currentLines = [lineEnumerator nextObject]) {
+ if([currentLines rangeOfString:@"#"].location != NSNotFound) continue;
+
+ if([currentLines rangeOfString:AFSD_CONF_OPTION].location != NSNotFound) {
+ lineScanner = [NSScanner scannerWithString:currentLines];
+ if(!lineScanner) continue;
+
+ //scann the line
+
+ [lineScanner scanUpToString:@"\"" intoString:¶mValue]; NSLog(paramValue);[lineScanner scanUpToString:@"-" intoString:¶mValue];
+ [lineScanner scanUpToString:@"\"" intoString:¶mValue]; NSLog(paramValue);
+
+ // read the asfd option param line
+ [self readAFSDParamLineContent:paramValue];
+ } else if([currentLines rangeOfString:AFSD_CONF_SYSNAME].location != NSNotFound) {
+
+ } else if([currentLines rangeOfString:AFSD_CONF_POST_INI].location != NSNotFound) {
+
+ } else if([currentLines rangeOfString:AFSD_CONF_PRE_SHUTDOWN].location != NSNotFound) {
+
+ }
+ }
+}
+
+
+// -------------------------------------------------------------------------------
+// writeCacheInfo:
+// -------------------------------------------------------------------------------
+-(int) writeAfsdOption:(NSString*)filePath
+{
+ int result = 0;
+ @try{
+ if(useAfsdConfVersion) {
+ result = [self writeNewAfsdOption:filePath];
+ } else {
+ result = [self writeOldAfsdOption:filePath];
+ }
+
+ }@catch(NSException *e){
+ @throw e;
+ }@finally{
+
+ }
+ return result;
+}
+
+// -------------------------------------------------------------------------------
+// writeOldAfsdOption:
+// -------------------------------------------------------------------------------
+-(int) writeOldAfsdOption:(NSString*)filePath;
+{
+ NSMutableString *oldConfFileContent = [[[NSMutableString alloc] init] autorelease];
+ //add afsd param
+ [oldConfFileContent appendString:[self makeChaceParamString]];
+
+ //add cariage return at end of file
+ [oldConfFileContent appendString:@"\n"];
+
+ //write content on file
+ [oldConfFileContent writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically: YES
+ encoding: NSASCIIStringEncoding
+ error: nil];
+ return noErr;
+
+}
+
+// -------------------------------------------------------------------------------
+// writeNewAfsdOption:
+// OPTIONS=
+// AFS_SYSNAME=
+// AFS_POST_INIT=afs_server_prefs
+// AFS_PRE_SHUTDOWN=
+// -------------------------------------------------------------------------------
+-(int) writeNewAfsdOption:(NSString*)filePath
+{
+ NSMutableString *newConfFileContent = [[[NSMutableString alloc] init] autorelease];
+
+ //Verbose
+ [newConfFileContent appendString:AFSD_CONF_VERBOSE]; [newConfFileContent appendString:@"="]; [newConfFileContent appendString:@"\n"];
+
+ //AFSD Option
+ [newConfFileContent appendString:AFSD_CONF_OPTION];[newConfFileContent appendString:@"=\""]; [newConfFileContent appendString:[self makeChaceParamString]]; [newConfFileContent appendString:@"\""]; [newConfFileContent appendString:@"\n"];
+
+ //AFS_SYSNAME
+ [newConfFileContent appendString:AFSD_CONF_SYSNAME];[newConfFileContent appendString:@"=\""];[newConfFileContent appendString:@"\""]; [newConfFileContent appendString:@"\n"];
+
+ //AFS_POST_INIT
+ [newConfFileContent appendString:AFSD_CONF_POST_INI];[newConfFileContent appendString:@"="]; [newConfFileContent appendString:@"\n"];
+
+ //AFS_PRE_SHUTDOWN
+ [newConfFileContent appendString:AFSD_CONF_PRE_SHUTDOWN];[newConfFileContent appendString:@"="]; [newConfFileContent appendString:@"\n"];
+
+ //add content on file
+ [newConfFileContent appendString:@"\n"];
+
+ //Write to file
+ [newConfFileContent writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically: YES
+ encoding: NSASCIIStringEncoding
+ error: nil];
+ return noErr;
+}
+
+// -------------------------------------------------------------------------------
+// getAfsVersion:
+// -------------------------------------------------------------------------------
+-(NSString*) getAfsVersion
+{
+ NSString *tmpString = nil;
+ NSString *result = [TaskUtil executeTaskSearchingPath:@"fs" args:[NSArray arrayWithObjects:@"-version", nil]];
+ if(result) NSLog(@"fs -version return: %s", [result cString]);
+
+
+ NSCharacterSet *endVersionCS = [NSCharacterSet characterSetWithCharactersInString:@"qwertyuiopasdfghjklzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWQ"];
+
+ NSCharacterSet *spaceCS = [NSCharacterSet characterSetWithCharactersInString:@" "];
+ NSScanner *versionS = [NSScanner scannerWithString:result];
+ //go to start of version
+ [versionS scanUpToCharactersFromSet:spaceCS intoString:&tmpString];
+
+ //get the total version string
+ [versionS scanUpToCharactersFromSet:endVersionCS intoString:&tmpString];
+
+ return tmpString;
+}
+
+// -------------------------------------------------------------------------------
+// getAfsMajorVersionVersion:
+// -------------------------------------------------------------------------------
+-(int) getAfsMajorVersionVersion
+{
+ NSString *tmpString = nil;
+ NSString *totalVersion = [self getAfsVersion];
+ NSCharacterSet *pointCS = [NSCharacterSet characterSetWithCharactersInString:@"."];
+ NSScanner *versionMS = [NSScanner scannerWithString:totalVersion];
+ [versionMS scanUpToCharactersFromSet:pointCS intoString:&tmpString];
+ return [tmpString intValue];
+}
+
+// -------------------------------------------------------------------------------
+// getAfsMinorVersionVersion:
+// -------------------------------------------------------------------------------
+-(int) getAfsMinorVersionVersion
+{
+ NSString *tmpString = nil;
+ NSString *totalVersion = [self getAfsVersion];
+ NSCharacterSet *numCS = [NSCharacterSet characterSetWithCharactersInString:@"1234567890"];
+ NSCharacterSet *pointCS = [NSCharacterSet characterSetWithCharactersInString:@"."];
+ NSScanner *versionMS = [NSScanner scannerWithString:totalVersion];
+ [versionMS scanUpToCharactersFromSet:pointCS intoString:&tmpString];[versionMS scanUpToCharactersFromSet:numCS intoString:&tmpString];[versionMS scanUpToCharactersFromSet:pointCS intoString:&tmpString];
+ return [tmpString intValue];
+}
+
+// -------------------------------------------------------------------------------
+// getAfsPatchVersionVersion:
+// -------------------------------------------------------------------------------
+-(int) getAfsPatchVersionVersion
+{
+ NSString *totalVersion = [self getAfsVersion];
+ NSCharacterSet *pointCS = [NSCharacterSet characterSetWithCharactersInString:@"."];
+ int lastPointIndex = [totalVersion rangeOfCharacterFromSet:pointCS
+ options:NSBackwardsSearch].location;
+ int patchVersion = [[totalVersion substringFromIndex:lastPointIndex+1] intValue];
+ return patchVersion;
+}
+
+
+// -------------------------------------------------------------------------------
+// clearConfiguration:
+// -------------------------------------------------------------------------------
+- (void) clearConfiguration{
+
+ // clear list of cell
+ [cellList removeAllObjects];
+
+ userDefaultCellArray= nil;
+
+ // remove the old cell name
+ if(cellName) {
+ [cellName release];
+ cellName = nil;
+ }
+}
+
+// -------------------------------------------------------------------------------
+// getCellList:
+// -------------------------------------------------------------------------------
+-(NSMutableArray*) getCellList
+{
+ return cellList;
+}
+
+
+
+// -------------------------------------------------------------------------------
+// getAllCellName:
+// -------------------------------------------------------------------------------
+-(NSArray*) getAllCellsName {
+ NSMutableArray *allCelListName = [[[NSMutableArray alloc] init] autorelease];
+ for(int idx = 0; idx < [cellList count]; idx++){
+ DBCellElement *elemnt = [cellList objectAtIndex:idx];
+ [allCelListName addObject:[elemnt getCellName]];
+ }
+ return allCelListName;
+}
+
+// -------------------------------------------------------------------------------
+// getCellList:
+// -------------------------------------------------------------------------------
+-(NSArray*) getUserDefaultForTokenCells {
+ return userDefaultCellArray;
+}
+
+// -------------------------------------------------------------------------------
+// getDefaultCellName:
+// -------------------------------------------------------------------------------
+-(NSArray*) getDefaultForTokenCellsName {
+ NSMutableArray *allCelListName = [[[NSMutableArray alloc] init] autorelease];
+ for(int idx = 0; idx < [cellList count]; idx++){
+ DBCellElement *elemnt = [cellList objectAtIndex:idx];
+ if([elemnt userDefaultForToken]) [allCelListName addObject:[[elemnt getCellName] retain]];
+ }
+ return allCelListName;
+}
+
+// -------------------------------------------------------------------------------
+// getCellName:
+// -------------------------------------------------------------------------------
+-(NSString*) getDefaultCellName
+{
+ return cellName;
+}
+
+// -------------------------------------------------------------------------------
+// setDefaultCellByName:
+// -------------------------------------------------------------------------------
+-(void) setDefaultCellByName:(NSString*)name
+{
+ DBCellElement *elementCell = nil;
+ BOOL cellFound = false;
+ if(!name) return;
+
+ for(int idx = 0; idx < [cellList count]; idx++) {
+ // check every cell for delete as old user default cell or selected as neww cell
+ elementCell = [cellList objectAtIndex:idx];
+ cellFound = [name compare:[elementCell getCellName]] == NSOrderedSame;
+ [elementCell setUserDefaultCell:cellFound];
+ if(cellFound) {
+ [elementCell setUserDefaultForToken:YES];
+ if(cellName)[cellName release];
+ cellName = [name retain];
+ }
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// setCellName:
+// -------------------------------------------------------------------------------
+- (void) setCellName:(NSString*)cell {
+ [self setDefaultCellByName:cell];
+}
+
+// -------------------------------------------------------------------------------
+// readCellInfo:
+// -------------------------------------------------------------------------------
+-(void) readCellInfo:(NSString*) configFile {
+
+
+ NSError *error = nil;
+ NSString *tmpStr = nil;
+ NSLog(@"Try to opening file: %s",[configFile cString] );
+ NSString * result = [NSString stringWithContentsOfFile:configFile
+ encoding:NSASCIIStringEncoding
+ error:&error];
+ if(!result && error){
+ if([error domain] )
+ @throw [NSException exceptionWithName:@"readCellInfo"
+ reason:kConfFileNotExits
+ userInfo:nil];
+ }
+ NSScanner *scanner = [NSScanner scannerWithString:result];
+
+ [scanner scanUpToString:@"\n"
+ intoString:&tmpStr];
+
+ // make a copy of self created string
+ cellName = [tmpStr retain];
+}
+
+// -------------------------------------------------------------------------------
+// readCellDB:
+// -------------------------------------------------------------------------------
+-(void) readCellDB:(NSString*) configFile {
+ NSString *tmpString = nil;
+ BOOL isInCellDefaultArray = NO; // the cell belong
+ BOOL isDefaultCell = NO;
+ DBCellElement *afsCellDBElement = nil;
+ NSCharacterSet *returnCS = [NSCharacterSet characterSetWithCharactersInString:@"\n"];
+ NSCharacterSet *spaceCS = [NSCharacterSet characterSetWithCharactersInString:@" \t"];
+
+ NSFileHandle *fileH = [NSFileHandle fileHandleForReadingAtPath:configFile];
+ NSData *dbCellData = [fileH readDataToEndOfFile];
+ NSString *strData = [[NSString alloc] initWithData:dbCellData
+ encoding:NSASCIIStringEncoding];
+ NSScanner *cellDBScanner = [NSScanner scannerWithString:strData];
+
+ @try{
+ [cellDBScanner scanUpToCharactersFromSet:[NSCharacterSet alphanumericCharacterSet] intoString:&tmpString];
+ while([cellDBScanner isAtEnd] == NO) {
+ // make new cell
+ afsCellDBElement = [[DBCellElement alloc] init];
+
+ // get the name of cell
+ [cellDBScanner scanUpToCharactersFromSet:spaceCS intoString:&tmpString];
+ [afsCellDBElement setCellName: tmpString];
+
+ //check if this cells is one of user has selected to get token
+ isInCellDefaultArray = [userDefaultCellArray containsObject:tmpString];
+ //check if this cell is also the default cell
+ isDefaultCell = [cellName compare:tmpString]==NSOrderedSame;
+
+ [afsCellDBElement setUserDefaultForToken:isInCellDefaultArray||isDefaultCell];
+ [afsCellDBElement setUserDefaultCell:isDefaultCell];
+
+
+
+
+
+ // get the cell comment
+ [cellDBScanner scanUpToCharactersFromSet:[NSCharacterSet alphanumericCharacterSet] intoString:nil];
+ [cellDBScanner scanUpToCharactersFromSet:returnCS intoString:&tmpString];
+ [afsCellDBElement setCellComment: tmpString];
+
+ // get all ip
+ [cellDBScanner scanUpToString:@">" intoString:&tmpString];
+ // scann all ip in list
+ [self scanIpForCell:afsCellDBElement allIP:tmpString];
+
+ // add cell to list
+ [cellList addObject:afsCellDBElement];
+ // release the object becasuse NSMutableArray make a retain on object
+ [afsCellDBElement release];
+ //repeat
+ [cellDBScanner scanUpToCharactersFromSet:[NSCharacterSet alphanumericCharacterSet] intoString:&tmpString];
+ }
+ }@catch(NSException *e){
+ @throw e;
+ }@finally{
+ //if(strData) [strData release];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// scanIpForCell:
+// -------------------------------------------------------------------------------
+-(void) scanIpForCell:(DBCellElement*) cellElement allIP:(NSString*)allIP {
+ NSScanner *ipScann = [NSScanner scannerWithString:allIP];
+ NSCharacterSet *returnCS = [NSCharacterSet characterSetWithCharactersInString:@"\n"];
+ NSCharacterSet *spaceCS = [NSCharacterSet characterSetWithCharactersInString:@" \t"];
+ NSCharacterSet *startCommentCS = [NSCharacterSet characterSetWithCharactersInString:@"#"];
+ NSString *tmpString = nil;
+ while([ipScann isAtEnd] == NO){
+ CellIp *cellIpDesc = [[CellIp alloc] init];
+
+ //ip string
+ [ipScann scanUpToCharactersFromSet:spaceCS
+ intoString:&tmpString];
+
+ [cellIpDesc setCellIp:tmpString];
+ //[tmpString release];
+
+ // go to comment
+ [ipScann scanUpToCharactersFromSet:startCommentCS intoString:nil];
+ // skip comment symbol
+ [ipScann scanUpToCharactersFromSet:[NSCharacterSet alphanumericCharacterSet] intoString:nil];
+ // get comment
+ [ipScann scanUpToCharactersFromSet:returnCS intoString:&tmpString];
+ [cellIpDesc setCellComment:tmpString];
+ //[tmpString release];
+
+ [cellElement addIpToCell:cellIpDesc];
+ // release the object becasuse NSMutableArray make a retain on object
+ [cellIpDesc release];
+ }
+}
+
+
+// -------------------------------------------------------------------------------
+// scanIpForCell:
+// -------------------------------------------------------------------------------
+-(NSArray*) readTheseCell:(NSString*) configFile {
+
+ NSFileHandle *fileH = [NSFileHandle fileHandleForReadingAtPath:configFile];
+ NSData *dbCellData = [fileH readDataToEndOfFile];
+ NSString *strData = [[NSString alloc] initWithData:dbCellData
+ encoding:NSASCIIStringEncoding];
+
+ return [strData componentsSeparatedByString:@"\n"];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) getTokenList
+// -------------------------------------------------------------------------------
+-(NSArray*) getTokenList
+{
+ int line = 0;
+ NSString *tokenLine = nil;
+ //NSString *tmpValue = nil;
+ NSMutableArray *tokenList = [[NSMutableArray alloc] init];
+ NSString *tokensOutput = [TaskUtil executeTaskSearchingPath:@"tokens" args:[NSArray arrayWithObjects:nil]];
+
+ // scann the tokens
+ NSScanner *tokenScan = [NSScanner scannerWithString:tokensOutput];
+ NSCharacterSet *returnCS = [NSCharacterSet characterSetWithCharactersInString:@"\n"];
+
+ while([tokenScan isAtEnd] == NO){
+ line++;
+ // get the next line
+ [tokenScan scanUpToCharactersFromSet:returnCS
+ intoString:&tokenLine];
+
+ // check for tokens end
+ if([tokenLine rangeOfString:@"--End of list--"].location != NSNotFound) break;
+
+
+ if(line >= 2){
+ NSLog(@"Token found %s", [tokenLine UTF8String]);
+ // add enteir row to result
+ [tokenList addObject:tokenLine];
+ // create the line scanner for all the row that contains token info
+ }
+ }
+ //
+ return tokenList;
+}
+
+// -------------------------------------------------------------------------------
+// +(void) klog:(NSString*)uName uPwd:(NSString*)uPwd
+// -------------------------------------------------------------------------------
+-(void) klog:(NSString*)uName uPwd:(NSString*)uPwd cell:(NSString*)theCell
+{
+ if(uName == @"" || uPwd == @"") return;
+
+ [TaskUtil executeTaskSearchingPath:@"klog"
+ args:(theCell==nil?[NSArray arrayWithObjects:@"-principal", uName, @"-password", uPwd, nil]:[NSArray arrayWithObjects:@"-principal", uName, @"-password", uPwd, @"-c", theCell, nil])];
+
+
+}
+
+
+// -------------------------------------------------------------------------------
+// +(void) aklog
+// -------------------------------------------------------------------------------
+-(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable {
+ KLPrincipal princ = nil;
+ KLStatus kstatus = noErr;
+ char *princName = malloc(255);
+ @try {
+ // trying to ket kerberos ticket
+ if(krb5CallEnable) {
+ kstatus = KLAcquireInitialTickets (0L, 0L, &princ, &princName);
+ if(kstatus != noErr && kstatus != klUserCanceledErr) @throw [NSException exceptionWithName:@"aklog"
+ reason:kPathNotEmpty
+ userInfo:nil];
+ } else kstatus = klNoErr;
+
+ //ok to launch aklog
+ if(kstatus == klNoErr) [TaskUtil executeTaskSearchingPath:@"aklog"
+ args:(theCell==nil?[NSArray arrayWithObjects:nil]:[NSArray arrayWithObjects:@"-c", theCell, nil])];
+
+ }
+ @catch (NSException * e) {
+ @throw e;
+ }
+ @finally {
+ // destory the kerberos va
+ if(princName && princ != nil)
+ KLDisposeString(princName);
+ else if(princName) free(princName);
+ }
+
+}
+
+
+// -------------------------------------------------------------------------------
+// getTokens:
+// -------------------------------------------------------------------------------
+- (void) getTokens:(BOOL)klogAklogFlag usr:(NSString*)usr pwd:(NSString*)pwd {
+
+ NSString *celStrName = nil;
+ NSArray *tmpDefaultArray = [self getDefaultForTokenCellsName];
+ if(tmpDefaultArray && [tmpDefaultArray count] > 1) {
+ //there are other cell to autenticate
+ for(int idx=0; idx < [tmpDefaultArray count]; idx++){
+ celStrName = [tmpDefaultArray objectAtIndex:idx];
+ if(klogAklogFlag)
+ [self klog:usr
+ uPwd:pwd
+ cell:celStrName];
+ else
+ [self aklog:celStrName noKerberosCall:YES];
+ }
+
+ } else {
+ //there is only default cell to autenticate
+ if(klogAklogFlag)
+ [self klog:usr
+ uPwd:pwd
+ cell:nil];
+ else
+ [self aklog:nil noKerberosCall:YES];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// +(void) unlog
+// -------------------------------------------------------------------------------
+-(void) unlog:(NSString*)cell
+{
+ [TaskUtil executeTaskSearchingPath:@"unlog"
+ args:(cell?[NSArray arrayWithObjects:@"-c",cell,nil]:[NSArray arrayWithObjects:nil])];
+}
+
+// -------------------------------------------------------------------------------
+// -(void) shutdown
+// -------------------------------------------------------------------------------
+-(void) shutdown
+{
+ NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256];
+ @try {
+ if([[AuthUtil shared] autorize] != noErr)
+ return;
+
+ /*const char *args0[] = {"stop", 0L};
+ [[AuthUtil shared] execUnixCommand:"/Library/StartupItems/OpenAFS/OpenAFS_stop"
+ args:args0
+ output:0L];*/
+
+ // unmount afs
+ const char *args1[] = {"-f", "/afs", 0L};
+ [[AuthUtil shared] execUnixCommand:"/sbin/umount"
+ args:args1
+ output:0L];
+
+ const char *args2[] = {"-shutdown", 0L};
+ [[AuthUtil shared] execUnixCommand:"/usr/sbin/afsd"
+ args:args2
+ output:0L];
+
+ const char *args3[] = {[filePath UTF8String], 0L};
+ [[AuthUtil shared] execUnixCommand:"/sbin/kextunload"
+ args:args3
+ output:0L];
+
+ }
+ @catch (NSException * e) {
+ @throw e;
+ }
+ @finally {
+
+ }
+
+
+}
+
+// -------------------------------------------------------------------------------
+// -(void) saveConfigurationFiles
+// -------------------------------------------------------------------------------
+-(void) saveConfigurationFiles:(BOOL) makeBackup
+{
+ NSError *err;
+ NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256];
+ NSMutableString *cellServDBString = [[NSMutableString alloc] initWithCapacity:256];
+ NSMutableString *theseCellString = [[NSMutableString alloc] initWithCapacity:256];
+ DBCellElement *cellElement = nil;
+
+ // save the configuration file
+ @try{
+ [self exceptionOnInvalidPath];
+
+ // ThisCell
+ [filePath setString: @"/tmp/ThisCell"];
+ [cellName writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically:YES
+ encoding: NSASCIIStringEncoding
+ error:nil];
+ // CellServDB
+
+ for(int idx = 0; idx < [cellList count]; idx++){
+ cellElement = [cellList objectAtIndex:idx];
+ [cellServDBString appendString:[cellElement description]];
+ if([cellElement userDefaultForToken]) {
+ [theseCellString appendString:[cellElement getCellName]];
+ [theseCellString appendString:@"\n"];
+ }
+ }
+
+
+ [filePath setString: @"/tmp/CellServDB"];
+ [cellServDBString writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically:YES
+ encoding: NSUTF8StringEncoding
+ error:&err];
+
+ [filePath setString: @"/tmp/TheseCells"];
+ [theseCellString writeToFile: [filePath stringByExpandingTildeInPath]
+ atomically:YES
+ encoding: NSUTF8StringEncoding
+ error:&err];
+
+ // backup original file
+ if([futil startAutorization] != noErr){
+ @throw [NSException exceptionWithName:@"saveConfigurationFiles:startAutorization"
+ reason:kUserNotAuth
+ userInfo:nil];
+ }
+
+ if(makeBackup) [self backupConfigurationFiles];
+
+ // install ThisCell
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/ThisCell"];
+ [self installConfigurationFile:@"/tmp/ThisCell"
+ destPath:filePath];
+
+ // install CellServDB
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/CellServDB"];
+ [self installConfigurationFile:@"/tmp/CellServDB"
+ destPath:filePath];
+
+ // install CellServDB
+ [filePath setString: installationPath];
+ [filePath appendString: @"/etc/TheseCells"];
+ [self installConfigurationFile:@"/tmp/TheseCells"
+ destPath:filePath];
+
+ } @catch (NSException *e) {
+ @throw e;
+ }@finally {
+ // dispose all variable used
+ if(filePath) [filePath release];
+ if(cellServDBString) [cellServDBString release];
+ }
+
+}
+
+// -------------------------------------------------------------------------------
+// -(void) saveCacheConfigurationFiles
+// -------------------------------------------------------------------------------
+-(void) saveCacheConfigurationFiles:(BOOL)makeBackup
+{
+ NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256];
+ // save the configuration file
+ @try{
+ [self exceptionOnInvalidPath];
+
+ // cacheinfo file creation
+ [self writeCacheInfo:@"/tmp/cacheinfo"];
+
+ //afsd.option or afs.conf file creation
+ [self writeAfsdOption:useAfsdConfVersion?AFSD_TMP_NEW_PREFERENCE_FILE:AFSD_TMP_OLD_PREFERENCE_FILE];
+
+ // backup original file
+ if([futil startAutorization] != noErr){
+ @throw [NSException exceptionWithName:@"AFSPropertyManager:saveCacheConfigurationFiles:startAutorization"
+ reason:kUserNotAuth
+ userInfo:nil];
+ }
+
+ if(makeBackup) {
+ //cacheinfo
+ [self backupFile:@"/etc/cacheinfo"];
+
+ //afsd.options
+ [self backupFile:useAfsdConfVersion?AFSD_NEW_PREFERENCE_FILE:AFSD_OLD_PREFERENCE_FILE];
+ }
+
+ // install cacheinfo
+ [filePath setString:installationPath];
+ [filePath appendString: @"/etc/cacheinfo"];
+ [self installConfigurationFile:@"/tmp/cacheinfo"
+ destPath:filePath];
+
+ // install afsd.conf or afs.conf configuration file
+ [filePath setString: installationPath];
+ [filePath appendString: useAfsdConfVersion?AFSD_NEW_PREFERENCE_FILE:AFSD_OLD_PREFERENCE_FILE];
+ [self installConfigurationFile:useAfsdConfVersion?AFSD_TMP_NEW_PREFERENCE_FILE:AFSD_TMP_OLD_PREFERENCE_FILE
+ destPath:filePath];
+
+ } @catch (NSException *e) {
+ @throw e;
+ }@finally {
+ if(filePath) [filePath release];
+ }
+
+
+}
+
+// -------------------------------------------------------------------------------
+// -(void) installConfigurationFile
+// -------------------------------------------------------------------------------
+-(void) installConfigurationFile:(NSString*)srcConfFile
+ destPath:(NSString*)destPath
+{
+ // delete the file original file
+
+ if([futil autorizedDelete:destPath] != noErr){
+ @throw [NSException exceptionWithName:@"installConfigurationFile:autorizedDelete"
+ reason:destPath
+ userInfo:nil];
+ }
+
+ // move the file
+ if([futil autorizedMoveFile:srcConfFile
+ toPath:destPath] != noErr) {
+ @throw [NSException exceptionWithName:@"saveConfigurationFiles:autorizedMoveFile"
+ reason:srcConfFile
+ userInfo:nil];
+ }
+
+
+ if([futil autorizedChown:destPath
+ owner:@"root"
+ group:@"wheel"]!= noErr) {
+ @throw [NSException exceptionWithName:@"saveConfigurationFiles:autorizedChown"
+ reason:destPath
+ userInfo:nil];
+ }
+}
+
+// -------------------------------------------------------------------------------
+// -(void) backupConfigurationFiles
+// -------------------------------------------------------------------------------
+-(void) backupConfigurationFiles
+{
+
+ @try{
+ if([futil startAutorization] != noErr){
+ @throw [NSException exceptionWithName:@"backupConfigurationFiles:startAutorization"
+ reason:kUserNotAuth
+ userInfo:nil];
+ }
+ //This cell
+ [self backupFile:@"/etc/ThisCell"];
+
+ //CellServDB
+ [self backupFile:@"/etc/CellServDB"];
+
+ //TheseCell
+ [self backupFile:@"/etc/TheseCells"];
+
+ //[futil endAutorization];
+ } @catch (NSException *e) {
+ @throw e;
+ } @finally {
+ }
+}
+
+// -------------------------------------------------------------------------------
+// -(void) backupFile:(NSString*)localAfsFilePath
+// -------------------------------------------------------------------------------
+-(void) backupFile:(NSString*)localAfsFilePath
+{
+ NSString *srcString = nil;
+ NSMutableString *filePath = [[NSMutableString alloc] initWithCapacity:256];
+ OSStatus err = noErr;
+ @try{
+ [filePath setString: installationPath];
+ [filePath appendString: localAfsFilePath];
+
+ //Check if the file at path exist
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+
+ //check if th efile exist
+ if(![fileManager fileExistsAtPath:[filePath stringByExpandingTildeInPath]]) return;
+
+ // store the source path
+ srcString = [filePath stringByExpandingTildeInPath];
+ [filePath appendString: @".afscommander_bk"];
+
+ // check for presence of bk file
+ if(![[NSFileManager defaultManager] fileExistsAtPath:[filePath stringByExpandingTildeInPath]]){
+ // backup the file
+ err = [futil autorizedCopy:srcString
+ toPath:[filePath stringByExpandingTildeInPath]];
+ }
+ } @catch (NSException *e) {
+ @throw e;
+ } @finally {
+ if(filePath) [filePath release];
+ }
+}
+// -------------------------------------------------------------------------------
+// checkAfsStatus:[NSArray arrayWithObjects:@"checkserver", nil];
+// -------------------------------------------------------------------------------
+-(BOOL) checkAfsStatus
+{
+ BOOL result = NO;
+ NSString *fsResult = [TaskUtil executeTaskSearchingPath:@"fs" args:[NSArray arrayWithObjects:@"checkserver", nil]];
+ result = (fsResult?([fsResult rangeOfString:@"All servers are running."].location != NSNotFound):NO);
+ return result;
+}
+
+// -------------------------------------------------------------------------------
+// makeChaceParamString
+// -------------------------------------------------------------------------------
+-(NSString*) makeChaceParamString
+{
+ NSNumber *tmpNum = nil;
+ NSMutableString *afsdOption = [[NSMutableString alloc] init];
+ if(!afsdOption) return @"";
+ //write the data for afsd config file '-afsdb -stat x -dcache x -daemons x -volumes x -dynroot -fakestat-all'
+ //afsdb
+ //dynRoot
+ if([self afsDB]) {
+ [afsdOption appendString:@AFSD_OPTION_AFSDB_KEY];[afsdOption appendString:@" "];
+ }
+
+ //Verbose
+ if([self verbose]) {
+ [afsdOption appendString:@AFSD_OPTION_VERBOSE_KEY];[afsdOption appendString:@" "];
+ }
+
+ //stat entry
+ tmpNum = [NSNumber numberWithInt:[self statCacheEntry]];
+ if([tmpNum intValue]) {[afsdOption appendString:@AFSD_OPTION_STAT_KEY];[afsdOption appendString:@" "];[afsdOption appendString:[tmpNum stringValue]];[afsdOption appendString:@" "];}
+
+ //dcace
+ tmpNum = [NSNumber numberWithInt:[self dCacheDim]];
+ if([tmpNum intValue]) {[afsdOption appendString:@AFSD_OPTION_DCACHE_KEY];[afsdOption appendString:@" "];[afsdOption appendString:[tmpNum stringValue]];[afsdOption appendString:@" "];}
+
+ //daemons
+ tmpNum = [NSNumber numberWithInt:[self daemonNumber]];
+ if([tmpNum intValue]) {[afsdOption appendString:@AFSD_OPTION_DAEMONS_KEY];[afsdOption appendString:@" "];[afsdOption appendString:[tmpNum stringValue]];[afsdOption appendString:@" "];}
+
+ //volumes
+ tmpNum = [NSNumber numberWithInt:[self nVolEntry]];
+ if([tmpNum intValue]) {[afsdOption appendString:@AFSD_OPTION_VOLUMES_KEY];[afsdOption appendString:@" "];[afsdOption appendString:[tmpNum stringValue]];[afsdOption appendString:@" "];}
+
+ //dynRoot
+ if([self dynRoot]) {
+ [afsdOption appendString:@AFSD_OPTION_DYNROOT_KEY];[afsdOption appendString:@" "];
+ }
+
+ //fakestat-all
+ [afsdOption appendString:@AFSD_OPTION_FKESTAT_ALL];[afsdOption appendString:@" "];
+
+ return [afsdOption autorelease];
+}
+
+@end
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBClasses</key>
+ <array>
+ <dict>
+ <key>CLASS</key>
+ <string>FirstResponder</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>SUPERCLASS</key>
+ <string>NSObject</string>
+ </dict>
+ <dict>
+ <key>CLASS</key>
+ <string>AFSMenuCredentialContoller</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>OUTLETS</key>
+ <dict>
+ <key>credWinController</key>
+ <string>CredentialWindowController</string>
+ <key>credentialController</key>
+ <string>id</string>
+ <key>credentialView</key>
+ <string>id</string>
+ </dict>
+ <key>SUPERCLASS</key>
+ <string>NSObject</string>
+ </dict>
+ <dict>
+ <key>ACTIONS</key>
+ <dict>
+ <key>closePanel</key>
+ <string>id</string>
+ <key>getToken</key>
+ <string>id</string>
+ </dict>
+ <key>CLASS</key>
+ <string>CredentialWindowController</string>
+ <key>LANGUAGE</key>
+ <string>ObjC</string>
+ <key>OUTLETS</key>
+ <dict>
+ <key>afsMenuController</key>
+ <string>id</string>
+ <key>credentialView</key>
+ <string>id</string>
+ <key>textEditPassword</key>
+ <string>id</string>
+ <key>textEditUserName</key>
+ <string>id</string>
+ </dict>
+ <key>SUPERCLASS</key>
+ <string>NSObject</string>
+ </dict>
+ </array>
+ <key>IBVersion</key>
+ <string>1</string>
+</dict>
+</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IBFramework Version</key>
+ <string>644</string>
+ <key>IBLastKnownRelativeProjectPath</key>
+ <string>../AFSCommander.xcodeproj</string>
+ <key>IBOldestOS</key>
+ <integer>5</integer>
+ <key>IBOpenObjects</key>
+ <array>
+ <integer>248</integer>
+ </array>
+ <key>IBSystem Version</key>
+ <string>9C31</string>
+ <key>targetFramework</key>
+ <string>IBCocoaFramework</string>
+</dict>
+</plist>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>AFSMenuExtra</string>
+ <key>CFBundleIdentifier</key>
+ <string>it.infn.lnf.network.AFSMenuExtra</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>INFN</string>
+ <key>CFBundleVersion</key>
+ <string>0.2a</string>
+ <key>NSPrincipalClass</key>
+ <string>AFSMenuExtra</string>
+</dict>
+</plist>
--- /dev/null
+//
+// AuthUtil.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 21/06/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#include <Security/Authorization.h>
+#include <Security/AuthorizationTags.h>
+
+@interface AuthUtil : NSObject {
+ AuthorizationRef authorizationRef;
+}
+-(id) init;
+-(OSStatus) autorize;
+-(BOOL) deautorize;
+-(AuthorizationRef) authorization;
+-(NSData*) extFormAuth;
+-(OSStatus) execUnixCommand:(const char*) commandPath args:(const char*[])args output:(NSMutableString*)output;
++(AuthUtil*) shared;
++ (id)allocWithZone:(NSZone *)zone;
+- (id)copyWithZone:(NSZone *)zone;
+- (id)retain;
+- (unsigned)retainCount;
+- (void)release;
+- (id)autorelease;
+@end
--- /dev/null
+//
+// AuthUtil.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 21/06/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "AuthUtil.h"
+//#include <stdio.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+static AuthUtil *sharedAuthUtil = nil;
+
+@implementation AuthUtil
+
++(AuthUtil*) shared
+{
+ @synchronized(self) {
+ if (sharedAuthUtil == nil) {
+ [[self alloc] init]; // assignment not done here
+ }
+ }
+ return sharedAuthUtil;
+}
+
++ (id)allocWithZone:(NSZone *)zone
+{
+ @synchronized(self) {
+ if (sharedAuthUtil == nil) {
+ sharedAuthUtil = [super allocWithZone:zone];
+ return sharedAuthUtil; // assignment and return on first allocation
+ }
+ }
+ return nil; //on subsequent allocation attempts return nil
+}
+
+- (id)copyWithZone:(NSZone *)zone
+{
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// init:
+// -------------------------------------------------------------------------------
+-(id) init {
+ [super init];
+ authorizationRef = nil;
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// autorize:
+// -------------------------------------------------------------------------------
+-(OSStatus) autorize
+{
+ OSStatus status = noErr;
+ AuthorizationFlags flags;
+ AuthorizationItem myItems = {kAuthorizationRightExecute, 0, NULL, 0};
+ AuthorizationRights myRights = {1, &myItems};
+ flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
+
+ /*if(authorizationRef) {
+ [self deautorize];
+ }*/
+
+ // chek if autorization is valid for and old password request
+ status = AuthorizationCopyRights (authorizationRef, &myRights, NULL, flags, NULL );
+
+ if (status != errAuthorizationSuccess) {
+ //
+ flags = kAuthorizationFlagDefaults;
+ if(!authorizationRef){
+ status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, flags, &authorizationRef);
+ if (status != errAuthorizationSuccess) {
+ return status;
+ }
+ }
+
+ flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize | kAuthorizationFlagExtendRights;
+ status = AuthorizationCopyRights (authorizationRef, &myRights, NULL, flags, NULL );
+
+ if (status != errAuthorizationSuccess) {
+ AuthorizationFree (authorizationRef, kAuthorizationFlagDefaults);
+ return status;
+ }
+ }
+
+ return status;
+}
+
+
+// -------------------------------------------------------------------------------
+// deatorize:
+// -------------------------------------------------------------------------------
+-(BOOL) deautorize
+{
+ OSStatus status = 0L;
+ if(authorizationRef){
+ status = AuthorizationFree (authorizationRef, kAuthorizationFlagDefaults);
+ authorizationRef = 0L;
+ }
+ return status == noErr;
+}
+
+
+// -------------------------------------------------------------------------------
+// authorization:
+// -------------------------------------------------------------------------------
+-(AuthorizationRef) authorization
+{
+ return authorizationRef;
+}
+
+// -------------------------------------------------------------------------------
+// authorization:
+// -------------------------------------------------------------------------------
+-(NSData*) extFormAuth {
+ AuthorizationExternalForm extAuth; // external authorization
+ NSData *authorizationData = nil;
+ if(AuthorizationMakeExternalForm([self authorization], &extAuth))
+ {
+ NSLog(@"Could not create external authorization form.");
+ return nil;
+ }
+ authorizationData = [NSData dataWithBytes:&extAuth length:sizeof(AuthorizationExternalForm)];
+ return authorizationData;
+}
+
+// -------------------------------------------------------------------------------
+// execUnixCommand:
+// -------------------------------------------------------------------------------
+-(OSStatus) execUnixCommand:(const char*) commandPath args:(const char*[])args output:(NSMutableString*)output
+{
+ OSStatus status = noErr;
+ FILE *commandOutIn = NULL;
+ char buff[1024];
+ int pid, pidStatus;
+
+ status = AuthorizationExecuteWithPrivileges (authorizationRef, commandPath, kAuthorizationFlagDefaults , (char *const *)args, &commandOutIn);
+ if (status == errAuthorizationSuccess && commandOutIn){
+ for(;;)
+ {
+ int bytesRead = read(fileno (commandOutIn), buff, sizeof (buff));
+ if (bytesRead < 1) break;
+ //write (fileno (stdout), buff, bytesRead);
+ if(output) {
+ [output appendString:[NSString stringWithCString:buff length:bytesRead]];
+ }
+ }
+ }
+ if(commandOutIn){
+ fflush(commandOutIn);
+ fclose(commandOutIn);
+ }
+ // whait for comand finish
+ pid = wait( &pidStatus );
+ if (pid == -1 || !WIFEXITED( pidStatus ))
+ {
+ NSLog( @"Error: problem with wait pid status: %d", pidStatus );
+ return 1;
+ }
+ return status;
+}
+
+- (id)retain
+{
+ return self;
+}
+
+- (unsigned)retainCount
+{
+ return UINT_MAX; //denotes an object that cannot be released
+}
+
+- (void)release
+{
+ //do nothing
+}
+
+- (id)autorelease
+{
+ return self;
+}
+@end
--- /dev/null
+//
+// CellIp.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 14/06/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface CellIp : NSObject {
+ NSString *ip;
+ NSString *ipComment;
+}
+-(id)init;
+-(void)dealloc;
+-(void)setCellIp:(NSString*)newip;
+-(NSString*) getCellIp;
+-(void)setCellComment:(NSString*)newcomment;
+-(NSString*) getCellComment;
+-(NSString*) description;
+@end
--- /dev/null
+//
+// CellIp.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 14/06/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "CellIp.h"
+
+
+@implementation CellIp
+// -------------------------------------------------------------------------------
+// init:
+// -------------------------------------------------------------------------------
+-(id)init {
+ [super init];
+ ip = @"0.0.0.0";
+ ipComment = @"-----";
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// dealloc:
+// -------------------------------------------------------------------------------
+-(void)dealloc{
+ if(ip) [ip release];
+ if(ipComment) [ipComment release];
+ [super dealloc];
+}
+
+// -------------------------------------------------------------------------------
+// setCellIp:
+// -------------------------------------------------------------------------------
+-(void)setCellIp:(NSString*)newip{
+ if(ip){
+ [ip release];
+ }
+ ip = [newip retain];
+}
+
+// -------------------------------------------------------------------------------
+// getCellIp:
+// -------------------------------------------------------------------------------
+-(NSString*) getCellIp{
+ return ip;
+}
+
+// -------------------------------------------------------------------------------
+// setCellComment:(NSString*)newcomment
+// -------------------------------------------------------------------------------
+-(void)setCellComment:(NSString*)newcomment{
+ if(ipComment){
+ [ipComment release];
+ }
+ ipComment = [newcomment retain];
+}
+
+// -------------------------------------------------------------------------------
+// getCellComment:
+// -------------------------------------------------------------------------------
+-(NSString*) getCellComment{
+ return ipComment;
+}
+
+// -------------------------------------------------------------------------------
+// description:
+// -------------------------------------------------------------------------------
+-(NSString*) description{
+ NSMutableString *desc = [[NSMutableString alloc] init];
+ [desc autorelease];
+ [desc appendString:ip];[desc appendString:@" "];[desc appendString:@"#"];[desc appendString:ipComment];[desc appendString:@"\n"];
+ return desc;
+}
+
+@end
--- /dev/null
+//
+// CredentialWindowController.h
+// AFSCommander
+//
+// Created by Claudio on 14/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "AFSMenuCredentialContoller.h"
+#import "global.h"
+
+@interface CredentialWindowController : NSObject {
+ id credentialView;
+ id afsMenuController;
+ id textEditUserName;
+ id textEditPassword;
+
+ BOOL taken;
+ NSString *uName;
+ NSString *uPwd;
+
+}
+
+- (IBAction) getToken:(id) sender;
+- (IBAction) closePanel:(id) sender;
+- (BOOL) takenToken;
+- (NSString*) uName;
+- (NSString*) uPwd;
+@end
--- /dev/null
+//
+// CredentialWindowController.m
+// AFSCommander
+//
+// Created by Claudio on 14/07/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+
+#import "CredentialWindowController.h"
+#import "AFSPropertyManager.h"
+
+@implementation CredentialWindowController
+// -------------------------------------------------------------------------------
+// awakeFromNib:
+// -------------------------------------------------------------------------------
+- (void)awakeFromNib
+{
+ NSLog(@"awakeFromNib");
+}
+
+// -------------------------------------------------------------------------------
+// getToken:
+// -------------------------------------------------------------------------------
+- (IBAction) getToken:(id) sender
+{
+ uName = [((NSTextField*) textEditUserName) stringValue];
+ uPwd = [((NSTextField*) textEditPassword) stringValue];
+ if(uName == @"" || uPwd == @"") return;
+ taken = YES;
+
+
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kLogWindowClosed];
+}
+
+
+// -------------------------------------------------------------------------------
+// closePanel:
+// -------------------------------------------------------------------------------
+- (IBAction) closePanel:(id) sender
+{
+ taken = NO;
+ NSLog(@"closePanel");
+ [[NSDistributedNotificationCenter defaultCenter] postNotificationName:kAFSMenuExtraID object:kLogWindowClosed];
+}
+
+
+// -------------------------------------------------------------------------------
+// takenToken:
+// -------------------------------------------------------------------------------
+- (BOOL) takenToken
+{
+ return taken;
+}
+
+// -------------------------------------------------------------------------------
+// takenToken:
+// -------------------------------------------------------------------------------
+- (NSString*) uName
+{
+ return uName;
+}
+
+// -------------------------------------------------------------------------------
+// takenToken:
+// -------------------------------------------------------------------------------
+- (NSString*) uPwd
+{
+ return uPwd;
+}
+
+@end
--- /dev/null
+//
+// DBCellElement.h
+// AFSCommander
+//
+// Created by Claudio Bisegni on 14/06/07.
+// Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
+//
+// Is the identification of a cell in he afs cell database
+
+#import <Cocoa/Cocoa.h>
+#import "CellIp.h"
+
+@interface DBCellElement : NSObject {
+ BOOL userDefaultForToken;
+ BOOL userDefaultCell;
+ NSString *cellName;
+ NSString *cellComment;
+ NSMutableArray *ipCellList;
+}
+
+/*!
+ @method init
+ @abstract
+ @discussion
+ */
+-(id) init;
+
+/*!
+ @method dealloc
+ @abstract
+ @discussion
+ */
+-(void) dealloc;
+
+/*!
+ @method setCellName
+ @abstract Set the cel name
+ @discussion Release the old cell name andretain the new one
+ @param name - Name of the cell
+ */
+-(void) setCellName:(NSString *)name;
+
+/*!
+ @method getCellName
+ @abstract Return the cell name
+ @discussion Return the cell name
+ @result Name of the cell
+ */
+-(NSString*) getCellName;
+
+/*!
+ @method setCellComment
+ @abstract Set the comment of the cell
+ @discussion Release the old cell comment and retain the new one
+ @param comment - Comment of the cell
+ */
+-(void) setCellComment:(NSString *)comment;
+
+/*!
+ @method getCellComment
+ @abstract Get the comment of the cell
+ @discussion Get the comment of the cell
+ @result comment of the cell
+
+ */
+-(NSString*) getCellComment;
+
+/*!
+ @method setUserDefaultForToken
+ @abstract Set the userde fault for tokens for the cell
+ @discussion If this cell is a cell used by user this flag will be true,
+ for multi cell authentication will be more cell with this flag on true.
+ @param isDefault - true if the this cell is default which the user want to ge token for
+
+ */
+-(void) setUserDefaultForToken:(BOOL)isDefault;
+
+/*!
+ @method userDefault
+ @abstract Return the user request for token flag
+ @discussion
+ @result if true this cell is used to get the tokens
+ */
+-(BOOL) userDefaultForToken;
+/*!
+ @method setUserDefaultCell
+ @abstract set the user default cell state
+ @discussion
+ @result set this cell as default user cell
+ */
+-(void) setUserDefaultCell:(BOOL)isDefault;
+/*!
+ @method userDefaultForCell
+ @abstract Return the user default cell state
+ @discussion
+ @result is true if this cell is the default cell
+ */
+-(BOOL) userDefaultForCell;
+/*!
+ @method addIpToCell
+ @abstract Add an ipcell description to this cell
+ @discussion Add a new IpCell class to this cell to specify the server ip
+ @param ip - CellIP class representing the ip of one server of the cell
+ */
+-(void) addIpToCell:(CellIp*)ip;
+
+/*!
+ @method getIp
+ @abstract Return the array containing all ip for thi cell
+ @discussion
+ @result The array containing all the cell ip decription class
+ */
+-(NSMutableArray*) getIp;
+
+/*!
+ @method description
+ @abstract Return the description of this cell
+ @discussion The description is the same stile used in CellServDB file(for a single cell)
+ so calling thi method for all cell will be reconstructed the entire afs configuration file for CellSerDB
+ @result The string description of the cell with all the ip
+ */
+-(NSString*) description;
+
+/*!
+ @method isEqual
+ @abstract Compare this object with anoter of the same type
+ @discussion Compare this object with the ine passed to the function
+ @param anObject - An object to compare with this.
+ @result true if the two object are the same.
+ */
+- (BOOL)isEqual:(id)anObject;
+
+- (BOOL)isEqualToString:(NSString *)aString;
+@end
--- /dev/null
+//
+// DBCellElement.m
+// AFSCommander
+//
+// Created by Claudio Bisegni on 14/06/07.
+// Copyright 2007 INFN. All rights reserved.
+//
+
+#import "DBCellElement.h"
+
+
+@implementation DBCellElement
+
+// -------------------------------------------------------------------------------
+// init:
+// -------------------------------------------------------------------------------
+-(id) init{
+ [super init];
+ userDefaultForToken = false;
+ userDefaultCell = false;
+ ipCellList = [[NSMutableArray alloc] init];
+ return self;
+}
+
+// -------------------------------------------------------------------------------
+// dealloc:
+// -------------------------------------------------------------------------------
+-(void) dealloc{
+ if(ipCellList) [ipCellList release];
+ if(cellName) [cellName release];
+ if(cellComment) [cellComment release];
+ [super dealloc];
+}
+
+// -------------------------------------------------------------------------------
+// setCellName:
+// -------------------------------------------------------------------------------
+-(void) setCellName:(NSString *)name
+{
+ if(cellName){
+ [cellName release];
+ }
+ cellName = [name retain];
+}
+
+// -------------------------------------------------------------------------------
+// getCellName:
+// -------------------------------------------------------------------------------
+-(NSString*) getCellName{
+ return cellName;
+}
+
+// -------------------------------------------------------------------------------
+// setCellComment:
+// -------------------------------------------------------------------------------
+-(void) setCellComment:(NSString *)comment{
+ if(cellComment){
+ [cellComment release];
+ }
+ cellComment = [comment retain];
+}
+
+// -------------------------------------------------------------------------------
+// getCellComment:
+// -------------------------------------------------------------------------------
+-(NSString*) getCellComment{
+ return cellComment;
+}
+
+// -------------------------------------------------------------------------------
+// setCellComment:
+// -------------------------------------------------------------------------------
+-(void) setUserDefaultForToken:(BOOL)isDefault {
+ userDefaultForToken = isDefault;
+}
+
+// -------------------------------------------------------------------------------
+// getCellComment:
+// -------------------------------------------------------------------------------
+-(BOOL) userDefaultForToken {
+ return userDefaultForToken;
+}
+
+// -------------------------------------------------------------------------------
+// setCellComment:
+// -------------------------------------------------------------------------------
+-(void) setUserDefaultCell:(BOOL)isDefault {
+ userDefaultCell = isDefault;
+}
+
+// -------------------------------------------------------------------------------
+// getCellComment:
+// -------------------------------------------------------------------------------
+-(BOOL) userDefaultForCell {
+ return userDefaultCell;
+}
+
+// -------------------------------------------------------------------------------
+// addIpToCell:
+// -------------------------------------------------------------------------------
+-(void) addIpToCell:(CellIp*)ip{
+ [ipCellList addObject:ip];
+}
+
+// -------------------------------------------------------------------------------
+// getIp:
+// -------------------------------------------------------------------------------
+-(NSMutableArray*) getIp{
+ return ipCellList;
+}
+
+// -------------------------------------------------------------------------------
+// description:
+// -------------------------------------------------------------------------------
+-(NSString*) description{
+ NSMutableString *desc = [[NSMutableString alloc] init];
+ // write the description according to CellServDB semantic
+ // write cell name
+ [desc appendString:@">"];[desc appendString:cellName];[desc appendString:@" "];[desc appendString:@"#"];[desc appendString:cellComment];[desc appendString:@"\n"];
+
+ // write all ip
+ for(int idx = 0, count = [ipCellList count]; idx < count; idx++){
+ CellIp *cellIP = (CellIp*)[ipCellList objectAtIndex:idx];
+ [desc appendString:[cellIP description]];
+ }
+
+ return desc;
+}
+
+// -------------------------------------------------------------------------------
+// description:
+// -------------------------------------------------------------------------------
+- (BOOL)isEqual:(id)anObject
+{
+ if(!anObject) return NO;
+ else return [cellName isEqual:[anObject getCellName]] && [cellComment isEqual:[anObject getCellComment]];
+}
+
+- (BOOL)isEqualToString:(NSString *)aString {
+ if(!aString) return NO;
+ else return [aString isEqualToString:[self getCellName]];
+}
+@end
--- /dev/null
+//
+// DialogUtility.h
+// OpenAFS
+//
+// Created by Claudio Bisegni on 01/05/08.
+// Copyright 2008 Infn. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface DialogUtility : NSObject {
+
+}
++ (BOOL) showMessageYesNo:(NSString*) message delegator:(id)delegator functionSelecter:(SEL)fSelector window:(NSWindow*)window;
+@end
--- /dev/null
+//
+// DialogUtility.m
+// OpenAFS
+//
+// Created by Claudio Bisegni on 01/05/08.
+// Copyright 2008 Infn. All rights reserved.
+//
+
+#import "DialogUtility.h"
+
+
+@implementation DialogUtility
+// -------------------------------------------------------------------------------
+// showMessage:
+// -------------------------------------------------------------------------------
++ (BOOL) showMessageYesNo:(NSString*) message delegator:(id)delegator functionSelecter:(SEL)fSelector window:(NSWindow*)window {
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+ [alert setMessageText:message];
+ [alert addButtonWithTitle:@"Yes"];
+ [alert addButtonWithTitle:@"No"];
+ [alert beginSheetModalForWindow:window
+ modalDelegate:delegator
+ didEndSelector:fSelector
+ contextInfo:nil];
+}
+@end
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+ <data>
+ <int key="IBDocument.SystemTarget">1050</int>
+ <string key="IBDocument.SystemVersion">9C31</string>
+ <string key="IBDocument.InterfaceBuilderVersion">648</string>
+ <string key="IBDocument.AppKitVersion">949.26</string>
+ <string key="IBDocument.HIToolboxVersion">352.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="500241113">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomObject" id="483479706">
+ <string key="NSClassName">AFSCommanderPref</string>
+ </object>
+ <object class="NSCustomObject" id="194032068">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="136977041">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSWindowTemplate" id="317089838">
+ <int key="NSWindowStyleMask">3</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{594, 606}, {360, 116}}</string>
+ <int key="NSWTFlags">1886912512</int>
+ <string key="NSWindowTitle">Panel</string>
+ <object class="NSMutableString" key="NSWindowClass">
+ <characters key="NS.bytes">NSPanel</characters>
+ </object>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <string key="NSWindowContentMinSize">{213, 107}</string>
+ <object class="NSView" key="NSWindowView" id="897176997">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTextField" id="1043652849">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{19, 75}, {63, 14}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="285386094">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">272629760</int>
+ <string key="NSContents">Username:</string>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <reference key="NSControlView" ref="1043652849"/>
+ <object class="NSColor" key="NSBackgroundColor" id="39862648">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="625691461">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="993541148">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="6777892">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{21, 47}, {61, 14}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="941629363">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">272629760</int>
+ <string key="NSContents">Password:</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="6777892"/>
+ <reference key="NSBackgroundColor" ref="39862648"/>
+ <reference key="NSTextColor" ref="625691461"/>
+ </object>
+ </object>
+ <object class="NSTextField" id="167535534">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{87, 73}, {253, 19}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="690718153">
+ <int key="NSCellFlags">-1804468671</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="167535534"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <object class="NSColor" key="NSBackgroundColor" id="547292417">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">textBackgroundColor</string>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="303282358">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">textColor</string>
+ <reference key="NSColor" ref="993541148"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSTextField" id="944739158">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{87, 45}, {253, 19}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="590522050">
+ <int key="NSCellFlags">-1804468671</int>
+ <int key="NSCellFlags2">272761856</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="944739158"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <reference key="NSBackgroundColor" ref="547292417"/>
+ <reference key="NSTextColor" ref="303282358"/>
+ </object>
+ </object>
+ <object class="NSButton" id="394185848">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{242, 13}, {103, 28}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="543624439">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134348800</int>
+ <string key="NSContents">Get Token</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="394185848"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage" id="961233622">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="37378773">
+ <reference key="NSNextResponder" ref="897176997"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{160, 13}, {80, 28}}</string>
+ <reference key="NSSuperview" ref="897176997"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="464336313">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134348800</int>
+ <string key="NSContents">Cancel</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="37378773"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="961233622"/>
+ <string key="NSAlternateContents"/>
+ <string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrame">{{1, 1}, {360, 116}}</string>
+ </object>
+ <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
+ <string key="NSMinSize">{213, 129}</string>
+ <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ </object>
+ <object class="NSCustomObject" id="643915252">
+ <string key="NSClassName">TokenCredentialController</string>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">afsCommanderPref</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="483479706"/>
+ </object>
+ <int key="connectionID">8</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">credentialCommander</string>
+ <reference key="source" ref="483479706"/>
+ <reference key="destination" ref="643915252"/>
+ </object>
+ <int key="connectionID">9</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">credentialSheet</string>
+ <reference key="source" ref="483479706"/>
+ <reference key="destination" ref="317089838"/>
+ </object>
+ <int key="connectionID">10</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">credentialPanel</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="317089838"/>
+ </object>
+ <int key="connectionID">11</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">textEditUserName</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="167535534"/>
+ </object>
+ <int key="connectionID">18</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">textEditPassword</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="944739158"/>
+ </object>
+ <int key="connectionID">19</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">getToken:</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="394185848"/>
+ </object>
+ <int key="connectionID">20</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">closePanel:</string>
+ <reference key="source" ref="643915252"/>
+ <reference key="destination" ref="37378773"/>
+ </object>
+ <int key="connectionID">21</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="500241113"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="483479706"/>
+ <reference key="parent" ref="0"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="194032068"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">5</int>
+ <reference key="object" ref="317089838"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="897176997"/>
+ </object>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">Panel</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">6</int>
+ <reference key="object" ref="897176997"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="1043652849"/>
+ <reference ref="6777892"/>
+ <reference ref="167535534"/>
+ <reference ref="944739158"/>
+ <reference ref="394185848"/>
+ <reference ref="37378773"/>
+ </object>
+ <reference key="parent" ref="317089838"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">12</int>
+ <reference key="object" ref="1043652849"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="285386094"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">13</int>
+ <reference key="object" ref="6777892"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="941629363"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">14</int>
+ <reference key="object" ref="167535534"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="690718153"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">15</int>
+ <reference key="object" ref="944739158"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="590522050"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">16</int>
+ <reference key="object" ref="394185848"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="543624439"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">17</int>
+ <reference key="object" ref="37378773"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="464336313"/>
+ </object>
+ <reference key="parent" ref="897176997"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">7</int>
+ <reference key="object" ref="643915252"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">TokenCredentialController</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">23</int>
+ <reference key="object" ref="285386094"/>
+ <reference key="parent" ref="1043652849"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">24</int>
+ <reference key="object" ref="941629363"/>
+ <reference key="parent" ref="6777892"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">25</int>
+ <reference key="object" ref="690718153"/>
+ <reference key="parent" ref="167535534"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">26</int>
+ <reference key="object" ref="590522050"/>
+ <reference key="parent" ref="944739158"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">27</int>
+ <reference key="object" ref="543624439"/>
+ <reference key="parent" ref="394185848"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">28</int>
+ <reference key="object" ref="464336313"/>
+ <reference key="parent" ref="37378773"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="136977041"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">Application</string>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.IBPluginDependency</string>
+ <string>-2.IBPluginDependency</string>
+ <string>12.IBPluginDependency</string>
+ <string>12.ImportedFromIB2</string>
+ <string>13.IBPluginDependency</string>
+ <string>13.ImportedFromIB2</string>
+ <string>14.IBPluginDependency</string>
+ <string>14.ImportedFromIB2</string>
+ <string>15.CustomClassName</string>
+ <string>15.IBPluginDependency</string>
+ <string>15.ImportedFromIB2</string>
+ <string>16.IBPluginDependency</string>
+ <string>16.ImportedFromIB2</string>
+ <string>17.IBPluginDependency</string>
+ <string>17.ImportedFromIB2</string>
+ <string>5.IBPluginDependency</string>
+ <string>5.ImportedFromIB2</string>
+ <string>5.windowTemplate.hasMinSize</string>
+ <string>5.windowTemplate.minSize</string>
+ <string>6.IBPluginDependency</string>
+ <string>6.ImportedFromIB2</string>
+ <string>7.IBPluginDependency</string>
+ <string>7.ImportedFromIB2</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <integer value="1" id="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>NSSecureTextField</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <reference ref="5"/>
+ <string>{213, 107}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <reference ref="5"/>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">28</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">AFSCommanderPref</string>
+ <string key="superclassName">NSPreferencePane</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addRemoveCell:</string>
+ <string>afsMenuActivationEvent:</string>
+ <string>aklogSwitchEvent:</string>
+ <string>getNewToken:</string>
+ <string>info:</string>
+ <string>refreshConfiguration:</string>
+ <string>saveCacheManagerParam:</string>
+ <string>saveConfiguration:</string>
+ <string>searchCellTextEvent:</string>
+ <string>showCellIP:</string>
+ <string>startStopAfs:</string>
+ <string>tableDoubleAction:</string>
+ <string>unlog:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>addCellButton</string>
+ <string>afsCommanderView</string>
+ <string>afsDB</string>
+ <string>afsDefaultCellLabel</string>
+ <string>afsMenucheckBox</string>
+ <string>afsRootMountPoint</string>
+ <string>afsVersionLabel</string>
+ <string>cacheDimension</string>
+ <string>cellIpButton</string>
+ <string>cellList</string>
+ <string>credentialCommander</string>
+ <string>credentialSheet</string>
+ <string>dCacheDim</string>
+ <string>daemonNumber</string>
+ <string>dynRoot</string>
+ <string>groupsBox</string>
+ <string>infoController</string>
+ <string>infoSheet</string>
+ <string>installationPathTextField</string>
+ <string>ipConfControllerCommander</string>
+ <string>ipConfigurationSheet</string>
+ <string>labelSaveResult</string>
+ <string>nVolEntry</string>
+ <string>refreshConfigurationButton</string>
+ <string>removeCellButton</string>
+ <string>saveConfigurationButton</string>
+ <string>startStopButton</string>
+ <string>statCacheEntry</string>
+ <string>textSearchField</string>
+ <string>tokensButton</string>
+ <string>tokensTable</string>
+ <string>unlogButton</string>
+ <string>useAklogCheck</string>
+ <string>verbose</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>NSView</string>
+ <string>NSButton</string>
+ <string>NSTextField</string>
+ <string>id</string>
+ <string>NSTextField</string>
+ <string>NSTextField</string>
+ <string>NSTextField</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSTextField</string>
+ <string>NSTextField</string>
+ <string>NSButton</string>
+ <string>NSBox</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSTextField</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>NSTextField</string>
+ <string>NSSearchField</string>
+ <string>NSButton</string>
+ <string>id</string>
+ <string>NSButton</string>
+ <string>NSButton</string>
+ <string>NSButton</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">AFSCommanderPref.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">AFSCommanderPref</string>
+ <string key="superclassName">NSPreferencePane</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">cellNameTextEdit</string>
+ <string key="NS.object.0">id</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">FirstResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSPreferencePane</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>_firstKeyView</string>
+ <string>_initialKeyView</string>
+ <string>_lastKeyView</string>
+ <string>_window</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSView</string>
+ <string>NSView</string>
+ <string>NSView</string>
+ <string>NSWindow</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">TokenCredentialController</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>closePanel:</string>
+ <string>getToken:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>afsCommanderPref</string>
+ <string>credentialPanel</string>
+ <string>textEditPassword</string>
+ <string>textEditUserName</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">TokenCredentialController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">TokenCredentialController</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBUserSource</string>
+ <string key="minorKey"/>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <nil key="IBDocument.LastKnownRelativeProjectPath"/>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ </data>
+</archive>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
+ <data>
+ <int key="IBDocument.SystemTarget">1050</int>
+ <string key="IBDocument.SystemVersion">9C31</string>
+ <string key="IBDocument.InterfaceBuilderVersion">648</string>
+ <string key="IBDocument.AppKitVersion">949.26</string>
+ <string key="IBDocument.HIToolboxVersion">352.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="429600039">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomObject" id="657952263">
+ <string key="NSClassName">AFSCommanderPref</string>
+ </object>
+ <object class="NSCustomObject" id="930067686">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="784296185">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSWindowTemplate" id="249730404">
+ <int key="NSWindowStyleMask">11</int>
+ <int key="NSWindowBacking">2</int>
+ <string key="NSWindowRect">{{622, 526}, {525, 370}}</string>
+ <int key="NSWTFlags">813170688</int>
+ <string key="NSWindowTitle">Panel</string>
+ <object class="NSMutableString" key="NSWindowClass">
+ <characters key="NS.bytes">NSPanel</characters>
+ </object>
+ <object class="NSMutableString" key="NSViewClass">
+ <characters key="NS.bytes">View</characters>
+ </object>
+ <string key="NSWindowContentMinSize">{525, 345}</string>
+ <object class="NSView" key="NSWindowView" id="274468230">
+ <nil key="NSNextResponder"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSButton" id="800283714">
+ <reference key="NSNextResponder" ref="274468230"/>
+ <int key="NSvFlags">289</int>
+ <string key="NSFrame">{{430, 13}, {80, 28}}</string>
+ <reference key="NSSuperview" ref="274468230"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="1042040079">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134348800</int>
+ <string key="NSContents">Ok</string>
+ <object class="NSFont" key="NSSupport" id="26">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">3100</int>
+ </object>
+ <reference key="NSControlView" ref="800283714"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <object class="NSFont" key="NSAlternateImage" id="845391598">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.100000e+01</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSButton" id="956015576">
+ <reference key="NSNextResponder" ref="274468230"/>
+ <int key="NSvFlags">289</int>
+ <string key="NSFrame">{{348, 13}, {80, 28}}</string>
+ <reference key="NSSuperview" ref="274468230"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="441391248">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134348800</int>
+ <string key="NSContents">Cancel</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="956015576"/>
+ <int key="NSButtonFlags">-2038284033</int>
+ <int key="NSButtonFlags2">1</int>
+ <reference key="NSAlternateImage" ref="845391598"/>
+ <string key="NSAlternateContents"/>
+ <object class="NSMutableString" key="NSKeyEquivalent">
+ <characters key="NS.bytes"/>
+ </object>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
+ <object class="NSTextField" id="680338282">
+ <reference key="NSNextResponder" ref="274468230"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{51, 344}, {54, 16}}</string>
+ <reference key="NSSuperview" ref="274468230"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="496687085">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">272760832</int>
+ <string type="base64-UTF8" key="NSContents">QWZzIENlbGw6Cg</string>
+ <reference key="NSSupport" ref="26"/>
+ <reference key="NSControlView" ref="680338282"/>
+ <object class="NSColor" key="NSBackgroundColor" id="319048697">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlColor</string>
+ <object class="NSColor" key="NSColor" id="315060860">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
+ </object>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="513483274">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">controlTextColor</string>
+ <object class="NSColor" key="NSColor" id="350675897">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSBox" id="338197250">
+ <reference key="NSNextResponder" ref="274468230"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSView" id="612441040">
+ <reference key="NSNextResponder" ref="338197250"/>
+ <int key="NSvFlags">256</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSScrollView" id="585065386">
+ <reference key="NSNextResponder" ref="612441040"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSClipView" id="786132725">
+ <reference key="NSNextResponder" ref="585065386"/>
+ <int key="NSvFlags">2304</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTableView" id="234348651">
+ <reference key="NSNextResponder" ref="786132725"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{453, 190}</string>
+ <reference key="NSSuperview" ref="786132725"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTableHeaderView" key="NSHeaderView" id="367895900">
+ <reference key="NSNextResponder" ref="336840699"/>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrameSize">{453, 17}</string>
+ <reference key="NSSuperview" ref="336840699"/>
+ <reference key="NSTableView" ref="234348651"/>
+ </object>
+ <object class="_NSCornerView" key="NSCornerView" id="211425262">
+ <reference key="NSNextResponder" ref="585065386"/>
+ <int key="NSvFlags">-2147483392</int>
+ <string key="NSFrame">{{-22, 0}, {12, 17}}</string>
+ <reference key="NSSuperview" ref="585065386"/>
+ </object>
+ <object class="NSMutableArray" key="NSTableColumns">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSTableColumn" id="304822933">
+ <string key="NSIdentifier">1</string>
+ <double key="NSWidth">2.080000e+02</double>
+ <double key="NSMinWidth">4.000000e+01</double>
+ <double key="NSMaxWidth">1.000000e+03</double>
+ <object class="NSTableHeaderCell" key="NSHeaderCell">
+ <int key="NSCellFlags">75628032</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">IP</string>
+ <reference key="NSSupport" ref="26"/>
+ <object class="NSColor" key="NSBackgroundColor" id="87486732">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
+ </object>
+ <object class="NSColor" key="NSTextColor" id="446718123">
+ <int key="NSColorSpace">6</int>
+ <string key="NSCatalogName">System</string>
+ <string key="NSColorName">headerTextColor</string>
+ <reference key="NSColor" ref="350675897"/>
+ </object>
+ </object>
+ <object class="NSTextFieldCell" key="NSDataCell" id="204595378">
+ <int key="NSCellFlags">337772096</int>
+ <int key="NSCellFlags2">133120</int>
+ <string key="NSContents">Text Cell</string>
+ <reference key="NSSupport" ref="26"/>
+