Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8f2f7ea9
authored
Jun 25, 2018
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logging in with invalid password, and other ui error handlings
1 parent
14334dff
Pipeline
#72
passed
in 0 seconds
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
20 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
code/moya-terminal-web/src/main/java/fi/codecrew/moya/terminal/view/AbstractView.java
code/moya-web/src/main/java/fi/codecrew/moya/exceptions/BortalExceptionHandler.java
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/MenuBean.java
View file @
8f2f7ea
...
@@ -127,6 +127,8 @@ public class MenuBean implements MenuBeanLocal {
...
@@ -127,6 +127,8 @@ public class MenuBean implements MenuBeanLocal {
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/resetmailSent"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/resetmailSent"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/passwordChanged"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/passwordChanged"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/notauthorized"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/auth/notauthorized"
),
null
).
setVisible
(
false
);
usermenu
.
addPage
(
menuitemfacade
.
findOrCreate
(
"/viewExpired"
),
null
).
setVisible
(
false
);
MenuNavigation
userEvent
=
usermenu
.
addPage
(
null
,
null
);
MenuNavigation
userEvent
=
usermenu
.
addPage
(
null
,
null
);
userEvent
.
setKey
(
"topnavi.userevent"
);
userEvent
.
setKey
(
"topnavi.userevent"
);
...
...
code/moya-terminal-web/src/main/java/fi/codecrew/moya/terminal/view/AbstractView.java
View file @
8f2f7ea
...
@@ -108,7 +108,7 @@ public abstract class AbstractView implements Serializable {
...
@@ -108,7 +108,7 @@ public abstract class AbstractView implements Serializable {
viewidbuilder
.
toString
());
viewidbuilder
.
toString
());
// navihandler.navigateTo("/permissionDenied");
// navihandler.navigateTo("/permissionDenied");
fcont
.
getApplication
().
getNavigationHandler
()
fcont
.
getApplication
().
getNavigationHandler
()
.
handleNavigation
(
fcont
,
null
,
"/permissionDenied"
);
.
handleNavigation
(
fcont
,
null
,
"/permissionDenied
?faces-redirect=true
"
);
}
}
return
ret
;
return
ret
;
...
...
code/moya-web/src/main/java/fi/codecrew/moya/exceptions/BortalExceptionHandler.java
View file @
8f2f7ea
...
@@ -23,6 +23,7 @@ import java.util.Map;
...
@@ -23,6 +23,7 @@ import java.util.Map;
import
javax.ejb.AccessLocalException
;
import
javax.ejb.AccessLocalException
;
import
javax.ejb.EJBAccessException
;
import
javax.ejb.EJBAccessException
;
import
javax.enterprise.context.NonexistentConversationException
;
import
javax.faces.FacesException
;
import
javax.faces.FacesException
;
import
javax.faces.application.NavigationHandler
;
import
javax.faces.application.NavigationHandler
;
import
javax.faces.application.ViewExpiredException
;
import
javax.faces.application.ViewExpiredException
;
...
@@ -50,43 +51,53 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
...
@@ -50,43 +51,53 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
return
wrapped
;
return
wrapped
;
}
}
@Override
@Override
public
void
handle
()
throws
FacesException
{
public
void
handle
()
throws
FacesException
{
Iterator
<
ExceptionQueuedEvent
>
i
=
getUnhandledExceptionQueuedEvents
().
iterator
();
Iterator
<
ExceptionQueuedEvent
>
i
=
getUnhandledExceptionQueuedEvents
().
iterator
();
while
(
i
.
hasNext
())
{
while
(
i
.
hasNext
())
{
ExceptionQueuedEvent
event
=
i
.
next
();
ExceptionQueuedEvent
event
=
i
.
next
();
ExceptionQueuedEventContext
context
=
(
ExceptionQueuedEventContext
)
event
.
getSource
();
ExceptionQueuedEventContext
context
=
(
ExceptionQueuedEventContext
)
event
.
getSource
();
Throwable
t
=
context
.
getException
();
Throwable
t
=
context
.
getException
();
logger
.
debug
(
"Found exception! handing it: {}"
,
t
.
getClass
().
toString
());
logger
.
debug
(
"Found exception! handing it: {}"
,
t
.
getClass
().
toString
());
if
(
t
instanceof
ViewExpiredException
)
{
if
(
checkException
(
i
,
t
)){
logger
.
debug
(
"ViewExpiredException details"
,
t
);
return
;
errorpage
(
i
,
t
,
"/viewExpired"
);
}
}
Throwable
cause
=
t
.
getCause
();
Throwable
cause
=
t
.
getCause
();
for
(
int
loop
=
0
;
loop
<
20
&&
cause
!=
null
;
++
loop
)
{
for
(
int
loop
=
0
;
loop
<
20
&&
cause
!=
null
;
++
loop
)
{
logger
.
debug
(
"Cause not null, but {}: {}, checking"
+
cause
.
getClass
(),
cause
.
getMessage
());
logger
.
debug
(
"Cause not null, but {}: {}, checking "
+
cause
.
getClass
(),
cause
.
getMessage
());
if
(
cause
instanceof
EJBAccessException
||
if
(
checkException
(
i
,
cause
)){
cause
instanceof
AccessLocalException
)
{
return
;
logger
.
debug
(
"Found Permission Denied cause: {}, {}"
,
cause
.
getClass
(),
cause
.
getMessage
());
// errorpage(i, t, "permissionDenied");
}
}
cause
=
cause
.
getCause
();
cause
=
cause
.
getCause
();
}
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents.
// Therefore, let the parent handle them.
getWrapped
().
handle
();
getWrapped
().
handle
();
}
}
private
void
errorpage
(
Iterator
<
ExceptionQueuedEvent
>
i
,
Throwable
t
,
String
navigateTo
)
{
private
boolean
checkException
(
Iterator
<
ExceptionQueuedEvent
>
i
,
Throwable
t
)
{
if
(
t
instanceof
ViewExpiredException
)
{
logger
.
debug
(
"ViewExpiredException details"
,
t
);
errorpage
(
i
,
t
,
"/viewExpired?faces-redirect=true"
);
}
else
if
(
t
instanceof
NonexistentConversationException
)
{
logger
.
debug
(
"Server restart? Got nonexistent converstation"
,
t
);
errorpage
(
i
,
t
,
"/viewExpired?faces-redirect=true"
);
}
else
if
(
t
instanceof
EJBAccessException
||
t
instanceof
AccessLocalException
)
{
logger
.
debug
(
"Found Permission Denied cause: {}, {}"
,
t
.
getClass
(),
t
.
getMessage
());
// We should handler permission checking elsewhere. Lets just pass the error through
//errorpage(i, t, "/permissionDenied?faces-redirect=true");
}
else
{
return
false
;
}
return
true
;
}
private
void
errorpage
(
Iterator
<
ExceptionQueuedEvent
>
iter
,
Throwable
t
,
String
navigateTo
)
{
logger
.
info
(
"navigating to {} because root exception: {}"
,
navigateTo
,
t
.
getClass
());
logger
.
info
(
"navigating to {} because root exception: {}"
,
navigateTo
,
t
.
getClass
());
ViewExpiredException
vee
=
null
;
ViewExpiredException
vee
=
null
;
if
(
t
instanceof
ViewExpiredException
)
{
if
(
t
instanceof
ViewExpiredException
)
{
...
@@ -106,7 +117,9 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
...
@@ -106,7 +117,9 @@ public class BortalExceptionHandler extends ExceptionHandlerWrapper {
nav
.
handleNavigation
(
fc
,
null
,
navigateTo
);
nav
.
handleNavigation
(
fc
,
null
,
navigateTo
);
fc
.
renderResponse
();
fc
.
renderResponse
();
}
finally
{
}
finally
{
i
.
remove
();
if
(
iter
!=
null
)
{
iter
.
remove
();
}
}
}
}
}
}
}
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/user/AuthView.java
View file @
8f2f7ea
...
@@ -121,8 +121,8 @@ public class AuthView extends GenericCDIView {
...
@@ -121,8 +121,8 @@ public class AuthView extends GenericCDIView {
}
}
public
void
executeLogin
(
String
onError
)
{
public
void
executeLogin
(
String
onError
)
{
if
(
onError
==
null
)
{
if
(
onError
==
null
||
onError
.
isEmpty
()
)
{
onError
=
"/auth/loginError"
;
onError
=
"/auth/loginError
?faces-redirect=true
"
;
}
}
doLogin
(
onError
);
doLogin
(
onError
);
}
}
...
@@ -188,9 +188,10 @@ public class AuthView extends GenericCDIView {
...
@@ -188,9 +188,10 @@ public class AuthView extends GenericCDIView {
try
{
try
{
request
.
logout
();
request
.
logout
();
request
.
getSession
().
invalidate
();
request
.
getSession
().
invalidate
();
request
.
getSession
(
true
);
//navihandler.forward("/frontpage?faces-redirect=true");
//navihandler.forward("/frontpage?faces-redirect=true");
if
(
onError
!=
null
)
{
if
(
onError
!=
null
)
{
logger
.
warn
(
"Redirecting to error"
,
onError
);
logger
.
warn
(
"Redirecting to error
: '{}'
"
,
onError
);
navihandler
.
forward
(
onError
);
navihandler
.
forward
(
onError
);
}
}
}
catch
(
ServletException
e
)
{
}
catch
(
ServletException
e
)
{
...
...
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