1
0
mirror of https://e.coding.net/circlecloud/AuthMe.git synced 2024-12-21 06:38:55 +00:00

clean up class..

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-10-29 20:01:07 +08:00
parent e1af61efa4
commit b5f5afe770

View File

@ -16,73 +16,53 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
}
@Override
public Result filter(LogEvent record) {
public Result filter(final LogEvent record) {
try {
if (record == null || record.getMessage() == null)
if (record == null || record.getMessage() == null) {
return Result.NEUTRAL;
String logM = record.getMessage().getFormattedMessage().toLowerCase();
if (!logM.contains("issued server command:"))
return Result.NEUTRAL;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ")
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ")
&& !logM.contains("/register "))
return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
}
final String logM = record.getMessage().getFormattedMessage().toLowerCase();
return isLogger(logM);
} catch (final NullPointerException npe) {
return Result.NEUTRAL;
}
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message, Throwable arg4) {
public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final Message message, final Throwable arg4) {
try {
if (message == null)
if (message == null) {
return Result.NEUTRAL;
String logM = message.getFormattedMessage().toLowerCase();
if (!logM.contains("issued server command:"))
return Result.NEUTRAL;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ")
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ")
&& !logM.contains("/register "))
return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
}
final String logM = message.getFormattedMessage().toLowerCase();
return isLogger(logM);
} catch (final NullPointerException npe) {
return Result.NEUTRAL;
}
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message, Throwable arg4) {
public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final Object message, final Throwable arg4) {
try {
if (message == null)
if (message == null) {
return Result.NEUTRAL;
String logM = message.toString().toLowerCase();
if (!logM.contains("issued server command:"))
return Result.NEUTRAL;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ")
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ")
&& !logM.contains("/register "))
return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
}
final String logM = message.toString().toLowerCase();
return isLogger(logM);
} catch (final NullPointerException npe) {
return Result.NEUTRAL;
}
}
@Override
public Result filter(Logger arg0, Level arg1, Marker arg2, String message, Object... arg4) {
public Result filter(final Logger arg0, final Level arg1, final Marker arg2, final String message, final Object... arg4) {
try {
if (message == null)
if (message == null) {
return Result.NEUTRAL;
String logM = message.toLowerCase();
if (!logM.contains("issued server command:"))
return Result.NEUTRAL;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ")
&& !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ")
&& !logM.contains("/register "))
return Result.NEUTRAL;
return Result.DENY;
} catch (NullPointerException npe) {
}
final String logM = message.toLowerCase();
return isLogger(logM);
} catch (final NullPointerException npe) {
return Result.NEUTRAL;
}
}
@ -97,4 +77,15 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
return Result.NEUTRAL;
}
private Result isLogger(final String logM) {
if (!logM.contains("issued server command:")) {
return Result.NEUTRAL;
}
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ")
&& !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register ")) {
return Result.NEUTRAL;
}
return Result.DENY;
}
}