Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Max Mecklin
/
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 25dcabce
authored
Dec 20, 2014
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting and code style
No functional changes. Only formatting. Found with sonarcube
1 parent
a1396449
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
144 additions
and
174 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BillBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/SessionMgmtBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/MenuitemFacade.java
code/moya-database/src/main/java/fi/codecrew/moya/model/PollAnswer.java
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/SystemProperty.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-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
code/moya-web/src/main/java/fi/codecrew/moya/web/converter/LocaleConverter.java
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BillBean.java
View file @
25dcabc
...
@@ -265,16 +265,16 @@ public class BillBean implements BillBeanLocal {
...
@@ -265,16 +265,16 @@ public class BillBean implements BillBeanLocal {
}
}
// if there is autoproducts, check that they exists in bill
// if there is autoproducts, check that they exists in bill
for
(
Product
product
:
productBean
.
listUserShoppableProducts
())
{
for
(
Product
product
:
productBean
.
listUserShoppableProducts
())
{
if
(
product
.
isUsershopAutoproduct
())
{
if
(
product
.
isUsershopAutoproduct
())
{
boolean
containsAutoproduct
=
false
;
boolean
containsAutoproduct
=
false
;
for
(
BillLine
line
:
bill
.
getBillLines
())
{
for
(
BillLine
line
:
bill
.
getBillLines
())
{
if
(
line
.
getLineProduct
()
!=
null
&&
line
.
getLineProduct
().
equals
(
product
)
&&
line
.
getQuantity
().
compareTo
(
BigDecimal
.
ONE
)
>=
0
)
{
if
(
line
.
getLineProduct
()
!=
null
&&
line
.
getLineProduct
().
equals
(
product
)
&&
line
.
getQuantity
().
compareTo
(
BigDecimal
.
ONE
)
>=
0
)
{
containsAutoproduct
=
true
;
containsAutoproduct
=
true
;
}
}
}
}
if
(!
containsAutoproduct
)
{
if
(!
containsAutoproduct
)
{
BillLine
line
=
new
BillLine
(
bill
,
product
,
BigDecimal
.
ONE
);
BillLine
line
=
new
BillLine
(
bill
,
product
,
BigDecimal
.
ONE
);
bill
.
getBillLines
().
add
(
line
);
bill
.
getBillLines
().
add
(
line
);
...
@@ -295,8 +295,9 @@ public class BillBean implements BillBeanLocal {
...
@@ -295,8 +295,9 @@ public class BillBean implements BillBeanLocal {
*/
*/
private
void
createPlaceslots
(
Bill
bill
)
{
private
void
createPlaceslots
(
Bill
bill
)
{
for
(
BillLine
bl
:
bill
.
getBillLines
())
{
for
(
BillLine
bl
:
bill
.
getBillLines
())
{
if
(
bl
==
null
)
if
(
bl
==
null
)
{
return
;
return
;
}
Product
prod
=
bl
.
getLineProduct
();
Product
prod
=
bl
.
getLineProduct
();
if
(
prod
==
null
||
prod
.
getPlaces
()
==
null
||
prod
.
getPlaces
().
isEmpty
())
{
if
(
prod
==
null
||
prod
.
getPlaces
()
==
null
||
prod
.
getPlaces
().
isEmpty
())
{
// Not a place product.
// Not a place product.
...
@@ -304,8 +305,7 @@ public class BillBean implements BillBeanLocal {
...
@@ -304,8 +305,7 @@ public class BillBean implements BillBeanLocal {
}
}
int
count
=
bl
.
getQuantity
().
intValue
();
int
count
=
bl
.
getQuantity
().
intValue
();
Date
now
=
new
Date
();
Date
now
=
new
Date
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
{
PlaceSlot
ps
=
new
PlaceSlot
();
PlaceSlot
ps
=
new
PlaceSlot
();
ps
.
setBill
(
bill
);
ps
.
setBill
(
bill
);
ps
.
setCreated
(
now
);
ps
.
setCreated
(
now
);
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BootstrapBean.java
View file @
25dcabc
...
@@ -38,27 +38,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -38,27 +38,8 @@ public class BootstrapBean implements BootstrapBeanLocal {
@EJB
@EJB
UserFacade
userFacade
;
UserFacade
userFacade
;
public
BootstrapBean
()
{
@EJB
}
private
DBModelFacade
dbModelFacade
;
/**
* Runs a "ALTER TABLE
* <table>
* <statement>" for each of tables.
*
* @param alterStatement
* e.g. "ADD meta json"
* @param tables
* table name strings
* @return1
*/
private
static
final
String
[]
alterTables
(
String
alterStatement
,
String
...
tables
)
{
String
[]
strings
=
new
String
[
tables
.
length
];
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
strings
[
i
]
=
"ALTER TABLE \""
+
tables
[
i
]
+
"\" "
+
alterStatement
;
}
return
strings
;
}
private
static
final
List
<
String
[]>
dbUpdates
=
new
ArrayList
<
String
[]>();
private
static
final
List
<
String
[]>
dbUpdates
=
new
ArrayList
<
String
[]>();
static
{
static
{
...
@@ -260,10 +241,29 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -260,10 +241,29 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE maps ADD COLUMN mime_type TEXT default 'image/png'"
,
"ALTER TABLE maps ADD COLUMN mime_type TEXT default 'image/png'"
,
});
});
}
// start_time timestamp without time zone,
}
@EJB
public
BootstrapBean
()
{
private
DBModelFacade
dbModelFacade
;
}
/**
* Runs a "ALTER TABLE
* <table>
* <statement>" for each of tables.
*
* @param alterStatement
* e.g. "ADD meta json"
* @param tables
* table name strings
* @return1
*/
private
static
final
String
[]
alterTables
(
String
alterStatement
,
String
...
tables
)
{
String
[]
strings
=
new
String
[
tables
.
length
];
for
(
int
i
=
0
;
i
<
tables
.
length
;
i
++)
{
strings
[
i
]
=
"ALTER TABLE \""
+
tables
[
i
]
+
"\" "
+
alterStatement
;
}
return
strings
;
}
@PostConstruct
@PostConstruct
public
void
bootstrap
()
{
public
void
bootstrap
()
{
...
@@ -272,7 +272,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
...
@@ -272,7 +272,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
private
void
doDBUpdates
()
{
private
void
doDBUpdates
()
{
DBModel
dBm
=
dbModelFacade
.
findLastRevision
();
DBModel
dBm
=
dbModelFacade
.
findLastRevision
();
Integer
upIdx
=
(
dbUpdates
.
size
()
-
1
)
;
Integer
upIdx
=
dbUpdates
.
size
()
-
1
;
if
(
dBm
!=
null
)
{
if
(
dBm
!=
null
)
{
Integer
revId
=
dBm
.
getRevision
();
Integer
revId
=
dBm
.
getRevision
();
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/BotBean.java
View file @
25dcabc
...
@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
...
@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
import
javax.ejb.LocalBean
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Singleton
;
import
javax.ejb.Singleton
;
import
javax.ejb.Stateless
;
import
fi.iudex.utils.irc.IrcBot
;
import
fi.iudex.utils.irc.IrcBot
;
...
@@ -19,7 +18,6 @@ public class BotBean implements BotBeanLocal {
...
@@ -19,7 +18,6 @@ public class BotBean implements BotBeanLocal {
* Default constructor.
* Default constructor.
*/
*/
public
BotBean
()
{
public
BotBean
()
{
// TODO Auto-generated constructor stub
}
}
@Override
@Override
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/CardPrintBean.java
View file @
25dcabc
...
@@ -86,8 +86,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -86,8 +86,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
@EJB
@EJB
private
CardTemplateFacade
cardTemplateFacade
;
private
CardTemplateFacade
cardTemplateFacade
;
@EJB
@EJB
private
UserFacade
userfacade
;
@EJB
private
BarcodeBean
barcodeBean
;
private
BarcodeBean
barcodeBean
;
@EJB
@EJB
private
PrintedCardFacade
printedCardFacade
;
private
PrintedCardFacade
printedCardFacade
;
...
@@ -99,7 +97,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
...
@@ -99,7 +97,6 @@ public class CardPrintBean implements CardPrintBeanLocal {
* Default constructor.
* Default constructor.
*/
*/
public
CardPrintBean
()
{
public
CardPrintBean
()
{
// TODO Auto-generated constructor stub
}
}
// TODO: Roles?
// TODO: Roles?
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/JaasBean.java
View file @
25dcabc
...
@@ -95,7 +95,6 @@ public class JaasBean implements MoyaRealmBeanRemote {
...
@@ -95,7 +95,6 @@ public class JaasBean implements MoyaRealmBeanRemote {
user
=
eventUser
.
getUser
();
user
=
eventUser
.
getUser
();
}
}
// no user found, let's see if user is stupid and using email-address instead of username
// no user found, let's see if user is stupid and using email-address instead of username
// this is how it work's in theory, on practice, the fucking UserPrincipal get it's principal
// this is how it work's in theory, on practice, the fucking UserPrincipal get it's principal
// from used loginname, so, let's do this shit on loginview
// from used loginname, so, let's do this shit on loginview
...
@@ -141,7 +140,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
...
@@ -141,7 +140,7 @@ public class JaasBean implements MoyaRealmBeanRemote {
}
}
// jos logitetaan anomuumi, niin uuden tapahtuman luominen hajoaa jännästi.
// jos logitetaan anomuumi, niin uuden tapahtuman luominen hajoaa jännästi.
if
(!
user
.
isAnonymous
())
if
(!
user
.
isAnonymous
())
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_SUCCESSFULL
,
eventUser
,
"User logged in with username: '"
,
username
,
"' eventuser: "
,
eventUser
);
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_SUCCESSFULL
,
eventUser
,
"User logged in with username: '"
,
username
,
"' eventuser: "
,
eventUser
);
}
else
{
}
else
{
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_FAILED
,
eventUserFacade
.
findByLogin
(
User
.
ANONYMOUS_LOGINNAME
),
"Login failed: Username not found: "
,
username
);
secubean
.
sendMessage
(
MoyaEventType
.
LOGIN_FAILED
,
eventUserFacade
.
findByLogin
(
User
.
ANONYMOUS_LOGINNAME
),
"Login failed: Username not found: "
,
username
);
...
@@ -225,8 +224,8 @@ public class JaasBean implements MoyaRealmBeanRemote {
...
@@ -225,8 +224,8 @@ public class JaasBean implements MoyaRealmBeanRemote {
default
:
default
:
throw
new
RuntimeException
(
"Unknown user type: "
+
usertype
);
throw
new
RuntimeException
(
"Unknown user type: "
+
usertype
);
}
}
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
logger
.
warn
(
"UserType authentication "
+
usertype
);
logger
.
warn
(
"UserType authentication "
+
usertype
,
t
);
}
}
}
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PermissionBean.java
View file @
25dcabc
...
@@ -212,10 +212,10 @@ public class PermissionBean implements PermissionBeanLocal {
...
@@ -212,10 +212,10 @@ public class PermissionBean implements PermissionBeanLocal {
public
String
getPrincipal
()
{
public
String
getPrincipal
()
{
Principal
principal
=
context
.
getCallerPrincipal
();
Principal
principal
=
context
.
getCallerPrincipal
();
logger
.
debug
(
"Principal: {}"
,
principal
);
//
logger.debug("Principal: {}", principal);
String
principalName
=
principal
.
getName
();
String
principalName
=
principal
.
getName
();
logger
.
debug
(
"Principal is {}"
,
principalName
);
//
logger.debug("Principal is {}", principalName);
return
principalName
;
return
principalName
;
}
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/beans/SessionMgmtBean.java
View file @
25dcabc
...
@@ -23,6 +23,8 @@ import java.util.HashMap;
...
@@ -23,6 +23,8 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentSkipListMap
;
import
java.util.concurrent.ConcurrentSkipListSet
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.DeclareRoles
;
import
javax.annotation.security.RolesAllowed
;
import
javax.annotation.security.RolesAllowed
;
...
@@ -51,18 +53,16 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
...
@@ -51,18 +53,16 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
private
final
Map
<
String
,
String
>
sessionUsers
=
Collections
.
synchronizedMap
(
new
HashMap
<
String
,
String
>()
);
private
final
ConcurrentSkipListMap
<
String
,
String
>
sessionUsers
=
new
ConcurrentSkipListMap
<
String
,
String
>(
);
private
final
Set
<
HttpSession
>
sessions
=
Collections
.
synchronizedSet
(
new
HashSet
<
HttpSession
>()
);
private
final
ConcurrentSkipListSet
<
HttpSession
>
sessions
=
new
ConcurrentSkipListSet
<
HttpSession
>(
);
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SessionMgmtBean
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SessionMgmtBean
.
class
);
@Override
@Override
public
void
updateSessionUser
(
String
sessionId
,
String
user
)
public
void
updateSessionUser
(
String
sessionId
,
String
user
)
{
{
if
(!
sessionUsers
.
containsKey
(
sessionId
))
if
(!
sessionUsers
.
containsKey
(
sessionId
))
{
{
sessionUsers
.
put
(
sessionId
,
user
);
sessionUsers
.
put
(
sessionId
,
user
);
}
}
}
}
...
@@ -80,8 +80,7 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
...
@@ -80,8 +80,7 @@ public class SessionMgmtBean implements SessionMgmtBeanLocal {
@Override
@Override
@RolesAllowed
(
UserPermission
.
S_MANAGE_HTTP_SESSION
)
@RolesAllowed
(
UserPermission
.
S_MANAGE_HTTP_SESSION
)
public
Set
<
HttpSession
>
getSessions
()
public
Set
<
HttpSession
>
getSessions
()
{
{
return
Collections
.
unmodifiableSet
(
sessions
);
return
Collections
.
unmodifiableSet
(
sessions
);
}
}
...
...
code/moya-beans/ejbModule/fi/codecrew/moya/facade/MenuitemFacade.java
View file @
25dcabc
...
@@ -34,8 +34,7 @@ import fi.codecrew.moya.model.Menuitem;
...
@@ -34,8 +34,7 @@ import fi.codecrew.moya.model.Menuitem;
@LocalBean
@LocalBean
public
class
MenuitemFacade
extends
IntegerPkGenericFacade
<
Menuitem
>
{
public
class
MenuitemFacade
extends
IntegerPkGenericFacade
<
Menuitem
>
{
private
static
final
Logger
logger
=
LoggerFactory
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MenuitemFacade
.
class
);
.
getLogger
(
MenuitemFacade
.
class
);
public
MenuitemFacade
()
{
public
MenuitemFacade
()
{
...
@@ -60,7 +59,7 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
...
@@ -60,7 +59,7 @@ public class MenuitemFacade extends IntegerPkGenericFacade<Menuitem> {
create
(
ret
);
create
(
ret
);
}
}
return
ret
;
return
ret
;
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
logger
.
warn
(
"Exception menussa"
+
url
,
e
);
logger
.
warn
(
"Exception menussa"
+
url
,
e
);
}
}
return
null
;
return
null
;
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/PollAnswer.java
View file @
25dcabc
...
@@ -31,86 +31,83 @@ import javax.persistence.Table;
...
@@ -31,86 +31,83 @@ import javax.persistence.Table;
@Table
(
name
=
"poll_answer"
)
@Table
(
name
=
"poll_answer"
)
public
class
PollAnswer
extends
GenericEntity
implements
Serializable
{
public
class
PollAnswer
extends
GenericEntity
implements
Serializable
{
/**
/**
*
*
*/
*/
private
static
final
long
serialVersionUID
=
-
9170023819401407461L
;
private
static
final
long
serialVersionUID
=
-
9170023819401407461L
;
@Lob
@Lob
@Column
(
name
=
"answer_text"
,
nullable
=
true
)
@Column
(
name
=
"answer_text"
,
nullable
=
true
)
private
String
answerText
=
""
;
private
String
answerText
=
""
;
@Column
(
name
=
"answer_boolean"
,
nullable
=
true
)
@Column
(
name
=
"answer_boolean"
,
nullable
=
true
)
private
Boolean
answerBoolean
=
false
;
private
Boolean
answerBoolean
=
false
;
@ManyToOne
@ManyToOne
@JoinColumn
(
name
=
"possible_answer_id"
,
referencedColumnName
=
PossibleAnswer
.
ID_COLUMN
,
nullable
=
false
)
@JoinColumn
(
name
=
"possible_answer_id"
,
referencedColumnName
=
PossibleAnswer
.
ID_COLUMN
,
nullable
=
false
)
private
PossibleAnswer
choice
;
private
PossibleAnswer
choice
;
@ManyToOne
@ManyToOne
@JoinColumn
(
name
=
"eventuser_id"
,
referencedColumnName
=
EventUser
.
ID_COLUMN
,
nullable
=
false
)
@JoinColumn
(
name
=
"eventuser_id"
,
referencedColumnName
=
EventUser
.
ID_COLUMN
,
nullable
=
false
)
private
EventUser
user
;
private
EventUser
user
;
public
PollAnswer
()
{
public
PollAnswer
()
{
super
();
super
();
}
}
@Override
public
boolean
equals
(
Object
o
)
@Override
{
public
boolean
equals
(
Object
o
)
boolean
ret
=
false
;
{
if
(
o
instanceof
PollAnswer
)
boolean
ret
=
false
;
{
if
(
o
instanceof
PollAnswer
)
{
PollAnswer
objO
=
(
PollAnswer
)
o
;
PollAnswer
objO
=
(
PollAnswer
)
o
;
if
(
super
.
getId
()
==
null
)
if
(
super
.
getId
()
==
null
)
{
{
ret
=
choice
.
equals
(
objO
.
getChoice
());
ret
=
choice
.
equals
(
objO
.
getChoice
());
}
else
{
}
ret
=
super
.
equals
(
o
);
else
}
{
}
ret
=
super
.
equals
(
o
);
return
ret
;
}
}
}
return
ret
;
public
PollAnswer
(
PossibleAnswer
possible
)
{
}
super
();
choice
=
possible
;
public
PollAnswer
(
PossibleAnswer
possible
)
{
}
super
();
choice
=
possible
;
public
void
setAnswerText
(
String
answerText
)
{
}
this
.
answerText
=
answerText
;
}
public
void
setAnswerText
(
String
answerText
)
{
this
.
answerText
=
answerText
;
public
String
getAnswerText
()
{
}
return
answerText
;
}
public
String
getAnswerText
()
{
return
answerText
;
public
void
setChoice
(
PossibleAnswer
choice
)
{
}
this
.
choice
=
choice
;
}
public
void
setChoice
(
PossibleAnswer
choice
)
{
this
.
choice
=
choice
;
public
PossibleAnswer
getChoice
()
{
}
return
choice
;
}
public
PossibleAnswer
getChoice
()
{
return
choice
;
public
void
setUser
(
EventUser
user
)
{
}
this
.
user
=
user
;
}
public
void
setUser
(
EventUser
user
)
{
this
.
user
=
user
;
public
EventUser
getUser
()
{
}
return
user
;
}
public
EventUser
getUser
()
{
return
user
;
public
void
setAnswerBoolean
(
Boolean
answerBoolean
)
{
}
this
.
answerBoolean
=
answerBoolean
;
}
public
void
setAnswerBoolean
(
Boolean
answerBoolean
)
{
this
.
answerBoolean
=
answerBoolean
;
public
Boolean
getAnswerBoolean
()
{
}
return
answerBoolean
;
}
public
Boolean
getAnswerBoolean
()
{
return
answerBoolean
;
}
}
}
code/moya-utils/src/main/java/fi/codecrew/moya/utilities/SystemProperty.java
View file @
25dcabc
...
@@ -13,9 +13,9 @@ import org.slf4j.LoggerFactory;
...
@@ -13,9 +13,9 @@ import org.slf4j.LoggerFactory;
public
enum
SystemProperty
{
public
enum
SystemProperty
{
MOYA_IRC_SERVER
,
MOYA_IRC_SERVER
,
MOYA_IRC_CHANNEL
(
"#moya-debug"
),
MOYA_IRC_CHANNEL
(
"#moya-debug"
),
MOYA_IRC_SERVERPASS
(),
MOYA_IRC_SERVERPASS
(),
;
;
private
final
String
defaultValue
;
private
final
String
defaultValue
;
...
@@ -54,7 +54,7 @@ public enum SystemProperty {
...
@@ -54,7 +54,7 @@ public enum SystemProperty {
Integer
intval
=
null
;
Integer
intval
=
null
;
try
{
try
{
intval
=
Integer
.
parseInt
(
val
);
intval
=
Integer
.
parseInt
(
val
);
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
intval
=
null
;
intval
=
null
;
logger
.
warn
(
"Unable to parse system property '{}' value '{}' as integer. Defaulting to {}"
,
name
(),
val
,
defaultIntegerValue
);
logger
.
warn
(
"Unable to parse system property '{}' value '{}' as integer. Defaulting to {}"
,
name
(),
val
,
defaultIntegerValue
);
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/HostnameFilter.java
View file @
25dcabc
...
@@ -106,12 +106,12 @@ public class HostnameFilter implements Filter {
...
@@ -106,12 +106,12 @@ public class HostnameFilter implements Filter {
Principal
userPrincipal
=
request
.
getUserPrincipal
();
Principal
userPrincipal
=
request
.
getUserPrincipal
();
if
(
userPrincipal
!=
null
)
{
if
(
userPrincipal
!=
null
)
{
String
userString
=
userPrincipal
.
getName
();
String
userString
=
userPrincipal
.
getName
();
MDC
.
put
(
"user"
,
userString
);
MDC
.
put
(
"user"
,
userString
);
MDC
.
put
(
"authtype"
,
authType
!=
null
?
authType
.
name
()
:
"null"
);
MDC
.
put
(
"authtype"
,
authType
!=
null
?
authType
.
name
()
:
"null"
);
}
else
{
}
else
{
MDC
.
put
(
"user"
,
"null"
);
MDC
.
put
(
"user"
,
"null"
);
MDC
.
put
(
"authtype"
,
"null"
);
MDC
.
put
(
"authtype"
,
"null"
);
}
}
}
}
/**
/**
...
@@ -152,13 +152,11 @@ public class HostnameFilter implements Filter {
...
@@ -152,13 +152,11 @@ public class HostnameFilter implements Filter {
try
{
try
{
authtype
=
AuthType
.
ANON
;
authtype
=
AuthType
.
ANON
;
httpRequest
.
login
(
User
.
ANONYMOUS_LOGINNAME
,
null
);
httpRequest
.
login
(
User
.
ANONYMOUS_LOGINNAME
,
null
);
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
logger
.
warn
(
"Error logging in as anonymous... ignoring.. "
,
t
);
logger
.
warn
(
"Error logging in as anonymous... ignoring.. "
,
t
);
}
}
}
}
}
}
else
if
(!
httpRequest
.
getUserPrincipal
().
getName
().
equals
(
User
.
ANONYMOUS_LOGINNAME
))
{
else
if
(!
httpRequest
.
getUserPrincipal
().
getName
().
equals
(
User
.
ANONYMOUS_LOGINNAME
))
{
authtype
=
AuthType
.
USER
;
authtype
=
AuthType
.
USER
;
sessionmgmt
.
updateSessionUser
(
httpRequest
.
getSession
().
getId
(),
httpRequest
.
getUserPrincipal
().
getName
());
sessionmgmt
.
updateSessionUser
(
httpRequest
.
getSession
().
getId
(),
httpRequest
.
getUserPrincipal
().
getName
());
}
}
...
@@ -168,7 +166,7 @@ public class HostnameFilter implements Filter {
...
@@ -168,7 +166,7 @@ public class HostnameFilter implements Filter {
try
{
try
{
insertLoggingContext
((
HttpServletRequest
)
request
,
authtype
);
insertLoggingContext
((
HttpServletRequest
)
request
,
authtype
);
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
if
(
AuthType
.
REST
==
authtype
)
{
if
(
AuthType
.
REST
==
authtype
)
{
logger
.
warn
(
"Caught exception at rest:"
,
t
);
logger
.
warn
(
"Caught exception at rest:"
,
t
);
}
}
...
@@ -191,7 +189,6 @@ public class HostnameFilter implements Filter {
...
@@ -191,7 +189,6 @@ public class HostnameFilter implements Filter {
// }
// }
private
boolean
restAuth
(
HttpServletRequest
httpRequest
,
ServletResponse
response
)
{
private
boolean
restAuth
(
HttpServletRequest
httpRequest
,
ServletResponse
response
)
{
// logger.info("Trying to authenticate for REST query. url {}, params '{}' method: {}, content type {}, and length {}", httpRequest.getRequestURL(), httpRequest.getQueryString(), httpRequest.getMethod(), httpRequest.getContentType(), httpRequest.getContentLength());
StringBuilder
hashBuilder
=
new
StringBuilder
();
StringBuilder
hashBuilder
=
new
StringBuilder
();
hashBuilder
.
append
(
"rest:"
);
hashBuilder
.
append
(
"rest:"
);
...
@@ -207,14 +204,11 @@ public class HostnameFilter implements Filter {
...
@@ -207,14 +204,11 @@ public class HostnameFilter implements Filter {
}
catch
(
ServletException
loginEx
)
{
}
catch
(
ServletException
loginEx
)
{
ret
=
false
;
ret
=
false
;
logger
.
info
(
"Rest api authentication failed! "
,
loginEx
);
logger
.
info
(
"Rest api authentication failed! "
,
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
);
}
}
}
finally
{
}
}
return
ret
;
return
ret
;
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/servlet/IrcServlet.java
View file @
25dcabc
...
@@ -103,8 +103,7 @@ public class IrcServlet extends HttpServlet {
...
@@ -103,8 +103,7 @@ public class IrcServlet extends HttpServlet {
String
ircserver
=
SystemProperty
.
MOYA_IRC_SERVER
.
getValueOrDefault
();
String
ircserver
=
SystemProperty
.
MOYA_IRC_SERVER
.
getValueOrDefault
();
logger
.
info
(
"Got irc server system property {}"
,
ircserver
);
logger
.
info
(
"Got irc server system property {}"
,
ircserver
);
if
(
ircserver
!=
null
)
if
(
ircserver
!=
null
)
{
{
logger
.
info
(
"Starting IRC client with server {}"
,
ircserver
);
logger
.
info
(
"Starting IRC client with server {}"
,
ircserver
);
IrcBot
bot
=
new
IrcBot
(
ircserver
,
6667
,
SystemProperty
.
MOYA_IRC_SERVERPASS
.
getValueOrNull
(),
SystemProperty
.
MOYA_IRC_CHANNEL
.
getValueOrDefault
(),
new
Profile
(
"moyabot"
,
"Moya bot"
,
"moya-bot"
));
IrcBot
bot
=
new
IrcBot
(
ircserver
,
6667
,
SystemProperty
.
MOYA_IRC_SERVERPASS
.
getValueOrNull
(),
SystemProperty
.
MOYA_IRC_CHANNEL
.
getValueOrDefault
(),
new
Profile
(
"moyabot"
,
"Moya bot"
,
"moya-bot"
));
botbean
.
add
(
bot
);
botbean
.
add
(
bot
);
...
@@ -132,7 +131,7 @@ public class IrcServlet extends HttpServlet {
...
@@ -132,7 +131,7 @@ public class IrcServlet extends HttpServlet {
try
{
try
{
b
.
stop
();
b
.
stop
();
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
logger
.
info
(
"Error stopping bot"
,
t
);
logger
.
info
(
"Error stopping bot"
,
t
);
}
}
}
}
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
View file @
25dcabc
...
@@ -56,9 +56,6 @@ public class AuthView extends GenericCDIView {
...
@@ -56,9 +56,6 @@ public class AuthView extends GenericCDIView {
private
NavigationHandler
navihandler
;
private
NavigationHandler
navihandler
;
@EJB
@EJB
private
transient
BootstrapBeanLocal
bootStrapBean
;
@EJB
private
PermissionBeanLocal
permbean
;
private
PermissionBeanLocal
permbean
;
@EJB
@EJB
...
@@ -106,7 +103,7 @@ public class AuthView extends GenericCDIView {
...
@@ -106,7 +103,7 @@ public class AuthView extends GenericCDIView {
return
"/frontpage"
;
return
"/frontpage"
;
}
}
public
void
executeLogoutNoRedirect
()
{
public
void
executeLogoutNoRedirect
()
{
HttpServletRequest
req
=
getRequest
();
HttpServletRequest
req
=
getRequest
();
if
(
permbean
.
isLoggedIn
())
{
if
(
permbean
.
isLoggedIn
())
{
...
@@ -119,8 +116,6 @@ public class AuthView extends GenericCDIView {
...
@@ -119,8 +116,6 @@ public class AuthView extends GenericCDIView {
req
.
getSession
().
invalidate
();
req
.
getSession
().
invalidate
();
}
}
public
void
executeLogin
()
{
public
void
executeLogin
()
{
...
@@ -128,21 +123,21 @@ public class AuthView extends GenericCDIView {
...
@@ -128,21 +123,21 @@ public class AuthView extends GenericCDIView {
}
}
public
void
executeLogin
(
String
onError
)
{
public
void
executeLogin
(
String
onError
)
{
if
(
onError
==
null
)
if
(
onError
==
null
)
{
onError
=
"/auth/loginError"
;
onError
=
"/auth/loginError"
;
}
doLogin
(
onError
);
doLogin
(
onError
);
}
}
private
void
doLogin
(
String
onError
)
{
private
void
doLogin
(
String
onError
)
{
// bootStrapBean.saneDefaults();
// bootStrapBean.saneDefaults();
if
(
login
==
null
||
password
==
null
||
login
.
isEmpty
()
||
password
.
isEmpty
())
{
if
(
login
==
null
||
password
==
null
||
login
.
isEmpty
()
||
password
.
isEmpty
())
{
return
;
return
;
}
}
HttpServletRequest
request
=
getRequest
();
HttpServletRequest
request
=
getRequest
();
if
(
request
.
getUserPrincipal
()
!=
null
)
{
if
(
request
.
getUserPrincipal
()
!=
null
)
{
logger
.
info
(
"Principal not empty. need to logout first"
);
logger
.
info
(
"Principal not empty. need to logout first"
);
...
@@ -156,12 +151,12 @@ public class AuthView extends GenericCDIView {
...
@@ -156,12 +151,12 @@ public class AuthView extends GenericCDIView {
// first, let's make some blindshooting, email-login
// first, let's make some blindshooting, email-login
String
userlogin
=
userbean
.
findUsernameByEmailUsername
(
login
.
trim
());
String
userlogin
=
userbean
.
findUsernameByEmailUsername
(
login
.
trim
());
if
(
userlogin
!=
null
)
if
(
userlogin
!=
null
)
{
login
=
userlogin
;
login
=
userlogin
;
}
try
{
try
{
request
.
login
(
login
.
trim
().
toLowerCase
(),
password
);
request
.
login
(
login
.
trim
().
toLowerCase
(),
password
);
}
catch
(
Throwable
e
)
{
}
catch
(
Exception
e
)
{
logger
.
info
(
"Error while trying to login {}"
,
e
.
getMessage
());
logger
.
info
(
"Error while trying to login {}"
,
e
.
getMessage
());
}
finally
{
}
finally
{
...
@@ -215,7 +210,6 @@ public class AuthView extends GenericCDIView {
...
@@ -215,7 +210,6 @@ public class AuthView extends GenericCDIView {
}
}
public
void
executeAdduserAutoLogin
(
EventUser
user
,
String
password2
)
{
public
void
executeAdduserAutoLogin
(
EventUser
user
,
String
password2
)
{
// TODO Auto-generated method stub
this
.
login
=
user
.
getLogin
();
this
.
login
=
user
.
getLogin
();
this
.
password
=
password2
;
this
.
password
=
password2
;
navihandler
.
saveNavigation
(
"/admin/adduser/update"
);
navihandler
.
saveNavigation
(
"/admin/adduser/update"
);
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/converter/LocaleConverter.java
View file @
25dcabc
...
@@ -39,7 +39,7 @@ public class LocaleConverter implements Converter {
...
@@ -39,7 +39,7 @@ public class LocaleConverter implements Converter {
if
(
value
!=
null
&&
!
value
.
isEmpty
()
&&
!
"null"
.
equals
(
value
))
{
if
(
value
!=
null
&&
!
value
.
isEmpty
()
&&
!
"null"
.
equals
(
value
))
{
try
{
try
{
ret
=
Locale
.
forLanguageTag
(
value
);
ret
=
Locale
.
forLanguageTag
(
value
);
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
logger
.
warn
(
"Error parsing locale: '{}'"
,
value
);
logger
.
warn
(
"Error parsing locale: '{}'"
,
value
);
}
}
}
}
...
@@ -57,10 +57,4 @@ public class LocaleConverter implements Converter {
...
@@ -57,10 +57,4 @@ public class LocaleConverter implements Converter {
return
ret
;
return
ret
;
}
}
public
static
void
main
(
String
[]
ad
)
{
Locale
loc
=
new
Locale
(
"fi"
,
"FI"
);
System
.
out
.
println
(
loc
.
toLanguageTag
());
System
.
out
.
println
(
loc
.
toString
());
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/helper/HttpSessionWrapper.java
View file @
25dcabc
...
@@ -58,7 +58,7 @@ public class HttpSessionWrapper implements HttpSession
...
@@ -58,7 +58,7 @@ public class HttpSessionWrapper implements HttpSession
Date
ret
=
null
;
Date
ret
=
null
;
try
{
try
{
ret
=
new
Date
(
session
.
getCreationTime
());
ret
=
new
Date
(
session
.
getCreationTime
());
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
ret
=
null
;
ret
=
null
;
}
}
return
ret
;
return
ret
;
...
@@ -78,7 +78,7 @@ public class HttpSessionWrapper implements HttpSession
...
@@ -78,7 +78,7 @@ public class HttpSessionWrapper implements HttpSession
Date
ret
=
null
;
Date
ret
=
null
;
try
{
try
{
ret
=
new
Date
(
session
.
getLastAccessedTime
());
ret
=
new
Date
(
session
.
getLastAccessedTime
());
}
catch
(
Throwable
t
)
{
}
catch
(
Exception
t
)
{
ret
=
null
;
ret
=
null
;
}
}
return
ret
;
return
ret
;
...
...
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