<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.umiacs.umd.edu/adapt/index.php?action=history&amp;feed=atom&amp;title=Saml%3AAuthenticateService</id>
	<title>Saml:AuthenticateService - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.umiacs.umd.edu/adapt/index.php?action=history&amp;feed=atom&amp;title=Saml%3AAuthenticateService"/>
	<link rel="alternate" type="text/html" href="https://wiki.umiacs.umd.edu/adapt/index.php?title=Saml:AuthenticateService&amp;action=history"/>
	<updated>2026-04-05T17:08:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.7</generator>
	<entry>
		<id>https://wiki.umiacs.umd.edu/adapt/index.php?title=Saml:AuthenticateService&amp;diff=1987&amp;oldid=prev</id>
		<title>Scsong at 23:42, 11 September 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.umiacs.umd.edu/adapt/index.php?title=Saml:AuthenticateService&amp;diff=1987&amp;oldid=prev"/>
		<updated>2008-09-11T23:42:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 23:42, 11 September 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l11&quot;&gt;Line 11:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Wss4j doesn&amp;#039;t know how to natively process SAML assertions, so it breaks it up into two parts, first is the signature verification, and second is the assertion processing. The signature verification checks to make sure the signature on the soap message was signed by a certificate issued by a trusted certificate authority. The trusted authorities are extraced from a supplied keystore (later). The saml assertion processing is limited to packing the assertion into the message context and letting you retrieve it from your call. This means it&amp;#039;s up to your call to check that the certificate from the xml signature is the same as the certificate in the assertion.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Wss4j doesn&amp;#039;t know how to natively process SAML assertions, so it breaks it up into two parts, first is the signature verification, and second is the assertion processing. The signature verification checks to make sure the signature on the soap message was signed by a certificate issued by a trusted certificate authority. The trusted authorities are extraced from a supplied keystore (later). The saml assertion processing is limited to packing the assertion into the message context and letting you retrieve it from your call. This means it&amp;#039;s up to your call to check that the certificate from the xml signature is the same as the certificate in the assertion.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Create standard webservice and use &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nop&amp;gt;&lt;/del&gt;CachedDoAllReceiver handlers===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Create standard webservice and use CachedDoAllReceiver handlers===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a standard, unauthenticated web service and make sure you can generate stubs and call it from a client. Now, in the deployment descriptor for your web service, you will need to set a requestflow.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a standard, unauthenticated web service and make sure you can generate stubs and call it from a client. Now, in the deployment descriptor for your web service, you will need to set a requestflow.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l34&quot;&gt;Line 34:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 34:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You can see how on the receiving side, the signature and saml token are seperated.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You can see how on the receiving side, the signature and saml token are seperated.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Prime &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;nop&amp;gt;&lt;/del&gt;CachedDoAllReceiver with keystore===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;===Prime CachedDoAllReceiver with keystore===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now that you will use cacheddoallreceiver to handle your signature checking, you need to tell it which keystore to use. In your context startup, you should load a keystore (see previous client example) and call&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Now that you will use cacheddoallreceiver to handle your signature checking, you need to tell it which keystore to use. In your context startup, you should load a keystore (see previous client example) and call&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Scsong</name></author>
	</entry>
	<entry>
		<id>https://wiki.umiacs.umd.edu/adapt/index.php?title=Saml:AuthenticateService&amp;diff=1986&amp;oldid=prev</id>
		<title>Scsong at 23:41, 11 September 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.umiacs.umd.edu/adapt/index.php?title=Saml:AuthenticateService&amp;diff=1986&amp;oldid=prev"/>
		<updated>2008-09-11T23:41:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Configure service for SAML Authentication==&lt;br /&gt;
&lt;br /&gt;
There are two parts to consuming SAML assertions in a web service. First is checking the low level embedding of the SAML assertion in the soap headers, and second is check any authorization statements in the assertion that you wish to act on.&lt;br /&gt;
&lt;br /&gt;
The previous client call hid a few  details of what really happens when you make a saml call. From the introduction, you&amp;#039;ll remember that we use holder-of-key to ensure that a client is allowed to use a given assertion. To use holder-of-key, a client must prove that is owns the private key corresponding to the public key in the assertion. According to the OASIS spec, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;The attesting entity includes an XML Signature that can be verified with the key information in the &amp;amp;lt;saml:ConfirmationMethod&amp;amp;gt; of the subject statements of the SAML assertion referenced for keyInfo by the Signature&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This translates to sign the soap message w/ clients private key and check the signature against the assertion.&lt;br /&gt;
&lt;br /&gt;
Wss4j doesn&amp;#039;t know how to natively process SAML assertions, so it breaks it up into two parts, first is the signature verification, and second is the assertion processing. The signature verification checks to make sure the signature on the soap message was signed by a certificate issued by a trusted certificate authority. The trusted authorities are extraced from a supplied keystore (later). The saml assertion processing is limited to packing the assertion into the message context and letting you retrieve it from your call. This means it&amp;#039;s up to your call to check that the certificate from the xml signature is the same as the certificate in the assertion.&lt;br /&gt;
&lt;br /&gt;
===Create standard webservice and use &amp;lt;nop&amp;gt;CachedDoAllReceiver handlers===&lt;br /&gt;
&lt;br /&gt;
Create a standard, unauthenticated web service and make sure you can generate stubs and call it from a client. Now, in the deployment descriptor for your web service, you will need to set a requestflow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;lt;service name=&amp;quot;Receiver&amp;quot; provider=&amp;quot;java:RPC&amp;quot; attachments=&amp;quot;DIME&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;requestFlow&amp;gt;&lt;br /&gt;
&lt;br /&gt;
            &amp;lt;handler type=&amp;quot;java:edu.umiacs.wssec.CachedDoAllReceiver&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;parameter name=&amp;quot;action&amp;quot; value=&amp;quot;Timestamp Signature SAMLTokenUnsigned&amp;quot;/&amp;gt;&lt;br /&gt;
            &amp;lt;/handler&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/requestFlow&amp;gt;&lt;br /&gt;
        &amp;lt;parameter name=&amp;quot;className&amp;quot; value=&amp;quot;edu.umiacs.pawn.receiving.Receiver&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;parameter name=&amp;quot;allowedMethods&amp;quot; value=&amp;quot;*&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;namespace&amp;gt;urn:receiving.pawn.umiacs.edu&amp;lt;/namespace&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
    &amp;lt;/service&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see how on the receiving side, the signature and saml token are seperated.&lt;br /&gt;
&lt;br /&gt;
===Prime &amp;lt;nop&amp;gt;CachedDoAllReceiver with keystore===&lt;br /&gt;
&lt;br /&gt;
Now that you will use cacheddoallreceiver to handle your signature checking, you need to tell it which keystore to use. In your context startup, you should load a keystore (see previous client example) and call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CachedDoAllReceiver.setSignatureKeyStore(ks);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The keystore that you load into the receiver should have all certificate authorities that are used to sign client certificates. Unlike a client, no callback configuration is needed since you&amp;#039;re not accessing locked (private key) information.&lt;br /&gt;
&lt;br /&gt;
===Initialize SAMLValidator===&lt;br /&gt;
&lt;br /&gt;
Now that wss4j is ready to receive signed messages w/ assetions in the headers, the next step is to setup validation of assertions. This is done through the SAMLValidator class in the pawn-ws-sec class. This class will take care of checking that the assertion was issued by a trusted authority and checks that the XML message signature matched the client certificate in the assertion.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
public class SampleContext extends edu.umiacs.servlet.StandardContextListener {&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
    private static SAMLValidator    samlValidator;&lt;br /&gt;
&lt;br /&gt;
    public void onContextStart(ServletContext ctx, Parameters paramInit)&lt;br /&gt;
            throws ServletException, ParameterException {&lt;br /&gt;
&lt;br /&gt;
        X509Certificate cert = ... ;// some authorities certificate&lt;br /&gt;
&lt;br /&gt;
        validator = new SAMLValidator();&lt;br /&gt;
        validator.putCertificate(cert);&lt;br /&gt;
    ...&lt;br /&gt;
    }&lt;br /&gt;
    public static SAMLValidator getSAMLValidator() {&lt;br /&gt;
        &lt;br /&gt;
        return samlValidator;&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SAMLValidator from webservice===&lt;br /&gt;
&lt;br /&gt;
Now, you need to piece it all together in your web service. wss4j will handle the incoming message, and put the cert of the xml message signature as well as the assertion into the ws-security message results. You can pass that entire message context into the saml validator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * web service call&lt;br /&gt;
     */&lt;br /&gt;
    public void testAuthorization() throws WebServiceFault {&lt;br /&gt;
        &lt;br /&gt;
        checkAuthorization(SAMLRoles.USER, SAMLRoles.SCHEDULER);&lt;br /&gt;
        &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * authorization check that takes a list of allowed roles&lt;br /&gt;
     */&lt;br /&gt;
    private void checkAuthorization(String ... roles) throws WebServiceFault {&lt;br /&gt;
        MessageContext  msgContext;&lt;br /&gt;
        SAMLAssertion   assertion;&lt;br /&gt;
&lt;br /&gt;
        // get the message context first&lt;br /&gt;
        msgContext = MessageContext.getCurrentContext();&lt;br /&gt;
        &lt;br /&gt;
        // challenge token&lt;br /&gt;
        if (!SampleContext.getSAMLValidator().validateMessageContext(msgContext) ) {&lt;br /&gt;
            &lt;br /&gt;
            throw new ClientFault(FaultCode.SAML_TOKEN_ERROR,&amp;quot;SAML Token can not be validated&amp;quot;);&lt;br /&gt;
            &lt;br /&gt;
        }&lt;br /&gt;
        // validateMessage loads the assertion it validated into a more convenient place in the message context&lt;br /&gt;
        assertion = (SAMLAssertion) msgContext.getProperty(Wss4jConstants.WSS4J_SAMLTOKEN_PROPERTY);&lt;br /&gt;
        &lt;br /&gt;
        LOG.debug(&amp;quot;token passes&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This just certifies that a token has a trusted authority. What you&amp;#039;ll probably want to do is to check the authorization information in the token. The SAMLUtilities class has some methods to help you out.&lt;br /&gt;
&lt;br /&gt;
boolean hasRoles(SAMLAssertion assertion, String ... roles);&lt;br /&gt;
&lt;br /&gt;
* assertion - assertion to check roles in.&lt;br /&gt;
* roles - list of roles from SAMLRoles that are allowed&lt;br /&gt;
&lt;br /&gt;
extractRoles, extractFilePlans, and extractNameIdentifiers are also available to extract roles, file plan ID&amp;#039;s and usernames from saml assertions. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        if (SAMLUtilities.hasRoles(assertion, roles)) {&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        for (String role : SAMLUtilities.extractRoles(assertion)) {&lt;br /&gt;
            LOG.debug(&amp;quot;Assertion has role: &amp;quot; + role);&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        // throw fault since we aren&amp;#039;t authorized&lt;br /&gt;
        throw new ClientFault(FaultCode.UNPRIVILEDGED_USER,&amp;quot;Client token fails, or not priviledged&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Scsong</name></author>
	</entry>
</feed>