001/* 002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others. 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-2.1.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 * Thomas Roger <troger@nuxeo.com> 016 */ 017 018package org.nuxeo.ecm.multi.tenant; 019 020import org.nuxeo.ecm.core.api.model.PropertyNotFoundException; 021import org.nuxeo.ecm.platform.usermanager.NuxeoPrincipalImpl; 022 023/** 024 * @author <a href="mailto:troger@nuxeo.com">Thomas Roger</a> 025 * @since 5.6 026 */ 027public class MultiTenantPrincipal extends NuxeoPrincipalImpl { 028 029 public MultiTenantPrincipal(NuxeoPrincipalImpl principal) { 030 super(principal.getName(), principal.isAnonymous(), principal.isAdministrator()); 031 setConfig(principal.getConfig()); 032 setModel(principal.getModel()); 033 setVirtualGroups(principal.getVirtualGroups()); 034 } 035 036 @Override 037 public String getTenantId() { 038 try { 039 return (String) model.getPropertyValue("user:tenantId"); 040 } catch (PropertyNotFoundException e) { 041 return null; 042 } 043 } 044 045}