Commit 9b9d4956 by Tuomas Riihimäki

Minor fixes and logging formatting

1 parent fad7c9a0
......@@ -84,7 +84,7 @@ public class BotBean implements BotBeanLocal {
bot.say(sb.toString());
} catch (JMSException e) {
logger.warn("Error sending message",e);
logger.warn("Error sending message", e);
bot.say("Error parsing message " + e.getMessage());
}
}
......@@ -104,7 +104,7 @@ public class BotBean implements BotBeanLocal {
@Override
public void addBot(IrcBot bot) {
// TODO Auto-generated method stub
setBot(bot);
}
......
......@@ -399,7 +399,7 @@ public class PlaceBean implements PlaceBeanLocal {
}
}
logger.info("Buying place {} for user {}", p.getName(), user.getUser().getLogin());
logSb.append(p.getName()).append(" ");
logSb.append(p.getName()).append(", ");
GroupMembership gm = buy(p, pg);
if (!associatedToPlace)
......
......@@ -76,7 +76,6 @@ public class MoyaEventSender implements LoggingBeanLocal {
StringBuilder sb = new StringBuilder();
for (Object m : message) {
sb.append(m);
sb.append(" ");
}
sendMessage(type, user, sb.toString());
......@@ -88,7 +87,6 @@ public class MoyaEventSender implements LoggingBeanLocal {
StringBuilder sb = new StringBuilder();
for (Object m : message) {
sb.append(m);
sb.append(" ");
}
sendMessage(type, permbean.getCurrentUser(), sb.toString());
......
......@@ -55,6 +55,7 @@ import fi.codecrew.moya.utilities.moyamessage.MoyaEventType;
@WebFilter(filterName = "hostnameFilter", displayName = "hostname and authentication filter", urlPatterns = { "/*" })
public class HostnameFilter implements Filter {
private static final String X_FORWARDED_PROTO = "X-Forwarded-Proto";
private static final String SESSION_HOSTNAMESTORE = "moya-session-hostname";
private static final Logger logger = LoggerFactory.getLogger(HostnameFilter.class);
private static final String HTTP_HOSTNAME_ID = "moya_hostname_session_id";
......@@ -228,14 +229,15 @@ public class HostnameFilter implements Filter {
String restAuthStr = null;
// Allow api auth with password only if ssl is enabled ( or in
// development mode... )
if (BortalLocalContextHolder.isSsl() || BortalLocalContextHolder.isInDevelopmentMode()) {
// if (BortalLocalContextHolder.isSsl() ||
// BortalLocalContextHolder.isInDevelopmentMode()) {
restAuthStr = httpRequest.getHeader("Authorization");
}
// }
if (restAuthStr == null) {
StringBuilder hashBuilder = new StringBuilder();
hashBuilder.append(JaasBeanLocal.REST_PREFIX );
hashBuilder.append(JaasBeanLocal.REST_PREFIX);
hashBuilder.append(httpRequest.getParameter("appkey")).append(":");
hashBuilder.append(httpRequest.getParameter("appuser")).append(":");
hashBuilder.append(httpRequest.getParameter("appstamp")).append(":");
......@@ -247,7 +249,8 @@ public class HostnameFilter implements Filter {
httpRequest.login(null, restAuthStr);
} catch (ServletException loginEx) {
ret = false;
logger.info("Rest api authentication failed for path "+httpRequest.getPathInfo() + " " +httpRequest.getParameterMap().toString() , loginEx);
logger.info("Rest api authentication failed for path " + httpRequest.getPathInfo() + " "
+ httpRequest.getParameterMap().toString(), loginEx);
if (response instanceof HttpServletResponse) {
HttpServletResponse httpResp = ((HttpServletResponse) response);
httpResp.setStatus(HttpServletResponse.SC_FORBIDDEN);
......@@ -285,10 +288,13 @@ public class HostnameFilter implements Filter {
}
String hostname = url.substring(beginindex, lastindex);
// httpRequest.getSession().setAttribute(EventBeanLocal.HTTP_URL_HOSTNAME,
// hostname);
String proto = url.substring(0, 5).toLowerCase();
boolean ssl = proto.equals("https");
// if proxy provides scheme in header, use it..
String scheme = httpRequest.getHeader(X_FORWARDED_PROTO);
if (scheme == null || scheme.isEmpty()) {
scheme = url.substring(0, 5).toLowerCase();
}
boolean ssl = scheme.trim().toLowerCase().equals("https");
BortalLocalContextHolder.setSsl(ssl);
HttpSession session = httpRequest.getSession();
......
......@@ -108,9 +108,9 @@ public class IrcServlet extends HttpServlet {
new Profile("moyabot", "Moya bot", "moya-bot"));
botbean.addBot(bot);
bot.addCmdListener("addIgnore", new MessgaeIgnoreListener());
bot.addCmdListener("rmIgnore", new RemoveMessgaeIgnoreListener());
bot.addCmdListener("lsIgnores", new ListMessgaeIgnoreListener());
bot.addCmdListener("addignore", new MessgaeIgnoreListener());
bot.addCmdListener("rmignore", new RemoveMessgaeIgnoreListener());
bot.addCmdListener("lsignores", new ListMessgaeIgnoreListener());
bots.add(bot);
bot.start();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!