Well it's a solution, but I found the programmatic solution.
I add some property to my controller coming from the applicationContext-security.xml (authenticationManager and rememberMeServices)
Code:
<bean id="createAccountController" class="springshop.web.CreateAccountController">
<!-- property coming from the security context -->
<property name="authenticationManager" ref="authenticationManager"/>
<property name="rememberMeServices" ref="rememberMeServices"/>
<!-- property related to the controller -->
<property name="sessionForm">
<value>true</value>
</property>
<property name="commandName">
<value>user</value>
</property>
<property name="formView">
<value>createAccount</value>
</property>
<property name="validator">
<bean class="springshop.web.form.validator.AccountValidator" />
</property>
<property name="userDBService">
<ref bean="userDBService"/>
</property>
<property name="mailerService">
<ref bean="mailerService"/>
</property>
</bean>
And Here is the code I add in the onSubmit() of my controller.
Code:
//that's it let's activate the account
GrantedAuthorityImpl[] arrayAuths = new GrantedAuthorityImpl[roles.size()];
int index = 0;
for (Iterator it=roles.iterator(); it.hasNext(); ) {
r = (Role) it.next();
GrantedAuthorityImpl authority = new GrantedAuthorityImpl(r.getName());
arrayAuths[index++] = authority;
}
UsernamePasswordAuthenticationToken spa = new UsernamePasswordAuthenticationToken(user.getLogin(),user.getPassword(),arrayAuths);
SecurityContextHolder.getContext().setAuthentication(spa);
request.getSession().setAttribute(ACEGI_SECURITY_LAST_USERNAME_KEY, user.getLogin());
AuthenticationManager authenticationManager = getAuthenticationManager();
authenticationManager.authenticate(spa);
getRememberMeServices().loginSuccess(request, response, spa);
That's it the user is authenticated, I don't publish event, but I should...