001/*
002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.api.login;
023
024import java.io.Serializable;
025import java.util.HashMap;
026import java.util.Map;
027
028/**
029 * Encapsulates some information about a user and how it must be authenticated.
030 *
031 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a>
032 */
033public class UserIdentificationInfo implements Serializable {
034
035    private static final long serialVersionUID = 6894397878763275157L;
036
037    protected String userName;
038
039    protected String password;
040
041    protected String token;
042
043    protected String authPluginName;
044
045    protected String loginPluginName;
046
047    protected final Map<String, String> loginParameters = new HashMap<String, String>();
048
049    public UserIdentificationInfo(String userName, String password) {
050        this.userName = userName;
051        this.password = password;
052    }
053
054    public UserIdentificationInfo(UserIdentificationInfo savedIdent) {
055        this(savedIdent.userName, savedIdent.password);
056        authPluginName = savedIdent.authPluginName;
057    }
058
059    /**
060     * Returns the name of the Authentication Plugin used to get user identity (FORM,BASIC,CAS2 ...).
061     */
062    public String getAuthPluginName() {
063        return authPluginName;
064    }
065
066    public void setAuthPluginName(String authPluginName) {
067        this.authPluginName = authPluginName;
068    }
069
070    public String getPassword() {
071        return password;
072    }
073
074    public void setPassword(String password) {
075        this.password = password;
076    }
077
078    public String getUserName() {
079        return userName;
080    }
081
082    public void setUserName(String userName) {
083        this.userName = userName;
084    }
085
086    public boolean containsValidIdentity() {
087        if (userName == null) {
088            return false;
089        }
090        return userName.length() != 0;
091    }
092
093    public Map<String, String> getLoginParameters() {
094        return loginParameters;
095    }
096
097    public void setLoginParameters(Map<String, String> loginParameters) {
098        this.loginParameters.putAll(loginParameters);
099    }
100
101    /**
102     * Returns the name of the LoginModule plugin that must be used to create the Principal.
103     */
104    public String getLoginPluginName() {
105        return loginPluginName;
106    }
107
108    public void setLoginPluginName(String loginPluginName) {
109        this.loginPluginName = loginPluginName;
110    }
111
112    public String getToken() {
113        return token;
114    }
115
116    public void setToken(String token) {
117        this.token = token;
118    }
119
120}