]> source.dussan.org Git - archiva.git/blob
e99d7b42d87b2de460a5ebc3ef3a3d352fbcd69f
[archiva.git] /
1 package org.apache.maven.archiva.web.repository;
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
40 /**
41  * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
42  * for every request to respond as success / true. 
43  *
44  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
45  * @version $Id$
46  * 
47  * @plexus.component 
48  *      role="org.codehaus.plexus.redback.system.SecuritySystem"
49  */
50 public class BypassSecuritySystem
51     extends DefaultSecuritySystem
52     implements SecuritySystem
53 {
54     private KeyManager bypassKeyManager;
55     private UserSecurityPolicy bypassPolicy;
56     private UserManager bypassUserManager;
57     
58     public BypassSecuritySystem()
59     {
60         bypassKeyManager = new MemoryKeyManager();
61         bypassPolicy = new DefaultUserSecurityPolicy();
62         bypassUserManager = new MemoryUserManager();
63     }
64     
65     public SecuritySession authenticate( AuthenticationDataSource source )
66         throws AuthenticationException, UserNotFoundException, AccountLockedException
67     {
68         AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
69         return new DefaultSecuritySession( result );
70     }
71
72     public AuthorizationResult authorize( SecuritySession session, Object permission )
73         throws AuthorizationException
74     {
75         return new AuthorizationResult( true, session.getUser(), null );
76     }
77
78     public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
79         throws AuthorizationException
80     {
81         return new AuthorizationResult( true, session.getUser(), null );
82     }
83
84     public String getAuthenticatorId()
85     {
86         return "bypass-authenticator";
87     }
88
89     public String getAuthorizerId()
90     {
91         return "bypass-authorizer";
92     }
93
94     public KeyManager getKeyManager()
95     {
96         return bypassKeyManager;
97     }
98
99     public UserSecurityPolicy getPolicy()
100     {
101         return bypassPolicy;
102     }
103
104     public String getUserManagementId()
105     {
106         return "bypass-managementid";
107     }
108
109     public UserManager getUserManager()
110     {
111         return bypassUserManager;
112     }
113
114     public boolean isAuthenticated( AuthenticationDataSource source )
115         throws AuthenticationException, UserNotFoundException, AccountLockedException
116     {
117         // Always true
118         return true;
119     }
120
121     public boolean isAuthorized( SecuritySession session, Object permission )
122         throws AuthorizationException
123     {
124         // Always true
125         return true;
126     }
127
128     public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
129         throws AuthorizationException
130     {
131         // Always true
132         return true;
133     }
134 }