Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.