use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditMgrConsole method printAuthNReport.
/**
* @param list
*/
void printAuthNReport(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("AUTHENTICATION AUDIT RECORD " + ctr++);
System.out.println("***************************************");
System.out.println(" UserId " + AuditUtil.getAuthZId(aBind.getReqDN()));
Date aDate = null;
try {
aDate = TUtil.decodeGeneralizedTime(aBind.getReqEnd());
} catch (ParseException pe) {
System.out.println(" Bind 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(" Bind Time " + formattedDate);
}
System.out.println(" AuthN Type " + aBind.getReqMethod());
System.out.println(" Success? " + aBind.getReqResult().equals("0"));
System.out.println(" Session " + aBind.getReqSession());
System.out.println(" Type " + aBind.getReqType());
System.out.println(" Version " + aBind.getReqVersion());
System.out.println();
System.out.println();
}
} 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 AuditDAO method getBindEntityFromLdapEntry.
/**
* @param le
* @return
* @throws LdapInvalidAttributeValueException
* @throws LdapException
*/
private Bind getBindEntityFromLdapEntry(Entry le, long sequence) throws LdapInvalidAttributeValueException {
Bind auditBind = new ObjectFactory().createBind();
auditBind.setSequenceId(sequence);
auditBind.setCreateTimestamp(getAttribute(le, CREATETIMESTAMP));
auditBind.setCreatorsName(getAttribute(le, CREATORSNAME));
auditBind.setEntryCSN(getAttribute(le, ENTRYCSN));
auditBind.setEntryDN(getAttribute(le, ENTRYDN));
auditBind.setEntryUUID(getAttribute(le, ENTRYUUID));
auditBind.setHasSubordinates(getAttribute(le, HASSUBORDINATES));
auditBind.setModifiersName(getAttribute(le, MODIFIERSNAME));
auditBind.setModifyTimestamp(getAttribute(le, MODIFYTIMESTAMP));
auditBind.setObjectClass(getAttribute(le, OBJECTCLASS));
auditBind.setReqAuthzID(getAttribute(le, REQUAUTHZID));
auditBind.setReqControls(getAttribute(le, REQCONTROLS));
auditBind.setReqDN(getAttribute(le, REQDN));
auditBind.setReqEnd(getAttribute(le, REQEND));
auditBind.setReqMethod(getAttribute(le, REQMETHOD));
auditBind.setReqResult(getAttribute(le, REQRESULT));
auditBind.setReqSession(getAttribute(le, REQSESSION));
auditBind.setReqStart(getAttribute(le, REQSTART));
auditBind.setReqType(getAttribute(le, REQTYPE));
auditBind.setReqVersion(getAttribute(le, REQVERSION));
auditBind.setStructuralObjectClass(getAttribute(le, STRUCTURALOBJECTCLASS));
return auditBind;
}
use of org.apache.directory.fortress.core.model.Bind in project directory-fortress-core by apache.
the class AuditDAO method searchBinds.
/**
* @param audit
* @return
* @throws org.apache.directory.fortress.core.FinderException
*/
List<Bind> searchBinds(UserAudit audit) throws FinderException {
List<Bind> auditList = new ArrayList<>();
LdapConnection ld = null;
String auditRoot = Config.getInstance().getProperty(AUDIT_ROOT);
String userRoot = getRootDn(audit.getContextId(), GlobalIds.USER_ROOT);
try {
String filter;
if (audit.getUserId() != null && audit.getUserId().length() > 0) {
filter = GlobalIds.FILTER_PREFIX + ACCESS_BIND_CLASS_NM + ")(" + REQDN + "=" + SchemaConstants.UID_AT + "=" + audit.getUserId() + "," + userRoot + ")";
if (audit.isFailedOnly()) {
filter += "(" + REQRESULT + ">=" + 1 + ")";
}
if (audit.getBeginDate() != null) {
String szTime = TUtil.encodeGeneralizedTime(audit.getBeginDate());
filter += "(" + REQEND + ">=" + szTime + ")";
}
filter += ")";
} else {
filter = GlobalIds.FILTER_PREFIX + ACCESS_BIND_CLASS_NM + ")";
if (audit.isFailedOnly()) {
filter += "(" + REQRESULT + ">=" + 1 + ")";
}
if (audit.getBeginDate() != null) {
String szTime = TUtil.encodeGeneralizedTime(audit.getBeginDate());
filter += "(" + REQEND + ">=" + szTime + ")";
}
filter += ")";
}
// log.warn("filter=" + filter);
ld = getLogConnection();
SearchCursor searchResults = search(ld, auditRoot, SearchScope.ONELEVEL, filter, AUDIT_BIND_ATRS, false, GlobalIds.BATCH_SIZE);
long sequence = 0;
while (searchResults.next()) {
auditList.add(getBindEntityFromLdapEntry(searchResults.getEntry(), sequence++));
}
} catch (LdapException e) {
String error = "LdapException in AuditDAO.searchBinds id=" + e.getMessage();
throw new FinderException(GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e);
} catch (CursorException e) {
String error = "CursorException in AuditDAO.searchBinds id=" + e.getMessage();
throw new FinderException(GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e);
} finally {
closeLogConnection(ld);
}
return auditList;
}
Aggregations