use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class DelegatedAdminMgrConsole method delete.
private void delete(OrgUnit.Type type) {
OrgUnit ou = new OrgUnit();
try {
ReaderUtil.clearScreen();
System.out.println("Enter orgunit name:");
ou.setName(ReaderUtil.readLn());
ou.setType(type);
dAmgr.delete(ou);
System.out.println("name [" + ou.getName() + "]");
System.out.println("has been deleted");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("delete caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class ReviewMgrConsole method findUsersByOrg.
/**
*/
void findUsersByOrg() {
String szOu;
ReaderUtil.clearScreen();
try {
System.out.println("Enter OrgUnit name");
szOu = ReaderUtil.readLn();
OrgUnit ou = new OrgUnit(szOu);
ou.setType(OrgUnit.Type.USER);
List<User> list = rm.findUsers(ou);
int ctr = 0;
for (User ue : list) {
System.out.println("USER[" + ++ctr + "]");
System.out.println(" userId [" + ue.getUserId() + "]");
System.out.println(" internalId [" + ue.getInternalId() + "]");
System.out.println(" description [" + ue.getDescription() + "]");
System.out.println(" common name [" + ue.getCn() + "]");
System.out.println(" surname [" + ue.getSn() + "]");
System.out.println(" orgUnitId [" + ue.getOu() + "]");
System.out.println(" pwpolicy [" + ue.getPwPolicy() + "]");
printTemporal(ue, "USER");
printAddress(ue.getAddress(), "ADDRESS");
printPhone(ue.getPhones(), "PHONES");
printPhone(ue.getMobiles(), "MOBILES");
if (ue.getRoles() != null) {
for (UserRole ur : ue.getRoles()) {
printTemporal(ur, "RBACROLE");
}
}
if (ue.getAdminRoles() != null) {
for (UserAdminRole ur : ue.getAdminRoles()) {
printAdminRole(ur);
printTemporal(ur, "ADMINROLE");
}
}
if (ue.getProperties() != null && ue.getProperties().size() > 0) {
int pctr = 0;
for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = ue.getProperty(key);
System.out.println("prop key[" + pctr + "]=" + key);
System.out.println("prop value[" + pctr++ + "]=" + val);
}
}
System.out.println();
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("findUsersByOrg caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class UsoUtil method loadGraph.
/**
* Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
* using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing user ou hierarchies.
*/
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph(String contextId) {
Hier inHier = new Hier(Hier.Type.ROLE);
inHier.setContextId(contextId);
LOG.info("loadGraph initializing USO context [{}]", inHier.getContextId());
List<Graphable> descendants = null;
try {
OrgUnit orgUnit = new OrgUnit();
orgUnit.setType(OrgUnit.Type.USER);
orgUnit.setContextId(contextId);
descendants = orgUnitP.getAllDescendants(orgUnit);
} catch (SecurityException se) {
LOG.info("loadGraph caught SecurityException={}", se);
}
Hier hier = HierUtil.loadHier(contextId, descendants);
SimpleDirectedGraph<String, Relationship> graph;
graph = HierUtil.buildGraph(hier);
usoCache.put(getKey(contextId), graph);
return graph;
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class PermP method validate.
/**
* Method will perform various validations to ensure the integrity of the Permission Object entity targeted for insertion
* or updating in directory. Data reasonability checks will be performed on all non-null attributes.
*
* @param pObj Permission Object entity contains data targeted for insertion or update.
* @param isUpdate if true update operation is being performed which specifies a different set of targeted attributes.
* @throws org.apache.directory.fortress.core.ValidationException in the event of data validation error.
*/
void validate(PermObj pObj, boolean isUpdate) throws ValidationException {
if (!isUpdate) {
// Validate length
VUtil.orgUnit(pObj.getOu());
// ensure ou exists in the OS-P pool:
OrgUnit ou = new OrgUnit(pObj.getOu(), OrgUnit.Type.PERM);
ou.setContextId(pObj.getContextId());
if (!orgUnitP.isValid(ou)) {
String error = "validate detected invalid orgUnit name [" + pObj.getOu() + "] for object name [" + pObj.getObjName() + "]";
// log.warn(error);
throw new ValidationException(GlobalErrIds.PERM_OU_INVALID, error);
}
if (StringUtils.isNotEmpty(pObj.getObjName())) {
VUtil.description(pObj.getObjName());
}
if (StringUtils.isNotEmpty(pObj.getOu())) {
VUtil.orgUnit(pObj.getOu());
}
if (StringUtils.isNotEmpty(pObj.getDescription())) {
VUtil.description(pObj.getDescription());
}
} else {
if (StringUtils.isNotEmpty(pObj.getOu())) {
VUtil.orgUnit(pObj.getOu());
// ensure ou exists in the OS-P pool:
OrgUnit ou = new OrgUnit(pObj.getOu(), OrgUnit.Type.PERM);
ou.setContextId(pObj.getContextId());
if (!orgUnitP.isValid(ou)) {
String error = "validate detected invalid orgUnit name [" + pObj.getOu() + "] for object name [" + pObj.getObjName() + "]";
throw new ValidationException(GlobalErrIds.PERM_OU_INVALID, error);
}
}
if (StringUtils.isNotEmpty(pObj.getDescription())) {
VUtil.description(pObj.getDescription());
}
}
}
use of org.apache.directory.fortress.core.model.OrgUnit in project directory-fortress-core by apache.
the class AdminRoleP method validateOrgs.
/**
* Called by validate()
*
* @param orgs
* @param contextId
* @throws SecurityException
*/
private void validateOrgs(Set<String> orgs, OrgUnit.Type type, String contextId) throws SecurityException {
for (String ou : orgs) {
OrgUnit inOe = new OrgUnit(ou);
inOe.setType(type);
inOe.setContextId(contextId);
op.read(inOe);
}
}
Aggregations