r153 - in trunk: . faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin faxtomail-ui-web/src/main/resources faxtomail-ui-web/src/main/webapp/WEB-INF/content faxtomail-ui-web/src/main/weba
Author: echatellier Date: 2014-06-09 16:38:49 +0200 (Mon, 09 Jun 2014) New Revision: 153 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/153 Log: Add authentication form Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/AuthenticationException.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailLoginInterceptor.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LogoutAction.java trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java trunk/faxtomail-ui-web/src/main/resources/struts.xml trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp trunk/pom.xml Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/LdapService.java 2014-06-09 14:38:49 UTC (rev 153) @@ -35,13 +35,13 @@ import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; -import com.franciaflex.faxtomail.FaxToMailConfiguration; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserGroup; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserGroupTopiaDao; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserImpl; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserTopiaDao; import com.franciaflex.faxtomail.services.FaxToMailServiceSupport; +import com.franciaflex.faxtomail.services.service.ldap.AuthenticationException; import com.franciaflex.faxtomail.services.service.ldap.LdapUser; import com.unboundid.ldap.sdk.LDAPConnection; import com.unboundid.ldap.sdk.LDAPException; @@ -219,4 +219,43 @@ String result = StringUtils.join(part, '/'); return result; } + + /** + * Return user for given user id. + * + * @param userTopiaId userTopiaId + * @return user bean (without password) + */ + public FaxToMailUser getUserBean(String userTopiaId) { + FaxToMailUser result = null; + + FaxToMailUserTopiaDao faxtomailUserDao = getPersistenceContext().getFaxToMailUserDao(); + FaxToMailUser user = faxtomailUserDao.findByTopiaId(userTopiaId); + if (user != null) { + Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class); + result = new FaxToMailUserImpl(); + faxToMailUserBinder.copyExcluding(user, result); + } + return result; + } + + /** + * Authenticate user. + * + * @param login login + * @param password password + * @return authenticated user + * @throws AuthenticationException if authentication fails + */ + public FaxToMailUser authenticateUser(String login, String password) throws AuthenticationException { + FaxToMailUserTopiaDao faxtomailUserDao = getPersistenceContext().getFaxToMailUserDao(); + FaxToMailUser user = faxtomailUserDao.forAll().findAnyOrNull(); + FaxToMailUser result = null; + if (user != null) { + Binder<FaxToMailUser, FaxToMailUser> faxToMailUserBinder = BinderFactory.newBinder(FaxToMailUser.class); + result = new FaxToMailUserImpl(); + faxToMailUserBinder.copyExcluding(user, result); + } + return result; + } } Added: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/AuthenticationException.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/AuthenticationException.java (rev 0) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/AuthenticationException.java 2014-06-09 14:38:49 UTC (rev 153) @@ -0,0 +1,36 @@ +package com.franciaflex.faxtomail.services.service.ldap; + +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +public class AuthenticationException extends Exception { + + public AuthenticationException(String message, Throwable cause) { + super(message, cause); + } + + public AuthenticationException(String message) { + super(message); + } +} Property changes on: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ldap/AuthenticationException.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailActionSupport.java 2014-06-09 14:38:49 UTC (rev 153) @@ -34,6 +34,7 @@ import com.franciaflex.faxtomail.FaxToMailConfiguration; import com.franciaflex.faxtomail.persistence.entities.FaxToMailEntityEnum; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFolder; import com.franciaflex.faxtomail.persistence.entities.MailFolderAbstract; import com.franciaflex.faxtomail.web.json.HibernateProxyTypeAdapter; @@ -76,29 +77,18 @@ return session; } - public boolean needAuthentication() { - return true; + public void setSession(FaxToMailSession session) { + this.session = session; } - public boolean rememberAsLastAction() { - return true; + public boolean isAuthenticated() { + return session.getAuthenticatedUserId() != null; } - public String getId(TopiaEntity entity) { - String id = ""; - - if (entity.getTopiaId() != null) { - id = Integer.toString(entity.getTopiaId().hashCode()); - } - - return id; - + public FaxToMailUser getAuthenticatedUser() { + return session.getAuthenticatedFaxToMailUser(); } - public void setSession(FaxToMailSession session) { - this.session = session; - } - public String toJson(Object element) { String result = null; try { Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailInterceptor.java 2014-06-09 14:38:49 UTC (rev 153) @@ -24,24 +24,28 @@ * #L% */ +import java.beans.PropertyDescriptor; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.beans.BeanUtil; + import com.franciaflex.faxtomail.FaxToMailApplicationContext; import com.franciaflex.faxtomail.FaxToMailConfiguration; import com.franciaflex.faxtomail.persistence.entities.FaxToMailTopiaPersistenceContext; +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.services.FaxToMailService; import com.franciaflex.faxtomail.services.FaxToMailServiceContext; +import com.franciaflex.faxtomail.services.service.LdapService; import com.google.common.base.Preconditions; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ActionProxy; import com.opensymphony.xwork2.interceptor.Interceptor; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.beans.BeanUtil; -import java.beans.PropertyDescriptor; -import java.util.Map; -import java.util.Set; - public class FaxToMailInterceptor implements Interceptor { private static final Log log = LogFactory.getLog(FaxToMailInterceptor.class); @@ -69,29 +73,20 @@ FaxToMailServiceContext serviceContext = newServiceContext(invocation); FaxToMailSession faxToMailSession = getFaxToMailSession(invocation); + populateUser(faxToMailSession, serviceContext); if (CollectionUtils.isNotEmpty(faxToMailSession.getMessages())) { - for (String message : faxToMailSession.getMessages()) { - faxToMailAction.addActionMessage(message); - } - faxToMailSession.getMessages().clear(); - } if (CollectionUtils.isNotEmpty(faxToMailSession.getErrorMessages())) { - for (String message : faxToMailSession.getErrorMessages()) { - faxToMailAction.addActionError(message); - } - faxToMailSession.getErrorMessages().clear(); - } Set<PropertyDescriptor> descriptors = @@ -102,45 +97,32 @@ for (PropertyDescriptor propertyDescriptor : descriptors) { Class<?> propertyType = propertyDescriptor.getPropertyType(); - Object toInject = null; if (FaxToMailService.class.isAssignableFrom(propertyType)) { - Class<? extends FaxToMailService> serviceClass = (Class<? extends FaxToMailService>) propertyType; - toInject = serviceContext.newService(serviceClass); } else if (FaxToMailSession.class.isAssignableFrom(propertyType)) { - toInject = faxToMailSession; } else if (FaxToMailConfiguration.class.isAssignableFrom(propertyType)) { - toInject = getFaxToMailApplicationContext(invocation).getApplicationConfig(); - } if (toInject != null) { - if (log.isTraceEnabled()) { log.trace("injecting " + toInject + " in action " + action); } - propertyDescriptor.getWriteMethod().invoke(action, toInject); - } } try { - return invocation.invoke(); - } finally { - serviceContext.getPersistenceContext().close(); - } } else { @@ -153,6 +135,15 @@ } + protected void populateUser(FaxToMailSession faxToMailSession, FaxToMailServiceContext serviceContext) { + if (StringUtils.isNotBlank(faxToMailSession.getAuthenticatedUserId())) { + LdapService ldapService = serviceContext.newService(LdapService.class); + FaxToMailUser user = ldapService.getUserBean(faxToMailSession.getAuthenticatedUserId()); + faxToMailSession.setAuthenticatedFaxToMailUser(user); + } + + } + protected void saveLastAction(ActionInvocation invocation) { Map<String, Object> session = invocation.getInvocationContext().getSession(); ActionProxy proxy = invocation.getProxy(); @@ -170,11 +161,8 @@ FaxToMailSession session = (FaxToMailSession) invocation.getInvocationContext().getSession().get(FaxToMailSession.SESSION_PARAMETER); if (session == null) { - session = new FaxToMailSession(); - invocation.getInvocationContext().getSession().put(FaxToMailSession.SESSION_PARAMETER, session); - } return session; @@ -199,23 +187,17 @@ protected FaxToMailServiceContext newServiceContext(ActionInvocation invocation) { FaxToMailApplicationContext extranetEncAhiApplicationContext = getFaxToMailApplicationContext(invocation); - FaxToMailTopiaPersistenceContext persistenceContext = extranetEncAhiApplicationContext.newPersistenceContext(); - FaxToMailServiceContext serviceContext = extranetEncAhiApplicationContext.newServiceContext(persistenceContext); return serviceContext; - } @Override public void destroy() { - if (log.isInfoEnabled()) { log.info("destroy " + this); } - } - } Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailLoginInterceptor.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailLoginInterceptor.java (rev 0) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailLoginInterceptor.java 2014-06-09 14:38:49 UTC (rev 153) @@ -0,0 +1,44 @@ +package com.franciaflex.faxtomail.web; + +import org.apache.commons.lang3.StringUtils; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.interceptor.Interceptor; + +/** + * Authentication interceptor. + * + * @author Eric Chatellier + */ +public class FaxToMailLoginInterceptor implements Interceptor { + + /** serialVersionUID. */ + private static final long serialVersionUID = -5760224375232019437L; + + /* + * @see com.opensymphony.xwork2.interceptor.Interceptor#init() + */ + @Override + public void init() { + + } + + public String intercept(ActionInvocation invocation) throws Exception { + ActionContext context = invocation.getInvocationContext(); + FaxToMailSession session = (FaxToMailSession) context.getSession().get(FaxToMailSession.SESSION_PARAMETER); + if (session == null || StringUtils.isBlank(session.getAuthenticatedUserId())) { + return "redirect-to-login"; + } else { + return invocation.invoke(); + } + } + + /* + * @see com.opensymphony.xwork2.interceptor.Interceptor#destroy() + */ + @Override + public void destroy() { + + } +} Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailLoginInterceptor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/FaxToMailSession.java 2014-06-09 14:38:49 UTC (rev 153) @@ -24,6 +24,7 @@ * #L% */ +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.google.common.collect.Lists; import java.io.Serializable; @@ -37,8 +38,10 @@ protected Collection<String> errorMessages; -// protected AuthenticatedExtranetUser authenticatedExtranetUser; + protected String authenticatedUserId; + protected transient FaxToMailUser authenticatedFaxToMailUser; + public Collection<String> getMessages() { if (messages == null) { messages = Lists.newLinkedList(); @@ -61,16 +64,24 @@ getErrorMessages().add(errorMessage); } - public void logout() { -// authenticatedExtranetUser.logout(); -// authenticatedExtranetUser = null; + public String getAuthenticatedUserId() { + return authenticatedUserId; } -// public AuthenticatedExtranetUser getAuthenticatedExtranetUser() { -// return authenticatedExtranetUser; -// } + public void setAuthenticatedUserId(String authenticatedUserId) { + this.authenticatedUserId = authenticatedUserId; + } -// public void setAuthenticatedExtranetUser(AuthenticatedExtranetUser authenticatedExtranetUser) { -// this.authenticatedExtranetUser = authenticatedExtranetUser; -// } + public FaxToMailUser getAuthenticatedFaxToMailUser() { + return authenticatedFaxToMailUser; + } + + public void setAuthenticatedFaxToMailUser(FaxToMailUser authenticatedFaxToMailUser) { + this.authenticatedFaxToMailUser = authenticatedFaxToMailUser; + } + + public void logout() { + setAuthenticatedUserId(null); + setAuthenticatedFaxToMailUser(null); + } } Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/IndexAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -25,44 +25,23 @@ */ import com.franciaflex.faxtomail.web.FaxToMailActionSupport; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; +@InterceptorRefs({ + @InterceptorRef("loginInterceptor"), + @InterceptorRef("faxToMailStack") +}) public class IndexAction extends FaxToMailActionSupport { private static final Log log = LogFactory.getLog(IndexAction.class); -// protected ApplicationSettingsService service; -// -// protected ApplicationSettings applicationSettings; - -// public void setService(ApplicationSettingsService service) { -// this.service = service; -// } - @Override public String execute() { - -// applicationSettings = service.getApplicationSettings(); - return SUCCESS; } -// public ApplicationSettings getApplicationSettings() { -// return applicationSettings; -// } - - public String getWelcomeText() { - -// String text = applicationSettings.getWelcomeText(); - String text = "Hello world"; - - text = "<p>" + text.replaceAll("\\r?\\n\\r?\\n", "</p><p>") + "</p>"; - - text = text.replaceAll("\\r?\\n", "<br/>"); - - return text; - - } - } Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java (rev 0) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -0,0 +1,80 @@ +package com.franciaflex.faxtomail.web.action; + +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Result; + +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.services.service.LdapService; +import com.franciaflex.faxtomail.services.service.ldap.AuthenticationException; +import com.franciaflex.faxtomail.web.FaxToMailActionSupport; + +public class LoginAction extends FaxToMailActionSupport { + + private static final Log log = LogFactory.getLog(LoginAction.class); + + protected LdapService ldapService; + + protected String login; + + protected String password; + + public void setLdapService(LdapService ldapService) { + this.ldapService = ldapService; + } + + public void setLogin(String login) { + this.login = login; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + @Action("login-input") + public String input() throws Exception { + return super.input(); + } + + @Override + @Action(results = { + @Result(type = "redirectAction", params = {"actionName", "configuration-input", "namespace", "/admin"})}) + public String execute() { + + String result = SUCCESS; + try { + FaxToMailUser user = ldapService.authenticateUser(login, password); + getSession().setAuthenticatedUserId(user.getTopiaId()); + } catch (AuthenticationException ex) { + result = ERROR; + addActionError("Can't login"); + } + return result; + } +} Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LoginAction.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LogoutAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LogoutAction.java (rev 0) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LogoutAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -0,0 +1,48 @@ +package com.franciaflex.faxtomail.web.action; + +/* + * #%L + * FaxToMail :: Web + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Franciaflex, Code Lutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.Result; + +import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; +import com.franciaflex.faxtomail.services.service.LdapService; +import com.franciaflex.faxtomail.services.service.ldap.AuthenticationException; +import com.franciaflex.faxtomail.web.FaxToMailActionSupport; + +public class LogoutAction extends FaxToMailActionSupport { + + private static final Log log = LogFactory.getLog(LogoutAction.class); + + @Override + @Action(results = { + @Result(type = "redirectAction", params = {"actionName", "index", "namespace", "/"})}) + public String execute() { + getSession().logout(); + return SUCCESS; + } +} Property changes on: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/LogoutAction.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ConfigurationAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -31,6 +31,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; import org.apache.struts2.convention.annotation.Result; import com.franciaflex.faxtomail.persistence.entities.Configuration; @@ -41,7 +44,6 @@ import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserGroup; import com.franciaflex.faxtomail.persistence.entities.FolderAction; -import com.franciaflex.faxtomail.persistence.entities.GroupChef; import com.franciaflex.faxtomail.persistence.entities.MailAction; import com.franciaflex.faxtomail.persistence.entities.MailField; import com.franciaflex.faxtomail.persistence.entities.MailFilter; @@ -57,6 +59,10 @@ * @author kmorin <kmorin@codelutin.com> * @since x.x */ +@InterceptorRefs({ + @InterceptorRef("loginInterceptor"), + @InterceptorRef("faxToMailStack") +}) public class ConfigurationAction extends FaxToMailActionSupport implements Preparable { private static final Log log = LogFactory.getLog(ConfigurationAction.class); @@ -91,7 +97,7 @@ } @Override - @org.apache.struts2.convention.annotation.Action("configuration-input") + @Action("configuration-input") public String input() throws Exception { etatAttentes = referentielService.getAllEtatAttente(); demandTypes = referentielService.getAllDemandType(); @@ -106,8 +112,7 @@ } @Override - @org.apache.struts2.convention.annotation.Action(results = { - @Result(type = "redirectAction", params = {"actionName", "configuration-input"})}) + @Action(results = {@Result(type = "redirectAction", params = {"actionName", "configuration-input"})}) public String execute() throws Exception { String result = super.execute(); Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/ImportAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -30,11 +30,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; import org.apache.struts2.convention.annotation.Result; import com.franciaflex.faxtomail.services.service.ReferentielService; import com.franciaflex.faxtomail.web.FaxToMailActionSupport; +@InterceptorRefs({ + @InterceptorRef("loginInterceptor"), + @InterceptorRef("faxToMailStack") +}) public class ImportAction extends FaxToMailActionSupport { private static final Log log = LogFactory.getLog(ImportAction.class); @@ -72,14 +79,13 @@ } @Override - @org.apache.struts2.convention.annotation.Action("import-input") + @Action("import-input") public String input() throws Exception { return INPUT; } @Override - @org.apache.struts2.convention.annotation.Action(results = { - @Result(type = "redirectAction", params = {"actionName", "import-input"})}) + @Action(results = {@Result(type = "redirectAction", params = {"actionName", "import-input"})}) public String execute() throws Exception { String result = super.execute(); Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/LdapAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -26,11 +26,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; import org.apache.struts2.convention.annotation.Result; import com.franciaflex.faxtomail.services.service.LdapService; import com.franciaflex.faxtomail.web.FaxToMailActionSupport; +@InterceptorRefs({ + @InterceptorRef("loginInterceptor"), + @InterceptorRef("faxToMailStack") +}) public class LdapAction extends FaxToMailActionSupport { private static final Log log = LogFactory.getLog(LdapAction.class); @@ -42,14 +49,13 @@ } @Override - @org.apache.struts2.convention.annotation.Action("ldap-input") + @Action("ldap-input") public String input() throws Exception { return INPUT; } @Override - @org.apache.struts2.convention.annotation.Action(results = { - @Result(type = "redirectAction", params = {"actionName", "ldap-input"})}) + @Action(results = {@Result(type = "redirectAction", params = {"actionName", "ldap-input"})}) public String execute() throws Exception { ldapService.updateLdapData(); return SUCCESS; Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin/UserFolderAction.java 2014-06-09 14:38:49 UTC (rev 153) @@ -26,13 +26,14 @@ import java.lang.reflect.Type; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.struts2.convention.annotation.Action; +import org.apache.struts2.convention.annotation.InterceptorRef; +import org.apache.struts2.convention.annotation.InterceptorRefs; import org.apache.struts2.convention.annotation.Result; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; @@ -43,6 +44,10 @@ import com.franciaflex.faxtomail.web.FaxToMailActionSupport; import com.google.gson.reflect.TypeToken; +@InterceptorRefs({ + @InterceptorRef("loginInterceptor"), + @InterceptorRef("faxToMailStack") +}) public class UserFolderAction extends FaxToMailActionSupport { private static final Log log = LogFactory.getLog(UserFolderAction.class); @@ -68,22 +73,16 @@ } @Override - @org.apache.struts2.convention.annotation.Action("user-folder-input") + @Action("user-folder-input") public String input() throws Exception { mailFolders = mailFolderService.getAllMailFolders(); users = configurationService.getAllUsers(); groups = configurationService.getAllGroups(); - - /*userFolders = new HashMap<>(); - for (FaxToMailUser user : users) { - userFolders.put(user.getTopiaId(), CollectionUtils.emptyIfNull(user.getAffectedFolders())); - }*/ return INPUT; } @Override - @org.apache.struts2.convention.annotation.Action(results = { - @Result(type = "redirectAction", params = {"actionName", "user-folder-input"})}) + @Action(results = {@Result(type = "redirectAction", params = {"actionName", "user-folder-input"})}) public String execute() throws Exception { configurationService.saveUserFolders(userFolders); Modified: trunk/faxtomail-ui-web/src/main/resources/struts.xml =================================================================== --- trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/resources/struts.xml 2014-06-09 14:38:49 UTC (rev 153) @@ -22,72 +22,41 @@ #L% --> <!DOCTYPE struts PUBLIC - "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" - "http://struts.apache.org/dtds/struts-2.0.dtd"> + "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" + "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> - <constant name="struts.convention.default.parent.package" value="faxtomail" /> - <bean class="org.nuiton.web.struts2.I18nTextProvider" name="i18nTextProvider" type="com.opensymphony.xwork2.TextProvider" /> - + + <constant name="struts.convention.default.parent.package" value="faxtomail" /> <constant name="struts.objectFactory" value="com.franciaflex.faxtomail.web.FaxToMailStrutsObjectFactory" /> - <constant name="struts.xworkTextProvider" value="i18nTextProvider" /> - <constant name="struts.multipart.maxSize" value="10485760" /> <package name="faxtomail" namespace="/" extends="struts-default"> <interceptors> - <interceptor name="faxToMailInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailInterceptor"/> + <interceptor name="loginInterceptor" class="com.franciaflex.faxtomail.web.FaxToMailLoginInterceptor" /> <interceptor-stack name="faxToMailStack"> <interceptor-ref name="faxToMailInterceptor" /> - - <interceptor-ref name="exception"/> - <interceptor-ref name="alias"/> - <interceptor-ref name="i18n"/> - <interceptor-ref name="checkbox"/> - <interceptor-ref name="multiselect"/> - <interceptor-ref name="params"> - <param name="excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*</param> - <param name="acceptParamNames">(\w|\(|\)|\[|\]|\.|'|-|\s|\u002C|\||")+</param> - </interceptor-ref> - <interceptor-ref name="servletConfig"/> - <interceptor-ref name="prepare"/> - <interceptor-ref name="chain"/> - <interceptor-ref name="modelDriven"/> - <interceptor-ref name="fileUpload"/> - <interceptor-ref name="staticParams"/> - <interceptor-ref name="actionMappingParams"/> - <interceptor-ref name="params"> - <param name="excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*</param> - <param name="acceptParamNames">(\w|\(|\)|\[|\]|\.|'|-|_|\s|\u002C|\||")+</param> - </interceptor-ref> - <interceptor-ref name="conversionError"/> - <interceptor-ref name="validation"> - <param name="excludeMethods">input,back,cancel,browse</param> - </interceptor-ref> - <interceptor-ref name="workflow"> - <param name="excludeMethods">input,back,cancel,browse</param> - </interceptor-ref> + <interceptor-ref name="paramsPrepareParamsStack" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="faxToMailStack"/> <global-results> - <result name="redirect-to-login" type="redirect">/</result> + <result name="redirect-to-login" type="redirect">/login-input</result> </global-results> - - <global-exception-mappings> + + <!-- <global-exception-mappings> <exception-mapping exception="com.franciaflex.faxtomail.web.FaxToMailNoIdException" result="NoIdException"></exception-mapping> <exception-mapping exception="com.franciaflex.faxtomail.web.FaxToMailEntityNotFoundException" result="EntityNotFoundException"></exception-mapping> <exception-mapping exception="com.franciaflex.faxtomail.web.FaxToMailIllegalAccessException" result="IllegalAccessException"></exception-mapping> - </global-exception-mappings> + </global-exception-mappings>--> </package> - </struts> Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/index.jsp 2014-06-09 14:38:49 UTC (rev 153) @@ -27,15 +27,21 @@ <html> <head> <title>Accueil</title> - <content tag="categorie-accueil">current</content> </head> <body> - <h1>Administration FaxToMail</h1> + <div id="main-container" class="container" ng-app="ConfigurationModule"> + <h1 class="page-header">Administration FaxToMail</h1> - <div class="content info-zone"> - - <s:property value="welcomeText" escapeHtml="false"/> - - </div> + <ul> + <li><a href="<s:url action='ldap-input' namespace="/admin" />"> + <span class="fa fa-database"></span> Ldap</a></li> + <li><a href="<s:url action='configuration-input' namespace="/admin" />"> + <span class="fa fa-cog"></span> Configuration</a></li> + <li><a href="<s:url action='import-input' namespace="/admin" />"> + <span class="fa fa-upload"></span> Import</a></li> + <li><a href="<s:url action='user-folder-input' namespace="/admin" />"> + <span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li> + </ul> + </div> </body> </html> Added: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp (rev 0) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp 2014-06-09 14:38:49 UTC (rev 153) @@ -0,0 +1,72 @@ +<%-- + #%L + FaxToMail :: Web + $Id$ + $HeadURL$ + %% + Copyright (C) 2014 Franciaflex, Code Lutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --%> +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<!DOCTYPE html> +<%@taglib uri="/struts-tags" prefix="s" %> +<html> + <head> + <title>Connexion</title> + </head> + <body> + + <div id="main-container" class="container" ng-app="ConfigurationModule"> + <h1 class="page-header">Connexion</h1> + + <s:form id="main_form" action="login" method="post" role="form" class="form-horizontal"> + + <div class="alert alert-warning"> + <strong>Attention!</strong> Le formulaire de connexion n'est pas encore branché sur le serveur LDAP. + Entrez n'importe quelles informations de connexion pour le moment. + </div> + + <div class="form-group"> + <label for="loginField" class="col-sm-2 control-label">Identifiant LDAP :</label> + <div class="col-sm-10"> + <input type="email" class="form-control" id="loginField" placeholder="nom.prenom@franciaflex.fr"> + </div> + </div> + <div class="form-group"> + <label for="passwordField" class="col-sm-2 control-label">Mot de passe :</label> + <div class="col-sm-10"> + <input type="password" class="form-control" id="passwordField" placeholder="password"> + </div> + </div> + <!-- <div class="form-group"> + <div class="col-sm-offset-2 col-sm-10"> + <div class="checkbox"> + <label> + <input type="checkbox"> Remember me + </label> + </div> + </div> + </div> --> + <div class="form-group"> + <div class="col-sm-offset-2 col-sm-10"> + <button type="submit" class="btn btn-primary">Connexion</button> + </div> + </div> + </s:form> + </div> + </body> +</html> Property changes on: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/login-input.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp =================================================================== --- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/decorators/layout.jsp 2014-06-09 14:38:49 UTC (rev 153) @@ -55,18 +55,27 @@ <div class="navbar-header"> <a href="<s:url value='/' />" class="navbar-brand">FaxToMail</a> </div> - <nav class="collapse navbar-collapse" role="navigation"> - <ul class="nav navbar-nav"> - <li><a href="<s:url action='ldap-input' namespace="/admin" />"> - <span class="fa fa-database"></span> Ldap</a></li> - <li><a href="<s:url action='configuration-input' namespace="/admin" />"> - <span class="fa fa-cog"></span> Configuration</a></li> - <li><a href="<s:url action='import-input' namespace="/admin" />"> - <span class="fa fa-upload"></span> Import</a></li> - <li><a href="<s:url action='user-folder-input' namespace="/admin" />"> - <span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li> - </ul> - </nav> + <s:if test="authenticated"> + <nav class="collapse navbar-collapse" role="navigation"> + <ul class="nav navbar-nav"> + <li><a href="<s:url action='ldap-input' namespace="/admin" />"> + <span class="fa fa-database"></span> Ldap</a></li> + <li><a href="<s:url action='configuration-input' namespace="/admin" />"> + <span class="fa fa-cog"></span> Configuration</a></li> + <li><a href="<s:url action='import-input' namespace="/admin" />"> + <span class="fa fa-upload"></span> Import</a></li> + <li><a href="<s:url action='user-folder-input' namespace="/admin" />"> + <span class="fa fa-folder-open"></span> Dossiers utilisateur</a></li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + <li><a><span class="fa fa-user"></span> + <s:property value="authenticatedUser.firstName" /> <s:property value="authenticatedUser.lastName" /></a></li> + <li><a href="<s:url action='logout' namespace="/" />"> + <span class="fa fa-power-off"></span> Déconnexion</a></li> + </ul> + </nav> + </s:if> </div> </header> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-06-08 20:44:39 UTC (rev 152) +++ trunk/pom.xml 2014-06-09 14:38:49 UTC (rev 153) @@ -539,14 +539,14 @@ <dependency> <groupId>org.nuiton.js</groupId> <artifactId>nuiton-js-bootstrap</artifactId> - <version>3.1.1-2-SNAPSHOT</version> + <version>3.1.1-1</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>angular-ui-sortable</artifactId> - <version>0.12.2</version> + <version>0.12.7</version> <scope>runtime</scope> </dependency> @@ -580,14 +580,14 @@ <dependency> <groupId>org.nuiton.js</groupId> <artifactId>nuiton-js-angularjs</artifactId> - <version>1.2.17-1-SNAPSHOT</version> + <version>1.2.17-1</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.nuiton.js</groupId> <artifactId>nuiton-js-font-awesome</artifactId> - <version>4.1.0-1-SNAPSHOT</version> + <version>4.1.0-1</version> <scope>runtime</scope> </dependency>
participants (1)
-
echatellier@users.forge.codelutin.com