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 2a7c9cde
authored
Mar 21, 2010
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login and logout stuff
1 parent
b1b30814
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
173 additions
and
6 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/SessionHandlerBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/SessionHandlerBeanLocal.java
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
code/LanBortalWeb/WebContent/resources/tools/login/login.xhtml
code/LanBortalWeb/WebContent/resources/tools/login/logout.xhtml
code/LanBortalWeb/WebContent/resources/tools/loginLogout.xhtml
code/LanBortalWeb/src/accessRightTargets
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/SessionHandlerBean.java
View file @
2a7c9cd
...
@@ -89,4 +89,12 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
...
@@ -89,4 +89,12 @@ public class SessionHandlerBean implements SessionHandlerBeanLocal {
return
false
;
return
false
;
}
}
public
User
tryLogin
(
String
username
,
String
password
)
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
}
public
User
getDefaultUser
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
}
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/SessionHandlerBeanLocal.java
View file @
2a7c9cd
...
@@ -9,4 +9,13 @@ public interface SessionHandlerBeanLocal {
...
@@ -9,4 +9,13 @@ public interface SessionHandlerBeanLocal {
boolean
hasPermission
(
String
target
,
User
user
,
RolePermission
permission
);
boolean
hasPermission
(
String
target
,
User
user
,
RolePermission
permission
);
/**
*
* @param username
* @param password
* @return User on success, null on fail
*/
User
tryLogin
(
String
username
,
String
password
);
User
getDefaultUser
();
}
}
code/LanBortalWeb/WebContent/WEB-INF/faces-config.xml
View file @
2a7c9cd
...
@@ -67,9 +67,22 @@
...
@@ -67,9 +67,22 @@
<from-outcome>
permissionDenied
</from-outcome>
<from-outcome>
permissionDenied
</from-outcome>
<to-view-id>
/permissionDenied.xhtml
</to-view-id>
<to-view-id>
/permissionDenied.xhtml
</to-view-id>
</navigation-case>
</navigation-case>
<navigation-case>
<from-outcome>
logout
</from-outcome>
<to-view-id>
/NotImplementedYet.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
loginSuccess
</from-outcome>
<to-view-id>
/NotImplementedYet.xhtml
</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>
loginFailed
</from-outcome>
<to-view-id>
/NotImplementedYet.xhtml
</to-view-id>
</navigation-case>
</navigation-rule>
</navigation-rule>
</faces-config>
</faces-config>
code/LanBortalWeb/WebContent/resources/tools/login/login.xhtml
0 → 100644
View file @
2a7c9cd
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<composite:interface>
<composite:attribute
type=
"java.lang.Boolean"
name=
"isOneliner"
required=
"false"
/>
</composite:interface>
<composite:implementation>
<h:form>
<c:choose>
<c:when
test=
"#{isOneliner}"
>
<h:inputText
value=
"#{sessionHandler.username}"
/>
<h:inputSecret
value=
"#{sessionHandler.password}"
/>
<h:commandButton
action=
"#{sessionHandler.login}"
/>
</c:when>
<c:otherwise>
<h:panelGrid
columns=
"2"
>
<h:inputText
value=
"#{sessionHandler.username}"
/>
<h:inputSecret
value=
"#{sessionHandler.password}"
/>
<h:commandButton
action=
"#{sessionHandler.login}"
/>
</h:panelGrid>
</c:otherwise>
</c:choose>
</h:form>
</composite:implementation>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/resources/tools/login/logout.xhtml
0 → 100644
View file @
2a7c9cd
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:commandButton
action=
"#{sessionHandler.logout}"
value=
"#{i18n['logout']}"
/>
</h:form>
</composite:implementation>
</html>
\ No newline at end of file
code/LanBortalWeb/WebContent/resources/tools/loginLogout.xhtml
0 → 100644
View file @
2a7c9cd
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:composite=
"http://java.sun.com/jsf/composite"
xmlns:ui=
"http://java.sun.com/jsf/facelets"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:login=
"http://java.sun.com/jsf/composite/tools/login"
xmlns:tools=
"http://java.sun.com/jsf/composite/tools"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<tools:canRead
target=
"login"
>
<f:facet
name=
"errorMessage"
>
<login:logout
/>
</f:facet>
<login:login
isOneliner=
"true"
/>
</tools:canRead>
</composite:implementation>
</html>
\ No newline at end of file
code/LanBortalWeb/src/accessRightTargets
View file @
2a7c9cd
userManagement
userManagement
roleManagement
roleManagement
\ No newline at end of file
login
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
View file @
2a7c9cd
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
* To change this template, choose Tools | Templates
* To change this template, choose Tools | Templates
* and open the template in the editor.
* and open the template in the editor.
*/
*/
package
fi
.
insomnia
.
bortal
.
handler
;
package
fi
.
insomnia
.
bortal
.
handler
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
...
@@ -24,7 +23,9 @@ public class SessionHandler {
...
@@ -24,7 +23,9 @@ public class SessionHandler {
@EJB
@EJB
private
SessionHandlerBeanLocal
handlerbean
;
private
SessionHandlerBeanLocal
handlerbean
;
private
User
user
;
private
User
user
=
null
;
private
String
username
=
""
;
private
String
password
=
""
;
/** Creates a new instance of SessionHandler */
/** Creates a new instance of SessionHandler */
public
SessionHandler
()
{
public
SessionHandler
()
{
...
@@ -66,11 +67,56 @@ public class SessionHandler {
...
@@ -66,11 +67,56 @@ public class SessionHandler {
}
}
public
User
getUser
()
{
public
User
getUser
()
{
if
(
user
==
null
)
{
user
=
handlerbean
.
getDefaultUser
();
}
return
user
;
return
user
;
}
}
public
boolean
hasLoggedIn
()
{
public
String
logout
()
{
throw
new
UnsupportedOperationException
();
user
=
null
;
return
"logout"
;
}
public
String
login
()
{
user
=
handlerbean
.
tryLogin
(
username
,
password
);
if
(
user
==
null
)
{
return
"loginFailed"
;
}
else
{
return
"loginSuccess"
;
}
}
/**
* @return the username
*/
public
String
getUsername
()
{
return
username
;
}
/**
* @param username the username to set
*/
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
/**
* @return the password
*/
public
String
getPassword
()
{
return
password
;
}
}
/**
* @param password the password to set
*/
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
}
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