Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Got it! Source (server was not responding in the time I wrote the question): <a href="http://developers.de/blogs/damir_dobric/archive/2007/02/22/Creating-of-SAML-token.aspx" rel="nofollow">http://developers.de/blogs/damir_dobric/archive/2007/02/22/Creating-of-SAML-token.aspx</a></p> <pre><code>private static void Main(string[] args) { SamlAssertion assertion = createSamlAssertion(); SamlSecurityToken samlToken = new SamlSecurityToken(assertion); } /// &lt;summary&gt; /// Creates some Test SAML assertion /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; private static SamlAssertion createSamlAssertion() { // Here we create some SAML assertion with ID and Issuer name. SamlAssertion assertion = new SamlAssertion(); assertion.AssertionId = "DaenetSamlTest"; assertion.Issuer = "damir"; // // Create some SAML subject. SamlSubject samlSubject = new SamlSubject(); samlSubject.Name = "My Subject"; // // Create one SAML attribute with few values. SamlAttribute attr = new SamlAttribute(); attr.Namespace = http://daenet.eu/saml; attr.AttributeValues.Add("Some Value 1"); attr.AttributeValues.Add("Some Value 2"); attr.Name = "My ATTR Value"; // // Now create the SAML statement containing one attribute and one subject. SamlAttributeStatement samlAttributeStatement = new SamlAttributeStatement(); samlAttributeStatement.Attributes.Add(attr); samlAttributeStatement.SamlSubject = samlSubject; // Append the statement to the SAML assertion. assertion.Statements.Add(samlAttributeStatement); return assertion; } </code></pre> <p>And this is for signing the assertion</p> <pre><code>/// &lt;summary&gt; /// Creates some signed Test SAML assertion. /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; private static SamlAssertion createSamlAssertion() { // // Create certificate from file. It must contain private key! X509Certificate2 cert = new X509Certificate2("filename.cert"); // The private key contained in the certificate will be used to sign the token. X509AsymmetricSecurityKey signingKey = new X509AsymmetricSecurityKey(cert); SamlAssertion assertion = createSamlAssertion(); // // Signing credentials are consisted // of private key in the certificate (see above), // the signature algorithm, security algortihm and key identifier. assertion.SigningCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.RsaSha1Signature, SecurityAlgorithms.Sha1Digest, new SecurityKeyIdentifier(new X509ThumbprintKeyIdentifierClause(cert))); // Finally create the SamlSecurityToken from the assertion SamlSecurityToken samlToken = new SamlSecurityToken(assertion); // Create a SecurityTokenSerializer that // will be used to serialize the SamlSecurityToken WSSecurityTokenSerializer ser = new WSSecurityTokenSerializer(); using (XmlWriter xWriter = XmlWriter.Create("saml.xml")) { ser.WriteToken(xWriter, samlToken); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload