/*******************************************************************************
* Copyright 2009, 2010 Innovation Gate GmbH. All Rights Reserved.
*
* This file is part of the OpenWGA server platform.
*
* OpenWGA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition, a special exception is granted by the copyright holders
* of OpenWGA called "OpenWGA plugin exception". You should have received
* a copy of this exception along with OpenWGA in file COPYING.
* If not, see <http://www.openwga.com/gpl-plugin-exception>.
*
* OpenWGA 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenWGA in file COPYING.
* If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package de.innovationgate.wgpublisher.auth;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.map.ListOrderedMap;
import de.innovationgate.webgate.api.WGDocumentKey;
import de.innovationgate.webgate.api.auth.AuthenticationSession;
import de.innovationgate.webgate.api.auth.LabeledNamesProvider;
public class Login implements AuthenticationSession, LabeledNamesProvider {
String _distinguishedName;
String _password;
String _mailAddress;
String _documentkey;
Object _additionalData;
Set _aliases = new HashSet();
Set _groups = new HashSet();
Map _labeledNames = new LinkedHashMap();
public Login(String userName, String password) {
_distinguishedName = userName;
_password = password;
}
public Login(String userName, String password, String email, String documentkey, Set aliases) {
_distinguishedName = userName;
_password = password;
_mailAddress = email;
_documentkey = documentkey;
if (aliases != null) {
_aliases = aliases;
}
_labeledNames.put("userdocument", new WGDocumentKey(documentkey).getName());
}
public void setGroups(Set groups) {
if (groups != null) {
_groups = groups;
}
}
public void setGroups(List groupsList) {
setGroups(new HashSet(groupsList));
}
public void setAliases(List namesList) {
setAliases(new HashSet(namesList));
}
/**
* @return Returns the password.
*/
public String getPassword() {
return _password;
}
/**
* @return Returns the userName.
*/
public String getDistinguishedName() {
return _distinguishedName;
}
/**
* @return Returns the documentkey.
*/
public String getDocumentkey() {
return _documentkey;
}
/**
* @return Returns the additionalData.
*/
public Object getAdditionalData() {
return _additionalData;
}
/**
* @param additionalData
* The additionalData to set.
*/
public void setAdditionalData(Object additionalData) {
_additionalData = additionalData;
}
/**
* @return Returns the email.
*/
public String getMailAddress() {
return _mailAddress;
}
/**
* @return Returns the aliases.
*/
public Set getNames() {
HashSet names = new HashSet(_aliases);
names.add(_distinguishedName);
return names;
}
public Set getGroups() {
return _groups;
}
public void logout() {
}
public boolean isValid() {
return true;
}
/**
* @param documentkey The documentkey to set.
*/
public void setDocumentkey(String documentkey) {
_documentkey = documentkey;
}
/**
* @param mailAddress The mailAddress to set.
*/
public void setMailAddress(String mailAddress) {
_mailAddress = mailAddress;
}
/**
* @param names The names to set.
*/
public void setAliases(Set names) {
_aliases = names;
}
/**
* @param password The password to set.
*/
public void setPassword(String password) {
_password = password;
}
/**
* @return Returns the aliases.
*/
public Set getAliases() {
return _aliases;
}
public void addGroups(Set set) {
_groups.addAll(set);
}
public String getSessionToken() {
return null;
}
public Map getLabeledNames() {
return Collections.unmodifiableMap(_labeledNames);
}
protected void addLabeledName(String label, Object name) {
_labeledNames.put(label, name);
}
}