Announcement Announcement Module
Collapse
No announcement yet.
Spring User Role authentication Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring User Role authentication

    I am new to spring security i have a task where i need to load user role depending upon the site url after the user logs i don't want to have it in the contsec.xml can anyone tell me the other way
    public class SpringSecurity {


    public static void doSpringAuthenticate(String userNameOrEmail, String password) {
    doSpringAuthenticate(userNameOrEmail, password, true);
    }

    public static void doSpringAuthenticate(String userNameOrEmail, String password, boolean eagerSavingContext) {
    org.springframework.security.authentication.Authen ticationManager authenticationManager = ContextUtil.getAuthenticationManager();
    Authentication authenticate = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userNameOrEmai l, password));



    if (authenticate.isAuthenticated()) {
    SecurityContextHolder.getContext().setAuthenticati on(authenticate);
    if (eagerSavingContext) {
    ExternalContext context = FacesContext.getCurrentInstance().getExternalConte xt();
    HttpServletRequest request = (HttpServletRequest) context.getRequest();
    HttpServletResponse response = (HttpServletResponse) context.getResponse();
    ContextUtil.getSecurityContextRepository().saveCon text(SecurityContextHolder.getContext(), request, response);
    }
    }
    }
    Last edited by tinku12345; Jul 14th, 2012, 08:23 AM.

  • #2
    It is not clear to me what you are trying to do. Can you please elaborate?

    Comment

    Working...
    X