use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class DelAccessMgrRestImpl method canAssign.
/**
* {@inheritDoc}
*/
@Override
public boolean canAssign(Session session, User user, Role role) throws SecurityException {
String methodName = CLS_NM + ".canAssign";
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, methodName);
VUtil.assertNotNull(user, GlobalErrIds.USER_NULL, methodName);
VUtil.assertNotNull(role, GlobalErrIds.ROLE_NULL, methodName);
boolean result;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
UserRole uRole = new UserRole(user.getUserId(), role.getName());
request.setSession(session);
request.setEntity(uRole);
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.ADMIN_ASSIGN);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
result = response.getAuthorized();
Session outSession = response.getSession();
session.copy(outSession);
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return result;
}
use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class GroupMgrRestImpl method groupRoles.
/**
* {@inheritDoc}
*/
@Override
public List<UserRole> groupRoles(Group group) throws SecurityException {
VUtil.assertNotNull(group, GlobalErrIds.GROUP_NULL, CLS_NM + ".groupRoles");
List<UserRole> retRoles;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(group);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.GROUP_ROLE_ASGNED);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
retRoles = response.getEntities();
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return retRoles;
}
use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class ReviewMgrConsole method displayUsers.
/**
* Description of the Method
*/
protected void displayUsers() {
try {
User ue;
ArrayList list = (ArrayList) rm.findUsers(new User());
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");
}
}
System.out.println();
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("displayUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class ReviewMgrConsole method assignedRoles.
/**
*/
void assignedRoles() {
ReaderUtil.clearScreen();
try {
System.out.println("Enter UserId:");
User user = new User();
user.setUserId(ReaderUtil.readLn());
List<UserRole> userRoles = rm.assignedRoles(user);
if (userRoles != null) {
for (UserRole userRole : userRoles) {
System.out.println("ROLE OBJECT:");
System.out.println(" name [" + userRole.getName() + "]");
printTemporal(userRole, "RBACROLE");
}
} else {
System.out.println(" userId [" + user.getUserId() + "] has no roles");
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("assignedRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserRole 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();
}
Aggregations