PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Example for using the SOAPAddSAMLAssertion function
SOAPAddSAMLAssertion (Example)
Example for using the SOAPAddSAMLAssertion function
This example is used to create an XML signature and to add an SAML assertion to a Webservice request.
MyRequest is wsRequest
MySecu is Security
// Builds an identifier
id is string = GetGUID(guidFormatted)
id = "_" + Middle(id, 2, Length(id) - 2)

// Initializes the signature
cMySignature is xmlSignature
cMySignature..AlgorithmNormalization = atC14NExclusive
cMySignature..AlgorithmSignature = asRSA_SHA_256

// Key file OR certificate
// retrieved by the certificate functions
cMySignature..Key = fExeDir + fSep + "mykey.p12"
cMySignature..KeyPassword = "password"
cMySignature..KeyFileType = tfcPKCS12
cMySignature..Reference[1]..AlgorithmHash = HA_SHA_256
cMySignature..Reference[1]..URI = "#" + id
cMySignature..Reference[1]..Transformation[1] = atEnveloped
cMySignature..Reference[1]..Transformation[2] = atC14NExclusive
x509 is xmlSignatureInformationKeyX509
x509..WithCertificate = True
cMySignature..KeyInformation[1] = x509

// End of signature initialization
dtCurrentDateTime is DateTime

// Adds the SAML assertion
nAssertionSub is int
nAssertionSub = SOAPAddSAMLAssertion(MyRequest, ...
MySecu.Assertion, cMySignature)

MySecu.Assertion[nAssertionSub].Issuer = "Test"
MySecu.Assertion[nAssertionSub].Issuer:Format = ...
"urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"

MySecu.Assertion[nAssertionSub].Subject.NameID = "01254155"
MySecu.Assertion[nAssertionSub].Subject.NameID:NameQualifier = "Test"
MySecu.Assertion[nAssertionSub].AttributeStatement.Attribute:Name = "ID"
MySecu.Assertion[nAssertionSub].AttributeStatement.Attribute.AttributeValue = ""
Minimum version required
  • Version 18
This page is also available for…
Comments
Click [Add] to post a comment