Eclipse Xquery For Complex payload - eclipse

I have the input request like below
<Input>
<BusinessObjects>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>857895</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
<BusinessObject>
<BusinessIdentifiers>
<BusinessIdentifier>
<BKey>BuCode</BKey>
<BValue>CDC</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>BuType</BKey>
<BValue>123</BValue>
</BusinessIdentifier>
<BusinessIdentifier>
<BKey>CsmNo</BKey>
<BValue>34567</BValue>
</BusinessIdentifier>
</BusinessIdentifiers>
</BusinessObject>
</BusinessObjects>
</Input>
i need to form an output like below schema
<Output>
<BusinessObject>
<BIKey></BIKey>
<BKey></BIKey>
<Bvalue></Bvalue>
<BOID></BOID>
</BusinessObject>
</Output>
For the above payload
The output should be
<Output>
<BusinessObjects>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:857895</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUCode</BKey>
<Bvalue>CDC</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>BUtype</BKey>
<Bvalue>123</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
<BusinessObject>
<BIKey>CDC:123:857895|CDC:123:34567</BIKey>
<BKey>CSMNo</BKey>
<Bvalue>857895</Bvalue>
<BOID>CDC:123:34567</BOID>
</BusinessObject>
</BusinessObjects>
</Output>
i have tried below Xquery to get the same but ended up with errors or not meeting the requiremnt
<Ouput>
<BusinessObjects>
{
for $bi in Input/BusinessObjects/BusinessObject/BusinessIdentifiers/BusinessIdentifier
return
<BIKey>
{
string-join(
for $bo in Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, '|'),
':'
)
}
</BIKey>
<BKey>data {$bi/Bkey}</BKey>
<Bvalue>data {$bi/Bvalue}</Bvalue>
for $bo in Input/BusinessObjects/BusinessObject return <BOID>{string-join($bo//BValue, ':')}<BOID>
}
</BusinessObjects>
</Ouput>
the description for the output fields as follows
BIKey-->it has formed with all the Bvalues of 'Business Identifier' concatenated with ':' and then for each businessobject it is separed with '|'
Bkey-->Straight mapping with bkey
Bvalue-->Straight mapping with Bvalue
BOID--> it has to formed for each businessobject, need to concatenate the values Bvalues of Business Identifiers with ':'
Any suggestions, i believe that i have to two complex loops in here, but not able to crack it.
Thanks for #Martin as he helped me to crack this using 'ancestor' axis, but some how eclispe is not identifying 'ancestor'.
Thanks

The BIKey will be the same for all of the output, so we can compute it outside of any loop and be done with it. We do so by joining all the BValues of a BusinessObject with :, and joining the result of this for each BusinessObject with | :
let $BIKey := string-join(for $bo in /Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, ':'), '|')
The BOID will depend on the BusinessObject we're handling, so we need to loop over those and we can extract the BOID at that point :
let $BIKEY := [...]
for $bo in /Input/BusinessObjects/BusinessObject
let $BOID := string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, ':')
The rest of the output fields depend on the BusinessIdentifier, so let's loop on these too and return a BusinessObject per BusinessIdentifier :
let $BIKEY := [...]
for $bo in [...]
let $BOID := [...]
return for $bi in $bo/BusinessIdentifiers/BusinessIdentifier/
return <BusinessObject>
<BIKey>{$BIKEY}</BIKey>
<BKey>{$bi/BKey}</BKey>
<Bvalue>{$bi/Value}</Bvalue>
<BOID>{$BOID}</BOID>
</BusinessObject>
Now all we need is to wrap those output BusinessObjects into their parent tags :
<output><BusinessObjects>{
let $BIKEY := string-join(for $bo in /Input/BusinessObjects/BusinessObject return string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, ':'), '|')
for $bo in /Input/BusinessObjects/BusinessObject
let $BOID := string-join($bo/BusinessIdentifiers/BusinessIdentifier/BValue, ':')
return
for $bi in $bo/BusinessIdentifiers/BusinessIdentifier
return <BusinessObject>
<BIKey>{$BIKEY}</BIKey>
<BKey>{$bi/BKey/text()}</BKey>
<Bvalue>{$bi/BValue/text()}</Bvalue>
<BOID>{$BOID}</BOID>
</BusinessObject>
}</BusinessObjects></output>
You can test it here.

Related

Soap request signing

Hello fellow developers,
I have no experience working on soap, saml and xml signing,
I am trying to generate this structure and then add 2 signature tags to it.
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header xmlns:a="http://www.w3.org/2005/08/addressing">
<a:MessageID></a:MessageID>
<a:To env:mustUnderstand="true"></a:To>
<a:Action env:mustUnderstand="true">urn:hl7-org:v3:PRPA_IN201305UV02:CrossGatewayPatientDiscovery</a:Action>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Timestamp wsu:Id="timestamp_ID">
<wsu:Created>2022-10-13T18:18:17.763Z</wsu:Created>
<wsu:Expires>2023-10-13T18:23:17.763Z</wsu:Expires>
</wsu:Timestamp>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ID="assertion_ID" IssueInstant="2022-10-13T18:18:17.763Z" Version="2.0">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName"></saml2:Issuer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#assertion_ID">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue></SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate></X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"></saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:holder-of-key">
<saml2:SubjectConfirmationData>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyValue>
<RSAKeyValue>
<Modulus></Modulus>
<Exponent>AQAB</Exponent>
</RSAKeyValue>
</KeyValue>
</KeyInfo>
</saml2:SubjectConfirmationData>
</saml2:SubjectConfirmation>
</saml2:Subject>
<saml2:Conditions NotBefore="2022-10-13T18:15:17.763Z" NotOnOrAfter="2022-10-13T18:23:17.763Z">
<saml2:AudienceRestriction>
<saml2:Audience></saml2:Audience>
</saml2:AudienceRestriction>
</saml2:Conditions>
<saml2:AuthnStatement AuthnInstant="2022-10-13T17:55:17.743Z" SessionIndex="1234567890">
<saml2:SubjectLocality Address="10.1.1.144" DNSName="localhost"/>
<saml2:AuthnContext>
<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
</saml2:AuthnContext>
</saml2:AuthnStatement>
<saml2:AttributeStatement>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:subject-id">
<saml2:AttributeValue>John Doe</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization">
<saml2:AttributeValue>Dr. John M Doe, MD Practice</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:organization-id">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:nhin:names:saml:homeCommunityId">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xacml:2.0:subject:role">
<saml2:AttributeValue>
<Role xmlns="urn:hl7-org:v3" code="112247003" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED CT" displayName="Medical doctor" xsi:type="CE"/>
</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xspa:1.0:subject:purposeofuse">
<saml2:AttributeValue>
<PurposeOfUse xmlns="urn:hl7-org:v3" code="TREATMENT" codeSystem="2.16.840.1.113883.3.18.7.1" codeSystemName="nhin-purpose" displayName="Treatment" xsi:type="CE"/>
</saml2:AttributeValue>
</saml2:Attribute>
<saml2:Attribute Name="urn:oasis:names:tc:xacml:2.0:resource:resource-id">
<saml2:AttributeValue></saml2:AttributeValue>
</saml2:Attribute>
</saml2:AttributeStatement>
</saml2:Assertion>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#timestamp_ID">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue></DigestValue>
</Reference>
</SignedInfo>
<SignatureValue></SignatureValue>
<KeyInfo>
<wsse:SecurityTokenReference xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0">
<wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID">assertion_ID</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
</KeyInfo>
</Signature>
</wsse:Security>
</env:Header>
<env:Body>
<PRPA_IN201305UV02 xmlns="urn:hl7-org:v3" ITSVersion="XML_1.0">
<id extension="126627497759" root="1.3.6.1.4.1.52618.1.3"/>
<creationTime value="20221013181817"/>
<interactionId extension="PRPA_IN201305UV02" root="2.16.840.1.113883.1.6"/>
<processingCode code="P"/>
<processingModeCode code="T"/>
<acceptAckCode code="AL"/>
<receiver typeCode="RCV">
<device classCode="DEV" determinerCode="INSTANCE">
<id root="0.0.0"/>
<telecom value="https://RH-Windows-TMP-b994dba9f85ba908.elb.us-east-1.amazonaws.com:4437/"/>
<asAgent classCode="AGNT">
<representedOrganization classCode="ORG" determinerCode="INSTANCE">
<id root=""/>
</representedOrganization>
</asAgent>
</device>
</receiver>
<sender typeCode="SND">
<device classCode="DEV" determinerCode="INSTANCE">
<id root="1.3.6.1.4.1.52618.1.2"/>
<asAgent classCode="AGNT">
<representedOrganization classCode="ORG" determinerCode="INSTANCE">
<id root="1.3.6.1.4.1.52618.1"/>
</representedOrganization>
</asAgent>
</device>
</sender>
<controlActProcess classCode="CACT" moodCode="EVN">
<code code="PRPA_TE201305UV02" codeSystem="2.16.840.1.113883.1.6"/>
<authorOrPerformer typeCode="AUT">
<assignedDevice classCode="ASSIGNED">
<id root="1.3.6.1.4.1.52618.1.1"/>
</assignedDevice>
</authorOrPerformer>
<queryByParameter>
<queryId extension="126627497760" root="1.3.6.1.4.1.52618.1.3.1"/>
<statusCode code="new"/>
<responseModalityCode code="R"/>
<responsePriorityCode code="I"/>
<parameterList>
<livingSubjectAdministrativeGender>
<value code="M"/>
<semanticsText>LivingSubject.administrativeGender</semanticsText>
</livingSubjectAdministrativeGender>
<livingSubjectBirthTime>
<value value=""/>
<semanticsText>LivingSubject.birthTime</semanticsText>
</livingSubjectBirthTime>
<livingSubjectId>
<value extension="" root="1.3.6.1.4.1.52618.1.1"/>
<semanticsText>LivingSubject.id</semanticsText>
</livingSubjectId>
<livingSubjectName>
<value>
<given></given>
<family>TEST</family>
</value>
<semanticsText>LivingSubject.name</semanticsText>
</livingSubjectName>
<patientAddress>
<value>
<streetAddressLine>Home Dr</streetAddressLine>
<city>Charlotte</city>
<state>NC</state>
<postalCode></postalCode>
<country>US</country>
</value>
<semanticsText>Patient.addr</semanticsText>
</patientAddress>
</parameterList>
</queryByParameter>
</controlActProcess>
</PRPA_IN201305UV02>
</env:Body>
</env:Envelope>
I am using rhino javascript and below is the code
//////////////////////////////////////////////////////////////////////////////////
// Generate our dynamic message values
//
var timestampId = UUIDGenerator.getUUID();
var assertionId = UUIDGenerator.getUUID();
var createdTimestamp = new Date().toISOString();
var expiresTimestamp = new Date((new Date()).getTime() + 10000*10).toISOString();
var samlenvelope="<env:Envelope xmlns:env=\"http://www.w3.org/2003/05/soap-envelope\">"+
"<env:Header xmlns:a=\"http://www.w3.org/2005/08/addressing\">"+
"<a:MessageID>urn:uuid:32886a29-98ad-4284-b00e-3fe4ded10d16</a:MessageID>"+
"<a:To env:mustUnderstand=\"true\"></a:To>"+
"<a:Action env:mustUnderstand=\"true\">urn:hl7-org:v3:PRPA_IN201305UV02:CrossGatewayPatientDiscovery</a:Action>"+
"<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">"+
"<wsu:Timestamp wsu:Id=\"timestamp_ID\">"+
"<wsu:Created>2022-10-13T18:18:17.763Z</wsu:Created>"+
"<wsu:Expires>2023-10-13T18:23:17.763Z</wsu:Expires>"+
"</wsu:Timestamp>"+
"<saml2:Assertion xmlns:saml2=\"urn:oasis:names:tc:SAML:2.0:assertion\" xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ID=\"assertion_ID\" IssueInstant=\"2022-10-13T18:18:17.763Z\" Version=\"2.0\">"+
"<saml2:Issuer Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:X509SubjectName\"></saml2:Issuer>"+
"<saml2:Subject>"+
"<saml2:NameID Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName\"></saml2:NameID>"+
"<saml2:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:holder-of-key\">"+
"<saml2:SubjectConfirmationData>"+
"<KeyInfo xmlns=\"http://www.w3.org/2000/09/xmldsig#\">"+
"<KeyValue>"+
"<RSAKeyValue>"+
"<Modulus></Modulus>"+
"<Exponent>AQAB</Exponent>"+
"</RSAKeyValue>"+
"</KeyValue>"+
"</KeyInfo>"+
"</saml2:SubjectConfirmationData>"+
"</saml2:SubjectConfirmation>"+
"</saml2:Subject>"+
"<saml2:Conditions NotBefore=\"2022-10-13T18:15:17.763Z\" NotOnOrAfter=\"2022-10-13T18:23:17.763Z\">"+
"</saml2:Conditions>"+
"<saml2:AuthnStatement AuthnInstant=\"2022-10-13T17:55:17.743Z\" SessionIndex=\"1234567890\">"+
"<saml2:SubjectLocality Address=\"10.1.1.144\" DNSName=\"localhost\"/>"+
"<saml2:AuthnContext>"+
"<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>"+
"</saml2:AuthnContext>"+
"</saml2:AuthnStatement>"+
"<saml2:AttributeStatement>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:subject-id\">"+
"<saml2:AttributeValue>John Doe</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:organization\">"+
"<saml2:AttributeValue>Dr. John M Doe, MD Practice</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:organization-id\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:nhin:names:saml:homeCommunityId\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xacml:2.0:subject:role\">"+
"<saml2:AttributeValue>"+
"<Role xmlns=\"urn:hl7-org:v3\" code=\"112247003\" codeSystem=\"2.16.840.1.113883.6.96\" codeSystemName=\"SNOMED CT\" displayName=\"Medical doctor\" xsi:type=\"CE\"/>"+
"</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xspa:1.0:subject:purposeofuse\">"+
"<saml2:AttributeValue>"+
"<PurposeOfUse xmlns=\"urn:hl7-org:v3\" code=\"TREATMENT\" codeSystem=\"2.16.840.1.113883.3.18.7.1\" codeSystemName=\"nhin-purpose\" displayName=\"Treatment\" xsi:type=\"CE\"/>"+
"</saml2:AttributeValue>"+
"</saml2:Attribute>"+
"<saml2:Attribute Name=\"urn:oasis:names:tc:xacml:2.0:resource:resource-id\">"+
"<saml2:AttributeValue></saml2:AttributeValue>"+
"</saml2:Attribute>"+
"</saml2:AttributeStatement>"+
"</saml2:Assertion>"+
"</wsse:Security>"+
"</env:Header>"+
"<env:Body>"+
"<PRPA_IN201305UV02 xmlns=\"urn:hl7-org:v3\" ITSVersion=\"XML_1.0\">"+
"<id extension=\"126627497759\" root=\"1.3.6.1.4.1.52618.1.3\"/>"+
"<creationTime value=\"20221013181817\"/>"+
"<interactionId extension=\"PRPA_IN201305UV02\" root=\"2.16.840.1.113883.1.6\"/>"+
"<processingCode code=\"P\"/>"+
"<processingModeCode code=\"T\"/>"+
"<acceptAckCode code=\"AL\"/>"+
"<receiver typeCode=\"RCV\">"+
"<device classCode=\"DEV\" determinerCode=\"INSTANCE\">"+
"<id root=\"0.0.0\"/>"+
"<telecom value=\"https://RH-Windows-TMP-b994dba9f85ba908.elb.us-east-1.amazonaws.com:4437/\"/>"+
"<asAgent classCode=\"AGNT\">"+
"<representedOrganization classCode=\"ORG\" determinerCode=\"INSTANCE\">"+
"<id root=\"\"/>"+
"</representedOrganization>"+
"</asAgent>"+
"</device>"+
"</receiver>"+
"<sender typeCode=\"SND\">"+
"<device classCode=\"DEV\" determinerCode=\"INSTANCE\">"+
"<id root=\"1.3.6.1.4.1.52618.1.2\"/>"+
"<asAgent classCode=\"AGNT\">"+
"<representedOrganization classCode=\"ORG\" determinerCode=\"INSTANCE\">"+
"<id root=\"1.3.6.1.4.1.52618.1\"/>"+
"</representedOrganization>"+
"</asAgent>"+
"</device>"+
"</sender>"+
"<controlActProcess classCode=\"CACT\" moodCode=\"EVN\">"+
"<code code=\"PRPA_TE201305UV02\" codeSystem=\"2.16.840.1.113883.1.6\"/>"+
"<authorOrPerformer typeCode=\"AUT\">"+
"<assignedDevice classCode=\"ASSIGNED\">"+
"<id root=\"1.3.6.1.4.1.52618.1.1\"/>"+
"</assignedDevice>"+
"</authorOrPerformer>"+
"<queryByParameter>"+
"<queryId extension=\"\" root=\"1.3.6.1.4.1.52618.1.3.1\"/>"+
"<statusCode code=\"new\"/>"+
"<responseModalityCode code=\"R\"/>"+
"<responsePriorityCode code=\"I\"/>"+
"<parameterList>"+
"<livingSubjectAdministrativeGender>"+
"<value code=\"M\"/>"+
"<semanticsText>LivingSubject.administrativeGender</semanticsText>"+
"</livingSubjectAdministrativeGender>"+
"<livingSubjectBirthTime>"+
"<value value=\"\"/>"+
"<semanticsText>LivingSubject.birthTime</semanticsText>"+
"</livingSubjectBirthTime>"+
"<livingSubjectId>"+
"<value extension=\"\" root=\"1.3.6.1.4.1.52618.1.1\"/>"+
"<semanticsText>LivingSubject.id</semanticsText>"+
"</livingSubjectId>"+
"<livingSubjectName>"+
"<value>"+
"<given></given>"+
"<family>TEST</family>"+
"</value>"+
"<semanticsText>LivingSubject.name</semanticsText>"+
"</livingSubjectName>"+
"<patientAddress>"+
"<value>"+
"<streetAddressLine>Home Dr</streetAddressLine>"+
"<city>Charlotte</city>"+
"<state>NC</state>"+
"<postalCode></postalCode>"+
"<country>US</country>"+
"</value>"+
"<semanticsText>Patient.addr</semanticsText>"+
"</patientAddress>"+
"</parameterList>"+
"</queryByParameter>"+
"</controlActProcess>"+
"</PRPA_IN201305UV02>"+
"</env:Body>"+
"</env:Envelope>"+;
var samlString = new java.lang.String(samlenvelope);
////////////////////////////////////////////////////////////////////////////////////
// Build our XML DOM for signature
//
var documentBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
var document = documentBuilderFactory.newDocumentBuilder().parse(new java.io.ByteArrayInputStream(samlString.getBytes("utf-8")));
////////////////////////////////////////////////////////////////////////////////////
// Configure Digital Signature utilities for required crypto operations
//
var xmlDsigFactory = javax.xml.crypto.dsig.XMLSignatureFactory.getInstance("DOM");
var parameterSpec = new javax.xml.crypto.dsig.spec.ExcC14NParameterSpec();
var reference = xmlDsigFactory.newReference
(
"#assertion_ID",
xmlDsigFactory.newDigestMethod(javax.xml.crypto.dsig.DigestMethod.SHA1, null),
java.util.Collections.singletonList(xmlDsigFactory.newTransform("http://www.w3.org/2001/10/xml-exc-c14n#", parameterSpec)),
null, //type
null //id
)
var signedInfo = xmlDsigFactory.newSignedInfo
(
xmlDsigFactory.newCanonicalizationMethod
(
javax.xml.crypto.dsig.CanonicalizationMethod.EXCLUSIVE,
parameterSpec
),
xmlDsigFactory.newSignatureMethod(javax.xml.crypto.dsig.SignatureMethod.RSA_SHA1, null),
java.util.Collections.singletonList(reference)
)
var reference1 = xmlDsigFactory.newReference
(
"#timestamp_ID",
xmlDsigFactory.newDigestMethod(javax.xml.crypto.dsig.DigestMethod.SHA1, null),
java.util.Collections.singletonList(xmlDsigFactory.newTransform("http://www.w3.org/2001/10/xml-exc-c14n#", parameterSpec)),
null, //type
null //id
)
var signedInfo1 = xmlDsigFactory.newSignedInfo
(
xmlDsigFactory.newCanonicalizationMethod
(
javax.xml.crypto.dsig.CanonicalizationMethod.EXCLUSIVE,
parameterSpec
),
xmlDsigFactory.newSignatureMethod(javax.xml.crypto.dsig.SignatureMethod.RSA_SHA1, null),
java.util.Collections.singletonList(reference1)
)
//////////////////////////////////////////////////////
// Fetch our certificate and key
//
var certificate;
try
{
var inputStream = new java.io.FileInputStream("test.crt");
var certificateFactory = java.security.cert.CertificateFactory.getInstance("X.509");
certificate = certificateFactory.generateCertificate(inputStream);
}
finally
{
if (inputStream != null)
inputStream.close();
}
var privateKey;
var keyFactory = java.security.KeyFactory.getInstance("RSA");
var keySpec = new java.security.spec.PKCS8EncodedKeySpec(java.nio.file.Files.readAllBytes(new java.io.File("private_key.der").toPath()));
privateKey = keyFactory.generatePrivate(keySpec);
////////////////////////////////////////////////////////
// Generate the KeyInfo for our signature
//
var keyInfoFactory = xmlDsigFactory.getKeyInfoFactory();
var x509Content = new java.util.ArrayList();
x509Content.add(certificate);
var x509Data = keyInfoFactory.newX509Data(x509Content);
var keyInfo = keyInfoFactory.newKeyInfo(java.util.Collections.singletonList(x509Data));
var signature = xmlDsigFactory.newXMLSignature(signedInfo, keyInfo);
var dsc = new javax.xml.crypto.dsig.dom.DOMSignContext(privateKey, document.getDocumentElement());
var rootEl = document.getDocumentElement();
rootEl.setIdAttribute("ID",true);
signature.sign(dsc);
var signature1 = xmlDsigFactory.newXMLSignature(signedInfo1, keyInfo1);
var dsc = new javax.xml.crypto.dsig.dom.DOMSignContext(privateKey, document.getDocumentElement());
signature1.sign(dsc);
/*
var newEle=document.createElement("Transform");
newEle.setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#enveloped-signature');
document.getElementsByTagName("Transforms").item(0).appendChild(newEle);*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define any formatting preferences get the signed document as a string
//
var transformerFactory = javax.xml.transform.TransformerFactory.newInstance();
var transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
var stringWriter = new java.io.StringWriter();
transformer.transform(new javax.xml.transform.dom.DOMSource(document), new javax.xml.transform.stream.StreamResult(stringWriter));
channelMap.put("soapMessage", stringWriter.toString());
when I run the code I get this error
Wrapped org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to
reference a node in a context where it does not exist.
Will appreciate your help

How to put And and OR filter type when RetrieveMultiple query is Fetch Expression

Please advice how to filter CRM/Model Driven App Unified Client Interface View using below same query expression in RetrieveMultiple plugin when input parameter query is of type Fetch Expression:
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression("reopeningcount", ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression("sourcechannelidname", ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression("valid", ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
qe.Criteria.AddFilter(filter);
I tried below by taking help from Microsoft documentation as described here:
https://learn.microsoft.com/en-us/powerapps/developer/data-platform/org-service/samples/modify-query-preoperation-stage
But I don't have any idea how to put And and OR filter type in below XML Document.
Any help or guidance would be appreciated a lot.
entityElement.Add(
new XElement("filter",
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);
In FetchXml the expression you're trying to write is (see the type='and'):
<filter type='and' >
<condition attribute='sourcechannelidname' operator='not-in' >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute='casetypecode' operator='eq' value='1' >
</filter>
So I think you just need to specify an XAttribute on the "filter" XElement
entityElement.Add(
new XElement("filter",
new XAttribute("type", "and"),
new XElement("condition",
new XAttribute("attribute", "sourcechannelidname"),
new XAttribute("operator", "not-in"), //not equal
new XElement("value", new XText("Central Bank")),
new XElement("value", new XText("AECB"))
),
new XElement("condition",
new XAttribute("attribute", "casetypecode"),
new XAttribute("operator", "eq"), //equal
new XAttribute("value", "1"), //Complaints
)
)
);
XrmToolbox can now parse C# into a fetch expression. Just use the "View" menu and choose "QueryExpression" to get it to pull open the window, then type (or paste) your valid code into it and click "Parse" and it will turn it into FetchXml for you.
You didn't include the full fetchXml query, and I didn't recognize the field names, but I copied it to the OOTB incident query (since I knew it had a casetypecode field) and replaced the field names with the same type. I made them parameters so you can easily replace them with your own params. Here is the code I used:
// Instantiate QueryExpression query
var query = new QueryExpression("incident");
query.TopCount = 50;
// Add all columns to query.ColumnSet
query.ColumnSet.AllColumns = true;
FilterExpression filter = new FilterExpression(LogicalOperator.Or);
string[] sourceChannel = new string[] { "Central Bank", "AECB" };
var stringColName = "ticketnumber";
var intColName = "timezoneruleversionnumber";
var pickColName = "servicestage";
FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
filter1.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.NotIn, sourceChannel));
filter1.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter2 = new FilterExpression(LogicalOperator.And);
filter2.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter2.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 1));
filter2.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter3 = new FilterExpression(LogicalOperator.And);
filter3.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter3.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter3.Conditions.Add(new ConditionExpression(intColName, ConditionOperator.GreaterThan, 0));
filter3.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
FilterExpression filter4 = new FilterExpression(LogicalOperator.And);
filter4.Conditions.Add(new ConditionExpression(stringColName, ConditionOperator.In, sourceChannel));
filter4.Conditions.Add(new ConditionExpression(pickColName , ConditionOperator.Equal, 2));
filter4.Conditions.Add(new ConditionExpression("statecode", ConditionOperator.NotEqual, 0));
filter4.Conditions.Add(new ConditionExpression("casetypecode", ConditionOperator.Equal, 1));
filter.AddFilter(filter1);
filter.AddFilter(filter2);
filter.AddFilter(filter3);
filter.AddFilter(filter4);
query.Criteria.AddFilter(filter);
and this is the filter it created:
<filter type="and" >
<filter type="or" >
<filter type="and" >
<condition attribute="ticketnumber" operator="not-in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="1" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="timezoneruleversionnumber" operator="gt" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
<filter type="and" >
<condition attribute="ticketnumber" operator="in" >
<value>Central Bank</value>
<value>AECB</value>
</condition>
<condition attribute="servicestage" operator="eq" value="2" />
<condition attribute="statecode" operator="ne" value="0" />
<condition attribute="casetypecode" operator="eq" value="1" />
</filter>
</filter>
</filter>

Expected behavior of the renderer for superscripts and subscripts in Word Open XML

It looks like ECMA specification for Word Open XML doesn't specify how to render "runs" with vertAlign attribute. Is there a document describing the expected behavior:
What font size to use for superscripts and subscripts?
For how much to shift the superscript/subscript text relatively to the baseline?
Just for reference, here's a document.xml generated by MS Word for a trivial document containing text "X²" (XML namespaces are omitted for brevity):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document>
<w:body>
<w:p w14:paraId="4B8ED8F1" w14:textId="3891D3E1"
w:rsidR="00CE1223" w:rsidRDefault="00886D56">
<w:r>
<w:t>X</w:t>
</w:r>
<w:r w:rsidRPr="00886D56">
<w:rPr>
<w:vertAlign w:val="superscript"/>
</w:rPr>
<w:t>2</w:t>
</w:r>
<w:bookmarkStart w:id="0" w:name="_GoBack"/>
<w:bookmarkEnd w:id="0"/>
</w:p>
<w:sectPr w:rsidR="00CE1223">
<w:pgSz w:w="12240" w:h="15840"/>
<w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"
w:header="720" w:footer="720" w:gutter="0"/>
<w:cols w:space="720"/>
<w:docGrid w:linePitch="360"/>
</w:sectPr>
</w:body>
</w:document>
The RunProperties elements has following two child elements which can be used to set the position and the font of a Run which has a VerticalTextAlignment:
The RunFonts element which can be used to set the type of font
The Position element which can be used to lower or raise the the run in relation to its default baseline.
Using these elements you can create a run which is in superscript and has an adjusted font:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
This will output the follwing openxml:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
And you can shift the vertical aligned run using these elements:
// Creates an RunProperties instance and adds its children.
public RunProperties GenerateRunProperties()
{
RunProperties runProperties1 = new RunProperties();
RunFonts runFonts1 = new RunFonts(){ Ascii = "Times New Roman", HighAnsi = "Times New Roman", ComplexScript = "Times New Roman" };
Position position1 = new Position(){ Val = "-10" };
FontSize fontSize1 = new FontSize(){ Val = "48" };
VerticalTextAlignment verticalTextAlignment1 = new VerticalTextAlignment(){ Val = VerticalPositionValues.Superscript };
runProperties1.Append(runFonts1);
runProperties1.Append(position1);
runProperties1.Append(fontSize1);
runProperties1.Append(verticalTextAlignment1);
return runProperties1;
}
Generating the follwing openXML:
<w:rPr xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman" w:cs="Times New Roman" />
<w:position w:val="-10" />
<w:sz w:val="48" />
<w:vertAlign w:val="superscript" />
</w:rPr>
Depending on the value that you assign to the position element the run will be raised or lowered in relation to its baseline:
Positve => Raised
Negative => Lowered

Changing RowIds when saving cache object that uses cache sql storage

First I apologise for the lengh of this question..
I have a global set up in the following manner:
^WHEAIPP(1,116444,1)=3
^WHEAIPP(1,116444,1,1)="58898^^LSWELFER^58898,0"
^WHEAIPP(1,116444,1,2)="58898^59128^MPHILLIPS^59135,0"
^WHEAIPP(1,116444,1,3)="62626^62745^FXALTMAN^62626,58427^^^^^^2^"
^WHEAIPP(1,116444,2)=3
^WHEAIPP(1,116444,2,1)="59129^^MPHILLIPS^59910,0^^^^^^"
^WHEAIPP(1,116444,2,2)="59129^59547^SSNARE^59934,0^^^^^^"
^WHEAIPP(1,116444,2,3)="59129^62954^FXALTMAN^62654,32289^^^^^^3^"
^WHEAIPP(1,116444,3)=4
^WHEAIPP(1,116444,3,1)="60311^^SALFANO^60311,0^^^^^^"
^WHEAIPP(1,116444,3,2)="60311^^SSNARE^60754,0^^^^^^2"
^WHEAIPP(1,116444,3,3)="60311^^NEPAXSON^60757,0^^^^^^2"
^WHEAIPP(1,116444,3,4)="60311^62636^FXALTMAN^62626,58428^=^100^=^25^^5"
^WHEAIPP(1,116444,4)=4
^WHEAIPP(1,116444,4,1)="59548^^SSNARE^59550,0"
^WHEAIPP(1,116444,4,2)="59548^60310^SSNARE^59934,0^^^^^^2"
^WHEAIPP(1,116444,4,3)="62626^^FXALTMAN^62626,61050^^^^^^^1"
^WHEAIPP(1,116444,4,4)="62617^62647^FXALTMAN^62627,27518^^^^^^4"
The first subscript is an internal Hmo, the sceond is an internal provide, the third is a line number and the last is a line detail number. The data at the 4th subscript level is a combined audit trail history of the line with the highest line detail number being the current line.
I have 3 classes set-up with parent child relationships as follows:
The main class
Class XFXA.Try3.IppProv Extends (%Persistent, %Populate, %XML.Adaptor) [ ClassType =
persistent, Inheritance = right, ProcedureBlock, SqlRowIdName = Id, StorageStrategy
= SQLMapping ]
{
Property Hmo As %Integer [ Required ];
Property Keen As %Integer [ Required ];
/// Contains the array of data initially loaded into the class
Property OriginalData As %String [ MultiDimensional ];
Property ReadyToFile As %Boolean [ InitialExpression = 0, Transient ];
Relationship IppLines As XFXA.Try3.IppProvLine [ Cardinality = children, Inverse =
relIppProv ];
Index iMaster On (Hmo, Keen) [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<DataLocation>^[%extRef("UCKE"),%extRef("SYKE")]WHEAIPP</DataLocation>
<ExtentSize>100000</ExtentSize>
<SequenceNumber>19</SequenceNumber>
<SQLMap name="DBMS">
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{Keen}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvS</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}
The Line class
Class XFXA.Try3.IppProvLine Extends (%Persistent, %Populate, %XML.Adaptor) [ ClassType
= persistent, Inheritance = right, ProcedureBlock, SqlRowIdName = Id, StorageStrategy
=SQLMapping ]
{
Relationship relIppProv As XFXA.Try3.IppProv [ Cardinality = parent, Inverse =
IppLines ];
Relationship IppLineDetail As XFXA.Try3.IppProvLineDetail [ Cardinality = children,
Inverse = relIppProvLinex ];
Property Line As %String;
Property IppLineDetailCount As %String;
Index iMaster On Line [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<ExtentSize>100000</ExtentSize>
<SequenceNumber>14</SequenceNumber>
<SQLMap name="DBMS">
<Data name="IppLineDetailCount">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>1</Piece>
</Data>
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{XFXA_Try3.IppProv.Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{XFXA_Try3.IppProv.Keen}</Expression>
</Subscript>
<Subscript name="3">
<Expression>{Line}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvLineS</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}
The Line Detail Class
Class XFXA.Try3.IppProvLineDetail Extends (%Persistent, %XML.Adaptor) [ ClassType =
persistent, Inheritance = right, ProcedureBlock, SqlRowIdName = Id, StorageStrategy =
SQLMapping ]
{
Relationship relIppProvLinex As XFXA.Try3.IppProvLine [ Cardinality = parent, Inverse =
IppLineDetail ];
Property LnDetail As %String;
Index iMaster On LnDetail [ IdKey, PrimaryKey, Unique ];
.
.
.
<Storage name="SQLMapping">
<ExtentSize>100000</ExtentSize>
<SQLMap name="DBMS">
<Data name="ClmAmtAllowed">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>6</Piece>
</Data>
<Data name="ClmLineAmtAllowed">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>8</Piece>
</Data>
<Data name="ClmLineOp">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>7</Piece>
</Data>
<Data name="ClmOp">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>5</Piece>
</Data>
<Data name="Deleted">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>11</Piece>
</Data>
<Data name="EffDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>1</Piece>
</Data>
<Data name="IppCode">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>10</Piece>
</Data>
<Data name="LastChgDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>4</Piece>
</Data>
<Data name="PxDxCdeFlag">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>9</Piece>
</Data>
<Data name="TermDt">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>2</Piece>
</Data>
<Data name="UserIni">
<Delimiter>"^"</Delimiter>
<Node>+0</Node>
<Piece>3</Piece>
</Data>
<Global>^[%extRef("UCKE"), %extRef("SYKE")]WHEAIPP</Global>
<Structure>delimited</Structure>
<Subscript name="1">
<Expression>{XFXA_Try3.IppProv.Hmo}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{XFXA_Try3.IppProv.Keen}</Expression>
</Subscript>
<Subscript name="3">
<Expression>{XFXA_Try3.IppProvLine.Line}</Expression>
</Subscript>
<Subscript name="4">
<Expression>{LnDetail}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^XFXA.Try3.IppProvLineDetails</StreamLocation>
<Type>%Library.CacheSQLStorage</Type>
</Storage>
}
When the user marks a line for deletion, a deleted flag is set to 1 in the current detail line at the 4th subscript level AND if this line is not the last line, the filing code moves to be the last line. If I try to do this in a delete method from my main class, I get an error message that says Updating RowIds is not allowed. this is because I tried to manipulate the Line property of the line class moving lines around to push the deleted one to the end. A check of the documentation found AllowRowIDUpdate with some warnings but not clear example of how to use it. Does anyone know of a way to accomplish this?
Well, the documentation on AllowRowIDUpdate says
"Set to 1 only if you are doing your own filing in a BEFORE trigger
and using the %SkipFiling flag. Otherwise, use the default of 0".
If you do your own filing in a BEFORE trigger and using the %SkipFiling flag then you mostly aren't using SQL Storage to store the data, you are just exposing your own storage so that it can be used via SQL.
I would suggest that the easiest thing to do would be to not update RowIDs. Instead of using update, use insert and delete to move the lines. This is essentially the same thing you would have to do using straight global access, since you can't update subscripts, per se, either.
Also, it's out of the scope of your question, but do I would consider different storage if I could. Moving line numbers around so there are no gaps doesn't seem to accomplish much when the line numbers are really stored in some kind of BTree like structure anyway, so maybe you could just leave gaps?
It's almost always better to use a synthetic/surrogate key that doesn't need to change.

What is the correct format for SAML 2.0 Assertions?

We have a customer trying to use ADFS to SSO on to our web application. We are using the ComponentSpace SAML 2.0 library. The assertion being sent to us looks like:
<Assertion ID="_b8a24809-ab6b-4acd-ad6a-8bcb97bb1889" IssueInstant="2012-05-24T13:30:33.917Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<Issuer>http://example.com/adfs/services/trust</Issuer>
<Subject>
<NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">mail#example.com</NameID>
<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<SubjectConfirmationData NotOnOrAfter="2012-05-24T13:35:33.920Z" Recipient="https://example.com/default.aspx" />
</SubjectConfirmation>
</Subject>
<Conditions NotBefore="2012-05-24T13:30:33.907Z" NotOnOrAfter="2012-05-24T14:30:33.907Z">
<AudienceRestriction>
<Audience>https://example.com</Audience>
</AudienceRestriction>
</Conditions>
<AttributeStatement>
<Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
<AttributeValue>mail#example.com</AttributeValue>
</Attribute>
</AttributeStatement>
<AuthnStatement AuthnInstant="2012-05-24T13:30:33.756Z" SessionIndex="_b8a24809-ab6b-4acd-ad6a-8bcb97bb1889">
<AuthnContext>
<AuthnContextClassRef>urn:federation:authentication:windows</AuthnContextClassRef>
</AuthnContext>
</AuthnStatement>
</Assertion>
The ComponentSpace library is pulling the full SamlResponse from the HTTP post but it reports no Assertions (ie samlResponse.GetAssertions().Count == 0). If I use the ComponentSpace examples it works but I notice all of the elements I build with the ComponentSpace library are prefixed with "saml:" (as I believe it should be).
Should the ComponentSpace library be able to find the Assertion without the saml: prefix or is there a way to configure ADFS to send it correctly?
A correct SAML response should contain namespace-qualified elements
<saml2p:Response Destination="https://www.google.com/a/squaresquare.biz/acs" IssueInstant="2010-08-04T17:47:20.956Z" xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" InResponseTo="djfnhepndikoonjjkeomgplmkjofobhdbdieihpa" Version="2.0" ID="_bd24b4a3514fd93800d2a43cafc98edb">
<saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">http://my.ssodemo.url.demo.google.com/idp/shibboleth</saml2:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>
<ds:Reference URI="#_bd24b4a3514fd93800d2a43cafc98edb">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="dssaml2saml2p"></ec:InclusiveNamespaces>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>
<ds:DigestValue>m/lUCS3nvfGuSJFKAtIz+ZrfxTU=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>PLdYgU9u5KirVrMHNSwYvk6fQ401dMbpuiDXpapKf0eOKC6pN3g7tnTEzvfOaXhkDNXVmGN+lXQ6iUDppWpdO2MbvPVZabOBPU1aAO+CWI53ciC0rYsxpFzQLLMC/7x9Wk7VFFmYEecxAJV+lTWvp8ZKXvwqZbhiTO/23EC0xconGhnwSvKjJWQuLnMMaFWSjDFYyzgsp34cR7aX/eqhhJyA/rr2uFdmgEdagAl+/17ppgHgthgK+PJtX16AALtsoXonv6uybRCX/YiDRvM1VsdwusVq5tXh9V+bTMZcgi/3Eh+Em/OZp0En8pqOngvL19U4LfqG0yJZjoDGkpHuhA==</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>MIIDgjCCAmqgAwIBAgIVAKgIqbzZl7+0p2qjxJFVJs3DE/jxMA0GCSqGSIb3DQEBBQUAMDAxLjAsBgNVBAMTJWh0dHA6Ly93cGgtdWJpcTI3LmhvdC5jb3JwLmdvb2dsZS5jb20wHhcNMTAwNzIxMTcxNTA5WhcNMzAwNzIxMTcxNTA5WjAwMS4wLAYDVQQDEyVodHRwOi8vd3BoLXViaXEyNy5ob3QuY29ycC5nb29nbGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAioQsJycRmjPjB2xlH0iSGn14lNbO/jIVgiGIlzZwlPkH1s2TTdwoTKKQBSe2s8AnJ4LliXlne/qWun3peYht0+RhejtB20L+Bw/I+iKQBGpHzgIKdkPGZnemWl9KqWQ/ZYKnY2x6qMEBmhUfYZcawzs26em5a+iaYlrTJNVEZ+QwWvg2/EOJvJNyBkSfXyxia5eAHV38Uy7xn0G5Zc9ge4ckCYj6b8a/UxpPJM61KztzY5coDwReQsDBq+DciGALJPbFk4783TW...etc.etc</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
<saml2p:Status>
<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"></saml2p:StatusCode>
</saml2p:Status>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Version="2.0" IssueInstant="2010-08-04T17:47:20.956Z" ID="_73fe28bcbb68e93df954d8e2f25097b1">
<saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">http://my.ssodemo.url.demo.google.com/idp/shibboleth</saml2:Issuer>
<saml2:Subject>
<saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">my_username</saml2:NameID>
<saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml2:SubjectConfirmationData NotOnOrAfter="2010-08-04T17:52:20.956Z" InResponseTo="djfnhepndikoonjjkeomgplmkjofobhdbdieihpa" Recipient="https://www.google.com/a/squaresquare.biz/acs" Address="172.24.6.38"></saml2:SubjectConfirmationData>
</saml2:SubjectConfirmation>
</saml2:Subject>
<saml2:Conditions NotOnOrAfter="2010-08-04T17:52:20.956Z" NotBefore="2010-08-04T17:47:20.956Z">
<saml2:AudienceRestriction>
<saml2:Audience>google.com</saml2:Audience>
</saml2:AudienceRestriction>
</saml2:Conditions>
<saml2:AuthnStatement SessionIndex="f306dd2bff4e9b3ba9218bd70fbaa87404d38a4c79547ac1edc9436a9f222213" AuthnInstant="2010-08-04T17:47:20.953Z">
<saml2:SubjectLocality Address="172.24.6.38"></saml2:SubjectLocality>
<saml2:AuthnContext>
<saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
</saml2:AuthnContext>
</saml2:AuthnStatement>
</saml2:Assertion>
</saml2p:Response>
Namespace qualifications are optional.
It turns out that the above XML is valid (ADFS adds the namespace to the overall XML but not each element). The problem was that the ComponentSpace library has different methods for getting Signed or Encrypted Assertions and I was just calling the generic GetAssertions. ADFS was generating signed assertions and I needed to call the other function.
Here is the code we ended up with:
IList<EncryptedAssertion> encryptedAssertions = samlResponse.GetEncryptedAssertions();
if (encryptedAssertions.Count > 0 && x509Certificate != null) {
// Decrypt the assertion
EncryptedAssertion encryptedAssertion = encryptedAssertions[0];
XmlElement decryptedElement = encryptedAssertion.DecryptToXml(x509Certificate, null);
LogMessage("Decrypted assertion: " + decryptedElement.OuterXml);
// Then verify the signature.
VerifySignature(x509Certificate, decryptedElement);
samlAssertion = new SAMLAssertion(decryptedElement);
} else {
if (samlResponse.GetSignedAssertions().Count > 0) {
// Get the signed assertion and verify the signature.
XmlElement signedAssertionElement = samlResponse.GetSignedAssertions()[0];
LogMessage("Signed assertion: " + signedAssertionElement.OuterXml);
VerifySignature(x509Certificate, signedAssertionElement);
samlAssertion = new SAMLAssertion(signedAssertionElement);
} else {
// Assertion is not encrypted or signed.
if (samlResponse.GetAssertions().Count > 0) {
samlAssertion = samlResponse.GetAssertions()[0];
LogMessage("Assertion: " + samlAssertion.ToXml().OuterXml);
} else {
LogFatalError("No assertions in response");
}
}
}