use of org.apache.directory.fortress.core.model.AuthZ in project directory-fortress-core by apache.
the class AuditMgrConsole method printAuthZReport.
/**
* @param list
*/
void printAuthZReport(List<AuthZ> list) {
ReaderUtil.clearScreen();
if (list != null && list.size() > 0) {
int ctr = 0;
for (AuthZ authZ : list) {
/*
public class AuthZ
{
private String createTimestamp;
private String creatorsName;
private String entryCSN;
private String entryDN;
private String entryUUID;
private String hasSubordinates;
private String modifiersName;
private String modifyTimestamp;
private String objectClass;
private String reqAttr;
private String reqAttrsOnly;
private String reqAuthzID;
private String reqControls;
private String reqDN;
private String reqDerefAliases;
private String reqEnd;
private String reqEntries;
private String reqFilter;
private String reqResult;
private String reqScope;
private String reqSession;
private String reqSizeLimit;
private String reqStart;
private String reqTimeLimit;
private String reqType;
private String structuralObjectClass;
private String subschemaSubentry;
*/
// System.out.println("**********************************");
System.out.println("AUTHORIZATION AUDIT RECORD " + ctr++);
System.out.println("***************************************");
Date aDate = null;
try {
aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
} catch (ParseException pe) {
System.out.println(" Access Time " + "ParseException=" + pe.getMessage());
}
if (aDate != null) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String formattedDate = formatter.format(aDate);
System.out.println(" Access Time " + formattedDate);
}
System.out.println(" userId " + AuditUtil.getAuthZId(authZ.getReqAuthzID()));
try {
Permission pOp = getAuthZPerm(authZ);
System.out.println(" Resource Name " + pOp.getObjName());
System.out.println(" Operation " + pOp.getOpName());
int rCtr = 0;
if (pOp.getRoles() != null) {
// TODO: fix the NPE that happens here:
System.out.println(" Success? " + authZ.getReqEntries().equals(GlobalIds.AUTHZ_COMPARE_FAILURE_FLAG));
for (String role : pOp.getRoles()) {
System.out.println(" Role[" + rCtr++ + "] " + role);
}
}
} catch (LdapInvalidDnException e) {
System.out.println("LdapInvalidDnException=" + e);
}
// System.out.println(" reqStart [" + authZ.getReqStart() + "]");
// System.out.println(" reqEnd [" + authZ.getReqEnd() + "]");
System.out.println();
System.out.println();
// System.out.println("**********************************");
}
} else {
System.out.println("AuthZ list empty");
}
}
use of org.apache.directory.fortress.core.model.AuthZ 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.AuthZ 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.AuthZ in project directory-fortress-core by apache.
the class AuditMgrConsole method getAuthZs.
/**
*/
void getAuthZs() {
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");
}
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.getUserAuthZs(uAudit);
printAuthZs(list);
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("getUserAuthZs caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
use of org.apache.directory.fortress.core.model.AuthZ in project directory-fortress-core by apache.
the class AuditMgrConsole method printfailedAuthNReport.
void printfailedAuthNReport(List<AuthZ> list) {
ReaderUtil.clearScreen();
if (list != null && list.size() > 0) {
int ctr = 0;
for (AuthZ authZ : list) {
/*
public class AuthZ
{
private String createTimestamp;
private String creatorsName;
private String entryCSN;
private String entryDN;
private String entryUUID;
private String hasSubordinates;
private String modifiersName;
private String modifyTimestamp;
private String objectClass;
private String reqAttr;
private String reqAttrsOnly;
private String reqAuthzID;
private String reqControls;
private String reqDN;
private String reqDerefAliases;
private String reqEnd;
private String reqEntries;
private String reqFilter;
private String reqResult;
private String reqScope;
private String reqSession;
private String reqSizeLimit;
private String reqStart;
private String reqTimeLimit;
private String reqType;
private String structuralObjectClass;
private String subschemaSubentry;
*/
// System.out.println("**********************************");
System.out.println("FAILED AUTHENTICATIONS AUDIT RECORD " + ctr++);
System.out.println("***************************************");
Date aDate = null;
try {
aDate = TUtil.decodeGeneralizedTime(authZ.getReqEnd());
} catch (ParseException pe) {
System.out.println(" Access Time " + "ParseException=" + pe.getMessage());
}
if (aDate != null) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
String formattedDate = formatter.format(aDate);
System.out.println(" Access Time " + formattedDate);
}
System.out.println(" userId " + AuditUtil.getAuthZId(authZ.getReqDN()));
System.out.println(" Success? " + authZ.getReqEntries().equals("1"));
System.out.println(" reqDN " + authZ.getReqDN());
System.out.println();
System.out.println();
}
} else {
System.out.println("AuthZ list empty");
}
}
Aggregations