Last active
June 30, 2018 13:43
-
-
Save skenderbeu/cd7cc35c64a08e1ec2be454b06dd02c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private RoyalMail.SecurityHeaderType getSecurityHeaderType(RecId _recId = 0) | |
{ | |
RoyalMail.SecurityHeaderType securityHeaderType = new RoyalMail.SecurityHeaderType(); | |
str passwordDigest; | |
str userName; | |
System.Byte[] hashedPassword; | |
System.Byte[] digest; | |
str concatednatedDigestInput; | |
str encodedNonce; | |
int i; | |
Counter counter = 0; | |
System.Xml.XmlElement xDocElement; | |
System.Xml.XmlNodeList xChildNodes; | |
System.Xml.XmlElement[] xHeaders; | |
System.Xml.XmlDocument xDoc; | |
int childNodeCount; | |
System.Exception ex; | |
System.Collections.IEnumerator enumerator; | |
str creationDate = this.getSecurityCreatedDate(); | |
str nonce = this.getNonce(_recId); | |
//Make a log of the Nonce used | |
this.updateRequestLogNonce(_recId, nonce); | |
try | |
{ | |
userName = this.parmRMUserName(); | |
hashedPassword = this.getSHA1(this.parmRMPassword()); | |
concatednatedDigestInput = this.concatDigest(nonce, creationDate, hashedPassword); | |
digest = this.getSHA1(concatednatedDigestInput); | |
passwordDigest = System.Convert::ToBase64String(digest); | |
encodedNonce = System.Convert::ToBase64String(this.encodeToBytes(nonce)); | |
xDoc = this.getSecurityHeaderXML(userName, passwordDigest, encodedNonce, creationDate); | |
xDocElement = xDoc.get_DocumentElement(); | |
xDocElement.RemoveAllAttributes(); | |
//Get the XMLNodelist of the document | |
xChildNodes = xDocElement.get_ChildNodes(); | |
childNodeCount = xChildNodes.get_Count(); | |
xHeaders = new System.Xml.XmlElement[childNodeCount](); | |
enumerator = xChildNodes.GetEnumerator(); | |
//Convert XMLNodelist to an array of XmlElements | |
while(enumerator.MoveNext()) | |
{ | |
xHeaders.SetValue(enumerator.get_Current(), counter); | |
counter ++; | |
} | |
securityHeaderType.set_Any(xHeaders); | |
} | |
catch(Exception::CLRError) | |
{ | |
error(AifUtil::getClrErrorMessage()); | |
} | |
return securityHeaderType; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment