cas 封装ticket的部分函数

1.绑定用户信息

  

protected void bindTicketGrantingTicket(String loginName, String loginPassword, HttpServletRequest request, HttpServletResponse response){   
    try {   
        UsernamePasswordCredentials credentials = new   UsernamePasswordCredentials();   
        credentials.setUsername(loginName);   
        credentials.setPassword(loginPassword);   
        String ticketGrantingTicket = centralAuthenticationService.createTicketGrantingTicket(credentials);   
        ticketGrantingTicketCookieGenerator.addCookie(request, response, ticketGrantingTicket);   
    } catch (TicketException te) {   
        logger.error("Validate the login name " + loginName + " failure, can't bind the TGT!", te);   
    } catch (Exception e){   
        logger.error("bindTicketGrantingTicket has exception.", e);   
    }   
}  

2.

    authenticationManager这个bean可以配置你的credentials。

     If you are using some other kind of credentials than UsernamePasswordCredentials, you will need to replace  DefaultCredentialsToPrincipalResolver with a CredentialsToPrincipalResolver that supports the credentials  you are using.

posted @ 2012-04-25 16:40  jiuzhongguo  阅读(627)  评论(0编辑  收藏  举报