On 9/11/06, Elias Torres <[EMAIL PROTECTED]> wrote:
Matt,
I think you probably missed this question since it was bundled up in
another email with a non-obvious subject, but I think this one should be
clear :)
-Elias
Elias Torres wrote:
[snip]
> Matt,
>
> I have one thing left to fix. In auto-provision mode, if a user has
> authenticated via SSO (LDAP), the only role they have is "register", so
> they can access the New Registration page. So, in RollerSession is
> UserData is null, I call AutoProvisionHelper to try to register the
> user. It works great, except that Acegi Security still believes the
> Authentication only has roles "register" and not "editor,[admin]". I see
> in SecurityContextHolder you can set Authentication, but I'm not sure
> how to proceed. Any suggestions?
Here's an example of how to set authentication programmatically:
// log user in automatically
Authentication auth = new
UsernamePasswordAuthenticationToken(user.getUsername(),
user.getConfirmPassword());
try {
ApplicationContext ctx =
WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
if (ctx != null) {
ProviderManager authenticationManager =
(ProviderManager) ctx.getBean("authenticationManager");
SecurityContextHolder.getContext().setAuthentication(authenticationManager.doAuthentication(auth));
}
} catch (NoSuchBeanDefinitionException n) {
// ignore, should only happen when testing
}
Hope this helps,
Matt
>
> -Elias
>