Jasperserver authenticate from within a Singleton bean

0

Hi,

I am trying to add a custom Spring bean to extend the functionality of Jasper server web application.
The bean is managed by Spring and it is initialized at the start of the web application.
When I try to Authenticate, before scheduling a Job using the Jasper server API, I get an exception "jsexception.no.such.user" 

-------- Code snippet -----------------

Authentication auth = new UsernamePasswordAuthenticationToken ("jasperadmin" "jasperadmin",getAuthorities()); SecurityContextHolder.getContext().setAuthentication(auth);

------------------------------------------------------------------

If I try to find the user by username it gives me "User not found with username "jasperadmin"

--------- Code snippet ----------------------

UserDetails userDetails = getUserDetailsService().loadUserByUsername("jasperadmin");
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authenticationToken);

--------------------------------------------------------------

Jasperserver is configured for external authentication with our LDAP server.
I have also tried to login using other external users (LDAP) and I get the same exception.

Can you please suggest a way to authenticate from within a Singleton bean?

Thanks,
PC Rao.

purnamg's picture
Joined: Mar 27 2014 - 12:07am
Last seen: 3 years 4 months ago

0 Answers:

No answers yet
Feedback