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.propagation; 20 21 import java.util.Collection; 22 import java.util.List; 23 import java.util.Map; 24 import java.util.Set; 25 import java.util.stream.Stream; 26 import org.apache.commons.lang3.tuple.Pair; 27 import org.apache.syncope.common.lib.Attr; 28 import org.apache.syncope.common.lib.request.AnyUR; 29 import org.apache.syncope.common.lib.request.UserUR; 30 import org.apache.syncope.common.lib.to.Item; 31 import org.apache.syncope.common.lib.to.Provision; 32 import org.apache.syncope.common.lib.types.AnyTypeKind; 33 import org.apache.syncope.common.lib.types.ResourceOperation; 34 import org.apache.syncope.core.persistence.api.entity.Any; 35 import org.apache.syncope.core.persistence.api.entity.ExternalResource; 36 import org.apache.syncope.core.persistence.api.entity.Realm; 37 import org.apache.syncope.core.provisioning.api.DerAttrHandler; 38 import org.apache.syncope.core.provisioning.api.PropagationByResource; 39 import org.apache.syncope.core.provisioning.api.UserWorkflowResult; 40 import org.identityconnectors.framework.common.objects.Attribute; 41 42 @SuppressWarnings("squid:S00107") 43 public interface PropagationManager { 44 45 /** 46 * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the 47 * mapping but not to be propagated. 48 */ 49 String MANDATORY_MISSING_ATTR_NAME = "__MANDATORY_MISSING__"; 50 51 /** 52 * Name for special propagation attribute used to indicate whether there are attributes, marked as mandatory in the 53 * mapping but about to be propagated as null or empty. 54 */ 55 String MANDATORY_NULL_OR_EMPTY_ATTR_NAME = "__MANDATORY_NULL_OR_EMPTY__"; 56 57 /** 58 * Create the any object tasks for every associated resource, unless in {@code excludedResources}. 59 * 60 * @param kind any object type kind 61 * @param key any object key 62 * @param enable whether any object should be enabled or not 63 * @param propByRes operation to be performed per resource 64 * @param vAttrs virtual attributes to be set 65 * @param excludedResources external resources performing not to be considered for propagation 66 * @return list of propagation tasks 67 */ 68 List<PropagationTaskInfo> getCreateTasks( 69 AnyTypeKind kind, 70 String key, 71 Boolean enable, 72 PropagationByResource<String> propByRes, 73 Collection<Attr> vAttrs, 74 Collection<String> excludedResources); 75 76 /** 77 * Create the user tasks for every associated resource, unless in {@code excludedResources}. 78 * 79 * @param key user key 80 * @param password to be set 81 * @param enable whether user must be enabled or not 82 * @param propByRes operation to be performed per resource 83 * @param propByLinkedAccount operation to be performed for linked accounts 84 * @param vAttrs virtual attributes to be set 85 * @param excludedResources external resources not to be considered for propagation 86 * @return list of propagation tasks 87 */ 88 List<PropagationTaskInfo> getUserCreateTasks( 89 String key, 90 String password, 91 Boolean enable, 92 PropagationByResource<String> propByRes, 93 PropagationByResource<Pair<String, String>> propByLinkedAccount, 94 Collection<Attr> vAttrs, 95 Collection<String> excludedResources); 96 97 /** 98 * Create the update tasks for the any object on each resource associated, unless in {@code excludedResources}. 99 * 100 * @param kind any object type kind 101 * @param key any object key 102 * @param changePwd whether password should be included for propagation attributes or not 103 * @param enable whether any object should be enabled or not, may be null to leave unchanged 104 * @param propByRes operation to be performed per resource 105 * @param propByLinkedAccount operation to be performed for linked accounts 106 * @param vAttrs virtual attributes to be set 107 * @param excludedResources external resource keys not to be considered for propagation 108 * @return list of propagation tasks 109 */ 110 List<PropagationTaskInfo> getUpdateTasks( 111 AnyTypeKind kind, 112 String key, 113 boolean changePwd, 114 Boolean enable, 115 PropagationByResource<String> propByRes, 116 PropagationByResource<Pair<String, String>> propByLinkedAccount, 117 Collection<Attr> vAttrs, 118 Collection<String> excludedResources); 119 120 /** 121 * Create the update tasks for the user on each resource associated, unless in {@code excludedResources}. 122 * 123 * @param wfResult user to be propagated (and info associated), as per result from workflow 124 * @param changePwd whether password should be included for propagation attributes or not 125 * @param excludedResources external resources not to be considered for propagation 126 * @return list of propagation tasks 127 */ 128 List<PropagationTaskInfo> getUserUpdateTasks( 129 UserWorkflowResult<Pair<UserUR, Boolean>> wfResult, 130 boolean changePwd, 131 Collection<String> excludedResources); 132 133 /** 134 * Create the update tasks for the user on each resource associated; propagate password update only to requested 135 * resources. 136 * 137 * @param wfResult user to be propagated (and info associated), as per result from workflow 138 * @return list of propagation tasks 139 */ 140 List<PropagationTaskInfo> getUserUpdateTasks(UserWorkflowResult<Pair<UserUR, Boolean>> wfResult); 141 142 /** 143 * Create the delete tasks for the any object from each resource associated, unless in {@code excludedResources}. 144 * 145 * @param kind any object type kind 146 * @param key any object key 147 * @param propByRes operation to be performed per resource 148 * @param propByLinkedAccount operation to be performed for linked accounts 149 * @param excludedResources external resource keys not to be considered for propagation 150 * @return list of propagation tasks 151 */ 152 List<PropagationTaskInfo> getDeleteTasks( 153 AnyTypeKind kind, 154 String key, 155 PropagationByResource<String> propByRes, 156 PropagationByResource<Pair<String, String>> propByLinkedAccount, 157 Collection<String> excludedResources); 158 159 PropagationTaskInfo newTask( 160 DerAttrHandler derAttrHandler, 161 Any<?> any, 162 ExternalResource resource, 163 ResourceOperation operation, 164 Provision provision, 165 Stream<Item> mappingItems, 166 Pair<String, Set<Attribute>> preparedAttrs); 167 168 /** 169 * Create the needed tasks for the realm for each resource associated, unless in {@code excludedResources}. 170 * 171 * @param realm realm 172 * @param propByRes operation to be performed per resource 173 * @param excludedResources external resource keys not to be considered for propagation 174 * @return list of propagation tasks 175 */ 176 List<PropagationTaskInfo> createTasks( 177 Realm realm, 178 PropagationByResource<String> propByRes, 179 Collection<String> excludedResources); 180 181 /** 182 * Prepare attributes for propagation. 183 * 184 * @param kind any object type kind 185 * @param key any object key 186 * @param password to be set (for users) 187 * @param changePwd whether password should be included for propagation attributes or not (for users) 188 * @param enable whether any object should be enabled or not, may be null to leave unchanged 189 * @param excludedResources external resource keys not to be considered for propagation 190 * @return map with prepared attributes per External Resource 191 */ 192 Map<Pair<String, String>, Set<Attribute>> prepareAttrs( 193 AnyTypeKind kind, 194 String key, 195 String password, 196 boolean changePwd, 197 Boolean enable, 198 Collection<String> excludedResources); 199 200 /** 201 * Prepare attributes for propagation. 202 * 203 * @param realm realm 204 * @return map with prepared attributes per External Resource 205 */ 206 Map<Pair<String, String>, Set<Attribute>> prepareAttrs(Realm realm); 207 208 /** 209 * Enrich the provided tasks with attribute deltas. 210 * 211 * @param tasks propagation tasks 212 * @param beforeAttrs attribute values before update 213 * @param updateRequest effective any update request 214 * @return enriched propagation tasks 215 */ 216 List<PropagationTaskInfo> setAttributeDeltas( 217 List<PropagationTaskInfo> tasks, 218 Map<Pair<String, String>, Set<Attribute>> beforeAttrs, 219 AnyUR updateRequest); 220 }