use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method updatePermObjs.
/**
* @param objArray
*/
public static void updatePermObjs(String msg, String[][] objArray, boolean isAdmin) {
LogUtil.logIt(msg);
PermObj pObj = new PermObj();
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] obj : objArray) {
pObj = PermTestData.getObj(obj);
// Todo - add props
adminMgr.updatePermObj(pObj);
LOG.debug("updatePermObjs objName [" + pObj.getObjName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("updatePermObjs objName [" + pObj.getObjName() + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method lockUsers.
/**
* @param msg
* @param uArray
*/
void lockUsers(String msg, String[][] uArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
adminMgr.lockUserAccount(user);
LOG.debug("lockUsers user [" + user.getUserId() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("lockUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class AdminMgrImplTest method resetPasswords.
/**
* @param msg
* @param uArray
*/
void resetPasswords(String msg, String[][] uArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
adminMgr.resetPassword(user, UserTestData.getPassword(usr));
LOG.debug("resetPasswords user [" + user.getUserId() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("resetPasswords: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method graceLoginLimit.
/**
* PT6
* 5.2.8 pwdGraceAuthNLimit
* <p>
* This attribute specifies the number of times an expired password can
* be used to authenticate. If this attribute is not present or if the
* value is 0, authentication will fail.
* @param msg
* @param usr
* @param plcy
*/
public void graceLoginLimit(String msg, String[] usr, String[] plcy) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = AdminMgrImplTest.getManagedAdminMgr();
AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
User user = UserTestData.getUser(usr);
user.setPwPolicy(PolicyTestData.getName(plcy));
adminMgr.updateUser(user);
String newPassword = user.getPassword() + "a";
adminMgr.changePassword(user, newPassword);
user.setPassword(newPassword);
TestUtils.sleep(PolicyTestData.getMaxAge(plcy));
TestUtils.sleep(1);
int numGrace = PolicyTestData.getGraceLoginLimit(plcy);
for (int i = 0; i < numGrace; i++) {
try {
accessMgr.createSession(user, false);
TestUtils.sleep(1);
} catch (SecurityException ex) {
fail(CLS_NM + ".graceLoginLimit name [" + PolicyTestData.getName(plcy) + "] user [" + UserTestData.getUserId(usr) + "] failed grace allowed=" + numGrace + " iteration=" + i);
assertTrue(CLS_NM + ".graceLoginLimit invalid error message userId [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.USER_PW_EXPIRED);
// still good
}
}
try {
accessMgr.createSession(user, false);
fail(CLS_NM + ".graceLoginLimit name [" + PolicyTestData.getName(plcy) + "] user [" + UserTestData.getUserId(usr) + "] failed grace test 2");
} catch (SecurityException ex) {
assertTrue(CLS_NM + ".graceLoginLimit invalid error message userId [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.USER_PW_EXPIRED);
// still good
}
} catch (SecurityException ex) {
LOG.error("graceLoginLimit caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.AdminMgr in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method mustChange.
/**
* PT11
* This attribute specifies with a value of "TRUE" that users must
* change their passwords when they first bind to the directory after a
* password is set or reset by a password administrator. If this
* attribute is not present, or if the value is "FALSE", users are not
* required to change their password upon binding after the password
* administrator sets or resets the password. This attribute is not set
* due to any actions specified by this document, it is typically set by
* a password administrator after resetting a user's password.
*
* @param msg
* @param usr
* @param plcy
*/
public void mustChange(String msg, String[] usr, String[] plcy) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
AdminMgr adminMgr = AdminMgrImplTest.getManagedAdminMgr();
AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
User user = UserTestData.getUser(usr);
policyMgr.updateUserPolicy(user.getUserId(), PolicyTestData.getName(plcy));
boolean mustChange = PolicyTestData.getMustChange(plcy);
adminMgr.resetPassword(user, "newpassword");
if (mustChange) {
try {
// because mustchange flag is set, this better fail:
User badUser = new User(user.getUserId(), "newpassword");
accessMgr.createSession(badUser, false);
fail(CLS_NM + ".mustChange name [" + PolicyTestData.getName(plcy) + "] user [" + UserTestData.getUserId(usr) + "] failed must change test flag=" + mustChange);
} catch (SecurityException ex) {
assertTrue(CLS_NM + ".mustChange invalid error message userId [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.USER_PW_RESET);
// still good
TestUtils.sleep(1);
}
} else {
// this better work:
User goodUser = new User(user.getUserId(), "newpassword");
accessMgr.createSession(goodUser, false);
}
} catch (SecurityException ex) {
LOG.error(CLS_NM + ".mustChange policy [" + PolicyTestData.getName(plcy) + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations