private boolean matches(ResourceAttribute<?> identifier, Collection<? extends ResourceAttribute<?>> attributesToMatch, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException { for (ResourceAttribute<?> attributeToMatch: attributesToMatch) { if (matches(identifier, attributeToMatch, matchingRuleRegistry)) { return true; } } return false; }
public static boolean matches(PrismObject<ShadowType> shadowToMatch, Collection<ResourceObjectPattern> protectedAccountPatterns, MatchingRuleRegistry matchingRuleRegistry, RelationRegistry relationRegistry) throws SchemaException { for (ResourceObjectPattern pattern: protectedAccountPatterns) { if (pattern.matches(shadowToMatch, matchingRuleRegistry, relationRegistry)) { return true; } } return false; }
public static boolean isProtectedShadow(RefinedObjectClassDefinition objectClassDefinition, PrismObject<ShadowType> shadow, MatchingRuleRegistry matchingRuleRegistry, RelationRegistry relationRegistry) throws SchemaException { boolean isProtected; if (objectClassDefinition == null) { isProtected = false; } else { Collection<ResourceObjectPattern> protectedAccountPatterns = objectClassDefinition.getProtectedObjectPatterns(); if (protectedAccountPatterns == null) { isProtected = false; } else { isProtected = ResourceObjectPattern.matches(shadow, protectedAccountPatterns, matchingRuleRegistry, relationRegistry); } } LOGGER.trace("isProtectedShadow: {}: {} = {}", objectClassDefinition, shadow, isProtected); return isProtected; }
public boolean matches(PrismObject<ShadowType> shadowToMatch, MatchingRuleRegistry matchingRuleRegistry, RelationRegistry relationRegistry) throws SchemaException { if (objectFilter != null) { ObjectTypeUtil.normalizeFilter(objectFilter, relationRegistry); // we suppose references in shadowToMatch are normalized (on return from repo) return ObjectQuery.match(shadowToMatch, objectFilter, matchingRuleRegistry); } else { // Deprecated method ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadowToMatch); if (attributesContainer == null) { return false; } Collection<ResourceAttribute<?>> attributesToMatch = attributesContainer.getAttributes(); for (ResourceAttribute<?> identifier: identifiers) { if (!matches(identifier, attributesToMatch, matchingRuleRegistry)) { return false; } } return true; } }
private void assertDeprecatedProtectedAccount(String message, ResourceObjectPattern protectedPattern, String identifierValue, RefinedObjectClassDefinition rAccount) throws SchemaException { Collection<ResourceAttribute<?>> identifiers = protectedPattern.getIdentifiers(); assertNotNull("Null identifiers in "+message, identifiers); assertEquals("Wrong number identifiers in "+message, 1, identifiers.size()); ResourceAttribute<?> identifier = identifiers.iterator().next(); assertNotNull("Null identifier in "+message, identifier); assertEquals("Wrong identifier value in "+message, identifier.getRealValue(), identifierValue); // Try matching PrismObject<ShadowType> shadow = rAccount.getObjectDefinition().instantiate(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, rAccount); ResourceAttribute<String> confusingAttr1 = createStringAttribute(new QName("http://whatever.com","confuseMe"), "HowMuchWoodWouldWoodchuckChuckIfWoodchuckCouldChudkWood"); attributesContainer.add(confusingAttr1); ResourceAttribute<String> nameAttr = createStringAttribute(SchemaTestConstants.ICFS_NAME, identifierValue); attributesContainer.add(nameAttr); ResourceAttribute<String> confusingAttr2 = createStringAttribute(new QName("http://whatever.com","confuseMeAgain"), "WoodchuckWouldChuckNoWoodAsWoodchuckCannotChuckWood"); attributesContainer.add(confusingAttr2); assertTrue("Test attr not matched in "+message, protectedPattern.matches(shadow, null, relationRegistry)); nameAttr.setRealValue("huhulumululul"); assertFalse("Test attr nonsense was matched in "+message, protectedPattern.matches(shadow, null, relationRegistry)); }