<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Minimum required for basic user/password authentication on a POJO?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/KBeowulph">Karl Beowulph</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/545289#545289">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've followed the authentication guide (<a class="" href="http://community.jboss.org/wiki/JBossWS-Authentication">http://community.jboss.org/wiki/JBossWS-Authentication</a>) and have (mostly) successfully implemented basic security on a POJO web service. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The problem I'm having though is that my client requires two-sets of authentication setting; once for the HTTP basic authentication, and again in the request context (same user and password).&#160; Is there a way I can set it so that the user only needs to authenticate at the request context level?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>My files are as follows...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h1>Service</h1><p><strong>web.xml</strong></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</span> 
<span class="jive-xml-tag"><span>&lt;web-app id="WebApp_ID" version="2.4" xmlns=</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee" target="_blank">http://java.sun.com/xml/ns/j2ee</a><span> 
xmlns:xsi=</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span> 
xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee" target="_blank">http://java.sun.com/xml/ns/j2ee</a><span> </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" target="_blank">http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd</a><span>"&gt;</span></span> 

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;display-name&gt;</span>securityWs_PoC<span class="jive-xml-tag">&lt;/display-name&gt;</span> 
&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-name&gt;</span>secureWs<span class="jive-xml-tag">&lt;/servlet-name&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-class&gt;</span>com.securityWs.SecureWs<span class="jive-xml-tag">&lt;/servlet-class&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;load-on-startup&gt;</span>1<span class="jive-xml-tag">&lt;/load-on-startup&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/servlet&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-mapping&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;servlet-name&gt;</span>secureWs<span class="jive-xml-tag">&lt;/servlet-name&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;url-pattern&gt;</span>/secureWs<span class="jive-xml-tag">&lt;/url-pattern&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/servlet-mapping&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file-list&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>index.html<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>index.htm<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>index.jsp<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>default.html<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>default.htm<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;welcome-file&gt;</span>default.jsp<span class="jive-xml-tag">&lt;/welcome-file&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/welcome-file-list&gt;</span> 


&#160;&#160;&#160;&#160; <span class="jive-xml-comment">&lt;!-- Security --&gt; &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;security-constraint&gt;</span> 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;web-resource-collection&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;web-resource-name&gt;</span>All resources<span class="jive-xml-tag">&lt;/web-resource-name&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;url-pattern&gt;</span>/*<span class="jive-xml-tag">&lt;/url-pattern&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- <span class="jive-xml-tag">&lt;http-method&gt;</span>POST<span class="jive-xml-tag">&lt;/http-method&gt;</span> --&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/web-resource-collection&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;auth-constraint&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;role-name&gt;</span>friend<span class="jive-xml-tag">&lt;/role-name&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/auth-constraint&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/security-constraint&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;security-role&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;role-name&gt;</span>friend<span class="jive-xml-tag">&lt;/role-name&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/security-role&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;login-config&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;auth-method&gt;</span>BASIC<span class="jive-xml-tag">&lt;/auth-method&gt;</span> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;realm-name&gt;</span>JBossWS<span class="jive-xml-tag">&lt;/realm-name&gt;</span> &#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/login-config&gt;</span> <span class="jive-xml-tag">&lt;/web-app&gt;</span>




























































</code></pre><p><br/><strong>jboss-web.xml</strong></p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;jboss-web&gt;</span>

&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;security-domain&gt;</span>java:/jaas/JBossWS<span class="jive-xml-tag">&lt;/security-domain&gt;</span>
<span class="jive-xml-tag">&lt;/jboss-web&gt;</span>








</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 10pt; color: #008080;"><span style="font-size: 10pt; color: #008080;"><span style="font-size: 10pt;"><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> &#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left"><span style="font-size: 10pt; color: #008080;"><span style="font-size: 10pt; color: #008080;"><p><span style="color: #000000;"><strong>SecureWs.java</strong></span></p><span style=": ; font-size: 2; font-color: #008080; "><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>package</b></font> com.securityWs; 
&#160;
<font color="navy"><b>import</b></font> javax.jws.WebService; 
&#160;
&#160;
@WebService
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> SecureWs <font color="navy">{</font> 
&#160;
&#160;
&#160;
&#160;&#160;&#160;&#160; <font color="navy"><b>public</b></font> String echo(String word)<font color="navy">{</font> &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <font color="navy"><b>return</b></font> word+<font color="red">" "</font>+word; &#160;&#160;&#160;&#160; <font color="navy">}</font>
&#160;
<font color="navy">}</font>
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
</code></pre></span></span><span style=": ; font-size: 2; font-color: #008080; "><pre class="jive-pre"><code class="jive-code"></code></pre></span></span></p><span style=": ; font-size: 2; font-color: #008080; "><pre class="jive-pre"><code class="jive-code"></code></pre></span></span><span style=": ; font-size: 2; font-color: #008080; "><pre class="jive-pre"><code class="jive-code"></code></pre></span></span><span style="font-color: #008080; font-size: 2; "><pre class="jive-pre"><code class="jive-code"></code></pre></span></span><pre class="jive-pre"><code class="jive-code jive-java"></code></pre></p><h1>Client</h1><p><strong>TestSecureClient.java</strong></p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>package</b></font> com.secureClient; 
&#160;
<font color="navy"><b>import</b></font> <font color="navy"><b>static</b></font> org.junit.Assert.assertEquals; 
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
&#160;
</code></pre><p><br/>Thanks.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/545289#545289">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2044">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>