1 package org.apache.maven.archiva.webdav;
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;
39 import org.springframework.stereotype.Service;
42 * BypassSecuritySystem - used to bypass the security system for testing reasons and allow
43 * for every request to respond as success / true.
48 * role="org.codehaus.plexus.redback.system.SecuritySystem"
50 @Service("securitySystem#bypass")
51 public class BypassSecuritySystem
52 extends DefaultSecuritySystem
53 implements SecuritySystem
55 private KeyManager bypassKeyManager;
56 private UserSecurityPolicy bypassPolicy;
57 private UserManager bypassUserManager;
59 public BypassSecuritySystem()
61 bypassKeyManager = new MemoryKeyManager();
62 bypassPolicy = new DefaultUserSecurityPolicy();
63 bypassUserManager = new MemoryUserManager();
66 public SecuritySession authenticate( AuthenticationDataSource source )
67 throws AuthenticationException, UserNotFoundException, AccountLockedException
69 AuthenticationResult result = new AuthenticationResult( true, source.getPrincipal(), null );
70 return new DefaultSecuritySession( result );
73 public AuthorizationResult authorize( SecuritySession session, Object permission )
74 throws AuthorizationException
76 return new AuthorizationResult( true, session.getUser(), null );
79 public AuthorizationResult authorize( SecuritySession session, Object permission, Object resource )
80 throws AuthorizationException
82 return new AuthorizationResult( true, session.getUser(), null );
85 public String getAuthenticatorId()
87 return "bypass-authenticator";
90 public String getAuthorizerId()
92 return "bypass-authorizer";
95 public KeyManager getKeyManager()
97 return bypassKeyManager;
100 public UserSecurityPolicy getPolicy()
105 public String getUserManagementId()
107 return "bypass-managementid";
110 public UserManager getUserManager()
112 return bypassUserManager;
115 public boolean isAuthenticated( AuthenticationDataSource source )
116 throws AuthenticationException, UserNotFoundException, AccountLockedException
122 public boolean isAuthorized( SecuritySession session, Object permission )
123 throws AuthorizationException
129 public boolean isAuthorized( SecuritySession session, Object permission, Object resource )
130 throws AuthorizationException