use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class AdminManagerTest method addUsers.
/**
* @param uArray
*/
private void addUsers(String msg, String[][] uArray, boolean isAdmin) {
LogUtil.logIt(msg);
try {
AdminMgr adminMgr;
if (isAdmin) {
adminMgr = getManagedAdminMgr();
} else {
adminMgr = AdminMgrFactory.createInstance(TestUtils.getContext());
}
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
adminMgr.addUser(user);
LOG.debug("addUsers user [" + user.getUserId() + "] successful");
// Does User have Role assignments?
Set<String> asgnRoles = UserTestData.getAssignedRoles(usr);
if (asgnRoles != null) {
for (String name : asgnRoles) {
adminMgr.assignUser(new UserRole(user.getUserId(), name));
}
}
}
} catch (SecurityException ex) {
ex.printStackTrace();
LOG.error("addUsers: caught SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class AccelMgrConsole method addActiveRole.
void addActiveRole() {
try {
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.addActiveRole");
ReaderUtil.clearScreen();
System.out.println("Enter userId");
String userId = ReaderUtil.readLn();
ReaderUtil.clearScreen();
System.out.println("Enter role name");
String role = ReaderUtil.readLn();
am.addActiveRole(session, new UserRole(userId, role));
System.out.println("addActiveRole successful");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("addActiveRole 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 AccelMgrConsole method sessionRoles.
void sessionRoles() {
try {
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.sessionRoles");
ReaderUtil.clearScreen();
List<UserRole> roles = am.sessionRoles(session);
// System.out.println(" USER [" + session.getUserId() + "]:");
if (roles != null) {
for (int i = 0; i < roles.size(); i++) {
UserRole ur = roles.get(i);
System.out.println(" USER ROLE[" + i + "]:");
System.out.println(" role name [" + ur.getName() + "]");
System.out.println(" begin time [" + ur.getBeginTime() + "]");
System.out.println(" end time [" + ur.getEndTime() + "]");
System.out.println(" begin date [" + ur.getBeginDate() + "]");
System.out.println(" end date [" + ur.getEndDate() + "]");
System.out.println(" begin lock [" + ur.getBeginLockDate() + "]");
System.out.println(" end lock [" + ur.getEndLockDate() + "]");
System.out.println(" day mask [" + ur.getDayMask() + "]");
System.out.println(" time out [" + ur.getTimeout() + "]");
}
}
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("sessionRoles caught SecurityException=" + e, e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserRole in project directory-fortress-core by apache.
the class AccelMgrConsole method dropActiveRole.
void dropActiveRole() {
try {
VUtil.assertNotNull(session, GlobalErrIds.USER_SESS_NULL, "AccelMgrConsole.dropActiveRole");
ReaderUtil.clearScreen();
System.out.println("Enter userId");
String userId = ReaderUtil.readLn();
ReaderUtil.clearScreen();
System.out.println("Enter role name");
String role = ReaderUtil.readLn();
am.dropActiveRole(session, new UserRole(userId, role));
System.out.println("dropActiveRole successful");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("dropActiveRole 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 AdminMgrConsole method deassignUser.
void deassignUser() {
try {
ReaderUtil.clearScreen();
System.out.println("Enter userId");
String userId = ReaderUtil.readLn();
UserRole uRole = new UserRole();
uRole.setUserId(userId);
System.out.println("Enter role name");
String roleNm = ReaderUtil.readLn();
uRole.setName(roleNm);
am.deassignUser(uRole);
System.out.println("userId [" + userId + "] name [" + roleNm + "]");
System.out.println("has been deassigned");
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("deassignUser caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations