Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 9b9d4956
authored
Jul 30, 2016
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes and logging formatting
1 parent
fad7c9a0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
18 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventSender.java
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
View file @
9b9d495
...
@@ -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
);
}
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
9b9d495
...
@@ -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
)
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/MoyaEventSender.java
View file @
9b9d495
...
@@ -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
());
...
...
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
View file @
9b9d495
...
@@ -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
();
...
...
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
View file @
9b9d495
...
@@ -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
(
"add
I
gnore"
,
new
MessgaeIgnoreListener
());
bot
.
addCmdListener
(
"add
i
gnore"
,
new
MessgaeIgnoreListener
());
bot
.
addCmdListener
(
"rm
I
gnore"
,
new
RemoveMessgaeIgnoreListener
());
bot
.
addCmdListener
(
"rm
i
gnore"
,
new
RemoveMessgaeIgnoreListener
());
bot
.
addCmdListener
(
"ls
I
gnores"
,
new
ListMessgaeIgnoreListener
());
bot
.
addCmdListener
(
"ls
i
gnores"
,
new
ListMessgaeIgnoreListener
());
bots
.
add
(
bot
);
bots
.
add
(
bot
);
bot
.
start
();
bot
.
start
();
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment