use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditMgrRestImpl method searchBinds.
/**
* {@inheritDoc}
*/
@Override
public List<Bind> searchBinds(UserAudit uAudit) throws SecurityException {
VUtil.assertNotNull(uAudit, GlobalErrIds.AUDT_INPUT_NULL, CLS_NM + ".searchBinds");
List<Bind> outRecords;
FortRequest request = new FortRequest();
request.setContextId(this.contextId);
request.setEntity(uAudit);
if (this.adminSess != null) {
request.setSession(adminSess);
}
String szRequest = RestUtils.marshal(request);
String szResponse = RestUtils.getInstance().post(szRequest, HttpIds.AUDIT_BINDS);
FortResponse response = RestUtils.unmarshall(szResponse);
if (response.getErrorCode() == 0) {
outRecords = response.getEntities();
// do not return a null list to the caller:
if (outRecords == null) {
outRecords = new ArrayList<>();
}
} else {
throw new SecurityException(response.getErrorCode(), response.getErrorMessage());
}
return outRecords;
}
use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditMgrImplTest method searchBinds.
/**
* @param msg
* @param uArray
*/
private static void searchBinds(String msg, String[][] uArray) {
LogUtil.logIt(msg);
try {
AuditMgr auditMgr = getManagedAuditMgr();
for (String[] usr : uArray) {
User user = UserTestData.getUser(usr);
// now search for successful authentications:
UserAudit uAudit = new UserAudit();
uAudit.setUserId(user.getUserId());
uAudit.setFailedOnly(false);
List<Bind> binds = auditMgr.searchBinds(uAudit);
assertNotNull(binds);
assertTrue(CLS_NM + "searchBinds failed search for successful authentication user [" + user.getUserId() + "]", binds.size() > 0);
// now search for failed authentications:
uAudit.setFailedOnly(true);
binds = auditMgr.searchBinds(uAudit);
assertNotNull(binds);
assertTrue(CLS_NM + "searchBinds failed search for failed authentication user [" + user.getUserId() + "]", binds.size() > 0);
}
LOG.debug("searchBinds successful");
} catch (SecurityException ex) {
LOG.error("searchBinds: failed with SecurityException rc=" + ex.getErrorId() + ", msg=" + ex.getMessage(), ex);
fail(ex.getMessage());
}
}
use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditMgrConsole method printAuthNs.
/**
* @param list
*/
void printAuthNs(List<Bind> list) {
if (list != null && list.size() > 0) {
int ctr = 0;
for (Bind aBind : list) {
/*
public class Bind
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 reqAuthzID;
private String reqControls;
private String reqDN;
private String reqEnd;
private String reqMethod;
private String reqResult;
private String reqSession;
private String reqStart;
private String reqType;
private String reqVersion;
private String structuralObjectClass;
*/
System.out.println("AUDIT BIND OBJECT [" + ctr++ + "]:");
System.out.println(" createTimestamp [" + aBind.getCreateTimestamp() + "]");
System.out.println(" creatorsName [" + aBind.getCreatorsName() + "]");
System.out.println(" entryCSN [" + aBind.getEntryCSN() + "]");
System.out.println(" entryDN [" + aBind.getEntryDN() + "]");
System.out.println(" entryUUID [" + aBind.getEntryUUID() + "]");
System.out.println(" hasSubordinates [" + aBind.getHasSubordinates() + "]");
System.out.println(" modifiersName [" + aBind.getModifiersName() + "]");
System.out.println(" modifyTimestamp [" + aBind.getModifyTimestamp() + "]");
System.out.println(" objectClass [" + aBind.getObjectClass() + "]");
System.out.println(" reqAuthzID [" + aBind.getReqAuthzID() + "]");
System.out.println(" reqControls [" + aBind.getReqControls() + "]");
System.out.println(" reqDN [" + aBind.getReqDN() + "]");
System.out.println(" reqEnd [" + aBind.getReqEnd() + "]");
System.out.println(" reqMethod [" + aBind.getReqMethod() + "]");
System.out.println(" reqResult [" + aBind.getReqResult() + "]");
System.out.println(" reqSession [" + aBind.getReqSession() + "]");
System.out.println(" reqStart [" + aBind.getReqStart() + "]");
System.out.println(" reqType [" + aBind.getReqType() + "]");
System.out.println(" reqVersion [" + aBind.getReqVersion() + "]");
System.out.println(" structuralObjectClass [" + aBind.getStructuralObjectClass() + "]");
}
} else {
System.out.println("no authN's found");
}
}
use of org.apache.directory.fortress.core.model.Bind 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();
}
use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditMgrConsole method findBinds.
/**
*/
void findBinds() {
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);
List<Bind> list = am.searchBinds(uAudit);
printAuthNs(list);
System.out.println("ENTER to continue");
} catch (SecurityException e) {
LOG.error("findBinds caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
}
ReaderUtil.readChar();
}
Aggregations