2016-10-07 108 views
0

我已經使用ldap實現了Spring安全,並且它在ldif文件中使用純文本密碼時工作正常,但是當我在ldap文件中使用散列{SHA}密碼時,它會引發我「未授權」如何在ldap文件中實現編碼(SHA)密碼ldap

代碼:

 AndFilter filter = new AndFilter(); 
    filter.and(new EqualsFilter("objectclass", "person")).and(
     new EqualsFilter("uid", authentication.getPrincipal() 
     .toString())); 

    boolean authenticatedUser = ldapTemplate.authenticate(<DN>, filter.encode(),<password>); 

test.ldif:

dn: uid=test ,ou=people,dc=springframework,dc=org 
    objectclass: top 
    objectclass: person 
    objectclass: organizationalPerson 
    objectclass: inetOrgPerson 
    cn: Rod Johnson 
    sn: Johnson 
    uid: test 
    userPassword: {SHA}a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 

什麼是落實ldapTemplate.authenticate正確的方法是什麼?

回答

0

LDAP目錄服務器通常會對用戶密碼進行哈希以防止某人發現它們。服務器如何處理導入或添加明文密碼或散列密碼是特定於服務器的。如果這是樣本數據,則以明文形式存在。如果要使用已經散列的密碼導入現有用戶數據,則應檢查所用算法是否受所選Directory Server的支持,以及服務器的表示方式。