private <T> void normalizeValues(Collection<PrismPropertyValue<T>> values, MatchingRule<T> matchingRule) throws SchemaException { for (PrismPropertyValue<T> pval: values) { T normalizedRealValue = matchingRule.normalize(pval.getValue()); pval.setValue(normalizedRealValue); } }
@Override public PolyString normalize(PolyString original) throws SchemaException { return new PolyString(nameMatchingRule.normalize(original.getOrig())); }
@Override public PolyString normalize(PolyString original) throws SchemaException { return new PolyString(nameMatchingRule.normalize(original.getOrig())); }
private void assertNormalized(MatchingRule<String> rule, String expected, String original) throws SchemaException { assertEquals("Normalized value does not match", expected, rule.normalize(original)); } }
private <T> Collection<T> getNormalizedAttributeValues(ResourceAttribute<T> attribute, RefinedAttributeDefinition rAttrDef) throws SchemaException { MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName()); if (matchingRule == null) { return attribute.getRealValues(); } else { Collection<T> normalizedValues = new ArrayList<>(); for (PrismPropertyValue<T> pval: attribute.getValues()) { T normalizedRealValue = matchingRule.normalize(pval.getValue()); normalizedValues.add(normalizedRealValue); } return normalizedValues; } }
<T> T getNormalizedAttributeValue(PrismPropertyValue<T> pval, RefinedAttributeDefinition rAttrDef) throws SchemaException { MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName()); if (matchingRule != null) { T normalizedRealValue = matchingRule.normalize(pval.getValue()); return normalizedRealValue; } else { return pval.getValue(); } }
private <T> List<PrismPropertyValue<T>> getNormalizedValue(PrismProperty<T> attr, RefinedObjectClassDefinition rObjClassDef) throws SchemaException { RefinedAttributeDefinition<T> refinedAttributeDefinition = rObjClassDef.findAttributeDefinition(attr.getElementName()); QName matchingRuleQName = refinedAttributeDefinition.getMatchingRuleQName(); MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, refinedAttributeDefinition.getTypeName()); List<PrismPropertyValue<T>> normalized = new ArrayList<>(); for (PrismPropertyValue<T> origPValue : attr.getValues()){ T normalizedValue = matchingRule.normalize(origPValue.getValue()); PrismPropertyValue<T> normalizedPValue = origPValue.clone(); normalizedPValue.setValue(normalizedValue); normalized.add(normalizedPValue); } return normalized; }
private <T> void normalizeAttribute(ResourceAttribute<T> attribute, RefinedAttributeDefinition rAttrDef) throws SchemaException { MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName()); if (matchingRule != null) { for (PrismPropertyValue<T> pval: attribute.getValues()) { T normalizedRealValue = matchingRule.normalize(pval.getValue()); pval.setValue(normalizedRealValue); } } }
if (eqFilter.getValues() != null) { for (PrismPropertyValue<T> ppval : eqFilter.getValues()) { T normalizedRealValue = matchingRule.normalize(ppval.getValue()); PrismPropertyValue<T> newPPval = ppval.clone(); newPPval.setValue(normalizedRealValue);
private static ObjectQuery createShadowQuery(ShadowType resourceShadow, ObjectClassComplexTypeDefinition objectClassDef, MatchingRule<String> uidMatchingRule, PrismContext prismContext) throws SchemaException { PrismContainer<?> attributesContainer = resourceShadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); QName identifierName = objectClassDef.getPrimaryIdentifiers().iterator().next().getName(); PrismProperty<String> identifier = attributesContainer.findProperty(ItemName.fromQName(identifierName)); if (identifier == null) { throw new SchemaException("No identifier in "+resourceShadow); } String identifierValue = identifier.getRealValue(); if (uidMatchingRule != null) { identifierValue = uidMatchingRule.normalize(identifierValue); } PrismPropertyDefinition<String> identifierDef = identifier.getDefinition(); return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(ShadowUtil.getResourceOid(resourceShadow)) .and().item(ItemPath.create(ShadowType.F_ATTRIBUTES, identifierDef.getName()), identifierDef).eq(identifierValue) .build(); }
private <TV,TA> ObjectQuery createQuery(RefinedAssociationDefinition assocDefType, RefinedAttributeDefinition<TA> assocAttrDef, ResourceAttribute<TV> valueAttr) throws SchemaException{ MatchingRule<TA> matchingRule = matchingRuleRegistry.getMatchingRule(assocDefType.getResourceObjectAssociationType().getMatchingRule(), assocAttrDef.getTypeName()); if (valueAttr.size() > 1) { throw new IllegalStateException("Attributes with more than 1 values are not supported here"); } PrismPropertyValue<TA> converted = PrismUtil.convertPropertyValue(valueAttr.getAnyValue(), valueAttr.getDefinition(), assocAttrDef, prismContext); TA normalizedRealValue = matchingRule.normalize(converted.getValue()); PrismPropertyValue<TA> normalized = prismContext.itemFactory().createPropertyValue(normalizedRealValue); LOGGER.trace("Converted entitlement filter value: {} ({}) def={}", normalized, normalized.getValue().getClass(), assocAttrDef); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, assocAttrDef.getName()), assocAttrDef).eq(normalized) .build(); query.setAllowPartialResults(true); return query; }
Object normalizedValue = matchingRule.normalize(value); if (!(normalizedValue instanceof String)) { checkResult.recordError(
@Test public void test405GetGroupSwashbucklers() throws Exception { final String TEST_NAME = "test405GetGroupSwashbucklers"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); PrismObject<ShadowType> provisioningShadow = provisioningService.getObject(ShadowType.class, GROUP_SWASHBUCKLERS_OID, null, task, result); // THEN displayThen(TEST_NAME); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); String uid = ShadowUtil.getSingleStringAttributeValue(provisioningShadowType, getPrimaryIdentifierQName()); assertNotNull(uid); ResourceAttribute<Object> memberAttr = ShadowUtil.getAttribute(provisioningShadow, new QName(RESOURCE_OPENDJ_NS, GROUP_MEMBER_ATTR_NAME)); assertNull("Member attribute sneaked in", memberAttr); Entry ldapEntry = openDJController.searchAndAssertByEntryUuid(uid); display("LDAP group", ldapEntry); assertNotNull("No LDAP group entry"); String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(groupDn)); assertShadows(19); }
} else { if (requireNormalizedIdentfiers) { assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule.normalize(username), idProp.getRealValue()); } else { PrismAsserts.assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule, username, idProp.getRealValue()); String expected = username; if (requireNormalizedIdentfiers && nameMatchingRule != null) { expected = nameMatchingRule.normalize(username);
} else { if (requireNormalizedIdentfiers) { assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule.normalize(username), idProp.getRealValue()); } else { PrismAsserts.assertEquals("Unexpected primary identifier in shadow for "+username, nameMatchingRule, username, idProp.getRealValue()); String expected = username; if (requireNormalizedIdentfiers && nameMatchingRule != null) { expected = nameMatchingRule.normalize(username);
null, taskManager.createTaskInstance(), result); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); assertNotNull("No LDAP group entry"); String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SWASHBUCKLERS_DN), dnMatchingRule.normalize(groupDn));
null, taskManager.createTaskInstance(), result); ShadowType provisioningShadowType = provisioningShadow.asObjectable(); assertEquals("Wrong ICF name (provisioning)", dnMatchingRule.normalize(GROUP_SPECIALISTS_DN), dnMatchingRule.normalize(provisioningShadowType.getName().getOrig())); assertNotNull("No LDAP group entry"); String groupDn = ldapEntry.getDN().toString(); assertEquals("Wrong group DN", dnMatchingRule.normalize(GROUP_SPECIALISTS_DN), dnMatchingRule.normalize(groupDn));
for (PrismPropertyValue attrVal: attrProperty.getValues()) { Object currentRealValue = attrVal.getValue(); Object normalizedRealValue = matchingRule.normalize(currentRealValue); if (!normalizedRealValue.equals(currentRealValue)) { if (attrDef.isSingleValue()) {
PropertyDelta<Object> attrAddDelta = currentResourceAttrProperty.createDelta(); for (PrismPropertyValue<?> pval: currentResourceAttrProperty.getValues()) { attrAddDelta.addRealValuesToAdd(matchingRule.normalize(pval.getValue())); Object currentResourceRealValue = currentResourceAttrProperty.getRealValue(); Object currentResourceNormalizedRealValue; currentResourceNormalizedRealValue = matchingRule.normalize(currentResourceRealValue); if (!currentResourceNormalizedRealValue.equals(oldRepoAttributeProperty.getRealValue())) { PropertyDelta delta = shadowDelta.addModificationReplaceProperty(currentResourceAttrProperty.getPath(), currentResourceNormalizedRealValue); PrismProperty<Object> normalizedCurrentResourceAttrProperty = currentResourceAttrProperty.clone(); for (PrismPropertyValue pval: normalizedCurrentResourceAttrProperty.getValues()) { Object normalizedRealValue = matchingRule.normalize(pval.getValue()); pval.setValue(normalizedRealValue);