Skip to content

Commit 36b2b78

Browse files
Whitespace cleanup. Removing tabs.
1 parent 99b4640 commit 36b2b78

File tree

5 files changed

+164
-164
lines changed

5 files changed

+164
-164
lines changed

src/main/java/org/owasp/esapi/logging/appender/ClientInfoSupplier.java

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -28,66 +28,66 @@
2828
* information.
2929
*/
3030
public class ClientInfoSupplier implements Supplier<String> {
31-
/** Default UserName string if the Authenticated user is null.*/
32-
private static final String DEFAULT_USERNAME = "#ANONYMOUS#";
33-
/** Default Last Host string if the Authenticated user is null.*/
34-
private static final String DEFAULT_LAST_HOST = "#UNKNOWN_HOST#";
35-
/** Session Attribute containing the ESAPI Session id. */
36-
private static final String ESAPI_SESSION_ATTR = "ESAPI_SESSION";
37-
/**
38-
* Minimum value for generating a random session value if one is not defined.
39-
*/
40-
private static final int ESAPI_SESSION_RAND_MIN = 0;
41-
/**
42-
* Maximum value for generating a random session value if one is not defined.
43-
*/
44-
private static final int ESAPI_SESSION_RAND_MAX = 1000000;
31+
/** Default UserName string if the Authenticated user is null.*/
32+
private static final String DEFAULT_USERNAME = "#ANONYMOUS#";
33+
/** Default Last Host string if the Authenticated user is null.*/
34+
private static final String DEFAULT_LAST_HOST = "#UNKNOWN_HOST#";
35+
/** Session Attribute containing the ESAPI Session id. */
36+
private static final String ESAPI_SESSION_ATTR = "ESAPI_SESSION";
37+
/**
38+
* Minimum value for generating a random session value if one is not defined.
39+
*/
40+
private static final int ESAPI_SESSION_RAND_MIN = 0;
41+
/**
42+
* Maximum value for generating a random session value if one is not defined.
43+
*/
44+
private static final int ESAPI_SESSION_RAND_MAX = 1000000;
4545

46-
/** Format for supplier output. */
47-
private static final String USER_INFO_FORMAT = "%s:%s@%s"; // USER_NAME, SID, USER_HOST_ADDRESS
46+
/** Format for supplier output. */
47+
private static final String USER_INFO_FORMAT = "%s:%s@%s"; // USER_NAME, SID, USER_HOST_ADDRESS
4848

49-
/** Whether to log the user info from this instance. */
50-
private boolean logUserInfo = true;
49+
/** Whether to log the user info from this instance. */
50+
private boolean logUserInfo = true;
5151

52-
@Override
53-
public String get() {
54-
String userInfo = "";
55-
56-
if (logUserInfo) {
57-
HttpServletRequest request = ESAPI.currentRequest();
58-
// create a random session number for the user to represent the user's
59-
// 'session', if it doesn't exist already
60-
String sid = "";
61-
if (request != null) {
62-
HttpSession session = request.getSession(false);
63-
if (session != null) {
64-
sid = (String) session.getAttribute(ESAPI_SESSION_ATTR);
65-
// if there is no session ID for the user yet, we create one and store it in the
66-
// user's session
67-
if (sid == null) {
68-
sid = "" + ESAPI.randomizer().getRandomInteger(ESAPI_SESSION_RAND_MIN, ESAPI_SESSION_RAND_MAX);
69-
session.setAttribute(ESAPI_SESSION_ATTR, sid);
70-
}
71-
}
72-
}
73-
// log user information - username:session@ipaddr
74-
User user = ESAPI.authenticator().getCurrentUser();
75-
if (user == null) {
76-
userInfo = String.format(USER_INFO_FORMAT, DEFAULT_USERNAME, sid, DEFAULT_LAST_HOST);
77-
} else {
78-
userInfo = String.format(USER_INFO_FORMAT, user.getAccountName(), sid, user.getLastHostAddress());
79-
}
80-
}
81-
return userInfo;
82-
}
52+
@Override
53+
public String get() {
54+
String userInfo = "";
8355

84-
/**
85-
* Specify whether the instance should record the client info.
86-
*
87-
* @param log {@code true} to record
88-
*/
89-
public void setLogUserInfo(boolean log) {
90-
this.logUserInfo = log;
91-
}
56+
if (logUserInfo) {
57+
HttpServletRequest request = ESAPI.currentRequest();
58+
// create a random session number for the user to represent the user's
59+
// 'session', if it doesn't exist already
60+
String sid = "";
61+
if (request != null) {
62+
HttpSession session = request.getSession(false);
63+
if (session != null) {
64+
sid = (String) session.getAttribute(ESAPI_SESSION_ATTR);
65+
// if there is no session ID for the user yet, we create one and store it in the
66+
// user's session
67+
if (sid == null) {
68+
sid = "" + ESAPI.randomizer().getRandomInteger(ESAPI_SESSION_RAND_MIN, ESAPI_SESSION_RAND_MAX);
69+
session.setAttribute(ESAPI_SESSION_ATTR, sid);
70+
}
71+
}
72+
}
73+
// log user information - username:session@ipaddr
74+
User user = ESAPI.authenticator().getCurrentUser();
75+
if (user == null) {
76+
userInfo = String.format(USER_INFO_FORMAT, DEFAULT_USERNAME, sid, DEFAULT_LAST_HOST);
77+
} else {
78+
userInfo = String.format(USER_INFO_FORMAT, user.getAccountName(), sid, user.getLastHostAddress());
79+
}
80+
}
81+
return userInfo;
82+
}
83+
84+
/**
85+
* Specify whether the instance should record the client info.
86+
*
87+
* @param log {@code true} to record
88+
*/
89+
public void setLogUserInfo(boolean log) {
90+
this.logUserInfo = log;
91+
}
9292

9393
}

src/main/java/org/owasp/esapi/logging/appender/EventTypeLogSupplier.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@
2525
*
2626
*/
2727
public class EventTypeLogSupplier implements Supplier<String> {
28-
/** EventType reference to supply log representation of. */
29-
private final EventType eventType;
28+
/** EventType reference to supply log representation of. */
29+
private final EventType eventType;
3030

31-
/**
32-
* Ctr
33-
*
34-
* @param evtyp EventType reference to supply log representation for
35-
*/
36-
public EventTypeLogSupplier(EventType evtyp) {
37-
this.eventType = evtyp;
38-
}
31+
/**
32+
* Ctr
33+
*
34+
* @param evtyp EventType reference to supply log representation for
35+
*/
36+
public EventTypeLogSupplier(EventType evtyp) {
37+
this.eventType = evtyp;
38+
}
3939

40-
@Override
41-
public String get() {
42-
return eventType == null ? "" : eventType.toString();
43-
}
40+
@Override
41+
public String get() {
42+
return eventType == null ? "" : eventType.toString();
43+
}
4444
}

src/main/java/org/owasp/esapi/logging/appender/LogAppender.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
*/
2424
public interface LogAppender {
2525

26-
/**
27-
* Creates a replacement Log Message and returns it to the caller.
28-
* @param logName name of the logger.
29-
* @param eventType EventType of the log event being processed.
30-
* @param message The original message.
31-
* @return Updated replacement message.
32-
*/
33-
public String appendTo(String logName, EventType eventType, String message);
26+
/**
27+
* Creates a replacement Log Message and returns it to the caller.
28+
* @param logName name of the logger.
29+
* @param eventType EventType of the log event being processed.
30+
* @param message The original message.
31+
* @return Updated replacement message.
32+
*/
33+
public String appendTo(String logName, EventType eventType, String message);
3434

3535
}

src/main/java/org/owasp/esapi/logging/appender/LogPrefixAppender.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,48 @@
2222
* EventType, Client data, and server data.
2323
*/
2424
public class LogPrefixAppender implements LogAppender {
25-
/** Output format used to assemble return values. */
26-
private static final String RESULT_FORMAT = "[%s %s -> %s] %s";// EVENT_TYPE, CLIENT_INFO, SERVER_INFO, messageBody
25+
/** Output format used to assemble return values. */
26+
private static final String RESULT_FORMAT = "[%s %s -> %s] %s";// EVENT_TYPE, CLIENT_INFO, SERVER_INFO, messageBody
2727

28-
/** Whether or not to record client information. */
29-
private final boolean logClientInfo;
30-
/** Whether or not to record server ip information. */
31-
private final boolean logServerIp;
32-
/** Whether or not to record application name. */
33-
private final boolean logApplicationName;
34-
/** Application Name to record. */
35-
private final String appName;
28+
/** Whether or not to record client information. */
29+
private final boolean logClientInfo;
30+
/** Whether or not to record server ip information. */
31+
private final boolean logServerIp;
32+
/** Whether or not to record application name. */
33+
private final boolean logApplicationName;
34+
/** Application Name to record. */
35+
private final String appName;
3636

37-
/**
38-
* Ctr.
39-
*
40-
* @param logClientInfo Whether or not to record client information
41-
* @param logServerIp Whether or not to record server ip information
42-
* @param logApplicationName Whether or not to record application name
43-
* @param appName Application Name to record.
44-
*/
45-
public LogPrefixAppender(boolean logClientInfo, boolean logServerIp, boolean logApplicationName, String appName) {
46-
this.logClientInfo = logClientInfo;
47-
this.logServerIp = logServerIp;
48-
this.logApplicationName = logApplicationName;
49-
this.appName = appName;
50-
}
37+
/**
38+
* Ctr.
39+
*
40+
* @param logClientInfo Whether or not to record client information
41+
* @param logServerIp Whether or not to record server ip information
42+
* @param logApplicationName Whether or not to record application name
43+
* @param appName Application Name to record.
44+
*/
45+
public LogPrefixAppender(boolean logClientInfo, boolean logServerIp, boolean logApplicationName, String appName) {
46+
this.logClientInfo = logClientInfo;
47+
this.logServerIp = logServerIp;
48+
this.logApplicationName = logApplicationName;
49+
this.appName = appName;
50+
}
5151

52-
@Override
53-
public String appendTo(String logName, EventType eventType, String message) {
54-
EventTypeLogSupplier eventTypeSupplier = new EventTypeLogSupplier(eventType);
52+
@Override
53+
public String appendTo(String logName, EventType eventType, String message) {
54+
EventTypeLogSupplier eventTypeSupplier = new EventTypeLogSupplier(eventType);
5555

56-
ClientInfoSupplier clientInfoSupplier = new ClientInfoSupplier();
57-
clientInfoSupplier.setLogUserInfo(logClientInfo);
56+
ClientInfoSupplier clientInfoSupplier = new ClientInfoSupplier();
57+
clientInfoSupplier.setLogUserInfo(logClientInfo);
5858

59-
ServerInfoSupplier serverInfoSupplier = new ServerInfoSupplier(logName);
60-
serverInfoSupplier.setLogServerIp(logServerIp);
61-
serverInfoSupplier.setLogApplicationName(logApplicationName, appName);
59+
ServerInfoSupplier serverInfoSupplier = new ServerInfoSupplier(logName);
60+
serverInfoSupplier.setLogServerIp(logServerIp);
61+
serverInfoSupplier.setLogApplicationName(logApplicationName, appName);
6262

63-
String eventTypeMsg = eventTypeSupplier.get();
64-
String clientInfoMsg = clientInfoSupplier.get();
65-
String serverInfoMsg = serverInfoSupplier.get();
63+
String eventTypeMsg = eventTypeSupplier.get();
64+
String clientInfoMsg = clientInfoSupplier.get();
65+
String serverInfoMsg = serverInfoSupplier.get();
6666

67-
return String.format(RESULT_FORMAT, eventTypeMsg, clientInfoMsg, serverInfoMsg, message);
68-
}
67+
return String.format(RESULT_FORMAT, eventTypeMsg, clientInfoMsg, serverInfoMsg, message);
68+
}
6969
}

src/main/java/org/owasp/esapi/logging/appender/ServerInfoSupplier.java

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,58 +26,58 @@
2626
* information.
2727
*/
2828
public class ServerInfoSupplier implements Supplier<String> {
29-
/** Whether to log the server connection info. */
30-
private boolean logServerIP = true;
31-
/** Whether to log the application name. */
32-
private boolean logAppName = true;
33-
/** The application name to log. */
34-
private String applicationName = "";
29+
/** Whether to log the server connection info. */
30+
private boolean logServerIP = true;
31+
/** Whether to log the application name. */
32+
private boolean logAppName = true;
33+
/** The application name to log. */
34+
private String applicationName = "";
3535

36-
/** Reference to the associated logname/module name. */
37-
private final String logName;
36+
/** Reference to the associated logname/module name. */
37+
private final String logName;
3838

39-
/**
40-
* Ctr.
41-
*
42-
* @param logName Reference to the logName to record as the module information
43-
*/
44-
public ServerInfoSupplier(String logName) {
45-
this.logName = logName;
46-
}
39+
/**
40+
* Ctr.
41+
*
42+
* @param logName Reference to the logName to record as the module information
43+
*/
44+
public ServerInfoSupplier(String logName) {
45+
this.logName = logName;
46+
}
4747

48-
@Override
49-
public String get() {
50-
// log server, port, app name, module name -- server:80/app/module
51-
StringBuilder appInfo = new StringBuilder();
52-
HttpServletRequest request = ESAPI.currentRequest();
53-
if (request != null && logServerIP) {
54-
appInfo.append(request.getLocalAddr()).append(":").append(request.getLocalPort());
55-
}
56-
if (logAppName) {
57-
appInfo.append("/").append(applicationName);
58-
}
59-
appInfo.append("/").append(logName);
48+
@Override
49+
public String get() {
50+
// log server, port, app name, module name -- server:80/app/module
51+
StringBuilder appInfo = new StringBuilder();
52+
HttpServletRequest request = ESAPI.currentRequest();
53+
if (request != null && logServerIP) {
54+
appInfo.append(request.getLocalAddr()).append(":").append(request.getLocalPort());
55+
}
56+
if (logAppName) {
57+
appInfo.append("/").append(applicationName);
58+
}
59+
appInfo.append("/").append(logName);
6060

61-
return appInfo.toString();
62-
}
61+
return appInfo.toString();
62+
}
6363

64-
/**
65-
* Specify whether the instance should record the server connection info.
66-
*
67-
* @param log {@code true} to record
68-
*/
69-
public void setLogServerIp(boolean log) {
70-
this.logServerIP = log;
71-
}
64+
/**
65+
* Specify whether the instance should record the server connection info.
66+
*
67+
* @param log {@code true} to record
68+
*/
69+
public void setLogServerIp(boolean log) {
70+
this.logServerIP = log;
71+
}
7272

73-
/**
74-
* Specify whether the instance should record the application name
75-
*
76-
* @param log {@code true} to record
77-
* @param appName String to record as the application name
78-
*/
79-
public void setLogApplicationName(boolean log, String appName) {
80-
this.logAppName = log;
81-
this.applicationName = appName;
82-
}
73+
/**
74+
* Specify whether the instance should record the application name
75+
*
76+
* @param log {@code true} to record
77+
* @param appName String to record as the application name
78+
*/
79+
public void setLogApplicationName(boolean log, String appName) {
80+
this.logAppName = log;
81+
this.applicationName = appName;
82+
}
8383
}

0 commit comments

Comments
 (0)