zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anmolnar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #338: ZOOKEEPER-1260:Audit logging in ZooKeeper serve...
Date Mon, 23 Apr 2018 15:29:40 GMT
Github user anmolnar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/338#discussion_r183434909
  
    --- Diff: src/java/main/org/apache/zookeeper/server/FinalRequestProcessor.java ---
    @@ -465,6 +488,127 @@ public void processRequest(Request request) {
             }
         }
     
    +    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String
path) {
    +        addSuccessAudit(request, cnxn, op, path, null);
    +    }
    +
    +    private void addSuccessAudit(Request request, ServerCnxn cnxn, String op, String
path,
    +            String acl) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        ZKAuditLogger.logSuccess(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                cnxn.getHostAddress());
    +    }
    +
    +    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String
path) {
    +        addFailureAudit(request, cnxn, op, path, null);
    +    }
    +
    +    private void addFailureAudit(Request request, ServerCnxn cnxn, String op, String
path,
    +            String acl) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        ZKAuditLogger.logFailure(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                cnxn.getHostAddress());
    +    }
    +
    +    private void addAuditLog(Request request, ServerCnxn cnxn, String op, String path,
String acl,
    +            Code err) {
    +        if (!ZKAuditLogger.isAuditEnabled) {
    +            return;
    +        }
    +        if (err == Code.OK) {
    +            ZKAuditLogger.logSuccess(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                    cnxn.getHostAddress());
    +        } else {
    +            ZKAuditLogger.logFailure(request.getUsers(), op, path, acl, cnxn.getSessionIdHex(),
    +                    cnxn.getHostAddress());
    +        }
    +    }
    +
    +    private String getACLs(Request request)
    +    {
    +        ByteBuffer reqData = request.request.duplicate();
    +        reqData.rewind();
    +        SetACLRequest setACLRequest = new SetACLRequest();
    +        try {
    +            ByteBufferInputStream.byteBuffer2Record(reqData, setACLRequest);
    +        } catch (IOException e) {
    +            e.printStackTrace();
    +        }
    +        return ZKUtil.aclToString(setACLRequest.getAcl());
    +    }
    +
    +    private void addFailedTxnAduitLog(Request request) {
    --- End diff --
    
    Typo here


---

Mime
View raw message