Merge branch 'fix/email-notif-auth'
This commit is contained in:
commit
d7851999da
|
@ -55,6 +55,7 @@ SOGo_HEADER_FILES = \
|
||||||
SOGoCASSession.h \
|
SOGoCASSession.h \
|
||||||
SOGoDAVAuthenticator.h \
|
SOGoDAVAuthenticator.h \
|
||||||
SOGoProxyAuthenticator.h \
|
SOGoProxyAuthenticator.h \
|
||||||
|
SOGoStaticAuthenticator.h \
|
||||||
SOGoWebAuthenticator.h \
|
SOGoWebAuthenticator.h \
|
||||||
SOGoWebDAVAclManager.h \
|
SOGoWebDAVAclManager.h \
|
||||||
SOGoWebDAVValue.h \
|
SOGoWebDAVValue.h \
|
||||||
|
@ -67,7 +68,9 @@ SOGo_HEADER_FILES = \
|
||||||
WORequest+SOGo.h \
|
WORequest+SOGo.h \
|
||||||
WOResourceManager+SOGo.h \
|
WOResourceManager+SOGo.h \
|
||||||
WOResponse+SOGo.h \
|
WOResponse+SOGo.h \
|
||||||
WOContext+SOGo.h
|
WOContext+SOGo.h \
|
||||||
|
\
|
||||||
|
SOGoCredentialsFile.h
|
||||||
|
|
||||||
# daemon tool
|
# daemon tool
|
||||||
all::
|
all::
|
||||||
|
@ -124,6 +127,7 @@ SOGo_OBJC_FILES = \
|
||||||
SOGoCASSession.m \
|
SOGoCASSession.m \
|
||||||
SOGoDAVAuthenticator.m \
|
SOGoDAVAuthenticator.m \
|
||||||
SOGoProxyAuthenticator.m \
|
SOGoProxyAuthenticator.m \
|
||||||
|
SOGoStaticAuthenticator.m \
|
||||||
SOGoWebAuthenticator.m \
|
SOGoWebAuthenticator.m \
|
||||||
SOGoWebDAVAclManager.m \
|
SOGoWebDAVAclManager.m \
|
||||||
SOGoWebDAVValue.m \
|
SOGoWebDAVValue.m \
|
||||||
|
@ -136,7 +140,10 @@ SOGo_OBJC_FILES = \
|
||||||
WORequest+SOGo.m \
|
WORequest+SOGo.m \
|
||||||
WOResourceManager+SOGo.m \
|
WOResourceManager+SOGo.m \
|
||||||
WOResponse+SOGo.m \
|
WOResponse+SOGo.m \
|
||||||
WOContext+SOGo.m
|
WOContext+SOGo.m \
|
||||||
|
\
|
||||||
|
SOGoCredentialsFile.m
|
||||||
|
|
||||||
|
|
||||||
SOGo_RESOURCE_FILES = \
|
SOGo_RESOURCE_FILES = \
|
||||||
SOGoDefaults.plist \
|
SOGoDefaults.plist \
|
||||||
|
|
43
SoObjects/SOGo/SOGoCredentialsFile.h
Normal file
43
SoObjects/SOGo/SOGoCredentialsFile.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/* SOGoCredentialsFile.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Inverse inc.
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SOGOCREDENTIALSFILE_H
|
||||||
|
#define SOGOCREDENTIALSFILE_H
|
||||||
|
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
|
@interface SOGoCredentialsFile : NSObject
|
||||||
|
{
|
||||||
|
NSString *_credentialsFile;
|
||||||
|
NSString *_username, *_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) credentialsFromFile: (NSString *) file;
|
||||||
|
|
||||||
|
- (id) initFromFile: (NSString *) file
|
||||||
|
withEncoding: (NSStringEncoding) enc;
|
||||||
|
|
||||||
|
- (NSString *) username;
|
||||||
|
- (NSString *) password;
|
||||||
|
- (NSString *) credentialsFile;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* SOGOCREDENTIALSFILE_H */
|
113
SoObjects/SOGo/SOGoCredentialsFile.m
Normal file
113
SoObjects/SOGo/SOGoCredentialsFile.m
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
/* SOGoCredentialsFile.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Inverse inc.
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/NSCharacterSet.h>
|
||||||
|
#import <Foundation/NSData.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
|
#import "SOGoCredentialsFile.h"
|
||||||
|
|
||||||
|
@implementation SOGoCredentialsFile
|
||||||
|
|
||||||
|
+ (id) credentialsFromFile: (NSString *) file
|
||||||
|
{
|
||||||
|
SOGoCredentialsFile *newCreds;
|
||||||
|
newCreds = [[self alloc] initFromFile: file
|
||||||
|
withEncoding: NSUTF8StringEncoding];
|
||||||
|
[newCreds autorelease];
|
||||||
|
return newCreds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ((self = [super init]))
|
||||||
|
{
|
||||||
|
_username = nil;
|
||||||
|
_password = nil;
|
||||||
|
_credentialsFile = nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[_username release];
|
||||||
|
[_password release];
|
||||||
|
[_credentialsFile release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initFromFile: (NSString *) file
|
||||||
|
withEncoding: (NSStringEncoding) enc
|
||||||
|
{
|
||||||
|
id ret;
|
||||||
|
NSData *credentialsData;
|
||||||
|
NSRange r;
|
||||||
|
NSString *creds;
|
||||||
|
|
||||||
|
ret = nil;
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
if ((self = [self init]))
|
||||||
|
{
|
||||||
|
credentialsData = [NSData dataWithContentsOfFile: file];
|
||||||
|
if (credentialsData == nil)
|
||||||
|
NSLog(@"Failed to load credentials file: %@", file);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
creds = [[NSString alloc] initWithData: credentialsData
|
||||||
|
encoding: enc];
|
||||||
|
[creds autorelease];
|
||||||
|
creds = [creds stringByTrimmingCharactersInSet:
|
||||||
|
[NSCharacterSet characterSetWithCharactersInString: @"\r\n"]];
|
||||||
|
r = [creds rangeOfString: @":"];
|
||||||
|
if (r.location == NSNotFound)
|
||||||
|
NSLog(@"Invalid credentials file content, missing ':' separator (%@)", file);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_username = [[creds substringToIndex: r.location] retain];
|
||||||
|
_password = [[creds substringFromIndex: r.location+1] retain];
|
||||||
|
_credentialsFile = [file retain];
|
||||||
|
ret = self;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
- (NSString *) username
|
||||||
|
{
|
||||||
|
return self->_username;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) password
|
||||||
|
{
|
||||||
|
return self->_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) credentialsFile
|
||||||
|
{
|
||||||
|
return self->_credentialsFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -35,6 +35,7 @@
|
||||||
#import "NSString+Utilities.h"
|
#import "NSString+Utilities.h"
|
||||||
#import "SOGoAuthenticator.h"
|
#import "SOGoAuthenticator.h"
|
||||||
#import "SOGoDomainDefaults.h"
|
#import "SOGoDomainDefaults.h"
|
||||||
|
#import "SOGoStaticAuthenticator.h"
|
||||||
#import "SOGoSystemDefaults.h"
|
#import "SOGoSystemDefaults.h"
|
||||||
#import "SOGoUser.h"
|
#import "SOGoUser.h"
|
||||||
#import "SOGoUserManager.h"
|
#import "SOGoUserManager.h"
|
||||||
|
@ -153,6 +154,10 @@
|
||||||
[client connectToAddress: addr];
|
[client connectToAddress: addr];
|
||||||
if ([authenticationType isEqualToString: @"plain"])
|
if ([authenticationType isEqualToString: @"plain"])
|
||||||
{
|
{
|
||||||
|
/* XXX Allow static credentials by peeking at the classname */
|
||||||
|
if ([authenticator isKindOfClass: [SOGoStaticAuthenticator class]])
|
||||||
|
login = [(SOGoStaticAuthenticator *)authenticator username];
|
||||||
|
else
|
||||||
login = [[SOGoUserManager sharedUserManager]
|
login = [[SOGoUserManager sharedUserManager]
|
||||||
getExternalLoginForUID: [[authenticator userInContext: woContext] loginInDomain]
|
getExternalLoginForUID: [[authenticator userInContext: woContext] loginInDomain]
|
||||||
inDomain: [[authenticator userInContext: woContext] domain]];
|
inDomain: [[authenticator userInContext: woContext] domain]];
|
||||||
|
|
51
SoObjects/SOGo/SOGoStaticAuthenticator.h
Normal file
51
SoObjects/SOGo/SOGoStaticAuthenticator.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* SOGoStaticAuthenticator.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Inverse inc.
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SOGOSTATICAUTHENTICATOR_H
|
||||||
|
#define SOGOSTATICAUTHENTICATOR_H
|
||||||
|
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
|
|
||||||
|
#import "SOGoAuthenticator.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
SOGoStaticAuthenticator
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@interface SOGoStaticAuthenticator : NSObject <SOGoAuthenticator>
|
||||||
|
{
|
||||||
|
NSString *_username;
|
||||||
|
NSString *_password;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) authenticatorWithUser: (NSString *) user
|
||||||
|
andPassword: (NSString *) password;
|
||||||
|
|
||||||
|
- (id) initWithUser: (NSString *) user
|
||||||
|
andPassword: (NSString *) password;
|
||||||
|
|
||||||
|
- (NSString *) username;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* SOGOSTATICAUTHENTICATOR_H */
|
||||||
|
|
87
SoObjects/SOGo/SOGoStaticAuthenticator.m
Normal file
87
SoObjects/SOGo/SOGoStaticAuthenticator.m
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/* SOGoStaticAuthenticator.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013 Inverse inc.
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
|
#import "SOGoStaticAuthenticator.h"
|
||||||
|
|
||||||
|
@implementation SOGoStaticAuthenticator
|
||||||
|
|
||||||
|
+ (id) authenticatorWithUser: (NSString *) user
|
||||||
|
andPassword: (NSString *) password
|
||||||
|
{
|
||||||
|
SOGoStaticAuthenticator *newAuthenticator;
|
||||||
|
newAuthenticator = [[self alloc] initWithUser: user
|
||||||
|
andPassword: password];
|
||||||
|
[newAuthenticator autorelease];
|
||||||
|
return newAuthenticator;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ((self = [super init]))
|
||||||
|
{
|
||||||
|
_username = nil;
|
||||||
|
_password = nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[_username release];
|
||||||
|
[_password release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) initWithUser: (NSString *) user
|
||||||
|
andPassword: (NSString *) password;
|
||||||
|
{
|
||||||
|
if ((self = [self init]))
|
||||||
|
{
|
||||||
|
_username = [user retain];
|
||||||
|
_password = [password retain];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) passwordInContext: (WOContext *) context
|
||||||
|
{
|
||||||
|
return _password;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (SOGoUser *) userInContext: (WOContext *) context
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) username
|
||||||
|
{
|
||||||
|
return _username;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) imapPasswordInContext: (WOContext *) context
|
||||||
|
forURL: (NSURL *) server
|
||||||
|
forceRenew: (BOOL) renew
|
||||||
|
{
|
||||||
|
return _password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -25,8 +25,11 @@
|
||||||
|
|
||||||
#import <Foundation/NSObject.h>
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
|
#import <SOGo/SOGoStaticAuthenticator.h>
|
||||||
|
|
||||||
@interface SOGoEAlarmsNotifier : NSObject
|
@interface SOGoEAlarmsNotifier : NSObject
|
||||||
{
|
{
|
||||||
|
SOGoStaticAuthenticator *staticAuthenticator;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) run;
|
- (BOOL) run;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoEAlarmsNotifier.m - this file is part of SOGo
|
/* SOGoEAlarmsNotifier.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Inverse inc.
|
* Copyright (C) 2011-2013 Inverse inc.
|
||||||
*
|
*
|
||||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSProcessInfo.h>
|
#import <Foundation/NSProcessInfo.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
#import <NGExtensions/NGHashMap.h>
|
#import <NGExtensions/NGHashMap.h>
|
||||||
#import <NGExtensions/NGQuotedPrintableCoding.h>
|
#import <NGExtensions/NGQuotedPrintableCoding.h>
|
||||||
|
@ -38,12 +39,14 @@
|
||||||
#import <NGCards/iCalEntityObject.h>
|
#import <NGCards/iCalEntityObject.h>
|
||||||
#import <NGCards/iCalPerson.h>
|
#import <NGCards/iCalPerson.h>
|
||||||
|
|
||||||
|
#import "SOGo/SOGoCredentialsFile.h"
|
||||||
#import <SOGo/NSCalendarDate+SOGo.h>
|
#import <SOGo/NSCalendarDate+SOGo.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
#import <SOGo/SOGoDomainDefaults.h>
|
#import <SOGo/SOGoDomainDefaults.h>
|
||||||
#import <SOGo/SOGoSystemDefaults.h>
|
|
||||||
#import <SOGo/SOGoMailer.h>
|
#import <SOGo/SOGoMailer.h>
|
||||||
#import <SOGo/SOGoProductLoader.h>
|
#import <SOGo/SOGoProductLoader.h>
|
||||||
|
#import <SOGo/SOGoStaticAuthenticator.h>
|
||||||
|
#import <SOGo/SOGoSystemDefaults.h>
|
||||||
#import <SOGo/SOGoUser.h>
|
#import <SOGo/SOGoUser.h>
|
||||||
#import <Appointments/iCalPerson+SOGo.h>
|
#import <Appointments/iCalPerson+SOGo.h>
|
||||||
#import <Appointments/SOGoEMailAlarmsManager.h>
|
#import <Appointments/SOGoEMailAlarmsManager.h>
|
||||||
|
@ -52,6 +55,21 @@
|
||||||
|
|
||||||
@implementation SOGoEAlarmsNotifier
|
@implementation SOGoEAlarmsNotifier
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ((self = [super init]))
|
||||||
|
{
|
||||||
|
staticAuthenticator = nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[staticAuthenticator release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) _messageID
|
- (NSString *) _messageID
|
||||||
{
|
{
|
||||||
static int pid = 0;
|
static int pid = 0;
|
||||||
|
@ -124,11 +142,10 @@
|
||||||
[message setBody: content];
|
[message setBody: content];
|
||||||
to = [attendee rfc822Email];
|
to = [attendee rfc822Email];
|
||||||
|
|
||||||
/* TODO: SMTP authentication for services */
|
|
||||||
[mailer sendMimePart: message
|
[mailer sendMimePart: message
|
||||||
toRecipients: [NSArray arrayWithObject: to]
|
toRecipients: [NSArray arrayWithObject: to]
|
||||||
sender: from
|
sender: from
|
||||||
withAuthenticator: nil inContext: nil];
|
withAuthenticator: staticAuthenticator inContext: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _processAlarm: (iCalAlarm *) alarm
|
- (void) _processAlarm: (iCalAlarm *) alarm
|
||||||
|
@ -160,14 +177,45 @@
|
||||||
withMailer: mailer];
|
withMailer: mailer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) usage
|
||||||
|
{
|
||||||
|
fprintf (stderr, "sogo-ealarms-notify [-p credentialFile] [-h]\n\n"
|
||||||
|
" -p credentialFile Specify the file containing credentials to use for SMTP AUTH\n"
|
||||||
|
" The file should contain a single line:\n"
|
||||||
|
" username:password\n"
|
||||||
|
" -h This message\n"
|
||||||
|
"\n"
|
||||||
|
"This program should be configured to run every minute from a crontab.\n");
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) run
|
- (BOOL) run
|
||||||
{
|
{
|
||||||
SOGoEMailAlarmsManager *eaMgr;
|
SOGoEMailAlarmsManager *eaMgr;
|
||||||
|
SOGoCredentialsFile *cf;
|
||||||
NSCalendarDate *startDate, *toDate;
|
NSCalendarDate *startDate, *toDate;
|
||||||
NSArray *alarms;
|
NSArray *alarms;
|
||||||
NSMutableArray *owners;
|
NSMutableArray *owners;
|
||||||
|
NSString *credsFilename;
|
||||||
int count, max;
|
int count, max;
|
||||||
|
|
||||||
|
if ([[NSUserDefaults standardUserDefaults] stringForKey: @"h"])
|
||||||
|
{
|
||||||
|
[self usage];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
credsFilename = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
|
||||||
|
if (credsFilename)
|
||||||
|
{
|
||||||
|
cf = [SOGoCredentialsFile credentialsFromFile: credsFilename];
|
||||||
|
if (!cf)
|
||||||
|
return NO;
|
||||||
|
staticAuthenticator =
|
||||||
|
[SOGoStaticAuthenticator authenticatorWithUser: [cf username]
|
||||||
|
andPassword: [cf password]];
|
||||||
|
[staticAuthenticator retain];
|
||||||
|
}
|
||||||
|
|
||||||
[[SOGoProductLoader productLoader]
|
[[SOGoProductLoader productLoader]
|
||||||
loadProducts: [NSArray arrayWithObject: @"Appointments.SOGo"]];
|
loadProducts: [NSArray arrayWithObject: @"Appointments.SOGo"]];
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoToolUserPreferences.m - this file is part of SOGo
|
/* SOGoToolUserPreferences.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Inverse inc.
|
* Copyright (C) 2011-2013 Inverse inc.
|
||||||
*
|
*
|
||||||
* Author: Francis Lachapelle <flachapelle@inverse.ca>
|
* Author: Francis Lachapelle <flachapelle@inverse.ca>
|
||||||
*
|
*
|
||||||
|
@ -37,10 +37,11 @@
|
||||||
#import <NGExtensions/NSNull+misc.h>
|
#import <NGExtensions/NSNull+misc.h>
|
||||||
|
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
#import <SOGo/SOGoUser.h>
|
#import "SOGo/SOGoCredentialsFile.h"
|
||||||
#import <SOGo/SOGoSystemDefaults.h>
|
|
||||||
#import <SOGo/SOGoUserDefaults.h>
|
|
||||||
#import <SOGo/SOGoSieveManager.h>
|
#import <SOGo/SOGoSieveManager.h>
|
||||||
|
#import <SOGo/SOGoSystemDefaults.h>
|
||||||
|
#import <SOGo/SOGoUser.h>
|
||||||
|
#import <SOGo/SOGoUserDefaults.h>
|
||||||
|
|
||||||
#import "SOGoTool.h"
|
#import "SOGoTool.h"
|
||||||
|
|
||||||
|
@ -180,9 +181,9 @@
|
||||||
|
|
||||||
- (BOOL) run
|
- (BOOL) run
|
||||||
{
|
{
|
||||||
NSData *credsData;
|
|
||||||
NSRange r;
|
NSRange r;
|
||||||
NSString *creds, *credsFile, *authname, *authpwd;
|
NSString *creds, *credsFilename, *authname, *authpwd;
|
||||||
|
SOGoCredentialsFile *cf;
|
||||||
BOOL rc;
|
BOOL rc;
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
|
@ -192,28 +193,19 @@
|
||||||
authpwd = nil;
|
authpwd = nil;
|
||||||
rc = NO;
|
rc = NO;
|
||||||
|
|
||||||
credsFile = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
|
credsFilename = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
|
||||||
if (credsFile)
|
if (credsFilename)
|
||||||
{
|
{
|
||||||
credsData = [NSData dataWithContentsOfFile: credsFile];
|
cf = [SOGoCredentialsFile credentialsFromFile: credsFilename];
|
||||||
if (credsData == nil)
|
authname = [cf username];
|
||||||
{
|
authpwd = [cf password];
|
||||||
NSLog(@"Error reading credential file '%@'", credsFile);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
creds = [[NSString alloc] initWithData: credsData
|
|
||||||
encoding: NSUTF8StringEncoding];
|
|
||||||
[creds autorelease];
|
|
||||||
creds = [creds stringByTrimmingCharactersInSet:
|
|
||||||
[NSCharacterSet characterSetWithCharactersInString: @"\r\n"]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* DEPRECATED: this is only kept around to avoid breaking existing setups */
|
||||||
if (max > 0)
|
if (max > 0)
|
||||||
{
|
{
|
||||||
/* assume we got the creds directly on the cli */
|
/* assume we got the creds directly on the cli */
|
||||||
creds = [sanitizedArguments objectAtIndex: 0];
|
creds = [sanitizedArguments objectAtIndex: 0];
|
||||||
}
|
|
||||||
|
|
||||||
if (creds)
|
if (creds)
|
||||||
{
|
{
|
||||||
r = [creds rangeOfString: @":"];
|
r = [creds rangeOfString: @":"];
|
||||||
|
@ -227,6 +219,8 @@
|
||||||
authpwd = [creds substringFromIndex: r.location+1];
|
authpwd = [creds substringFromIndex: r.location+1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (authname && authpwd)
|
if (authname && authpwd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* SOGoToolUserPreferences.m - this file is part of SOGo
|
/* SOGoToolUserPreferences.m - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Inverse inc.
|
* Copyright (C) 2011-2013 Inverse inc.
|
||||||
*
|
*
|
||||||
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
|
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#import <Foundation/NSUserDefaults.h>
|
#import <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
|
#import "SOGo/SOGoCredentialsFile.h"
|
||||||
#import <SOGo/SOGoUser.h>
|
#import <SOGo/SOGoUser.h>
|
||||||
#import <SOGo/SOGoUserDefaults.h>
|
#import <SOGo/SOGoUserDefaults.h>
|
||||||
#import <SOGo/SOGoUserSettings.h>
|
#import <SOGo/SOGoUserSettings.h>
|
||||||
|
@ -109,34 +110,17 @@ typedef enum
|
||||||
[theKey caseInsensitiveCompare: @"Vacation"] == NSOrderedSame)
|
[theKey caseInsensitiveCompare: @"Vacation"] == NSOrderedSame)
|
||||||
{
|
{
|
||||||
/* credentials file handling */
|
/* credentials file handling */
|
||||||
NSData *credsData;
|
NSString *credsFilename, *authname, *authpwd;
|
||||||
NSRange r;
|
SOGoCredentialsFile *cf;
|
||||||
NSString *credsFile, *creds, *authname, *authpwd;
|
|
||||||
authname = nil;
|
|
||||||
authpwd = nil;
|
|
||||||
|
|
||||||
|
credsFilename = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
|
||||||
credsFile = [[NSUserDefaults standardUserDefaults] stringForKey: @"p"];
|
if (credsFilename)
|
||||||
if (credsFile)
|
|
||||||
{
|
{
|
||||||
/* TODO: add back support for user:pwd here? */
|
cf = [SOGoCredentialsFile credentialsFromFile: credsFilename];
|
||||||
credsData = [NSData dataWithContentsOfFile: credsFile];
|
authname = [cf username];
|
||||||
if (credsData == nil)
|
authpwd = [cf password];
|
||||||
{
|
|
||||||
NSLog(@"Error reading credential file '%@'", credsFile);
|
|
||||||
return NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
creds = [[NSString alloc] initWithData: credsData
|
|
||||||
encoding: NSUTF8StringEncoding];
|
|
||||||
[creds autorelease];
|
|
||||||
creds = [creds stringByTrimmingCharactersInSet:
|
|
||||||
[NSCharacterSet characterSetWithCharactersInString: @"\r\n"]];
|
|
||||||
|
|
||||||
r = [creds rangeOfString: @":"];
|
|
||||||
authname = [creds substringToIndex: r.location];
|
|
||||||
authpwd = [creds substringFromIndex: r.location+1];
|
|
||||||
}
|
|
||||||
if (authname == nil || authpwd == nil)
|
if (authname == nil || authpwd == nil)
|
||||||
{
|
{
|
||||||
NSLog(@"To update Sieve scripts, you must provide the \"-p credentialFile\" parameter");
|
NSLog(@"To update Sieve scripts, you must provide the \"-p credentialFile\" parameter");
|
||||||
|
|
Loading…
Reference in a new issue