2 Copyright (C) 2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <NGLdap/NGLdapConnection.h>
23 #import "SOGoPermissions.h"
25 #import "LDAPUserManager.h"
27 #import "SOGoAuthenticator.h"
31 @implementation SOGoAuthenticator
33 static SOGoAuthenticator *auth = nil;
35 + (id) sharedSOGoAuthenticator
38 auth = [[self alloc] init];
44 if ((self = [super init]))
46 ud = [NSUserDefaults standardUserDefaults];
52 authMethod = [[ud stringForKey:@"AuthentificationMethod"] retain];
53 if ([authMethod isEqualToString: @"LDAP"])
55 // LDAPBaseDN = [[ud stringForKey:@"LDAPRootDN"] retain];
56 // LDAPHost = [[ud stringForKey:@"LDAPHost"] retain];
57 // LDAPPort = [ud integerForKey:@"LDAPPort"];
74 - (BOOL) checkLogin: (NSString *) _login
75 password: (NSString *) _pwd
79 if ([authMethod isEqualToString: @"LDAP"])
80 accept = [self LDAPCheckLogin: _login password: _pwd];
82 accept = ([_login length] > 0);
84 return (([_login isEqualToString: @"freebusy"]
85 && [_pwd isEqualToString: @"freebusy"])
89 - (BOOL) LDAPCheckLogin: (NSString *) _login
90 password: (NSString *) _pwd
94 um = [LDAPUserManager sharedUserManager];
96 return [um checkLogin: _login andPassword: _pwd];
101 - (SOGoUser *) userInContext: (WOContext *)_ctx
103 static SOGoUser *anonymous = nil, *freebusy;
105 NSArray *traversalPath;
110 = [[SOGoUser alloc] initWithLogin: @"anonymous"
111 roles: [NSArray arrayWithObject: SoRole_Anonymous]];
114 = [[SOGoUser alloc] initWithLogin: @"freebusy"
115 roles: [NSArray arrayWithObject: SOGoRole_FreeBusy]];
117 login = [self checkCredentialsInContext:_ctx];
120 if ([login isEqualToString: @"anonymous"])
122 traversalPath = [_ctx objectForKey: @"SoRequestTraversalPath"];
123 if ([[traversalPath lastObject] isEqualToString: @"freebusy.ifb"])
129 user = [SOGoUser userWithLogin: login
130 roles: [self rolesForLogin: login]];
138 // - (BOOL) renderException: (NSException *) exception
139 // inContext: (WOContext *) context
141 // id renderedException;
142 // WOComponent *tmpComponent;
143 // WOResponse *response;
146 // rc = [super renderException: exception inContext: context];
149 // tmpComponent = [WOComponent new];
150 // renderedException = [tmpComponent pageWithName: @"UIxException"];
151 // if (renderedException)
154 // response = [context response];
155 // [response setHeader: @"text/html" forKey: @"content-type"];
156 // [renderedException setClientObject: exception];
157 // [context setPage: renderedException];
158 // [renderedException appendToResponse: response
159 // inContext: context];
161 // [tmpComponent release];
167 @end /* SOGoAuthenticator */