diff --git a/zanata-war/src/main/java/org/zanata/action/LoginAction.java b/zanata-war/src/main/java/org/zanata/action/LoginAction.java index 721e796901..8a2a448097 100644 --- a/zanata-war/src/main/java/org/zanata/action/LoginAction.java +++ b/zanata-war/src/main/java/org/zanata/action/LoginAction.java @@ -33,6 +33,9 @@ import org.zanata.security.ZanataCredentials; import org.zanata.security.openid.OpenIdProviderType; +import lombok.Getter; +import lombok.Setter; + /** * This action takes care of logging a user into the system. It contains logic * to handle the different authentication mechanisms offered by the system. @@ -55,122 +58,63 @@ public class LoginAction implements Serializable @In private ApplicationConfiguration applicationConfiguration; - @In - private AccountDAO accountDAO; - - @In(create = true) - private InactiveAccountAction inactiveAccountAction; - + @Getter @Setter private String username; + @Getter @Setter private String password; - private String authProvider; - - - public String getUsername() - { - return username; - } - - public void setUsername(String username) - { - this.username = username; - } - - public String getPassword() - { - return password; - } - - public void setPassword(String password) - { - this.password = password; - } - - public String getAuthProvider() - { - return authProvider; - } - - public void setAuthProvider(String authProvider) - { - this.authProvider = authProvider; - } + @Getter @Setter + private String openId = "http://"; - /** - * Prepares authentication credentials based on the passed parameters. - */ - private void prepareCredentials() + public String login() { - AuthenticationType authType = null; - OpenIdProviderType openIdProviderType = null; - - credentials.setUsername( username ); - credentials.setPassword( password ); - - // All others - if (authProvider == null) + credentials.setUsername(username); + credentials.setPassword(password); + if (applicationConfiguration.isInternalAuth()) { - if (applicationConfiguration.isInternalAuth()) - { - authType = AuthenticationType.INTERNAL; - } - else if (applicationConfiguration.isJaasAuth()) - { - authType = AuthenticationType.JAAS; - } - else if (applicationConfiguration.isKerberosAuth()) - { - authType = AuthenticationType.KERBEROS; - } + credentials.setAuthType(AuthenticationType.INTERNAL); } - // Open Id / internal auth - else + else if (applicationConfiguration.isJaasAuth()) { - try - { - // If it is open Id - openIdProviderType = OpenIdProviderType.valueOf(authProvider); - authType = AuthenticationType.OPENID; - } - catch (Exception e) - { - // If it's not open id, it might be another authentication type - openIdProviderType = null; - authType = AuthenticationType.valueOf(authProvider); - } + credentials.setAuthType(AuthenticationType.JAAS); } - credentials.setAuthType( authType ); - credentials.setOpenIdProviderType( openIdProviderType ); - } - - public String login() - { - this.prepareCredentials(); - String loginResult = null; + String loginResult; switch (credentials.getAuthType()) { - case OPENID: - loginResult = authenticationManager.openIdLogin(); - break; case INTERNAL: + credentials.setAuthType(AuthenticationType.INTERNAL); loginResult = authenticationManager.internalLogin(); break; case JAAS: + credentials.setAuthType(AuthenticationType.JAAS); loginResult = authenticationManager.jaasLogin(); break; // Kerberos auth happens on its own + default: + throw new RuntimeException("login() only supports internal or jaas authentication"); } return loginResult; } - public String login( String authProvider ) + /** + * Only for open id. + * @param authProvider Open Id authentication provider. + */ + public String openIdLogin(String authProvider) { - this.authProvider = authProvider; - return login(); + OpenIdProviderType providerType = OpenIdProviderType.valueOf(authProvider); + + if( providerType == OpenIdProviderType.Generic ) + { + credentials.setUsername(openId); + } + + credentials.setAuthType(AuthenticationType.OPENID); + credentials.setOpenIdProviderType(providerType); + return authenticationManager.openIdLogin(); } } diff --git a/zanata-war/src/main/java/org/zanata/security/FacesSecurityEvents.java b/zanata-war/src/main/java/org/zanata/security/FacesSecurityEvents.java new file mode 100644 index 0000000000..c86fa74def --- /dev/null +++ b/zanata-war/src/main/java/org/zanata/security/FacesSecurityEvents.java @@ -0,0 +1,51 @@ +/* + * Copyright 2013, Red Hat, Inc. and individual contributors as indicated by the + * @author tags. See the copyright.txt file in the distribution for a full + * listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This software 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 Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this software; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF + * site: http://www.fsf.org. + */ +package org.zanata.security; + +import org.jboss.seam.ScopeType; +import org.jboss.seam.annotations.Install; +import org.jboss.seam.annotations.Name; +import org.jboss.seam.annotations.Scope; +import org.jboss.seam.annotations.Startup; +import org.jboss.seam.annotations.intercept.BypassInterceptors; +import org.jboss.seam.international.StatusMessage; + +import static org.jboss.seam.annotations.Install.APPLICATION; + +/** + * Override the {@link org.jboss.seam.security.FacesSecurityEvents} component to + * alter default values. + * + * @author Carlos Munoz camunoz@redhat.com + */ +@Name("org.jboss.seam.security.facesSecurityEvents") +@Scope(ScopeType.APPLICATION) +@Install(precedence = APPLICATION, classDependencies = "javax.faces.context.FacesContext") +@BypassInterceptors +@Startup +public class FacesSecurityEvents extends org.jboss.seam.security.FacesSecurityEvents +{ + @Override + public StatusMessage.Severity getLoginFailedMessageSeverity() + { + return StatusMessage.Severity.ERROR; + } +} diff --git a/zanata-war/src/main/webapp/WEB-INF/template/template.xhtml b/zanata-war/src/main/webapp/WEB-INF/template/template.xhtml index 65ca6dfe67..730a57b971 100755 --- a/zanata-war/src/main/webapp/WEB-INF/template/template.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/template/template.xhtml @@ -18,24 +18,24 @@ - + <ui:insert name="page_title" /> - + - + - + - + - + #{messages['jsf.Zanata']}: <ui:insert name="page_title" />
- - -
-
- -
-
- -
-
-
-
-
+ + + + + + +
+
+ +
+
+ +
+
+
+
+ - + diff --git a/zanata-war/src/main/webapp/account/login.xhtml b/zanata-war/src/main/webapp/account/login.xhtml index 3e89f0d4fc..62b5c9d326 100644 --- a/zanata-war/src/main/webapp/account/login.xhtml +++ b/zanata-war/src/main/webapp/account/login.xhtml @@ -11,21 +11,13 @@ #{messages['jsf.Login']} -
- - - -
-
+

Log In

-

with Zanata

@@ -39,13 +31,18 @@
- Forgot password? + + + #{messages['jsf.ForgotYourPassword']} + +
- or Sign Up + or +
@@ -56,23 +53,23 @@
  • - +
  • - +
  • - +
  • - +
    - +