利用 别人修改的 CAS 需注意如下问题


最近碰到一个问题 ,是这样的 ,我们项目利用了CAS认证中心,APP需要与CAS整合 ,官网原先提供的DEMO 默认好像是不支持RestFul的 。后来 我用了其他公司稍微修改的

CAS,平时CAS一般 只是简单的使用。



后来通过反编译,修改了如下代码:


(1):


public class QueryDatabaseAuthenticationHandler extends AbstractJdbcUsernamePasswordAuthenticationHandler
{

  @NotNull
  private String sql;

  protected final boolean authenticateUsernamePasswordInternal(UsernamePasswordCredentials credentials)
    throws AuthenticationException
  {
    String username1 = getPrincipalNameTransformer().transform(credentials.getUsername());
    String username = Encodes.encodeBase64(username1);
    String password = credentials.getPassword();

    System.out.println("Q����ǰ:" + username1 + " ���ܺ�:" + username);
    String encryptedPassword = getPasswordEncoder().encode(
      password);
    try
    {
      String dbPassword = (String)getJdbcTemplate().queryForObject(this.sql, String.class, new Object[] { username });
      return dbPassword.equals(encryptedPassword);
    } catch (IncorrectResultSizeDataAccessException e) {
    }
    return false;
  }

  public void setSql(String sql)
  {
    this.sql = sql;
  }
}


通过反编译发现 该CAS修改了 username,把username encode了 


我测试的时候,还发现了另一个问题,用户名和密码一样才可以登入  


<!--  
    | This is the authentication handler declaration that every CAS deployer will need to change before deploying CAS   
    | into production.  The default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials  
    | where the username equals the password.  You will need to replace this with an AuthenticationHandler that implements your  
    | local authentication strategy.  You might accomplish this by coding a new such handler and declaring  
    | edu.someschool.its.cas.MySpecialHandler here, or you might use one of the handlers provided in the adaptors modules.  
    +-->  
<bean  
    class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />  

通过默认的配置文件的描述,我们可以看到 ,如果 没有 把该Bean注释掉,则 用户名和密码需要一样才可以登入



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值