[jboss-user] [JBoss Portal] - custom sso :cas
jsports
do-not-reply at jboss.com
Tue Aug 26 23:20:16 EDT 2008
I have done cas sso with jboss portal successfully.
Now I want to use our userinfo database for Authenticate.
I write a new CASAuthenticationService implements AuthenticationService
instead of the CASAuthenticationService in the portal-identity-sso-lib.jar.
| public class CASAuthenticationService implements AuthenticationService{
| private final static Logger logger = Logger.getLogger(CASAuthenticationService.class);
| private String datasource = null;
| private String queryPasswordByUserNameSql = null;
|
|
| public String getQueryPasswordByUserNameSql() {
| return queryPasswordByUserNameSql;
| }
| public void setQueryPasswordByUserNameSql(String queryPasswordByUserNameSql) {
| this.queryPasswordByUserNameSql = queryPasswordByUserNameSql;
| }
|
|
|
| public String getDatasource() {
| return datasource;
| }
| public void setDatasource(String datasource) {
| this.datasource = datasource;
| }
| public void start(){
|
| }
| public void stop(){
|
| }
|
| @Override
| public boolean authenticate(String userName, String password) {
| logger.info("userName="+userName+",password="+password);
| Connection c = null;
| PreparedStatement ps = null;
| ResultSet rs = null;
| try {
| Context ctx = new InitialContext();
| DataSource ds = (DataSource) ctx.lookup(this.datasource);
| c = ds.getConnection();
| ps = c.prepareStatement(this.queryPasswordByUserNameSql);
| ps.setString(1, userName);
| rs = ps.executeQuery();
| if(rs!=null&&rs.next()){
| String tmpPassword = rs.getString(1);
| tmpPassword = EncryptHelper.dencrypt(tmpPassword);
| logger.info("password equals="+(password.equals(tmpPassword)));
| return password.equals(tmpPassword);
| }
| } catch (Exception e) {
| e.printStackTrace();
| logger.error(e);
| return false;
| }finally{
| try{
| if(rs!=null){
| rs.close();
| }
| if(ps!=null){
| ps.close();
| }
| if(!c.isClosed()){
| c.close();
| }
| }catch(Exception e){
| logger.error(e);
| }
| }
| return false;
| }
|
| }
|
| <mbean code="test.portal.identity.sso.cas.crm.CASAuthenticationService"
| name="portal:service=Module,type=CASAuthenticationService"
| xmbean-dd=""
| xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
| <xmbean/>
| <attribute name="Datasource">java:/jdbc/CRM</attribute>
| <attribute name="QueryPasswordByUserNameSql">select password from personinfo where userCode=?</attribute>
| </mbean>
|
I deploy the jar and start server.
It runs well.
and the CASAuthenticationService ruturn true after sign in,cas server gives a ticket too.
But portal still redirect to a portal login page.
I am wondering and puzled.
I need help.
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4172729#4172729
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4172729
More information about the jboss-user
mailing list