use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PswdPolicyMgrImplTest method add.
/**
* @param msg
* @param pArray
*/
public static void add(String msg, String[][] pArray, boolean nofail) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = getManagedPswdMgr();
for (String[] plcy : pArray) {
PwPolicy policy = PolicyTestData.getPolicy(plcy);
policyMgr.add(policy);
LOG.debug("add name [" + policy.getName() + "] successful");
}
} catch (SecurityException ex) {
if (!nofail) {
LOG.error("add 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 read.
/**
* @param msg
* @param pArray
*/
public void read(String msg, String[][] pArray) {
LogUtil.logIt(msg);
try {
PwPolicyMgr policyMgr = PwPolicyMgrFactory.createInstance(TestUtils.getContext());
for (String[] plcy : pArray) {
PwPolicy entity = policyMgr.read(PolicyTestData.getName(plcy));
PolicyTestData.assertEquals(entity, plcy);
}
} catch (SecurityException ex) {
LOG.error("read 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 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());
}
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PolicyMgrConsole method add.
void add() {
PwPolicy policy = new PwPolicy();
try {
/*
* public class PwPolicy
* {
private String name;
private String attribute;
private Integer minAge;
private Integer maxAge;
private Short inHistory;
private Short checkQuality;
private Short minLength;
private Integer expireWarning;
private Short graceLoginLimit;
private Boolean lockout;
private Integer lockoutDuration;
private Short maxFailure;
private Short failureCountInterval;
private Boolean mustChange;
private Boolean allowUserChange;
private Boolean safeModify;
* }
*/
ReaderUtil.clearScreen();
System.out.println("ADD PASSWORD POLICY");
System.out.println("Enter name:");
policy.setName(ReaderUtil.readLn());
System.out.println(PWDCHECKQUALITY);
System.out.println("Enter checkQuality:");
policy.setCheckQuality(new Short(ReaderUtil.readLn()));
System.out.println(PWDMAXAGE);
System.out.println("Enter maxAge:");
policy.setMaxAge(new Long(ReaderUtil.readLn()));
System.out.println(PWDMINAGE);
System.out.println("Enter minAge:");
policy.setMinAge(new Integer(ReaderUtil.readLn()));
System.out.println(PWDMINLENGTH);
System.out.println("Enter minLength:");
policy.setMinLength(new Short(ReaderUtil.readLn()));
System.out.println(PWDFAILURECOUNTINTERVAL);
System.out.println("Enter failureCountInterval:");
policy.setFailureCountInterval(new Short(ReaderUtil.readLn()));
System.out.println(PWDMAXFAILURE);
System.out.println("Enter maxFailure:");
policy.setMaxFailure(new Short(ReaderUtil.readLn()));
System.out.println(PWDSAFEMODIFY);
System.out.println("Enter safeModify:");
policy.setSafeModify(Boolean.valueOf(ReaderUtil.readLn()));
System.out.println(PWDMUSTCHANGE);
System.out.println("Enter mustChange:");
policy.setMustChange(Boolean.valueOf(ReaderUtil.readLn()));
System.out.println(PWDINHISTORY);
System.out.println("Enter inHistory:");
policy.setInHistory(new Short(ReaderUtil.readLn()));
System.out.println(PWDGRACELOGINLIMIT);
System.out.println("Enter graceLoginLimit:");
policy.setGraceLoginLimit(new Short(ReaderUtil.readLn()));
System.out.println(PWDLOCKOUT);
System.out.println("Enter lockout:");
policy.setLockout(Boolean.valueOf(ReaderUtil.readLn()));
System.out.println(PWDLOCKOUTDURATION);
System.out.println("Enter lockoutDuration:");
policy.setLockoutDuration(new Integer(ReaderUtil.readLn()));
System.out.println(PWDALLOWUSERCHANGE);
System.out.println("Enter allowUserChange:");
policy.setAllowUserChange(Boolean.valueOf(ReaderUtil.readLn()));
System.out.println(PWDEXPIREWARNING);
System.out.println("Enter expireWarning:");
policy.setExpireWarning(new Long(ReaderUtil.readLn()));
pm.add(policy);
System.out.print("policy name [" + policy.getName() + "]");
System.out.println(" has been added");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("add caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.PwPolicy in project directory-fortress-core by apache.
the class PolicyDAO method findPolicy.
/**
* @param policy
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
List<PwPolicy> findPolicy(PwPolicy policy) throws FinderException {
List<PwPolicy> policyArrayList = new ArrayList<>();
LdapConnection ld = null;
String policyRoot = getPolicyRoot(policy.getContextId());
String searchVal = null;
try {
searchVal = encodeSafeText(policy.getName(), GlobalIds.PWPOLICY_NAME_LEN);
String szFilter = GlobalIds.FILTER_PREFIX + PW_POLICY_CLASS + ")(" + PW_PWD_ID + "=" + searchVal + "*))";
ld = getAdminConnection();
SearchCursor searchResults = search(ld, policyRoot, SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
policyArrayList.add(unloadLdapEntry(searchResults.getEntry(), sequence++));
}
} catch (LdapException e) {
String error = "findPolicy name [" + searchVal + "] caught LdapException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "findPolicy name [" + searchVal + "] caught CursorException=" + e.getMessage();
throw new FinderException(GlobalErrIds.PSWD_SEARCH_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return policyArrayList;
}
Aggregations