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:at@nuxeo.com">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 @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<>(); 064 065 @XNodeList(value = "group", type = ArrayList.class, componentType = String.class) 066 public List<String> groups; 067 068 @Override 069 public String getId() { 070 return id; 071 } 072 073 @Override 074 public String getPassword() { 075 return password; 076 } 077 078 @Override 079 public Map<String, Serializable> getProperties() { 080 Map<String, Serializable> props = new HashMap<>(); 081 props.putAll(properties); 082 for (Map.Entry<String, PropertyListDescriptor> prop : listProperties.entrySet()) { 083 props.put(prop.getKey(), prop.getValue().getValues()); 084 } 085 return props; 086 } 087 088 @Override 089 public List<String> getGroups() { 090 return groups; 091 } 092 093 @Override 094 public boolean isSearchable() { 095 return searchable; 096 } 097 098}