001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
018 */
019
020package org.nuxeo.ecm.platform.api.login;
021
022import java.io.Serializable;
023import java.util.HashMap;
024import java.util.Map;
025
026/**
027 * Encapsulates some information about a user and how it must be authenticated.
028 *
029 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a>
030 */
031public class UserIdentificationInfo implements Serializable {
032
033    private static final long serialVersionUID = 6894397878763275157L;
034
035    protected String userName;
036
037    protected String password;
038
039    protected String token;
040
041    protected String authPluginName;
042
043    protected String loginPluginName;
044
045    protected final Map<String, String> loginParameters = new HashMap<String, String>();
046
047    public UserIdentificationInfo(String userName, String password) {
048        this.userName = userName;
049        this.password = password;
050    }
051
052    public UserIdentificationInfo(UserIdentificationInfo savedIdent) {
053        this(savedIdent.userName, savedIdent.password);
054        authPluginName = savedIdent.authPluginName;
055    }
056
057    /**
058     * Returns the name of the Authentication Plugin used to get user identity (FORM,BASIC,CAS2 ...).
059     */
060    public String getAuthPluginName() {
061        return authPluginName;
062    }
063
064    public void setAuthPluginName(String authPluginName) {
065        this.authPluginName = authPluginName;
066    }
067
068    public String getPassword() {
069        return password;
070    }
071
072    public void setPassword(String password) {
073        this.password = password;
074    }
075
076    public String getUserName() {
077        return userName;
078    }
079
080    public void setUserName(String userName) {
081        this.userName = userName;
082    }
083
084    public boolean containsValidIdentity() {
085        if (userName == null) {
086            return false;
087        }
088        return userName.length() != 0;
089    }
090
091    public Map<String, String> getLoginParameters() {
092        return loginParameters;
093    }
094
095    public void setLoginParameters(Map<String, String> loginParameters) {
096        this.loginParameters.putAll(loginParameters);
097    }
098
099    /**
100     * Returns the name of the LoginModule plugin that must be used to create the Principal.
101     */
102    public String getLoginPluginName() {
103        return loginPluginName;
104    }
105
106    public void setLoginPluginName(String loginPluginName) {
107        this.loginPluginName = loginPluginName;
108    }
109
110    public String getToken() {
111        return token;
112    }
113
114    public void setToken(String token) {
115        this.token = token;
116    }
117
118}