use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class MidpointFunctionsImpl method computeProjectionLifecycle.
@Override
public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowType shadow, ResourceType resource) {
if (focus == null || shadow == null) {
return null;
}
if (!(focus instanceof UserType)) {
return null;
}
if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) {
return null;
}
ProtectedStringType passwordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
if (passwordPs != null && passwordPs.canGetCleartext()) {
return null;
}
CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
if (credentialsCapabilityType == null) {
return null;
}
PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword();
if (passwordCapabilityType == null) {
return null;
}
if (passwordCapabilityType.isEnabled() == Boolean.FALSE) {
return null;
}
return SchemaConstants.LIFECYCLE_PROPOSED;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestRefinedSchema method assertAccountShadow.
private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<ResourceType> resource, PrismContext prismContext) throws SchemaException, JAXBException {
ResourceType resourceType = resource.asObjectable();
QName objectClassQName = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass");
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_NAME, createPolyString("jack"));
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_OBJECT_CLASS, objectClassQName);
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_INTENT, SchemaConstants.INTENT_DEFAULT);
PrismContainer<?> attributes = accObject.findOrCreateContainer(SchemaConstants.C_ATTRIBUTES);
assertEquals("Wrong type of <attributes> definition in account", ResourceAttributeContainerDefinitionImpl.class, attributes.getDefinition().getClass());
ResourceAttributeContainerDefinition attrDef = (ResourceAttributeContainerDefinition) attributes.getDefinition();
assertAttributeDefs(attrDef, resourceType, null, LayerType.MODEL);
PrismAsserts.assertPropertyValue(attributes, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "cn"), "Jack Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "givenName"), "Jack");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "sn"), "Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "uid"), "jack");
assertEquals("JAXB class name doesn't match (1)", ShadowType.class, accObject.getCompileTimeClass());
accObject.checkConsistence();
ShadowType accObjectType = accObject.asObjectable();
assertEquals("Wrong JAXB name", createPolyStringType("jack"), accObjectType.getName());
assertEquals("Wrong JAXB objectClass", objectClassQName, accObjectType.getObjectClass());
ShadowAttributesType attributesType = accObjectType.getAttributes();
assertNotNull("null ResourceObjectShadowAttributesType (JAXB)", attributesType);
List<Object> attributeElements = attributesType.getAny();
TestUtil.assertElement(attributeElements, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "cn"), "Jack Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "givenName"), "Jack");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "sn"), "Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "uid"), "jack");
String accString = PrismTestUtil.serializeObjectToString(accObjectType.asPrismObject());
System.out.println("Result of JAXB marshalling:\n" + accString);
accObject.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestRefinedSchema method testApplyAttributeDefinition.
@Test
public void testApplyAttributeDefinition() throws JAXBException, SchemaException, SAXException, IOException {
System.out.println("\n===[ testApplyAttributeDefinition ]===\n");
// GIVEN
PrismContext prismContext = createInitializedPrismContext();
PrismObject<ResourceType> resource = prismContext.parseObject(RESOURCE_COMPLEX_FILE);
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resource, prismContext);
RefinedObjectClassDefinition defaultAccountDefinition = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
assertNotNull("No refined default account definition in " + rSchema, defaultAccountDefinition);
System.out.println("Refined account definition:");
System.out.println(defaultAccountDefinition.debugDump());
PrismObject<ShadowType> accObject = prismContext.parseObject(new File(TEST_DIR_NAME, "account-jack.xml"));
PrismContainer<Containerable> attributesContainer = accObject.findContainer(ShadowType.F_ATTRIBUTES);
System.out.println("Attributes container:");
System.out.println(attributesContainer.debugDump());
// WHEN
attributesContainer.applyDefinition((PrismContainerDefinition) defaultAccountDefinition.toResourceAttributeContainerDefinition(), true);
// THEN
System.out.println("Parsed account:");
System.out.println(accObject.debugDump());
assertAccountShadow(accObject, resource, prismContext);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class AssociationSearchExpressionEvaluatorCache method invalidate.
// shadow may be null
public void invalidate(PrismObject<ResourceType> resource, PrismObject<? extends ShadowType> shadow) {
LOGGER.trace("Invalidating cache for resource = {}, shadow kind = {}", resource, shadow != null ? shadow.asObjectable().getKind() : "(no shadow)");
if (resource == null || resource.getOid() == null) {
// shouldn't occur
LOGGER.warn("No resource - invalidating all the cache");
queries.clear();
return;
}
String resourceOid = resource.getOid();
ShadowKindType kind = null;
if (shadow != null) {
kind = shadow.asObjectable().getKind();
}
Set<Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult>> entries = queries.entrySet();
Iterator<Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult>> iterator = entries.iterator();
while (iterator.hasNext()) {
Map.Entry<AssociationSearchQueryKey, AssociationSearchQueryResult> entry = iterator.next();
if (matches(entry, resourceOid, kind)) {
LOGGER.trace("Invalidating query key {}", entry.getKey());
iterator.remove();
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType in project midpoint by Evolveum.
the class TestCorrelationConfiramtionEvaluator method test005CorrelationMatchCaseInsensitive.
@Test
public void test005CorrelationMatchCaseInsensitive() throws Exception {
String TEST_NAME = "test005CorrelationMatchCaseInsensitive";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(TEST_NAME);
OperationResult result = task.getResult();
// importObjectFromFile(USER_JACK_FILENAME);
PrismObject<UserType> userType = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
//assert jack
assertNotNull(userType);
ShadowType shadow = parseObjectType(ACCOUNT_SHADOW_JACK_DUMMY_FILE, ShadowType.class);
ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(CORRELATION_CASE_INSENSITIVE_EMPL_NUMBER), ConditionalSearchFilterType.COMPLEX_TYPE);
// ObjectQuery query = ObjectQuery.createObjectQuery(EqualsFilter.createEqual(null, userType.getDefinition().findItemDefinition(UserType.F_EMPLOYEE_NUMBER), "stringIgnoreCase", "ps1234"));
// List<QueryType> queries = new ArrayList<QueryType>();
// queries.add(query);
//
ResourceType resourceType = parseObjectType(RESOURCE_DUMMY_FILE, ResourceType.class);
resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear();
resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query);
userType.asObjectable().setEmployeeNumber("JaCk");
ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0);
try {
boolean matchedUsers = evaluator.matchUserCorrelationRule(UserType.class, shadow.asPrismObject(), userType, objectSynchronizationType, resourceType, getSystemConfiguration(), task, result);
System.out.println("matched users " + matchedUsers);
AssertJUnit.assertTrue(matchedUsers);
} catch (Exception ex) {
LOGGER.error("exception occured: {}", ex.getMessage(), ex);
throw ex;
}
// assertNotNull("Correlation evaluator returned null collection of matched users.", matchedUsers);
// assertEquals("Found more than one user.", 1, matchedUsers.size());
//
// PrismObject<UserType> jack = matchedUsers.get(0);
// assertUser(jack, "c0c010c0-d34d-b33f-f00d-111111111111", "jack", "Jack Sparrow", "Jack", "Sparrow");
}
Aggregations