private BeanMarshaller getBeanMarshaller() { return ((PrismContextImpl) prismContext).getBeanMarshaller(); }
@NotNull private BeanMarshaller getBeanMarshaller() { return ((PrismContextImpl) getPrismContext()).getBeanMarshaller(); } //endregion
@Override public QName determineTypeForClass(Class<?> clazz) { if (XmlTypeConverter.canConvert(clazz)) { return XsdTypeMapper.toXsdType(clazz); } else { return ((PrismContextImpl) prismContext).getBeanMarshaller().determineTypeForClass(clazz); } }
@Override public void revive(PrismContext prismContext) throws SchemaException { super.revive(prismContext); if (value != null) { if (value instanceof Revivable) { ((Revivable)value).revive(prismContext); } else { BeanMarshaller marshaller = ((PrismContextImpl) prismContext).getBeanMarshaller(); if (marshaller.canProcess(value.getClass())) { marshaller.revive(value, prismContext); } } } }
/** * TODO rewrite this method using Prism API */ @Override public void serializeFaultMessage(Detail detail, Object faultInfo, QName faultMessageElementName, Trace logger) { try { XNodeImpl faultMessageXnode = prismContext.getBeanMarshaller().marshall(faultInfo); RootXNodeImpl xroot = new RootXNodeImpl(faultMessageElementName, faultMessageXnode); xroot.setExplicitTypeDeclaration(true); QName faultType = prismContext.getSchemaRegistry().determineTypeForClass(faultInfo.getClass()); xroot.setTypeQName(faultType); prismContext.getParserDom().serializeUnderElement(xroot, faultMessageElementName, detail); } catch (SchemaException e) { logger.error("Error serializing fault message (SOAP fault detail): {}", e.getMessage(), e); } }
@Test public void testParseProtectedStringEncrypted() throws Exception { final String TEST_NAME = "testParseProtectedStringEncrypted"; displayTestTitle(TEST_NAME); // GIVEN Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128); ProtectedStringType protectedStringType = protector.encryptString("salalala"); PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN MapXNodeImpl protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null); System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump()); // THEN ProtectedStringType unmarshalled = new ProtectedStringType(); prismContext.hacks().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext()); System.out.println("Unmarshalled value: " + unmarshalled); assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled); }
@Test public void testMarshallObjectDeltaType() throws Exception { ObjectDeltaType delta = new ObjectDeltaType(); delta.setOid("07b32c14-0c18-460b-bd4a-99b96699f952"); delta.setChangeType(ChangeTypeType.MODIFY); ItemDeltaType item1 = new ItemDeltaType(); delta.getItemDelta().add(item1); item1.setModificationType(ModificationTypeType.REPLACE); Document document = DOMUtil.getDocument(); // Element path = document.createElementNS(SchemaConstantsGenerated.NS_TYPES, "path"); // path.setTextContent("c:credentials/c:password"); ItemPath path = ItemPath.create(SchemaConstantsGenerated.C_CREDENTIALS, CredentialsType.F_PASSWORD); item1.setPath(new ItemPathType(path)); ProtectedStringType protectedString = new ProtectedStringType(); protectedString.setEncryptedData(new EncryptedDataType()); RawType value = new RawType(((PrismContextImpl) PrismTestUtil.getPrismContext()).getBeanMarshaller().marshall(protectedString), PrismTestUtil.getPrismContext()); item1.getValue().add(value); String xml = PrismTestUtil.serializeJaxbElementToString( new JAXBElement<>(new QName("http://www.example.com", "custom"), Object.class, delta)); assertNotNull(xml); }
@Test public void testParseProtectedStringHashed() throws Exception { final String TEST_NAME = "testParseProtectedStringHashed"; displayTestTitle(TEST_NAME); // GIVEN ProtectedStringType protectedStringType = new ProtectedStringType(); protectedStringType.setClearValue("blabla"); Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128); protector.hash(protectedStringType); PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN MapXNodeImpl protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null); System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump()); // THEN ProtectedStringType unmarshalled = new ProtectedStringType(); prismContext.hacks().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext()); System.out.println("Unmarshalled value: " + unmarshalled); assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled); } }