]> source.dussan.org Git - archiva.git/blob
733679f879088c9699b44da44c51a70362811643
[archiva.git] /
1 package org.apache.maven.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.codehaus.plexus.redback.authentication.AuthenticationDataSource;
23 import org.codehaus.plexus.redback.authentication.AuthenticationException;
24 import org.codehaus.plexus.redback.authentication.AuthenticationResult;
25 import org.codehaus.plexus.redback.authorization.AuthorizationException;
26 import org.codehaus.plexus.redback.authorization.AuthorizationResult;
27 import org.codehaus.plexus.redback.keys.KeyManager;
28 import org.codehaus.plexus.redback.keys.memory.MemoryKeyManager;
29 import org.codehaus.plexus.redback.policy.AccountLockedException;
30 import org.codehaus.plexus.redback.policy.DefaultUserSecurityPolicy;
31 import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
32 import org.codehaus.plexus.redback.system.DefaultSecuritySession;
33 import org.codehaus.plexus.redback.system.DefaultSecuritySystem;
34 import org.codehaus.plexus.redback.system.SecuritySession;
35 import org.codehaus.plexus.redback.system.SecuritySystem;
36 import org.codehaus.plexus.redback.users.UserManager;
37 import org.codehaus.plexus.redback.users.UserNotFoundException;
38 import org.codehaus.plexus.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  * plexus.component
48  *      role="org.codehaus.plexus.redback.system.SecuritySystem"
49  */
50 @Service("securitySystem#bypass")
51 public class BypassSecuritySystem
52     extends DefaultSecuritySystem
53     implements SecuritySystem
54 {
55     private KeyManager bypassKeyManager;
56     private UserSecurityPolicy bypassPolicy;
57     private UserManager bypassUserManager;
58     
59     public BypassSecuritySystem()
60     {
61         bypassKeyManager = new MemoryKeyManager();
62         bypassPolicy = new DefaultUserSecurityPolicy();
63         bypassUserManager = new MemoryUserManager();
64     }
65     
66     public SecuritySession authenticate( AuthenticationDataSource source )
67         throws AuthenticationException, UserNotFoundException, AccountLockedException
68     {
69         AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
70         return new DefaultSecuritySession( result );
71     }
72
73     public AuthorizationResult authorize( SecuritySession session, Object permission )
74         throws AuthorizationException
75     {
76         return new AuthorizationResult( true, session.getUser(), null );
77     }
78
79     public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
80         throws AuthorizationException
81     {
82         return new AuthorizationResult( true, session.getUser(), null );
83     }
84
85     public String getAuthenticatorId()
86     {
87         return "bypass-authenticator";
88     }
89
90     public String getAuthorizerId()
91     {
92         return "bypass-authorizer";
93     }
94
95     public KeyManager getKeyManager()
96     {
97         return bypassKeyManager;
98     }
99
100     public UserSecurityPolicy getPolicy()
101     {
102         return bypassPolicy;
103     }
104
105     public String getUserManagementId()
106     {
107         return "bypass-managementid";
108     }
109
110     public UserManager getUserManager()
111     {
112         return bypassUserManager;
113     }
114
115     public boolean isAuthenticated( AuthenticationDataSource source )
116         throws AuthenticationException, UserNotFoundException, AccountLockedException
117     {
118         // Always true
119         return true;
120     }
121
122     public boolean isAuthorized( SecuritySession session, Object permission )
123         throws AuthorizationException
124     {
125         // Always true
126         return true;
127     }
128
129     public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
130         throws AuthorizationException
131     {
132         // Always true
133         return true;
134     }
135 }