use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PwPolicyMgrRestImpl method read.
/**
* {@inheritDoc}
*/
@Override
public PwPolicy read(String name) throws SecurityException {
VUtil.assertNotNullOrEmpty(name, GlobalErrIds.PSWD_NAME_NULL, CLS_NM + ".read");
PwPolicy retPolicy;
FortRequest request = RestUtils.getRequest(this.contextId);
request.setEntity(new PwPolicy(name));
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.PSWD_READ);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retPolicy = (PwPolicy) response.getEntity();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retPolicy;
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PolicyTestData method getPolicy.
/**
* @param plcy
* @return
*/
public static PwPolicy getPolicy(String[] plcy) {
PwPolicy policy = new PwPolicy();
policy.setName(getName(plcy));
// policy.setAttribute(getAttribute(plcy));
policy.setMinAge(getMinAge(plcy));
policy.setMaxAge(getMaxAge(plcy));
policy.setInHistory(getInHistory(plcy));
policy.setCheckQuality(getCheckQuality(plcy));
policy.setMinLength(getMinLength(plcy));
policy.setExpireWarning(getExpireWarning(plcy));
policy.setGraceLoginLimit(getGraceLoginLimit(plcy));
policy.setLockout(getLockout(plcy));
policy.setLockoutDuration(getLockoutDuration(plcy));
policy.setMaxFailure(getMaxFailure(plcy));
policy.setFailureCountInterval(getFailureCountInterval(plcy));
policy.setMustChange(getMustChange(plcy));
policy.setAllowUserChange(getAllowUserChange(plcy));
policy.setSafeModify(getSafeModify(plcy));
return policy;
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method search.
/**
* @param msg
* @param pArray
*/
public void search(String msg, String srchValue, String[][] pArray) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(TestUtils.getContext());
List<PwPolicy> policies = policyMgr.search(srchValue);
assertNotNull(policies);
assertTrue(CLS_NM + "search list size check", pArray.length == policies.size());
for (String[] plcy : pArray) {
int indx = policies.indexOf(new PwPolicy(PolicyTestData.getName(plcy)));
if (indx != -1) {
PwPolicy entity = policies.get(indx);
assertNotNull(entity);
PolicyTestData.assertEquals(entity, plcy);
} else {
msg = "search srchValue [" + srchValue + "] failed list search";
LogUtil.logIt(msg);
fail(msg);
}
}
} catch (SecurityException ex) {
LOG.error("search srchValue [" + srchValue + "] caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method update.
/**
* @param msg
* @param pArray
*/
public void update(String msg, String[][] pArray) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
for (String[] plcy : pArray) {
PwPolicy policy = PolicyTestData.getPolicy(plcy);
policyMgr.update(policy);
LOG.debug("update name [" + policy.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("update caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method checkQuality.
/**
* PT14
* 5.2.5 pwdCheckQuality
* <p>
* This attribute indicates how the password quality will be verified
* while being modified or added. If this attribute is not present, or
* if the value is '0', quality checking will not be enforced. A value
* of '1' indicates that the server will check the quality, and if the
* server is unable to check it (due to a hashed password or other
* reasons) it will be accepted. A value of '2' indicates that the
* server will check the quality, and if the server is unable to verify
* it, it will return an error refusing the password.
*
* @param msg
* @param pArray
*/
public void checkQuality(String msg, String[][] pArray) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
for (String[] plcy : pArray) {
PwPolicy policy = PolicyTestData.getPolicy(plcy);
policyMgr.add(policy);
LOG.debug("checkQuality name [" + policy.getName() + "] successful");
}
} catch (SecurityException ex) {
LOG.error("checkQuality caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations