Search in sources :

Example 21 with AuthzAuditEvent

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;
}
Also used : AuthzAuditEvent(org.apache.ranger.audit.model.AuthzAuditEvent) Date(java.util.Date)

Example 22 with AuthzAuditEvent

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;
}
Also used : AuthzAuditEvent(org.apache.ranger.audit.model.AuthzAuditEvent)

Example 23 with AuthzAuditEvent

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;
}
Also used : AuthzAuditEvent(org.apache.ranger.audit.model.AuthzAuditEvent)

Aggregations

AuthzAuditEvent (org.apache.ranger.audit.model.AuthzAuditEvent)23 ArrayList (java.util.ArrayList)3 AccessDeniedException (org.apache.hadoop.hbase.security.AccessDeniedException)2 User (org.apache.hadoop.hbase.security.User)2 RangerAccessRequest (org.apache.ranger.plugin.policyengine.RangerAccessRequest)2 RangerAccessResource (org.apache.ranger.plugin.policyengine.RangerAccessResource)2 RangerAccessResult (org.apache.ranger.plugin.policyengine.RangerAccessResult)2 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)2 SolrInputDocument (org.apache.solr.common.SolrInputDocument)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 NavigableSet (java.util.NavigableSet)1 Properties (java.util.Properties)1 Set (java.util.Set)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1