1 package org.apache.maven.archiva.web.rss;
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 java.util.ArrayList;
23 import java.util.HashMap;
24 import java.util.List;
27 import org.codehaus.plexus.redback.authentication.AuthenticationDataSource;
28 import org.codehaus.plexus.redback.authentication.AuthenticationException;
29 import org.codehaus.plexus.redback.authentication.AuthenticationResult;
30 import org.codehaus.plexus.redback.authorization.AuthorizationException;
31 import org.codehaus.plexus.redback.authorization.AuthorizationResult;
32 import org.codehaus.plexus.redback.keys.KeyManager;
33 import org.codehaus.plexus.redback.policy.AccountLockedException;
34 import org.codehaus.plexus.redback.policy.UserSecurityPolicy;
35 import org.codehaus.plexus.redback.system.DefaultSecuritySession;
36 import org.codehaus.plexus.redback.system.SecuritySession;
37 import org.codehaus.plexus.redback.system.SecuritySystem;
38 import org.codehaus.plexus.redback.users.User;
39 import org.codehaus.plexus.redback.users.UserManager;
40 import org.codehaus.plexus.redback.users.UserNotFoundException;
41 import org.codehaus.plexus.redback.users.jdo.JdoUser;
44 * SecuritySystem stub used for testing.
46 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
49 public class SecuritySystemStub
50 implements SecuritySystem
52 Map<String, String> users = new HashMap<String, String>();
54 List<String> repoIds = new ArrayList<String>();
56 public SecuritySystemStub()
58 users.put( "user1", "password1" );
59 users.put( "user2", "password2" );
60 users.put( "user3", "password3" );
62 repoIds.add( "test-repo" );
65 public SecuritySession authenticate( AuthenticationDataSource source )
66 throws AuthenticationException, UserNotFoundException, AccountLockedException
68 AuthenticationResult result = null;
69 SecuritySession session = null;
71 if ( users.get( source.getPrincipal() ) != null )
73 result = new AuthenticationResult( true, source.getPrincipal(), null );
75 User user = new JdoUser();
76 user.setUsername( source.getPrincipal() );
77 user.setPassword( users.get( source.getPrincipal() ) );
79 session = new DefaultSecuritySession( result, user );
83 result = new AuthenticationResult( false, source.getPrincipal(), null );
84 session = new DefaultSecuritySession( result );
89 public AuthorizationResult authorize( SecuritySession arg0, Object arg1 )
90 throws AuthorizationException
92 // TODO Auto-generated method stub
96 public AuthorizationResult authorize( SecuritySession arg0, Object arg1, Object arg2 )
97 throws AuthorizationException
99 // TODO Auto-generated method stub
103 public String getAuthenticatorId()
105 // TODO Auto-generated method stub
109 public String getAuthorizerId()
111 // TODO Auto-generated method stub
115 public KeyManager getKeyManager()
117 // TODO Auto-generated method stub
121 public UserSecurityPolicy getPolicy()
123 // TODO Auto-generated method stub
127 public String getUserManagementId()
129 // TODO Auto-generated method stub
133 public UserManager getUserManager()
135 // TODO Auto-generated method stub
139 public boolean isAuthenticated( AuthenticationDataSource arg0 )
140 throws AuthenticationException, UserNotFoundException, AccountLockedException
142 // TODO Auto-generated method stub
146 public boolean isAuthorized( SecuritySession arg0, Object arg1 )
147 throws AuthorizationException
149 // TODO Auto-generated method stub
153 public boolean isAuthorized( SecuritySession arg0, Object arg1, Object arg2 )
154 throws AuthorizationException
156 if ( repoIds.contains( arg2 ) )