public static Collection<ResourceAttribute<?>> getPrimaryIdentifiers(PrismObject<? extends ShadowType> shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } return attributesContainer.getPrimaryIdentifiers(); }
public static Collection<ResourceAttribute<?>> getPrimaryIdentifiers(ShadowType shadowType) { return getPrimaryIdentifiers(shadowType.asPrismObject()); }
public static String getResourceOid(ShadowType shadowType) { return getResourceOid(shadowType.asPrismObject()); }
public static ResourceObjectIdentification getResourceObjectIdentification( PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { return new ResourceObjectIdentification(objectClassDefinition, ShadowUtil.getPrimaryIdentifiers(shadow), ShadowUtil.getSecondaryIdentifiers(shadow)); }
public static void validateAttributeSchema(PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) throws SchemaException { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); for (ResourceAttribute<?> attribute: attributesContainer.getAttributes()) { validateAttribute(attribute, objectClassDefinition); } }
public static <F extends FocusType> LensProjectionContext getProjectionContext(LensContext<F> context, PrismObject<ShadowType> equivalentAccount, ProvisioningService provisioningService, PrismContext prismContext, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ShadowType equivalentAccountType = equivalentAccount.asObjectable(); ShadowKindType kind = ShadowUtil.getKind(equivalentAccountType); return getProjectionContext(context, ShadowUtil.getResourceOid(equivalentAccountType), kind, equivalentAccountType.getIntent(), provisioningService, prismContext, task, result); }
private void transplantIdentifiers(PrismContainerValue<ShadowAssociationType> association, PrismObject<ShadowType> repoShadow) throws SchemaException { PrismContainer<Containerable> identifiersContainer = association .findContainer(ShadowAssociationType.F_IDENTIFIERS); if (identifiersContainer == null) { ResourceAttributeContainer origContainer = ShadowUtil.getAttributesContainer(repoShadow); identifiersContainer = ObjectFactory.createResourceAttributeContainer(ShadowAssociationType.F_IDENTIFIERS, origContainer.getDefinition(), prismContext); association.add(identifiersContainer); } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : identifiers) { identifiersContainer.add(identifier.clone()); } Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil .getSecondaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : secondaryIdentifiers) { identifiersContainer.add(identifier.clone()); } }
ShadowUtil.getAttributesContainer(associationCVal, ShadowAssociationType.F_IDENTIFIERS); Collection<ResourceAttribute<?>> entitlementIdentifiersFromAssociation = identifiersContainer.getAttributes(); ResourceAttribute<TV> valueAttr = ShadowUtil.getAttribute(subjectShadow, valueAttrName); if (valueAttr == null) { if (!ShadowUtil.isFullShadow(subjectShadow)) { Collection<ResourceAttribute<?>> subjectIdentifiers = ShadowUtil.getAllIdentifiers(subjectShadow); LOGGER.trace("Fetching {} ({})", subjectShadow, subjectIdentifiers); subjectShadow = resourceObjectReferenceResolver.fetchResourceObject(subjectCtx, subjectIdentifiers, null, result); subjectShadowAfter = subjectShadow; valueAttr = ShadowUtil.getAttribute(subjectShadow, valueAttrName);
Collection<? extends ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(repositoryShadow); if (primaryIdentifiers == null || primaryIdentifiers.isEmpty()) { if (ProvisioningUtil.hasPendingAddOperation(repositoryShadow) || ShadowUtil.isDead(repositoryShadow.asObjectable())) { if (ProvisioningUtil.isFuturePointInTime(options)) { Collection<? extends ResourceAttribute<?>> identifiers = ShadowUtil.getAllIdentifiers(repositoryShadow); try { if (!ShadowUtil.isProtected(resourceShadow)) { InternalMonitor.recordCount(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
public <T> T getAttributeValue(ShadowType shadow, javax.xml.namespace.QName attributeQname) throws SchemaException { return ShadowUtil.getAttributeValue(shadow, attributeQname); }
sb.append(name); } else { Collection<ResourceAttribute<?>> primaryIdentifiers = getPrimaryIdentifiers(shadow); if (primaryIdentifiers != null && !primaryIdentifiers.isEmpty()) { shortDumpShadowIdentifiers(sb, shadow, primaryIdentifiers); } else { Collection<ResourceAttribute<?>> secondaryIdentifiers = getSecondaryIdentifiers(shadow); if (secondaryIdentifiers != null && !secondaryIdentifiers.isEmpty()) { shortDumpShadowIdentifiers(sb, shadow, secondaryIdentifiers);
@Override public boolean handle(PrismObject<ShadowType> entitlementShadow) { Collection<? extends ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(entitlementShadow); ResourceObjectDiscriminator disc = new ResourceObjectDiscriminator(entitlementOcDef.getTypeName(), primaryIdentifiers); ResourceObjectOperations operations = roMap.get(disc); roMap.put(disc, operations); operations.setResourceObjectContext(entitlementCtx); Collection<? extends ResourceAttribute<?>> allIdentifiers = ShadowUtil.getAllIdentifiers(entitlementShadow); operations.setAllIdentifiers(allIdentifiers);
@Override protected String createTicketAdd(PrismObject<? extends ShadowType> object, Collection<Operation> additionalOperations, OperationResult result) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException { LOGGER.debug("Creating case to add account\n{}", object.debugDump(1)); ObjectDelta<? extends ShadowType> objectDelta = DeltaFactory.Object.createAddDelta(object); ObjectDeltaType objectDeltaType = DeltaConvertor.toObjectDeltaType(objectDelta); String shadowName; if (object.getName() != null) { shadowName = object.getName().toString(); } else { shadowName = getShadowIdentifier(ShadowUtil.getPrimaryIdentifiers(object)); } String description = "Please create resource account: "+shadowName; PrismObject<CaseType> acase = addCase(description, ShadowUtil.getResourceOid(object.asObjectable()), shadowName, objectDeltaType, result); return acase.getOid(); }
private void toAssociation(PrismObject<ShadowType> shadow, ShadowAssociationType shadowAssociationType) { shadowAssociationType.setShadowRef(new ObjectReferenceType().oid(shadow.getOid()).type(ShadowType.COMPLEX_TYPE)); // We also need to add identifiers here. Otherwise the delta won't match the shadow association. // And therefore new values won't be computed correctly (MID-4948) // This is not a clean systemic solution. But there was no time for a better solution before 3.9 release. try { ResourceAttributeContainer shadowAttributesContainer = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, shadowAttributesContainer.getDefinition(), prismContext); shadowAssociationType.asPrismContainerValue().add(identifiersContainer); Collection<ResourceAttribute<?>> shadowIdentifiers = ShadowUtil.getAllIdentifiers(shadow); for (ResourceAttribute<?> shadowIdentifier : shadowIdentifiers) { identifiersContainer.add(shadowIdentifier.clone()); } } catch (SchemaException e) { // Should not happen throw new SystemException(e.getMessage(), e); } }
public static ResourceAttribute<String> getSecondaryIdentifier(PrismObject<? extends ShadowType> shadow) throws SchemaException { Collection<ResourceAttribute<?>> secondaryIdentifiers = getSecondaryIdentifiers(shadow); if (secondaryIdentifiers == null || secondaryIdentifiers.isEmpty()) { return null; } if (secondaryIdentifiers.size() > 1) { throw new SchemaException("Too many secondary identifiers in "+shadow+": "+secondaryIdentifiers); } return (ResourceAttribute<String>) secondaryIdentifiers.iterator().next(); }
public void addDeadShadowDeltas(PrismObject<ShadowType> repoShadow, AsynchronousOperationResult asyncResult, List<ItemDelta> shadowModifications) { LOGGER.trace("Marking shadow {} as dead", repoShadow); if (ShadowUtil.isExists(repoShadow.asObjectable())) { shadowModifications.add(createShadowPropertyReplaceDelta(repoShadow, ShadowType.F_EXISTS, Boolean.FALSE)); } if (!ShadowUtil.isDead(repoShadow.asObjectable())) { shadowModifications.add(createShadowPropertyReplaceDelta(repoShadow, ShadowType.F_DEAD, Boolean.TRUE)); } }
private void checkPrivBargain(PrismObject<ShadowType> shadow, OperationResult result) throws SchemaException { checkEntitlementShadow(shadow, result, OBJECTCLAS_PRIVILEGE_LOCAL_NAME, true); assertShadowName(shadow, PRIVILEGE_BARGAIN_NAME); assertEquals("Wrong kind (provisioning)", ShadowKindType.ENTITLEMENT, shadow.asObjectable().getKind()); Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow); assertEquals("Unexpected number of attributes", 2, attributes.size()); assertNull("The _PASSSWORD_ attribute sneaked into shadow", ShadowUtil.getAttributeValues( shadow, new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); }
private <F extends FocusType> LensProjectionContext createProjectionContext(LensContext<F> context, PrismObject<ShadowType> account, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ShadowType shadowType = account.asObjectable(); String resourceOid = ShadowUtil.getResourceOid(shadowType); if (resourceOid == null) { throw new SchemaException("The " + account + " has null resource reference OID"); } String intent = ShadowUtil.getIntent(shadowType); ShadowKindType kind = ShadowUtil.getKind(shadowType); ResourceType resource = LensUtil.getResourceReadOnly(context, resourceOid, provisioningService, task, result); String accountIntent = LensUtil.refineProjectionIntent(kind, intent, resource, prismContext); ResourceShadowDiscriminator rsd = new ResourceShadowDiscriminator(resourceOid, kind, accountIntent); LensProjectionContext accountSyncContext = context.findProjectionContext(rsd); if (accountSyncContext != null) { throw new SchemaException("Attempt to add "+account+" to a user that already contains account of type '"+accountIntent+"' on "+resource); } accountSyncContext = context.createProjectionContext(rsd); accountSyncContext.setResource(resource); accountSyncContext.setOid(account.getOid()); return accountSyncContext; }
public <T> Collection<T> getAttributeValues(ShadowType shadow, javax.xml.namespace.QName attributeQname) { return ShadowUtil.getAttributeValues(shadow, attributeQname); }
public static ResourceObjectIdentification createFromShadow(ObjectClassComplexTypeDefinition objectClassDefinition, ShadowType shadowType) throws SchemaException { return createFromAttributes(objectClassDefinition, ShadowUtil.getAttributes(shadowType)); }