@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 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); } }
String value = "someValue"; Protector protector256 = PrismInternalTestUtil.createProtector(XMLCipher.AES_256); Protector protector128 = PrismInternalTestUtil.createProtector(XMLCipher.AES_128);
assertFalse(pst.isEmpty()); Protector protector256 = PrismInternalTestUtil.createProtector(XMLCipher.AES_256);