use of org.apache.directory.fortress.core.model.UserAdminRole 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.UserAdminRole in project directory-fortress-core by apache.
the class ReviewMgrConsole method getUser.
void getUser() {
String userVal;
ReaderUtil.clearScreen();
try {
System.out.println("Enter Internal id for user:");
userVal = ReaderUtil.readLn();
User ue = new User();
ue.setInternalId(userVal);
ArrayList list = (ArrayList) rm.findUsers(ue);
int size = list.size();
for (int i = 0; i < size; i++) {
ue = (User) list.get(i);
System.out.println("USER[" + i + "]");
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");
printPosixAccount(ue, "POSIX");
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 ctr = 0;
for (Enumeration e = ue.getProperties().propertyNames(); e.hasMoreElements(); ) {
String key = (String) e.nextElement();
String val = ue.getProperty(key);
System.out.println("prop key[" + ctr + "]=" + key);
System.out.println("prop value[" + ctr++ + "]=" + val);
}
}
System.out.println();
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("getUser caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class UserDAO method getUserAdminRoles.
/**
* @param user
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
List<UserAdminRole> getUserAdminRoles(User user) throws FinderException {
List<UserAdminRole> roles = null;
LdapConnection ld = null;
String userDn = getDn(user.getUserId(), user.getContextId());
try {
ld = getAdminConnection();
Entry findEntry = read(ld, userDn, AROLE_ATR);
roles = unloadUserAdminRoles(findEntry, user.getUserId(), user.getContextId());
} catch (LdapNoSuchObjectException e) {
String warning = "getUserAdminRoles COULD NOT FIND ENTRY for user [" + user.getUserId() + "]";
throw new FinderException(GlobalErrIds.USER_NOT_FOUND, warning);
} catch (LdapException e) {
String error = "getUserAdminRoles [" + userDn + "]= caught LDAPException=" + e.getMessage();
throw new FinderException(GlobalErrIds.USER_READ_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
return roles;
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class UserDAO method unloadUserAdminRoles.
/**
* Given an ldap entry containing ARBAC roles assigned to user, retrieve the raw data and convert to a collection
* of {@link UserAdminRole}
* including {@link org.apache.directory.fortress.core.model.Constraint}.
*
* @param entry contains ldap entry to retrieve admin roles from.
* @param userId attribute maps to {@link UserAdminRole#userId}.
* @param contextId
* @return List of type {@link UserAdminRole} containing admin roles assigned to a particular user.
*/
private List<UserAdminRole> unloadUserAdminRoles(Entry entry, String userId, String contextId) {
List<UserAdminRole> uRoles = null;
List<String> roles = getAttributes(entry, GlobalIds.USER_ADMINROLE_DATA);
if (roles != null) {
long sequence = 0;
uRoles = new ArrayList<>();
for (String raw : roles) {
UserAdminRole ure = new ObjectFactory().createUserAdminRole();
ure.load(raw, contextId, RoleUtil.getInstance());
ure.setSequenceId(sequence++);
ure.setUserId(userId);
uRoles.add(ure);
}
}
return uRoles;
}
use of org.apache.directory.fortress.core.model.UserAdminRole in project directory-fortress-core by apache.
the class UserDAO method loadUserAdminRoles.
/**
* Given a collection of ARBAC roles, {@link UserAdminRole}, convert to raw data format and load into ldap
* modification set in preparation for ldap modify.
*
* @param list contains List of type {@link UserAdminRole} targeted for updating to ldap.
* @param mods contains ldap modification set containing ARBAC role assignments in raw ldap format to be updated.
* @throws LdapInvalidAttributeValueException
*/
private void loadUserAdminRoles(List<UserAdminRole> list, List<Modification> mods) throws LdapInvalidAttributeValueException {
Attribute userAdminRoleData = new DefaultAttribute(GlobalIds.USER_ADMINROLE_DATA);
Attribute userAdminRoleAssign = new DefaultAttribute(GlobalIds.USER_ADMINROLE_ASSIGN);
if (list != null) {
boolean nameSeen = false;
for (UserAdminRole userRole : list) {
userAdminRoleData.add(userRole.getRawData());
if (!nameSeen) {
userAdminRoleAssign.add(userRole.getName());
nameSeen = true;
}
}
if (userAdminRoleData.size() != 0) {
mods.add(new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, userAdminRoleData));
mods.add(new DefaultModification(ModificationOperation.REPLACE_ATTRIBUTE, userAdminRoleAssign));
}
}
}
Aggregations