001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2007
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.faces.beans;
034:
035: import com.flexive.faces.FxJsfUtils;
036: import com.flexive.faces.messages.FxFacesMsgErr;
037: import com.flexive.shared.FxContext;
038: import com.flexive.shared.security.UserTicket;
039: import com.flexive.war.FxRequest;
040:
041: import java.io.Serializable;
042:
043: public class AuthenticationBean implements Serializable {
044: private static final long serialVersionUID = -8245131162897398694L;
045:
046: private String username;
047: private String password;
048: private boolean takeover;
049:
050: public UserTicket getTicket() {
051: return FxContext.get().getTicket();
052: }
053:
054: public boolean getIsLoggedIn() {
055: return FxContext.get().getTicket().isGuest();
056: }
057:
058: public String getUsername() {
059: return username;
060: }
061:
062: public void setUsername(String username) {
063: this .username = username;
064: }
065:
066: public String getPassword() {
067: return this .password;
068: }
069:
070: public void setPassword(String password) {
071: this .password = password;
072: }
073:
074: public boolean isTakeover() {
075: return takeover;
076: }
077:
078: public void setTakeover(boolean takeover) {
079: this .takeover = takeover;
080: }
081:
082: public String login() {
083: try {
084: FxRequest request = FxJsfUtils.getRequest();
085: request.login(username, password, takeover);
086: request.getUserTicket();
087: return "loginSuccess";
088: } catch (Exception exc) {
089: new FxFacesMsgErr(exc).addToContext();
090: }
091: return "login";
092: }
093:
094: public String logout() {
095: try {
096: FxRequest request = FxJsfUtils.getRequest();
097: request.logout();
098: } catch (Exception exc) {
099: new FxFacesMsgErr(exc).addToContext();
100: }
101: return "login";
102: }
103: }
|