1 package org.apache.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 org.apache.archiva.redback.users.User;
23 import org.apache.archiva.redback.users.UserManager;
24 import org.apache.archiva.redback.users.UserManagerListener;
25 import org.apache.archiva.redback.users.UserNotFoundException;
26 import org.apache.archiva.redback.users.UserQuery;
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.jdo.JdoUser;
40 import java.util.ArrayList;
41 import java.util.Date;
42 import java.util.HashMap;
43 import java.util.List;
47 * SecuritySystem stub used for testing.
51 public class SecuritySystemStub
52 implements SecuritySystem
54 Map<String, String> users = new HashMap<String, String>();
56 List<String> repoIds = new ArrayList<String>();
58 public SecuritySystemStub()
60 users.put( "user1", "password1" );
61 users.put( "user2", "password2" );
62 users.put( "user3", "password3" );
64 repoIds.add( "test-repo" );
67 public SecuritySession authenticate( AuthenticationDataSource source )
68 throws AuthenticationException, UserNotFoundException, AccountLockedException
70 AuthenticationResult result = null;
71 SecuritySession session = null;
73 if ( users.get( source.getPrincipal() ) != null )
75 result = new AuthenticationResult( true, source.getPrincipal(), null );
77 User user = new JdoUser();
78 user.setUsername( source.getPrincipal() );
79 user.setPassword( users.get( source.getPrincipal() ) );
81 session = new DefaultSecuritySession( result, user );
85 result = new AuthenticationResult( false, source.getPrincipal(), null );
86 session = new DefaultSecuritySession( result );
91 public AuthorizationResult authorize( SecuritySession arg0, Object arg1 )
92 throws AuthorizationException
97 public AuthorizationResult authorize( SecuritySession arg0, Object arg1, Object arg2 )
98 throws AuthorizationException
100 AuthorizationResult result = new AuthorizationResult( true, arg1, null );
105 public String getAuthenticatorId()
110 public String getAuthorizerId()
115 public KeyManager getKeyManager()
120 public UserSecurityPolicy getPolicy()
125 public String getUserManagementId()
130 public UserManager getUserManager()
132 return new UserManager()
134 public boolean isReadOnly()
136 return false; //To change body of implemented methods use File | Settings | File Templates.
139 public String getId()
141 return null; //To change body of implemented methods use File | Settings | File Templates.
144 public void addUserManagerListener( UserManagerListener listener )
146 //To change body of implemented methods use File | Settings | File Templates.
149 public void removeUserManagerListener( UserManagerListener listener )
151 //To change body of implemented methods use File | Settings | File Templates.
154 public User createUser( String username, String fullName, String emailAddress )
156 return null; //To change body of implemented methods use File | Settings | File Templates.
159 public User createGuestUser()
163 public Object getPrincipal()
168 public String getUsername()
170 return null; //To change body of implemented methods use File | Settings | File Templates.
173 public void setUsername( String name )
175 //To change body of implemented methods use File | Settings | File Templates.
178 public String getFullName()
180 return null; //To change body of implemented methods use File | Settings | File Templates.
183 public void setFullName( String name )
185 //To change body of implemented methods use File | Settings | File Templates.
188 public String getEmail()
190 return null; //To change body of implemented methods use File | Settings | File Templates.
193 public void setEmail( String address )
195 //To change body of implemented methods use File | Settings | File Templates.
198 public String getPassword()
200 return null; //To change body of implemented methods use File | Settings | File Templates.
203 public void setPassword( String rawPassword )
205 //To change body of implemented methods use File | Settings | File Templates.
208 public String getEncodedPassword()
210 return null; //To change body of implemented methods use File | Settings | File Templates.
213 public void setEncodedPassword( String encodedPassword )
215 //To change body of implemented methods use File | Settings | File Templates.
218 public Date getLastPasswordChange()
220 return null; //To change body of implemented methods use File | Settings | File Templates.
223 public void setLastPasswordChange( Date passwordChangeDate )
225 //To change body of implemented methods use File | Settings | File Templates.
228 public List<String> getPreviousEncodedPasswords()
230 return null; //To change body of implemented methods use File | Settings | File Templates.
233 public void setPreviousEncodedPasswords( List<String> encodedPasswordList )
235 //To change body of implemented methods use File | Settings | File Templates.
238 public void addPreviousEncodedPassword( String encodedPassword )
240 //To change body of implemented methods use File | Settings | File Templates.
243 public boolean isPermanent()
245 return false; //To change body of implemented methods use File | Settings | File Templates.
248 public void setPermanent( boolean permanent )
250 //To change body of implemented methods use File | Settings | File Templates.
253 public boolean isLocked()
255 return false; //To change body of implemented methods use File | Settings | File Templates.
258 public void setLocked( boolean locked )
260 //To change body of implemented methods use File | Settings | File Templates.
263 public boolean isPasswordChangeRequired()
265 return false; //To change body of implemented methods use File | Settings | File Templates.
268 public void setPasswordChangeRequired( boolean changeRequired )
270 //To change body of implemented methods use File | Settings | File Templates.
273 public boolean isValidated()
275 return false; //To change body of implemented methods use File | Settings | File Templates.
278 public void setValidated( boolean valid )
280 //To change body of implemented methods use File | Settings | File Templates.
283 public int getCountFailedLoginAttempts()
285 return 0; //To change body of implemented methods use File | Settings | File Templates.
288 public void setCountFailedLoginAttempts( int count )
290 //To change body of implemented methods use File | Settings | File Templates.
293 public Date getAccountCreationDate()
295 return null; //To change body of implemented methods use File | Settings | File Templates.
298 public void setAccountCreationDate( Date date )
300 //To change body of implemented methods use File | Settings | File Templates.
303 public Date getLastLoginDate()
305 return null; //To change body of implemented methods use File | Settings | File Templates.
308 public void setLastLoginDate( Date date )
310 //To change body of implemented methods use File | Settings | File Templates.
315 public UserQuery createUserQuery()
317 return null; //To change body of implemented methods use File | Settings | File Templates.
320 public List<User> getUsers()
322 return null; //To change body of implemented methods use File | Settings | File Templates.
325 public List<User> getUsers( boolean orderAscending )
327 return null; //To change body of implemented methods use File | Settings | File Templates.
330 public User addUser( User user )
332 return null; //To change body of implemented methods use File | Settings | File Templates.
335 public User updateUser( User user )
336 throws UserNotFoundException
338 return null; //To change body of implemented methods use File | Settings | File Templates.
341 public User findUser( String username )
342 throws UserNotFoundException
344 return null; //To change body of implemented methods use File | Settings | File Templates.
347 public User getGuestUser()
348 throws UserNotFoundException
352 public Object getPrincipal()
357 public String getUsername()
359 return null; //To change body of implemented methods use File | Settings | File Templates.
362 public void setUsername( String name )
364 //To change body of implemented methods use File | Settings | File Templates.
367 public String getFullName()
369 return null; //To change body of implemented methods use File | Settings | File Templates.
372 public void setFullName( String name )
374 //To change body of implemented methods use File | Settings | File Templates.
377 public String getEmail()
379 return null; //To change body of implemented methods use File | Settings | File Templates.
382 public void setEmail( String address )
384 //To change body of implemented methods use File | Settings | File Templates.
387 public String getPassword()
389 return null; //To change body of implemented methods use File | Settings | File Templates.
392 public void setPassword( String rawPassword )
394 //To change body of implemented methods use File | Settings | File Templates.
397 public String getEncodedPassword()
399 return null; //To change body of implemented methods use File | Settings | File Templates.
402 public void setEncodedPassword( String encodedPassword )
404 //To change body of implemented methods use File | Settings | File Templates.
407 public Date getLastPasswordChange()
409 return null; //To change body of implemented methods use File | Settings | File Templates.
412 public void setLastPasswordChange( Date passwordChangeDate )
414 //To change body of implemented methods use File | Settings | File Templates.
417 public List<String> getPreviousEncodedPasswords()
419 return null; //To change body of implemented methods use File | Settings | File Templates.
422 public void setPreviousEncodedPasswords( List<String> encodedPasswordList )
424 //To change body of implemented methods use File | Settings | File Templates.
427 public void addPreviousEncodedPassword( String encodedPassword )
429 //To change body of implemented methods use File | Settings | File Templates.
432 public boolean isPermanent()
434 return false; //To change body of implemented methods use File | Settings | File Templates.
437 public void setPermanent( boolean permanent )
439 //To change body of implemented methods use File | Settings | File Templates.
442 public boolean isLocked()
444 return false; //To change body of implemented methods use File | Settings | File Templates.
447 public void setLocked( boolean locked )
449 //To change body of implemented methods use File | Settings | File Templates.
452 public boolean isPasswordChangeRequired()
454 return false; //To change body of implemented methods use File | Settings | File Templates.
457 public void setPasswordChangeRequired( boolean changeRequired )
459 //To change body of implemented methods use File | Settings | File Templates.
462 public boolean isValidated()
464 return false; //To change body of implemented methods use File | Settings | File Templates.
467 public void setValidated( boolean valid )
469 //To change body of implemented methods use File | Settings | File Templates.
472 public int getCountFailedLoginAttempts()
474 return 0; //To change body of implemented methods use File | Settings | File Templates.
477 public void setCountFailedLoginAttempts( int count )
479 //To change body of implemented methods use File | Settings | File Templates.
482 public Date getAccountCreationDate()
484 return null; //To change body of implemented methods use File | Settings | File Templates.
487 public void setAccountCreationDate( Date date )
489 //To change body of implemented methods use File | Settings | File Templates.
492 public Date getLastLoginDate()
494 return null; //To change body of implemented methods use File | Settings | File Templates.
497 public void setLastLoginDate( Date date )
499 //To change body of implemented methods use File | Settings | File Templates.
504 public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
506 return null; //To change body of implemented methods use File | Settings | File Templates.
509 public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
511 return null; //To change body of implemented methods use File | Settings | File Templates.
514 public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
516 return null; //To change body of implemented methods use File | Settings | File Templates.
519 public List<User> findUsersByQuery( UserQuery query )
521 return null; //To change body of implemented methods use File | Settings | File Templates.
524 public User findUser( Object principal )
525 throws UserNotFoundException
527 return null; //To change body of implemented methods use File | Settings | File Templates.
530 public boolean userExists( Object principal )
532 return false; //To change body of implemented methods use File | Settings | File Templates.
535 public void deleteUser( Object principal )
536 throws UserNotFoundException
538 //To change body of implemented methods use File | Settings | File Templates.
541 public void deleteUser( String username )
542 throws UserNotFoundException
544 //To change body of implemented methods use File | Settings | File Templates.
547 public void addUserUnchecked( User user )
549 //To change body of implemented methods use File | Settings | File Templates.
552 public void eraseDatabase()
554 //To change body of implemented methods use File | Settings | File Templates.
557 public User updateUser( User user, boolean passwordChangeRequired )
558 throws UserNotFoundException
560 return null; //To change body of implemented methods use File | Settings | File Templates.
565 public boolean isAuthenticated( AuthenticationDataSource arg0 )
566 throws AuthenticationException, UserNotFoundException, AccountLockedException
571 public boolean isAuthorized( SecuritySession arg0, Object arg1 )
572 throws AuthorizationException
577 public boolean isAuthorized( SecuritySession arg0, Object arg1, Object arg2 )
578 throws AuthorizationException
580 if ( repoIds.contains( arg2 ) )