]> err.no Git - sope/blob - sope-appserver/NGObjWeb/SoObjects/SoSecurityException.m
fixed various warnings
[sope] / sope-appserver / NGObjWeb / SoObjects / SoSecurityException.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "SoSecurityException.h"
24 #include "SoSecurityManager.h"
25 #include "common.h"
26
27 @implementation SoSecurityException
28
29 + (id)securityExceptionOnObject:(id)_o 
30   withAuthenticator:(id)_a 
31   andManager:(id)_m 
32 {
33   return [[[self alloc] 
34             initWithObject:_o authenticator:_a manager:_m] autorelease];
35 }
36 - (id)initWithObject:(id)_object authenticator:(id)_auth manager:(id)_manager {
37   NSString *n, *r;
38   
39   if ((n = [self name]) == nil)
40     n = NSStringFromClass([self class]);
41   if ((r = [self reason]) == nil)
42     r = @"generic security exception";
43   
44   if ((self = [super initWithName:n reason:r userInfo:nil])) {
45     self->object          = [_object  retain];
46     self->authenticator   = [_auth    retain];
47     self->securityManager = [_manager retain];
48   }
49   return self;
50 }
51
52 - (void)dealloc {
53   [self->object          release];
54   [self->securityManager release];
55   [self->authenticator   release];
56   [super dealloc];
57 }
58
59 /* accessors */
60
61 - (SoSecurityManager *)securityManager {
62   return self->securityManager;
63 }
64 - (id)authenticator {
65   return self->authenticator;
66 }
67 - (id)object {
68   return self->object;
69 }
70
71 @end /* SoSecurityManager */
72
73 @implementation SoAuthRequiredException
74
75 - (unsigned short)httpStatus {
76   return 401;
77 }
78
79 - (NSString *)name {
80   return @"SoAuthRequired";
81 }
82 - (NSString *)reason {
83   return @"authentication required";
84 }
85
86 @end /* SoAuthRequiredException */
87
88 @implementation SoAccessDeniedException
89
90 - (unsigned short)httpStatus {
91   return 403;
92 }
93
94 @end /* SoAccessDeniedException */