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.
48 public class SecuritySystemStub
49 implements SecuritySystem
51 Map<String, String> users = new HashMap<String, String>();
53 List<String> repoIds = new ArrayList<String>();
55 public SecuritySystemStub()
57 users.put( "user1", "password1" );
58 users.put( "user2", "password2" );
59 users.put( "user3", "password3" );
61 repoIds.add( "test-repo" );
64 public SecuritySession authenticate( AuthenticationDataSource source )
65 throws AuthenticationException, UserNotFoundException, AccountLockedException
67 AuthenticationResult result = null;
68 SecuritySession session = null;
70 if ( users.get( source.getPrincipal() ) != null )
72 result = new AuthenticationResult( true, source.getPrincipal(), null );
74 User user = new JdoUser();
75 user.setUsername( source.getPrincipal() );
76 user.setPassword( users.get( source.getPrincipal() ) );
78 session = new DefaultSecuritySession( result, user );
82 result = new AuthenticationResult( false, source.getPrincipal(), null );
83 session = new DefaultSecuritySession( result );
88 public AuthorizationResult authorize( SecuritySession arg0, Object arg1 )
89 throws AuthorizationException
94 public AuthorizationResult authorize( SecuritySession arg0, Object arg1, Object arg2 )
95 throws AuthorizationException
97 AuthorizationResult result = new AuthorizationResult( true, arg1, null);
102 public String getAuthenticatorId()
104 // TODO Auto-generated method stub
108 public String getAuthorizerId()
110 // TODO Auto-generated method stub
114 public KeyManager getKeyManager()
116 // TODO Auto-generated method stub
120 public UserSecurityPolicy getPolicy()
122 // TODO Auto-generated method stub
126 public String getUserManagementId()
128 // TODO Auto-generated method stub
132 public UserManager getUserManager()
134 // TODO Auto-generated method stub
138 public boolean isAuthenticated( AuthenticationDataSource arg0 )
139 throws AuthenticationException, UserNotFoundException, AccountLockedException
141 // TODO Auto-generated method stub
145 public boolean isAuthorized( SecuritySession arg0, Object arg1 )
146 throws AuthorizationException
148 // TODO Auto-generated method stub
152 public boolean isAuthorized( SecuritySession arg0, Object arg1, Object arg2 )
153 throws AuthorizationException
155 if ( repoIds.contains( arg2 ) )