Commit 9b9d4956 by Tuomas Riihimäki

Minor fixes and logging formatting

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