001/* 002 * (C) Copyright 2006-2015 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 * Nuxeo - initial API and implementation 018 * 019 */ 020 021package org.nuxeo.usermapper.service; 022 023import java.io.Serializable; 024import java.util.Map; 025import java.util.Set; 026 027import org.nuxeo.ecm.core.api.NuxeoException; 028import org.nuxeo.ecm.core.api.NuxeoPrincipal; 029import org.nuxeo.usermapper.extension.UserMapper; 030 031/** 032 * This service allows to map Nuxeo Users with users coming from external system like SSO or IDM. 033 * 034 * @author tiry 035 * @since 7.4 036 */ 037public interface UserMapperService { 038 039 /** 040 * Should retrieve (create if needed) and update the NuxeoPrincipal according to the given userObject 041 * 042 * @param mappingName the name of the contributed mapping to use 043 * @param userObject the native userObject 044 * @return the matching {@link NuxeoPrincipal} 045 */ 046 NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(String mappingName, Object userObject) throws NuxeoException; 047 048 /** 049 * Should retrieve (create if needed) and update the NuxeoPrincipal according to the given userObject 050 * 051 * @param mappingName the name of the contributed mapping to use 052 * @param userObject the native userObject 053 * @param createIfNeeded flag to allow creation (default is true) 054 * @param update flag to run update (default is true) 055 * @return the matching {@link NuxeoPrincipal} 056 */ 057 NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(String mappingName, Object userObject, boolean createIfNeeded, 058 boolean update, Map<String, Serializable> params) throws NuxeoException; 059 060 /** 061 * Wrap the {@link NuxeoPrincipal} as the userObject used in the external authentication system * 062 * 063 * @param mappingName the name of the contributed mapping to use 064 * @param principal the {@link NuxeoPrincipal} to wrap 065 * @param nativePrincipal the principal Object in the target system (can be null) 066 */ 067 Object wrapNuxeoPrincipal(String mappingName, NuxeoPrincipal principal, Object nativePrincipal, 068 Map<String, Serializable> params) throws NuxeoException; 069 070 /** 071 * Gives access to the contributed Mapping names 072 */ 073 Set<String> getAvailableMappings(); 074 075 /** 076 * returns the named mapper is any 077 */ 078 UserMapper getMapper(String mappingName) throws NuxeoException; 079}