2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.beans.login;
19 import javax.enterprise.context.SessionScoped;
20 import javax.faces.view.facelets.FaceletException;
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.naming.Context;
24 import javax.naming.InitialContext;
25 import javax.naming.NamingException;
26 import org.mxchange.addressbook.beans.user.UserWebController;
27 import org.mxchange.jusercore.exceptions.UserNotFoundException;
28 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
29 import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
30 import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote;
31 import org.mxchange.jusercore.model.user.User;
34 * A web bean for user registration
36 * @author Roland Haeder
38 @Named ("loginController")
40 public class UserLoginWebBean implements UserLoginWebController {
43 * Reemote register session bean
45 private UserLoginSessionBeanRemote loginBean;
51 private UserWebController userController;
56 private static final long serialVersionUID = 47_828_986_719_691_592L;
61 public UserLoginWebBean () {
63 // Get initial context
64 Context context = new InitialContext();
67 this.loginBean = (UserLoginSessionBeanRemote) context.lookup("ejb/stateless-login"); //NOI18N
68 } catch (final NamingException ex) {
70 throw new FaceletException(ex);
75 public void doLogin () {
77 User user = this.userController.createUserInstance();
81 this.loginBean.loginUser(user);
82 } catch (final UserNotFoundException | UserStatusLockedException | UserStatusUnconfirmedException ex) {
84 throw new FaceletException(ex);