View Javadoc

1   /*
2    * Created on Mar 29, 2006
3    *
4    */
5   package org.musicontroller.security;
6   
7   import org.acegisecurity.Authentication;
8   import org.acegisecurity.context.SecurityContextHolder;
9   import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
10  import org.acegisecurity.providers.dao.DaoAuthenticationProvider;
11  
12  /**
13   * 
14   * @author Arjan Verstoep
15   * @version $Id: ServiceRoleProvider.java,v 1.1 2010/03/16 18:55:42 varienaja Exp $
16   */
17  public class ServiceRoleProvider {
18  	
19  	private static DaoAuthenticationProvider _ap;
20  	
21  	public ServiceRoleProvider() {
22  		_ap = null;
23  	}
24  	
25  	public void setProvider(DaoAuthenticationProvider ap) {
26  		_ap = ap;
27  	}
28  	
29  	public DaoAuthenticationProvider getProvider() {
30  		return _ap;
31  	}
32  	
33  	/**
34  	 * Zorgt ervoor dat de huidige Thread geauthenticeerd is als 'service'
35  	 *
36  	 */
37  	public static void provideServiceAccount() {
38  		Authentication auth = _ap.authenticate(new UsernamePasswordAuthenticationToken("system",""));
39          SecurityContextHolder.getContext().setAuthentication(auth);
40  	}
41  
42  }