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