001/*
002 * (C) Copyright 2006-2008 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 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.usermanager;
021
022import java.io.Serializable;
023import java.util.ArrayList;
024import java.util.HashMap;
025import java.util.List;
026import java.util.Map;
027
028import org.nuxeo.common.xmap.annotation.XNode;
029import org.nuxeo.common.xmap.annotation.XNodeList;
030import org.nuxeo.common.xmap.annotation.XNodeMap;
031import org.nuxeo.common.xmap.annotation.XObject;
032
033/**
034 * Descriptor for virtual users. APG-240 All attributes are defined public because the user manager service do not get
035 * access to the fields. OSGI don't allow splitted packages having access to public members defined from an another
036 * package provider.
037 *
038 * @author Anahide Tchertchian
039 */
040@XObject("virtualUser")
041public class VirtualUserDescriptor implements VirtualUser {
042
043    private static final long serialVersionUID = 1L;
044
045    @XNode("@id")
046    public String id;
047
048    @XNode("@remove")
049    public boolean remove;
050
051    // searchable by default
052    @XNode("@searchable")
053    public boolean searchable = true;
054
055    @XNode("password")
056    public String password;
057
058    // XXX for now only dealing with String properties
059    @XNodeMap(value = "property", key = "@name", type = HashMap.class, componentType = String.class)
060    public Map<String, String> properties;
061
062    @XNodeMap(value = "propertyList", key = "@name", type = HashMap.class, componentType = PropertyListDescriptor.class)
063    public Map<String, PropertyListDescriptor> listProperties = new HashMap<String, PropertyListDescriptor>();
064
065    @XNodeList(value = "group", type = ArrayList.class, componentType = String.class)
066    public List<String> groups;
067
068    public String getId() {
069        return id;
070    }
071
072    public String getPassword() {
073        return password;
074    }
075
076    public Map<String, Serializable> getProperties() {
077        Map<String, Serializable> props = new HashMap<String, Serializable>();
078        props.putAll(properties);
079        for (Map.Entry<String, PropertyListDescriptor> prop : listProperties.entrySet()) {
080            props.put(prop.getKey(), prop.getValue().getValues());
081        }
082        return props;
083    }
084
085    public List<String> getGroups() {
086        return groups;
087    }
088
089    public boolean isSearchable() {
090        return searchable;
091    }
092
093}