private Object convertToConnIdSingle(PrismProperty<?> configProperty, Class<?> expectedType) throws ConfigurationException { if (configProperty == null) { return null; } PrismPropertyValue<?> pval = configProperty.getValue(); return convertToIcf(pval, expectedType); }
private String determinePasswordValue(PrismProperty<ProtectedStringType> password) { if (password == null || password.getValue(ProtectedStringType.class) == null) { return null; } ProtectedStringType passValue = password.getRealValue(); return determinePasswordValue(passValue); }
@SuppressWarnings({ "rawtypes", "unchecked" }) private <T> T getPropertyNewValue(PropertyDelta propertyDelta, Class<T> clazz) throws SchemaException { PrismProperty<PrismPropertyValue<T>> prop = propertyDelta.getPropertyNewMatchingPath(); if (prop == null){ return null; } PrismPropertyValue<T> propValue = prop.getValue(clazz); if (propValue == null){ return null; } return propValue.getValue(); }
PrismPropertyValue<?> pvalue = property.getValue(); if (pvalue == null) { return null;
public static ObjectClassComplexTypeDefinition determineObjectClass(RefinedResourceSchema refinedSchema, Task task) throws SchemaException { QName objectclass = null; PrismProperty<QName> objectclassProperty = task.getExtensionProperty(ModelConstants.OBJECTCLASS_PROPERTY_NAME); if (objectclassProperty != null) { objectclass = objectclassProperty.getValue().getValue(); } ShadowKindType kind = null; PrismProperty<ShadowKindType> kindProperty = task.getExtensionProperty(ModelConstants.KIND_PROPERTY_NAME); if (kindProperty != null) { kind = kindProperty.getValue().getValue(); } String intent = null; PrismProperty<String> intentProperty = task.getExtensionProperty(ModelConstants.INTENT_PROPERTY_NAME); if (intentProperty != null) { intent = intentProperty.getValue().getValue(); } return determineObjectClassInternal(refinedSchema, objectclass, kind, intent, task); }
protected <T> void assertExpression(PrismProperty<T> prop, String evaluatorName) { PrismPropertyValue<T> pval = prop.getValue(); ExpressionWrapper expressionWrapper = pval.getExpression(); assertNotNull("No expression wrapper in "+prop, expressionWrapper); Object expressionObj = expressionWrapper.getExpression(); assertNotNull("No expression in "+prop, expressionObj); assertTrue("Wrong expression type: " +expressionObj.getClass(), expressionObj instanceof ExpressionType); ExpressionType expressionType = (ExpressionType)expressionObj; JAXBElement<?> evaluatorElement = expressionType.getExpressionEvaluator().iterator().next(); assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); }
public static Element findXsdElement(PrismContainerValue<XmlSchemaType> xmlSchemaContainerValue) { PrismProperty<SchemaDefinitionType> definitionProperty = xmlSchemaContainerValue.findProperty(XmlSchemaType.F_DEFINITION); if (definitionProperty == null) { return null; } SchemaDefinitionType schemaDefinition = definitionProperty.getValue().getValue(); if (schemaDefinition == null) { return null; } return schemaDefinition.getSchema(); // List<Element> schemaElements = DOMUtil.listChildElements(definitionElement); // for (Element e : schemaElements) { // if (QNameUtil.compareQName(DOMUtil.XSD_SCHEMA_ELEMENT, e)) { // DOMUtil.fixNamespaceDeclarations(e); // return e; // } // } // return null; }
@Override protected boolean initializeRun(H handler, TaskRunResult runResult, Task task, OperationResult opResult) { boolean cont = super.initializeRun(handler, runResult, task, opResult); if (!cont) { return false; } XMLGregorianCalendar lastScanTimestamp = null; PrismProperty<XMLGregorianCalendar> lastScanTimestampProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME); if (lastScanTimestampProperty != null) { lastScanTimestamp = lastScanTimestampProperty.getValue().getValue(); } handler.setLastScanTimestamp(lastScanTimestamp); handler.setThisScanTimestamp(clock.currentTimeXMLGregorianCalendar()); return true; }
private <T> void assertExpression(PrismProperty<T> prop, String evaluatorName) { System.out.println("Prop:"); System.out.println(prop.debugDump(1)); PrismPropertyValue<T> pval = prop.getValue(); ExpressionWrapper expressionWrapper = pval.getExpression(); assertNotNull("No expression wrapper in "+prop, expressionWrapper); Object expressionObj = expressionWrapper.getExpression(); assertNotNull("No expression in "+prop, expressionObj); System.out.println("- Expression: "+expressionObj); if (namespaces) { assertTrue("Wrong expression type ("+language+","+(namespaces?"ns":"no-ns") + ") : " +expressionObj.getClass(), expressionObj instanceof ExpressionType); ExpressionType expressionType = (ExpressionType)expressionObj; JAXBElement<?> evaluatorElement = expressionType.getExpressionEvaluator().iterator().next(); assertEquals("Wrong expression evaluator name", evaluatorName, evaluatorElement.getName().getLocalPart()); } }
@SuppressWarnings("rawtypes") private PrismProperty getTokenProperty(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException { PrismProperty tokenProperty = null; if (task.getExtension() != null) { tokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN); } if (tokenProperty != null && (tokenProperty.getAnyRealValue() == null)) { LOGGER.warn("Sync token exists, but it is empty (null value). Ignoring it."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty sync token property:\n{}", tokenProperty.debugDump()); } tokenProperty = null; } // if the token is not specified in the task, get the latest token if (tokenProperty == null) { tokenProperty = shadowCache.fetchCurrentToken(shadowCoordinates, result); if (tokenProperty == null || tokenProperty.getValue() == null || tokenProperty.getValue().getValue() == null) { LOGGER.warn("Empty current sync token provided by {}", shadowCoordinates); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty current sync token property."); } return null; } } return tokenProperty; }
@Override public TaskRunResult run(Task task) { OperationResult result = task.getResult().createSubresult(DOT_CLASS + "run"); TaskRunResult runResult = new TaskRunResult(); PrismProperty<ExecuteScriptType> executeScriptProperty = task.getExtensionProperty(SchemaConstants.SE_EXECUTE_SCRIPT); if (executeScriptProperty == null || executeScriptProperty.getValue().getValue() == null || executeScriptProperty.getValue().getValue().getScriptingExpression() == null) { throw new IllegalStateException("There's no script to be run in task " + task + " (property " + SchemaConstants.SE_EXECUTE_SCRIPT + ")"); } try { ScriptExecutionResult executionResult = scriptingService.evaluateExpression(executeScriptProperty.getRealValue(), emptyMap(), true, task, result); LOGGER.debug("Execution output: {} item(s)", executionResult.getDataOutput().size()); LOGGER.debug("Execution result:\n{}", executionResult.getConsoleOutput()); result.computeStatus(); runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED); } catch (ScriptExecutionException | SecurityViolationException | SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException e) { result.recordFatalError("Couldn't execute script: " + e.getMessage(), e); LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script", e); runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.PERMANENT_ERROR); } task.getResult().computeStatus(); runResult.setOperationResult(task.getResult()); return runResult; }
datePP.getValue().setValue(XmlTypeConverter.createXMLGregorianCalendar(yesterday)); AssertJUnit.fail("Value was changed when immutable!"); } catch (RuntimeException e) {
SchemaDefinitionType definitionElement = definitionProperty.getValue().getValue(); System.out.println("Re-parsed definition element:"); System.out.println(DOMUtil.serializeDOMToString(definitionElement.getSchema()));
@Test public void testPasswordChange() throws Exception { System.out.println("===[ testPasswordChange ]===="); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "user-modify-password.xml"), ObjectModificationType.COMPLEX_TYPE); // WHEN ObjectDelta<UserType> objectDelta = DeltaConvertor.createObjectDelta(objectChange, UserType.class, getPrismContext()); // THEN assertNotNull("No object delta", objectDelta); objectDelta.checkConsistence(); assertEquals("Wrong OID", "c0c010c0-d34d-b33f-f00d-111111111111", objectDelta.getOid()); PropertyDelta<ProtectedStringType> protectedStringDelta = objectDelta.findPropertyDelta(CREDENTIALS_PASSWORD_VALUE_PATH); assertNotNull("No protectedString delta", protectedStringDelta); Collection<PrismPropertyValue<ProtectedStringType>> valuesToReplace = protectedStringDelta.getValuesToReplace(); assertEquals("Wrong number of values to replace", 1, valuesToReplace.size()); PrismPropertyValue<ProtectedStringType> protectedStringVal = valuesToReplace.iterator().next(); assertNotNull("Null value in protectedStringDelta", protectedStringVal); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE); // apply to user objectDelta.applyTo(user); PrismProperty<ProtectedStringType> protectedStringProperty = user.findProperty(CREDENTIALS_PASSWORD_VALUE_PATH); PrismPropertyValue<ProtectedStringType> protectedStringPropertyValue = protectedStringProperty.getValue(); assertTrue("protectedString not equivalent", protectedStringPropertyValue.equals(protectedStringVal, EquivalenceStrategy.REAL_VALUE)); objectDelta.assertDefinitions(); }
String filename = filenameProperty.getValue().getValue(); if (filename == null) { LOGGER.error("Import: No file specified");
for (PrismProperty<?> identifier : identifiers) { RefinedAttributeDefinition rAttrDef; PrismPropertyValue<?> identifierValue = identifier.getValue(); if (objectClassDefinition == null) {
String entryUuid = (String) resourceObject.getPrimaryIdentifier().getValue().getValue(); Entry entry = openDJController.searchAndAssertByEntryUuid(entryUuid); display("Entry before change", entry);
private void assertDummyResource(PrismObject<ResourceType> resource, boolean fromRepo) { PrismContainer<Containerable> configurationPropertiesContainer = assertResource(resource, "Dummy Resource", RESOURCE_DUMMY_NAMESPACE, dummyConnector.getOid(), fromRepo); PrismProperty<ProtectedStringType> guardedProperty = configurationPropertiesContainer.findProperty( new ItemName(CONNECTOR_DUMMY_NAMESPACE, "uselessGuardedString")); // The resource was pulled from the repository. Therefore it does not have the right schema here. We should proceed with caution // and inspect the DOM elements there assertNotNull("No uselessGuardedString property in configuration properties", guardedProperty); PrismPropertyValue<ProtectedStringType> guardedPVal = guardedProperty.getValue(); if (fromRepo) { Object passwordRawElement = guardedPVal.getRawElement(); if (!(passwordRawElement instanceof MapXNode)) { AssertJUnit.fail("Expected password value of type "+ MapXNode.class+" but got "+passwordRawElement.getClass()); } MapXNode passwordXNode = (MapXNode) passwordRawElement; assertTrue("uselessGuardedString was not encrypted (clearValue)", passwordXNode.get(new QName("clearValue")) == null); assertTrue("uselessGuardedString was not encrypted (no encryptedData)", passwordXNode.get(new QName("encryptedData")) != null); } else { ProtectedStringType psType = guardedPVal.getValue(); assertNull("uselessGuardedString was not encrypted (clearValue)", psType.getClearValue()); assertNotNull("uselessGuardedString was not encrypted (no EncryptedData)", psType.getEncryptedDataType()); } }
displayNamePP.getValue().setValue("Green point"); AssertJUnit.fail("Value was changed when immutable!"); } catch (RuntimeException e) {
private void assertTask(PrismObject<TaskType> task) { task.checkConsistence(); assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); PrismObjectDefinition<TaskType> usedDefinition = task.getDefinition(); assertNotNull("No task definition", usedDefinition); PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), TaskType.COMPLEX_TYPE, TaskType.class); assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); TaskType taskType = task.asObjectable(); assertNotNull("asObjectable resulted in null", taskType); assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2")); assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); PrismProperty<TaskExecutionStatusType> executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); PrismPropertyValue<TaskExecutionStatusType> executionStatusValue = executionStatusProperty.getValue(); TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); PrismContainer extension = task.getExtension(); PrismContainerValue extensionValue = extension.getValue(); assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); }