1 package org.apache.maven.archiva.web.repository;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
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;
41 * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
42 * for every request to respond as success / true.
44 * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
48 * role="org.codehaus.plexus.redback.system.SecuritySystem"
50 public class BypassSecuritySystem
51 extends DefaultSecuritySystem
52 implements SecuritySystem
54 private KeyManager bypassKeyManager;
55 private UserSecurityPolicy bypassPolicy;
56 private UserManager bypassUserManager;
58 public BypassSecuritySystem()
60 bypassKeyManager = new MemoryKeyManager();
61 bypassPolicy = new DefaultUserSecurityPolicy();
62 bypassUserManager = new MemoryUserManager();
65 public SecuritySession authenticate( AuthenticationDataSource source )
66 throws AuthenticationException, UserNotFoundException, AccountLockedException
68 AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
69 return new DefaultSecuritySession( result );
72 public AuthorizationResult authorize( SecuritySession session, Object permission )
73 throws AuthorizationException
75 return new AuthorizationResult( true, session.getUser(), null );
78 public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
79 throws AuthorizationException
81 return new AuthorizationResult( true, session.getUser(), null );
84 public String getAuthenticatorId()
86 return "bypass-authenticator";
89 public String getAuthorizerId()
91 return "bypass-authorizer";
94 public KeyManager getKeyManager()
96 return bypassKeyManager;
99 public UserSecurityPolicy getPolicy()
104 public String getUserManagementId()
106 return "bypass-managementid";
109 public UserManager getUserManager()
111 return bypassUserManager;
114 public boolean isAuthenticated( AuthenticationDataSource source )
115 throws AuthenticationException, UserNotFoundException, AccountLockedException
121 public boolean isAuthorized( SecuritySession session, Object permission )
122 throws AuthorizationException
128 public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
129 throws AuthorizationException