use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrConsole method addDsd.
/**
*/
void addDsd() {
SDSet se = new SDSet();
try {
ReaderUtil.clearScreen();
System.out.println("Enter DSD Set name:");
se.setName(ReaderUtil.readLn());
System.out.println("Enter DSD's description field");
se.setDescription(ReaderUtil.readLn());
System.out.println("Enter role member, or null to skip:");
String role = ReaderUtil.readLn();
for (; ; ) {
if (role != null && role.length() > 0) {
se.addMember(role);
} else {
break;
}
System.out.println("Enter another role member, or null to skip:");
role = ReaderUtil.readLn();
}
System.out.println("Enter DSD Set cardinality:");
int cardinality = ReaderUtil.readInt();
se.setCardinality(cardinality);
SDSet se2 = am.createDsdSet(se);
System.out.println("name [" + se2.getName() + "]");
System.out.println("internalId [" + se2.getId() + "]");
System.out.println("name description [" + se2.getDescription() + "]");
System.out.println("has been added");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("addDsd caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrConsole method addSsd.
/**
*/
void addSsd() {
SDSet se = new SDSet();
try {
ReaderUtil.clearScreen();
System.out.println("Enter SSD Set name:");
se.setName(ReaderUtil.readLn());
System.out.println("Enter SSD's description field");
se.setDescription(ReaderUtil.readLn());
System.out.println("Enter role member, or null to skip:");
String role = ReaderUtil.readLn();
for (; ; ) {
if (role != null && role.length() > 0) {
se.addMember(role);
} else {
break;
}
System.out.println("Enter another role member, or null to skip:");
role = ReaderUtil.readLn();
}
System.out.println("Enter SSD Set cardinality:");
int cardinality = ReaderUtil.readInt();
se.setCardinality(cardinality);
SDSet se2 = am.createSsdSet(se);
System.out.println("name [" + se2.getName() + "]");
System.out.println("internalId [" + se2.getId() + "]");
System.out.println("name description [" + se2.getDescription() + "]");
System.out.println("has been added");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("addSsd caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class Options method getSdSet.
/**
*/
public SDSet getSdSet() {
SDSet sdSet = new SDSet();
sdSet.setName(getName());
sdSet.setDescription(getDescription());
updateRoleAssigns(sdSet);
try {
Integer cardinality = Integer.valueOf(getCardinality());
sdSet.setCardinality(cardinality);
} catch (NumberFormatException ne) {
// default is '2'.
sdSet.setCardinality(2);
}
return sdSet;
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AccessMgrImplTest method addActiveRolesDSD.
public static void addActiveRolesDSD(String msg, String[][] uArray, String[][] sArray) {
LogUtil.logIt(msg);
try {
AccessMgr accessMgr = AccessMgrFactory.createInstance(TestUtils.getContext());
int i = 0;
for (String[] usr : uArray) {
SDSet dsd = RoleTestData.getSDSet(sArray[i++]);
// Set<String> roles = dsd.getMembers().keySet();
Set<String> roles = dsd.getMembers();
User user = UserTestData.getUser(usr);
Session session = accessMgr.authenticate(user.getUserId(), user.getPassword());
int j = 0;
for (String role : roles) {
j++;
try {
assertNotNull(session);
// Activate Role(s):
accessMgr.addActiveRole(session, new UserRole(role));
if (j >= dsd.getCardinality()) {
fail(CLS_NM + ".addActiveRolesDSD user [" + user.getUserId() + "] role [" + role + "] ssd [" + dsd.getName() + "] cardinality [" + dsd.getCardinality() + "] count [" + j + "] failed");
}
} catch (SecurityException ex) {
assertTrue(CLS_NM + ".addActiveRolesDSD cardinality test failed user [" + user.getUserId() + "] role [" + role + "] ssd [" + dsd.getName() + "] cardinality [" + dsd.getCardinality() + "] count [" + j + "]", j >= (dsd.getCardinality()));
assertTrue(CLS_NM + ".addActiveRolesDSD cardinality test failed [" + UserTestData.getUserId(usr) + "]", ex.getErrorId() == GlobalErrIds.DSD_VALIDATION_FAILED);
// still good, break from loop, we're done here
break;
}
}
}
} catch (SecurityException ex) {
LOG.error("addActiveRolesDSD caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.SDSet in project directory-fortress-core by apache.
the class AdminMgrImplTest method addSsdRoleMember.
/**
* @param sArray
*/
public static void addSsdRoleMember(String msg, String[][] sArray, String[][] rArray) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr = getManagedAdminMgr();
ReviewMgr reviewMgr = ReviewMgrImplTest.getManagedReviewMgr();
for (String[] ssdle : sArray) {
SDSet ssd = RoleTestData.getSDSet(ssdle);
SDSet entity = adminMgr.createSsdSet(ssd);
LOG.debug("addSsdRoleMember SSD [" + entity.getName() + "] successful");
for (String[] rle : rArray) {
Role role = RoleTestData.getRole(rle);
adminMgr.addSsdRoleMember(ssd, role);
List<SDSet> ssdSets = reviewMgr.ssdRoleSets(role);
assertNotNull(ssdSets);
assertTrue(CLS_NM + "addSsdRoleMember list size check", ssdSets.size() == 1);
SDSet ssd2 = ssdSets.get(0);
assertTrue(CLS_NM + "addSsdRoleMember SSD name check", ssd.getName().equals(ssd2.getName()));
assertTrue(CLS_NM + "addSsdRoleMember SSD role check", ssd2.getMembers().contains(role.getName()));
}
}
} catch (SecurityException ex) {
LOG.error("addSsdRoleMember caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
Aggregations