Ldap Websphere Portal 8登录服务检查现有密码是否正确
我有一个portlet,用于更改登录用户的密码。用户必须输入当前密码和新密码两次。它调用LoginService.checkPassword(字符串userId,char[]password)来确定现有密码是否正确。如果此方法返回true,则通过Puma配置文件获取当前用户并使用PumaController.setAttributes(user-user,Map-attributes)调用设置更新的属性来更新密码。然后通过PumaProfile.reload方法重新加载puma配置文件(我也尝试过使用PumaController.reload()方法) 我面临的问题是,LoginService.checkPassword(stringuserid,char[]password)对当前密码和旧密码返回true,而不仅仅是对当前密码。有人知道为什么会这样吗Ldap Websphere Portal 8登录服务检查现有密码是否正确,ldap,portlet,websphere-portal,puma,Ldap,Portlet,Websphere Portal,Puma,我有一个portlet,用于更改登录用户的密码。用户必须输入当前密码和新密码两次。它调用LoginService.checkPassword(字符串userId,char[]password)来确定现有密码是否正确。如果此方法返回true,则通过Puma配置文件获取当前用户并使用PumaController.setAttributes(user-user,Map-attributes)调用设置更新的属性来更新密码。然后通过PumaProfile.reload方法重新加载puma配置文件(我也尝试
在ldap中,密码字段是一个单属性字段,就像wimdomain.xml中一样,如果我注销并尝试登录,我只能使用当前密码登录(如您所料).发现这是门户中的一个bug。即使使用开箱即用的概要文件编辑portlet,也会遇到同样的问题验证Websphere Portal用户的密码 有两种方法可以验证用户的密码- 1) 使用“用户注册表” 2) 使用“登录文本”
猜测这取决于“LoginService.checkPassword(stringuserid,char[]password)”方法对LDAP的作用。这是比较吗?许多LDAP实现永远不会返回实际密码。也许LDAP跟踪会揭示这个问题。
public static boolean checkUserAuthenticatedLDAP(String userId, String password) {
try {
Context ctx = new InitialContext();
com.ibm.websphere.security.UserRegistry reg =
(com.ibm.websphere.security.UserRegistry) ctx.lookup("UserRegistry");
String res = reg.checkPassword(userId, password);
return res != null;
} catch (Exception ex) {
return false;
}
}
/**
* This method validates the user based on the user id and password
* attributes, If the user id or password is not valid then throws Exception.
*
* @param userId
* @param password
* @return boolean
* @throws Exception
*/
public boolean checkUserAuthenticated(String userId, String password) throws Exception {
javax.security.auth.login.LoginContext loginContext = null;
Subject subject = null;
try {
loginContext = new javax.security.auth.login.LoginContext("WSLogin",
new com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl(userId, password));
} catch (javax.security.auth.login.LoginException e) {
throw new Exception("Cannot create LoginContext", e);
}
try {
loginContext.login();
subject = loginContext.getSubject();
} catch (com.ibm.websphere.security.auth.WSLoginFailedException e) {
throw new Exception("Password is incorrect", e);
} catch (Exception e) {
throw new Exception("Unknown username", e);
}
if (subject == null)
throw new Exception("Password is incorrect");
return true;
}