2 Copyright (C) 2000-2005 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 #include "WOContext+Agenor.h"
25 @implementation WOContext(Agenor)
27 static EOQualifier *internetDetectQualifier = nil;
29 static EOQualifier *getInternetDetectQualifier(void) {
30 static BOOL didCheck = NO;
34 if (didCheck) return internetDetectQualifier;
36 ud = [NSUserDefaults standardUserDefaults];
38 if ((s = [ud stringForKey:@"SOGoInternetDetectQualifier"]) != nil) {
39 internetDetectQualifier =
40 [[EOQualifier qualifierWithQualifierFormat:s] retain];
41 if (internetDetectQualifier == nil)
42 NSLog(@"ERROR: could not parse qualifier: '%@'", s);
44 if (internetDetectQualifier == nil)
45 NSLog(@"Note: no 'SOGoInternetDetectQualifier' configured.");
47 NSLog(@"Note: detect Internet access using: %@",
48 internetDetectQualifier);
52 return internetDetectQualifier;
55 - (BOOL)isAccessFromIntranet {
56 id<EOQualifierEvaluation> q;
61 if ((bv = [self objectForKey:@"_agenorUnrestricedAccess"]) != nil)
62 return [bv boolValue];
64 if ((rq = [self request]) == nil) {
65 [self logWithFormat:@"ERROR: got no request for context!"];
70 if ((q = (id)getInternetDetectQualifier()) == nil)
71 /* if no qualifier is set, allow access */
74 /* is Internet request? */
75 ok = [q evaluateWithObject:[rq headers]] ? NO : YES;
77 bv = [NSNumber numberWithBool:ok];
78 [self setObject:bv forKey:@"_agenorUnrestricedAccess"];
82 @end /* WOContext(Agenor) */