use of org.apache.directory.fortress.core.PwPolicyMgr in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method allowUserChange.
/**
* PT12
* This attribute indicates whether users can change their own
* passwords, although the change operation is still subject to access
* control. If this attribute is not present, a value of "TRUE" is
* assumed. This attribute is intended to be used in the absense of an
* access control mechanism.
*
* @param msg
* @param usr
* @param plcy
*/
public void allowUserChange(String msg, String[] usr, String[] plcy) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
AdminMgr adminMgr = AdminMgrImplTest.getManagedAdminMgr();
User user = UserTestData.getUser(usr);
policyMgr.updateUserPolicy(user.getUserId(), PolicyTestData.getName(plcy));
boolean allowChange = PolicyTestData.getAllowUserChange(plcy);
if (!allowChange) {
try {
// because allowchange flag is false, this better fail:
adminMgr.changePassword(user, "newPassword");
fail(CLS_NM + ".allowUserChange name [" + PolicyTestData.getName(plcy) + "] user [" + UserTestData.getUserId(usr) + "] failed allow change test flag=" + allowChange);
} catch (SecurityException ex) {
assertTrue(CLS_NM + ".allowUserChange invalid error message userId [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.USER_PW_MOD_NOT_ALLOWED);
// still good
TestUtils.sleep(1);
}
} else {
// this better work:
adminMgr.changePassword(user, "newPassword");
}
} catch (SecurityException ex) {
LOG.error("allowUserChange policy [" + PolicyTestData.getName(plcy) + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.PwPolicyMgr in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method delete.
/**
* @param msg
* @param pArray
*/
public void delete(String msg, String[][] pArray) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
for (String[] plcy : pArray) {
PwPolicy policy = PolicyTestData.getPolicy(plcy);
policyMgr.delete(policy);
LOG.debug("deleteRecursive name [" + PolicyTestData.getName(plcy) + "] successful");
}
} catch (SecurityException ex) {
LOG.error("deleteRecursive caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations