use of org.apache.ranger.audit.model.AuthzAuditEvent in project ranger by apache.
the class TestEvents method getTestEvent.
private static AuditEventBase getTestEvent(int idx) {
AuthzAuditEvent event = new AuthzAuditEvent();
event.setClientIP("127.0.0.1");
event.setAccessResult((short) (idx % 2 > 0 ? 1 : 0));
event.setAclEnforcer("ranger-acl");
switch(idx % 5) {
case 0:
event.setRepositoryName("hdfsdev");
event.setRepositoryType(EnumRepositoryType.HDFS);
event.setResourcePath("/tmp/test-audit.log");
event.setResourceType("file");
event.setAccessType("read");
if (idx % 2 > 0) {
event.setAclEnforcer("hadoop-acl");
}
break;
case 1:
event.setRepositoryName("hbasedev");
event.setRepositoryType(EnumRepositoryType.HBASE);
event.setResourcePath("test_table/test_cf/test_col");
event.setResourceType("column");
event.setAccessType("read");
break;
case 2:
event.setRepositoryName("hivedev");
event.setRepositoryType(EnumRepositoryType.HIVE);
event.setResourcePath("test_database/test_table/test_col");
event.setResourceType("column");
event.setAccessType("select");
break;
case 3:
event.setRepositoryName("knoxdev");
event.setRepositoryType(EnumRepositoryType.KNOX);
event.setResourcePath("topologies/ranger-admin");
event.setResourceType("service");
event.setAccessType("get");
break;
case 4:
event.setRepositoryName("stormdev");
event.setRepositoryType(EnumRepositoryType.STORM);
event.setResourcePath("topologies/read-finance-stream");
event.setResourceType("topology");
event.setAccessType("submit");
break;
}
event.setEventTime(new Date());
event.setResultReason(Integer.toString(idx));
return event;
}
use of org.apache.ranger.audit.model.AuthzAuditEvent in project ranger by apache.
the class RangerDefaultAuditHandler method getAuthzEvents.
public AuthzAuditEvent getAuthzEvents(RangerAccessResult result) {
if (LOG.isDebugEnabled()) {
LOG.debug("==> RangerDefaultAuditHandler.getAuthzEvents(" + result + ")");
}
AuthzAuditEvent ret = null;
RangerAccessRequest request = result != null ? result.getAccessRequest() : null;
if (request != null && result != null && result.getIsAudited()) {
// RangerServiceDef serviceDef = result.getServiceDef();
RangerAccessResource resource = request.getResource();
String resourceType = resource == null ? null : resource.getLeafName();
String resourcePath = resource == null ? null : resource.getAsString();
ret = createAuthzAuditEvent();
ret.setRepositoryName(result.getServiceName());
ret.setRepositoryType(result.getServiceType());
ret.setResourceType(resourceType);
ret.setResourcePath(resourcePath);
ret.setRequestData(request.getRequestData());
ret.setEventTime(request.getAccessTime());
ret.setUser(request.getUser());
ret.setAction(request.getAccessType());
ret.setAccessResult((short) (result.getIsAllowed() ? 1 : 0));
ret.setPolicyId(result.getPolicyId());
ret.setAccessType(request.getAction());
ret.setClientIP(request.getClientIPAddress());
ret.setClientType(request.getClientType());
ret.setSessionId(request.getSessionId());
ret.setAclEnforcer(RangerModuleName);
Set<String> tags = getTags(request);
if (tags != null) {
ret.setTags(tags);
}
ret.setAdditionalInfo(getAdditionalInfo(request));
ret.setClusterName(request.getClusterName());
populateDefaults(ret);
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== RangerDefaultAuditHandler.getAuthzEvents(" + result + "): " + ret);
}
return ret;
}
use of org.apache.ranger.audit.model.AuthzAuditEvent in project ranger by apache.
the class TestAuditQueue method createEvent.
private AuthzAuditEvent createEvent(String user, String accessType, String resource, boolean isAllowed) {
AuthzAuditEvent event = new AuthzAuditEvent();
event.setUser(user);
event.setAccessType(accessType);
event.setResourcePath(resource);
event.setAccessResult(isAllowed ? (short) 1 : (short) 0);
event.setSeqNum(++seqNum);
return event;
}
Aggregations