use of org.apache.directory.fortress.core.model.UserAudit in project directory-fortress-core by apache.
the class AuditMgrImplTest method searchMods.
/**
* @param msg
* @param uArray
*/
private static void searchMods(String msg, String[][] uArray) {
LogUtil.logIt(msg);
try {
AuditMgr auditMgr = getManagedAuditMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
// now search for successful session creation events:
UserAudit uAudit = new UserAudit();
uAudit.setUserId(user.getUserId());
uAudit.setFailedOnly(false);
List<Mod> mods = auditMgr.searchUserSessions(uAudit);
assertNotNull(mods);
assertTrue(CLS_NM + "searchUserSessions failed search for successful authentication user [" + user.getUserId() + "]", mods.size() > 0);
}
LOG.debug("searchUserSessions successful");
} catch (SecurityException ex) {
LOG.error("searchUserSessions: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserAudit in project directory-fortress-core by apache.
the class AuditMgrImplTest method searchAdminMods.
/**
* @param msg
* @param uArray
*/
private static void searchAdminMods(String msg, String[][] uArray, String[][] oArray, String[][] opArray) {
LogUtil.logIt(msg);
try {
AuditMgr auditMgr = getManagedAuditMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
// now search for successful session creation events:
UserAudit uAudit = new UserAudit();
uAudit.setUserId(user.getUserId());
for (String[] obj : oArray) {
String objName = AdminUtil.getObjName(PermTestData.getName(obj));
uAudit.setObjName(objName);
for (String[] op : opArray) {
uAudit.setOpName(PermTestData.getName(op));
List<Mod> mods = auditMgr.searchAdminMods(uAudit);
assertNotNull(mods);
assertTrue(CLS_NM + "searchAdminMods failed search for successful authentication user [" + user.getUserId() + "] object [" + objName + "] operation [" + PermTestData.getName(op) + "]", mods.size() > 0 || !isAudit(objName, PermTestData.getName(op)));
boolean result = mods.size() > 0 || !isAudit(objName, PermTestData.getName(op));
LOG.debug("searchAdminMods search user [" + user.getUserId() + "] object [" + objName + "] operation [" + PermTestData.getName(op) + "] result: " + result);
// System.out.println("searchAdminMods search user [" + user.getUserId() + "] object [" + objName + "] operation [" + PermTestData.getName(op) + "] result: " + result);
}
}
}
LOG.debug("searchAdminMods successful");
} catch (SecurityException ex) {
LOG.error("searchAdminMods: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.UserAudit in project directory-fortress-core by apache.
the class AuditMgrConsole method getAuthReport.
/**
*/
void getAuthReport() {
ReaderUtil.clearScreen();
try {
UserAudit uAudit = new UserAudit();
System.out.println("Enter userId to search Audit AuthZs with:");
String val = ReaderUtil.readLn();
if (StringUtils.isNotEmpty(val)) {
uAudit.setUserId(val);
System.out.println("size=" + val.length() + " val=" + val);
} else {
System.out.println("val is empty or null");
}
// uAudit.setUserId(val);
System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
val = ReaderUtil.readLn();
if (val.equalsIgnoreCase("Y"))
uAudit.setFailedOnly(true);
System.out.println("Check within the last n hours? Enter number of hours or null for unlimited");
val = ReaderUtil.readLn();
if (val != null && val.length() > 0) {
int hours = Integer.parseInt(val);
Date date = new Date();
long millis = date.getTime();
millis = millis - (1000 * 60 * 60 * hours);
Date date2 = new Date(millis);
uAudit.setBeginDate(date2);
}
List<AuthZ> list = am.getUserAuthZs(uAudit);
printAuthZReport(list);
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("getAuthReport caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserAudit in project directory-fortress-core by apache.
the class AuditMgrConsole method findAuthZs.
/**
*/
void findAuthZs() {
ReaderUtil.clearScreen();
try {
System.out.println("Enter object name to search Audit AuthZs with:");
String val = ReaderUtil.readLn();
UserAudit uAudit = new UserAudit();
uAudit.setObjName(val);
System.out.println("Enter operation name to search Audit AuthZs with:");
val = ReaderUtil.readLn();
uAudit.setOpName(val);
System.out.println("Enter userId to search Audit AuthZs with:");
val = ReaderUtil.readLn();
if (StringUtils.isNotEmpty(val)) {
uAudit.setUserId(val);
System.out.println("size=" + val.length() + " val=" + val);
} else {
System.out.println("val is empty or null");
}
// uAudit.setUserId(val);
System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
val = ReaderUtil.readLn();
if (val.equalsIgnoreCase("Y"))
uAudit.setFailedOnly(true);
List<AuthZ> list = am.searchAuthZs(uAudit);
printAuthZs(list);
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("findAuthZs caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.UserAudit in project directory-fortress-core by apache.
the class AuditMgrConsole method getBindReport.
/**
*/
void getBindReport() {
ReaderUtil.clearScreen();
try {
System.out.println("Enter userId value to search Audit Binds with or null to retrieve all:");
String val = ReaderUtil.readLn();
UserAudit uAudit = new UserAudit();
uAudit.setUserId(val);
System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
val = ReaderUtil.readLn();
if (val.equalsIgnoreCase("Y"))
uAudit.setFailedOnly(true);
System.out.println("Check within the last n hours? Enter number of hours or null for unlimited");
val = ReaderUtil.readLn();
if (val != null && val.length() > 0) {
int hours = Integer.parseInt(val);
Date date = new Date();
long millis = date.getTime();
millis = millis - (1000 * 60 * 60 * hours);
Date date2 = new Date(millis);
uAudit.setBeginDate(date2);
}
List<Bind> list = am.searchBinds(uAudit);
printAuthNReport(list);
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("getBindReport caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations