use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class SynchronizationUtils method createSynchronizationSituationDescriptionDelta.
public static List<PropertyDelta<?>> createSynchronizationSituationDescriptionDelta(PrismObject object, SynchronizationSituationType situation, XMLGregorianCalendar timestamp, String sourceChannel, boolean full) {
SynchronizationSituationDescriptionType syncSituationDescription = new SynchronizationSituationDescriptionType();
syncSituationDescription.setSituation(situation);
syncSituationDescription.setChannel(sourceChannel);
syncSituationDescription.setTimestamp(timestamp);
syncSituationDescription.setFull(full);
List<PropertyDelta<?>> deltas = new ArrayList<PropertyDelta<?>>();
PropertyDelta syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
syncSituationDelta.addValueToAdd(new PrismPropertyValue(syncSituationDescription));
deltas.add(syncSituationDelta);
List<PrismPropertyValue<SynchronizationSituationDescriptionType>> oldSituationDescriptions = getSituationFromSameChannel(object, sourceChannel);
if (oldSituationDescriptions != null && !oldSituationDescriptions.isEmpty()) {
syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
syncSituationDelta.addValuesToDelete(oldSituationDescriptions);
deltas.add(syncSituationDelta);
}
return deltas;
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class CryptoUtil method checkEncrypted.
private static <T extends ObjectType> void checkEncrypted(PrismPropertyValue<?> pval) {
Itemable item = pval.getParent();
if (item == null) {
return;
}
ItemDefinition itemDef = item.getDefinition();
if (itemDef == null || itemDef.getTypeName() == null) {
return;
}
if (itemDef.getTypeName().equals(ProtectedStringType.COMPLEX_TYPE)) {
QName propName = item.getElementName();
PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>) pval;
ProtectedStringType ps = psPval.getValue();
if (ps.getClearValue() != null) {
throw new IllegalStateException("Unencrypted value in field " + propName);
}
} else if (itemDef.getTypeName().equals(NotificationConfigurationType.COMPLEX_TYPE)) {
// this is really ugly hack needed because currently it is not possible to break NotificationConfigurationType into prism item [pm]
NotificationConfigurationType ncfg = ((PrismPropertyValue<NotificationConfigurationType>) pval).getValue();
if (ncfg.getMail() != null) {
for (MailServerConfigurationType mscfg : ncfg.getMail().getServer()) {
if (mscfg.getPassword() != null && mscfg.getPassword().getClearValue() != null) {
throw new IllegalStateException("Unencrypted value in mail server config password entry");
}
}
}
if (ncfg.getSms() != null) {
for (SmsConfigurationType smscfg : ncfg.getSms()) {
for (SmsGatewayConfigurationType gwcfg : smscfg.getGateway()) {
if (gwcfg.getPassword() != null && gwcfg.getPassword().getClearValue() != null) {
throw new IllegalStateException("Unencrypted value in SMS gateway config password entry");
}
}
}
}
}
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class CryptoUtil method encryptValue.
private static <T extends ObjectType> void encryptValue(Protector protector, PrismPropertyValue<?> pval) throws EncryptionException {
Itemable item = pval.getParent();
if (item == null) {
return;
}
ItemDefinition itemDef = item.getDefinition();
if (itemDef == null || itemDef.getTypeName() == null) {
return;
}
if (itemDef.getTypeName().equals(ProtectedStringType.COMPLEX_TYPE)) {
QName propName = item.getElementName();
PrismPropertyValue<ProtectedStringType> psPval = (PrismPropertyValue<ProtectedStringType>) pval;
ProtectedStringType ps = psPval.getValue();
encryptProtectedStringType(protector, ps, propName.getLocalPart());
if (pval.getParent() == null) {
pval.setParent(item);
}
} else if (itemDef.getTypeName().equals(NotificationConfigurationType.COMPLEX_TYPE)) {
// this is really ugly hack needed because currently it is not possible to break NotificationConfigurationType into prism item [pm]
NotificationConfigurationType ncfg = ((PrismPropertyValue<NotificationConfigurationType>) pval).getValue();
if (ncfg.getMail() != null) {
for (MailServerConfigurationType mscfg : ncfg.getMail().getServer()) {
encryptProtectedStringType(protector, mscfg.getPassword(), "mail server password");
}
}
if (ncfg.getSms() != null) {
for (SmsConfigurationType smscfg : ncfg.getSms()) {
for (SmsGatewayConfigurationType gwcfg : smscfg.getGateway()) {
encryptProtectedStringType(protector, gwcfg.getPassword(), "sms gateway password");
}
}
}
}
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class TestJaxbSanity method testUnmarshallAndEqualsResource.
@Test
public void testUnmarshallAndEqualsResource() throws JAXBException, SchemaException, FileNotFoundException {
System.out.println("\n\n ===[testUnmarshallAndEqualsResource]===\n");
// GIVEN
ResourceType resource1Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class);
assertNotNull(resource1Type);
System.out.println("Resource1 " + resource1Type.asPrismObject().debugDump());
PrismObject resource1 = resource1Type.asPrismObject();
ResourceType resource2Type = JaxbTestUtil.getInstance().unmarshalObject(new File(RESOURCE_OPENDJ_FILENAME), ResourceType.class);
assertNotNull(resource2Type);
System.out.println("Resource2 " + resource2Type.asPrismObject().debugDump());
PrismObject resource2 = resource2Type.asPrismObject();
// WHEN, THEN
ObjectDelta<ResourceType> objectDelta = resource1.diff(resource2);
System.out.println("Resource delta:");
System.out.println(objectDelta.debugDump());
assertTrue("Resource delta is not empty", objectDelta.isEmpty());
assertTrue("Resource not equal", resource1Type.equals(resource2Type));
System.out.println("HASH");
System.out.println(resource1Type.hashCode());
System.out.println(resource2Type.hashCode());
assertTrue("Resource hashcode does not match", resource1Type.hashCode() == resource2Type.hashCode());
PrismPropertyValue<Object> pv1 = new PrismPropertyValue<Object>(resource1Type.getConnectorConfiguration());
PrismPropertyValue<Object> pv2 = new PrismPropertyValue<Object>(resource2Type.getConnectorConfiguration());
assertTrue("Real property values not equal", pv1.equalsRealValue(pv2));
}
use of com.evolveum.midpoint.prism.PrismPropertyValue in project midpoint by Evolveum.
the class TestMappingTime method testNoReferenceTime.
@Test
public void testNoReferenceTime() throws Exception {
final String TEST_NAME = "testNoReferenceTime";
System.out.println("===[ " + TEST_NAME + "]===");
// GIVEN
PrismObject<UserType> userOld = evaluator.getUserOld();
userOld.asObjectable().getActivation().setDisableTimestamp(null);
Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", null, userOld);
builder.setNow(TIME_PAST);
PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
builder.setDefaultTargetDefinition(existenceDef);
Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
assertNullTriple(outputTriple);
assertNextRecompute(mapping, null);
}
Aggregations