Commit fbb74bd0 by Tuomas Riihimäki

Added security messages

1 parent 5db922ed
...@@ -27,13 +27,13 @@ public class UserFacade extends GenericFacade<Integer, User>{ ...@@ -27,13 +27,13 @@ public class UserFacade extends GenericFacade<Integer, User>{
public User findByLogin(String login) { public User findByLogin(String login) {
// TODO: Bug in glassfish.... change when fixed... // TODO: Bug in glassfish.... change when fixed...
// TypedQuery<User> q = em.createNamedQuery("User.findByLogin", TypedQuery<User> q = em.createNamedQuery("User.findByLogin",
// User.class); User.class);
// q.setParameter("login", login);
// return q.getSingleResult();
TypedQuery<User> q = em.createQuery("SELECT u FROM User u WHERE u.login = :login", User.class);
q.setParameter("login", login); q.setParameter("login", login);
return getSingleNullableResult(q); return getSingleNullableResult(q);
// TypedQuery<User> q = em.createQuery("SELECT u FROM User u WHERE u.login = :login", User.class);
// q.setParameter("login", login);
// return getSingleNullableResult(q);
} }
......
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:users="http://java.sun.com/jsf/composite/tools/user" xmlns:c="http://java.sun.com/jsp/jstl/core"> <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head> <h:head>
<title></title> <title></title>
</h:head> </h:head>
...@@ -11,19 +16,7 @@ ...@@ -11,19 +16,7 @@
<ui:define name="header">Add new user</ui:define> <ui:define name="header">Add new user</ui:define>
<ui:define name="content"> <ui:define name="content">
<form method="post" action="j_security_check"> <tools:login />
<h:panelGrid columns="2">
<h:outputText value="#{i18n['login.username']}" />
<input type="text" name="j_username" />
<h:outputText value="#{i18n['login.password']}" />
<input type="password" name="j_password" />
</h:panelGrid>
<h:outputText>
<input type="submit" value="#{i18n['login.submit']}" />
</h:outputText>
</form>
</ui:define> </ui:define>
<ui:define name="footer">footer</ui:define> <ui:define name="footer">footer</ui:define>
</ui:composition> </ui:composition>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Insomnia - Login</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<form method="post" action="j_security_check">
<table>
<tr>
<td>Username:</td>
<td><input type="text" name="j_username" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="j_password" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
\ No newline at end of file
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<composite:implementation> <composite:implementation>
<h:form> <h:form>
<h:commandButton action="#{sessionHandler.logout}" value="#{i18n['logout']}" /> <h:commandLink action="#{sessionHandler.logout}" value="#{i18n['logout']}" />
</h:form> </h:form>
</composite:implementation> </composite:implementation>
......
...@@ -13,6 +13,7 @@ import javax.servlet.http.HttpSession; ...@@ -13,6 +13,7 @@ import javax.servlet.http.HttpSession;
import fi.insomnia.bortal.HostnameFilter; import fi.insomnia.bortal.HostnameFilter;
import fi.insomnia.bortal.beans.RolePermission; import fi.insomnia.bortal.beans.RolePermission;
import fi.insomnia.bortal.beans.SecurityBeanLocal;
import fi.insomnia.bortal.beans.SessionHandlerBeanLocal; import fi.insomnia.bortal.beans.SessionHandlerBeanLocal;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
...@@ -28,6 +29,9 @@ public class SessionHandler { ...@@ -28,6 +29,9 @@ public class SessionHandler {
private SessionHandlerBeanLocal handlerbean; private SessionHandlerBeanLocal handlerbean;
private User user = null; private User user = null;
@EJB
private SecurityBeanLocal secubean;
/** Creates a new instance of SessionHandler */ /** Creates a new instance of SessionHandler */
public SessionHandler() { public SessionHandler() {
} }
...@@ -81,8 +85,11 @@ public class SessionHandler { ...@@ -81,8 +85,11 @@ public class SessionHandler {
if (user == null) { if (user == null) {
this.user = getUser(); this.user = getUser();
} else if (canExecute("impersonateUser")) { } else if (canExecute("user")) {
secubean.logMessage(handlerbean.getCurrentUser(), "Successfully impersonating user id: " + user.getId() + " and login: " + user.getLogin());
this.user = user; this.user = user;
} else {
secubean.logMessage(handlerbean.getCurrentUser(), "User tried to impersonate as id: "+user.getId()+" login: "+user.getLogin()+" but did not have enough rights");
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!