]> source.dussan.org Git - archiva.git/blob
2699721875294289bd7de0af0172701a23c28ca0
[archiva.git] /
1 package org.apache.archiva.webdav;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import org.apache.archiva.redback.authentication.AuthenticationException;
23 import org.apache.archiva.redback.users.UserManager;
24 import org.apache.archiva.redback.authentication.AuthenticationDataSource;
25 import org.apache.archiva.redback.authentication.AuthenticationResult;
26 import org.apache.archiva.redback.authorization.AuthorizationException;
27 import org.apache.archiva.redback.authorization.AuthorizationResult;
28 import org.codehaus.plexus.redback.keys.KeyManager;
29 import org.codehaus.plexus.redback.keys.memory.MemoryKeyManager;
30 import org.codehaus.plexus.redback.policy.AccountLockedException;
31 import org.codehaus.plexus.redback.policy.DefaultUserSecurityPolicy;
32 import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
33 import org.codehaus.plexus.redback.system.DefaultSecuritySession;
34 import org.codehaus.plexus.redback.system.DefaultSecuritySystem;
35 import org.codehaus.plexus.redback.system.SecuritySession;
36 import org.codehaus.plexus.redback.system.SecuritySystem;
37 import org.apache.archiva.redback.users.UserNotFoundException;
38 import org.apache.archiva.redback.users.memory.MemoryUserManager;
39 import org.springframework.stereotype.Service;
40
41 /**
42  * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
43  * for every request to respond as success / true. 
44  *
45  * @version $Id$
46  */
47 @Service("securitySystem#bypass")
48 public class BypassSecuritySystem
49     extends DefaultSecuritySystem
50     implements SecuritySystem
51 {
52     private KeyManager bypassKeyManager;
53     private UserSecurityPolicy bypassPolicy;
54     private UserManager bypassUserManager;
55     
56     public BypassSecuritySystem()
57     {
58         bypassKeyManager = new MemoryKeyManager();
59         bypassPolicy = new DefaultUserSecurityPolicy();
60         bypassUserManager = new MemoryUserManager();
61     }
62     
63     public SecuritySession authenticate( AuthenticationDataSource source )
64         throws AuthenticationException, UserNotFoundException, AccountLockedException
65     {
66         AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
67         return new DefaultSecuritySession( result );
68     }
69
70     public AuthorizationResult authorize( SecuritySession session, Object permission )
71         throws AuthorizationException
72     {
73         return new AuthorizationResult( true, session.getUser(), null );
74     }
75
76     public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
77         throws AuthorizationException
78     {
79         return new AuthorizationResult( true, session.getUser(), null );
80     }
81
82     public String getAuthenticatorId()
83     {
84         return "bypass-authenticator";
85     }
86
87     public String getAuthorizerId()
88     {
89         return "bypass-authorizer";
90     }
91
92     public KeyManager getKeyManager()
93     {
94         return bypassKeyManager;
95     }
96
97     public UserSecurityPolicy getPolicy()
98     {
99         return bypassPolicy;
100     }
101
102     public String getUserManagementId()
103     {
104         return "bypass-managementid";
105     }
106
107     public UserManager getUserManager()
108     {
109         return bypassUserManager;
110     }
111
112     public boolean isAuthenticated( AuthenticationDataSource source )
113         throws AuthenticationException, UserNotFoundException, AccountLockedException
114     {
115         // Always true
116         return true;
117     }
118
119     public boolean isAuthorized( SecuritySession session, Object permission )
120         throws AuthorizationException
121     {
122         // Always true
123         return true;
124     }
125
126     public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
127         throws AuthorizationException
128     {
129         // Always true
130         return true;
131     }
132 }