How to add values into Spring SecurityContextHolder

Viewed 11257

I have there login parameters

1.userName

2.password

3.companyId

I have got user name and password using following code

 Authentication auth = SecurityContextHolder.getContext().getAuthentication();

 String name = auth.getName();

 String pwd = auth.getCredentials();

 String companyId= ???//How can i set and then get company Id here.

My Question is how can i get an extra login parameter(companyId) using SecurityContextHolder?

The extracting class may not be a spring controller.That is why i am using SecurityContextHolder instead of HttpSession.

Thanks,

1 Answers
Related