1 17 package org.alfresco.repo.security.authentication; 18 19 import net.sf.acegisecurity.AuthenticationManager; 20 import net.sf.acegisecurity.UserDetails; 21 import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken; 22 23 public class AuthenticationComponentImpl extends AbstractAuthenticationComponent 24 { 25 private MutableAuthenticationDao authenticationDao; 26 27 AuthenticationManager authenticationManager; 28 29 public AuthenticationComponentImpl() 30 { 31 super(); 32 } 33 34 39 public void setAuthenticationManager(AuthenticationManager authenticationManager) 40 { 41 this.authenticationManager = authenticationManager; 42 } 43 44 49 public void setAuthenticationDao(MutableAuthenticationDao authenticationDao) 50 { 51 this.authenticationDao = authenticationDao; 52 } 53 54 57 public void authenticate(String userName, char[] password) throws AuthenticationException 58 { 59 try 60 { 61 UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userName, 62 new String (password)); 63 authenticationManager.authenticate(authentication); 64 setCurrentUser(userName); 65 66 } 67 catch (net.sf.acegisecurity.AuthenticationException ae) 68 { 69 throw new AuthenticationException(ae.getMessage(), ae); 70 } 71 } 72 73 74 77 protected UserDetails getUserDetails(String userName) 78 { 79 return (UserDetails) authenticationDao.loadUserByUsername(userName); 80 } 81 82 83 86 public String getMD4HashedPassword(String userName) 87 { 88 return authenticationDao.getMD4HashedPassword(userName); 89 } 90 91 92 95 public NTLMMode getNTLMMode() 96 { 97 return NTLMMode.MD4_PROVIDER; 98 } 99 100 @Override 101 protected boolean implementationAllowsGuestLogin() 102 { 103 return true; 104 } 105 106 107 } 108 | Popular Tags |