1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.syncope.core.provisioning.api; 20 21 import java.util.List; 22 import java.util.Optional; 23 import java.util.Set; 24 import org.apache.commons.lang3.tuple.Pair; 25 import org.apache.syncope.common.lib.to.AnyTO; 26 import org.apache.syncope.common.lib.to.Item; 27 import org.apache.syncope.common.lib.to.OrgUnit; 28 import org.apache.syncope.common.lib.to.Provision; 29 import org.apache.syncope.common.lib.to.RealmTO; 30 import org.apache.syncope.common.lib.types.AttrSchemaType; 31 import org.apache.syncope.core.persistence.api.entity.Any; 32 import org.apache.syncope.core.persistence.api.entity.ExternalResource; 33 import org.apache.syncope.core.persistence.api.entity.PlainAttrValue; 34 import org.apache.syncope.core.persistence.api.entity.Realm; 35 import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount; 36 import org.apache.syncope.core.persistence.api.entity.user.User; 37 import org.identityconnectors.framework.common.objects.Attribute; 38 39 public interface MappingManager { 40 41 /** 42 * Get connObjectKey internal value. 43 * 44 * @param any any object 45 * @param resource resource information 46 * @param provision provision information 47 * @return connObjectKey internal value 48 */ 49 Optional<String> getConnObjectKeyValue(Any<?> any, ExternalResource resource, Provision provision); 50 51 /** 52 * Get connObjectKey internal value. 53 * 54 * @param realm realm 55 * @param orgUnit orgUnit information 56 * @return connObjectKey internal value 57 */ 58 Optional<String> getConnObjectKeyValue(Realm realm, OrgUnit orgUnit); 59 60 /** 61 * Get attribute values for the given {@link Item} and any object. 62 * 63 * @param resource resource information 64 * @param provision provision information 65 * @param mapItem mapping item 66 * @param intAttrName int attr name 67 * @param schemaType schema type 68 * @param any any object 69 * @param usernameAccountGetter function to get actual account instance for username 70 * @param plainAttrGetter function to get PlainAttr instances 71 * @return attribute values and their type 72 */ 73 Pair<AttrSchemaType, List<PlainAttrValue>> getIntValues( 74 ExternalResource resource, 75 Provision provision, 76 Item mapItem, 77 IntAttrName intAttrName, 78 AttrSchemaType schemaType, 79 Any<?> any, 80 AccountGetter usernameAccountGetter, 81 PlainAttrGetter plainAttrGetter); 82 83 /** 84 * Prepare attribute for sending to a connector instance. 85 * 86 * @param resource resource information 87 * @param provision provision information 88 * @param item mapping item 89 * @param any given any object 90 * @param password clear-text password 91 * @param usernameAccountGetter function to get actual account instance for username 92 * @param passwordAccountGetter function to get actual account instance for password 93 * @param plainAttrGetter function to get PlainAttr instances 94 * @return connObjectLink (if it is the case) + prepared attribute 95 */ 96 Pair<String, Attribute> prepareAttr( 97 ExternalResource resource, 98 Provision provision, 99 Item item, 100 Any<?> any, 101 String password, 102 AccountGetter usernameAccountGetter, 103 AccountGetter passwordAccountGetter, 104 PlainAttrGetter plainAttrGetter); 105 106 /** 107 * Prepare attributes for sending to a connector instance. 108 * 109 * @param any given any object 110 * @param password clear-text password 111 * @param changePwd whether password should be included for propagation attributes or not 112 * @param enable whether any object must be enabled or not 113 * @param resource resource information 114 * @param provision provision information 115 * @return connObjectLink + prepared attributes 116 */ 117 Pair<String, Set<Attribute>> prepareAttrsFromAny( 118 Any<?> any, 119 String password, 120 boolean changePwd, 121 Boolean enable, 122 ExternalResource resource, 123 Provision provision); 124 125 /** 126 * Prepare attributes for sending to a connector instance. 127 * 128 * @param user given user 129 * @param account linked account 130 * @param password user's clear-text password, to use as default value in case 131 * @param changePwd whether password should be included for propagation attributes or not 132 * @param provision provision information 133 * @return prepared attributes 134 */ 135 Set<Attribute> prepareAttrsFromLinkedAccount( 136 User user, LinkedAccount account, String password, boolean changePwd, Provision provision); 137 138 /** 139 * Prepare attributes for sending to a connector instance. 140 * 141 * @param realm Realm 142 * @param orgUnit provision information 143 * @return connObjectLink + prepared attributes 144 */ 145 Pair<String, Set<Attribute>> prepareAttrsFromRealm(Realm realm, OrgUnit orgUnit); 146 147 /** 148 * Set attribute values, according to the given {@link Item}, to any object from attribute received from 149 * connector. 150 * 151 * @param <T> any object 152 * @param mapItem mapping item 153 * @param attr attribute received from connector 154 * @param anyTO any object 155 */ 156 <T extends AnyTO> void setIntValues(Item mapItem, Attribute attr, T anyTO); 157 158 /** 159 * Set attribute values, according to the given {@link Item}, to realm from attribute received from 160 * connector. 161 * 162 * @param orgUnitItem mapping item 163 * @param attr attribute received from connector 164 * @param realmTO realm 165 */ 166 void setIntValues(Item orgUnitItem, Attribute attr, RealmTO realmTO); 167 168 /** 169 * Checks if there is a mapping item in the given {@link Provision} for {@code mustChangePassword}. 170 * 171 * @param provision provision 172 * @return if there is a mapping item in the given provision for {@code mustChangePassword} 173 */ 174 boolean hasMustChangePassword(Provision provision); 175 }