Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 1a6f11c0
authored
Oct 25, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IrcStuff
1 parent
ad194633
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
43 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/LoggingBean.java
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/LoggingBean.java
View file @
1a6f11c
...
...
@@ -44,22 +44,24 @@ import fi.codecrew.moya.model.User;
* Session Bean implementation class SercurityBean
*/
@Stateless
@TransactionManagement
(
TransactionManagementType
.
BEAN
)
//
@TransactionManagement(TransactionManagementType.BEAN)
public
class
LoggingBean
implements
LoggingBeanLocal
{
private
static
final
boolean
DEBUG
=
true
;
private
final
Logger
logger
=
org
.
slf4j
.
LoggerFactory
.
getLogger
(
LoggingBean
.
class
);
@EJB
private
LogEntryTypeFacade
typeFacade
;
@EJB
private
LogEntryFacade
entryFacade
;
//
@EJB
//
private LogEntryTypeFacade typeFacade;
//
@EJB
//
private LogEntryFacade entryFacade;
@EJB
private
EventBeanLocal
eventbean
;
@EJB
private
MoyaEventSender
sender
;
@Resource
UserTransaction
utx
;
//
@Resource
//
UserTransaction utx;
// @Override
// public LogEntry logPermissionDenied(User user, Exception exception) {
...
...
@@ -113,28 +115,25 @@ public class LoggingBean implements LoggingBeanLocal {
public
LogEntry
logMessage
(
SecurityLogType
paramType
,
LanEvent
event
,
User
user
,
Object
...
description
)
{
LogEntry
entry
=
null
;
if
(
event
==
null
)
{
if
(
event
==
null
)
{
event
=
eventbean
.
getCurrentEvent
();
}
try
{
String
desc
=
toString
(
description
);
utx
.
begin
(
);
LogEntryType
type
=
typeFacade
.
findOrCreate
(
paramType
);
entry
=
new
LogEntry
(
Calendar
.
getInstance
());
entry
.
setParentEvent
(
event
);
entry
.
setType
(
type
);
entry
.
setDescription
(
desc
);
entry
.
setUser
(
user
);
logger
.
warn
(
"Sending logmsg {}"
,
desc
);
//
LogEntryType type = typeFacade.findOrCreate(paramType);
//
entry = new LogEntry(Calendar.getInstance());
//
entry.setParentEvent(event);
//
entry.setType(type);
//
entry.setDescription(desc);
//
entry.setUser(user);
entryFacade
.
create
(
entry
);
if
(
DEBUG
)
{
logger
.
debug
(
"SECURITY DEBUG: Type: \"{}\" user \"{}\", description \"{}\""
,
new
String
[]
{
paramType
.
name
(),
(
user
==
null
)
?
"null"
:
user
.
getLogin
(),
desc
});
}
utx
.
commit
();
// entryFacade.create(entry);
String
msg
=
"SECURITY DEBUG: Type: \""
+
paramType
.
name
()
+
"\" user \""
+
paramType
.
name
()
+
"\", description \""
+
((
user
==
null
)
?
"null"
:
user
.
getLogin
())
+
"\""
+
desc
;
sender
.
sendMessage
(
msg
);
// utx.commit();
}
catch
(
Exception
e
)
{
logger
.
warn
(
"Exception at SecurityBean"
,
e
);
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
View file @
1a6f11c
...
...
@@ -52,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
fi.codecrew.moya.beans.BotBeanLocal
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.beans.PlaceBeanLocal
;
...
...
@@ -73,6 +74,9 @@ public class IrcServlet extends HttpServlet {
private
PermissionBeanLocal
permBean
;
private
final
ArrayList
<
IrcBot
>
bots
=
new
ArrayList
<>();
@EJB
private
BotBeanLocal
botbean
;
/**
* @see HttpServlet#HttpServlet()
*/
...
...
@@ -81,10 +85,6 @@ public class IrcServlet extends HttpServlet {
// TODO Auto-generated constructor stub
}
private
class
EventListener
{
}
@EJB
private
PlaceBeanLocal
placebean
;
...
...
@@ -92,23 +92,10 @@ public class IrcServlet extends HttpServlet {
* @see Servlet#init(ServletConfig)
*/
public
void
init
(
ServletConfig
config
)
throws
ServletException
{
IrcBot
bot
=
new
IrcBot
(
"irc.cc.tut.fi"
,
"#
codecrew.ry
"
,
"moya-bot"
);
bot
.
addCmdListener
(
"places"
,
new
IrcPlaceFetcher
(
placebean
)
);
IrcBot
bot
=
new
IrcBot
(
"irc.cc.tut.fi"
,
"#
moya-debug
"
,
"moya-bot"
);
bot
bean
.
add
(
bot
);
bots
.
add
(
bot
);
bot
.
start
();
bot
.
addCmdListener
(
"foo"
,
new
IrcBotListener
()
{
@Override
public
String
getUsageMessage
()
{
// TODO Auto-generated method stub
return
null
;
}
@Override
public
void
executeIrc
(
IrcBot
bot
,
String
data
)
{
bot
.
say
(
""
);
}
});
}
...
...
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