Skip to content

Commit adfc516

Browse files
authored
Merge pull request #1313 from tulinkry/stats
Adding unauthorized requests into statistics
2 parents a3c09f7 + 8ad6c89 commit adfc516

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/org/opensolaris/opengrok/web/AuthorizationFilter.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opensolaris.opengrok.web;
2424

@@ -50,10 +50,16 @@ public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc) thr
5050
HttpServletResponse httpRes = (HttpServletResponse) sr1;
5151

5252
PageConfig config = PageConfig.get(httpReq);
53+
long processTime = System.currentTimeMillis();
5354

5455
Project p = config.getProject();
5556
if (p != null && !config.isAllowed(p)) {
56-
LOGGER.log(Level.SEVERE, "access denied for uri: {0}", httpReq.getRequestURI());
57+
LOGGER.log(Level.INFO, "access denied for uri: {0}", httpReq.getRequestURI());
58+
config.getEnv().getStatistics().addRequest(httpReq);
59+
config.getEnv().getStatistics().addRequest(httpReq, "requests_forbidden");
60+
config.getEnv().getStatistics().addRequestTime(httpReq,
61+
"requests_forbidden",
62+
System.currentTimeMillis() - processTime);
5763
httpRes.sendError(403, "Access forbidden");
5864
return;
5965
}

0 commit comments

Comments
 (0)