<!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;"> </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;"> </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).  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;"> </p><p>My files are as follows...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><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>"></span></span>
     <span class="jive-xml-tag"><display-name></span>securityWs_PoC<span class="jive-xml-tag"></display-name></span>
     <span class="jive-xml-tag"><servlet></span>           <span class="jive-xml-tag"><servlet-name></span>secureWs<span class="jive-xml-tag"></servlet-name></span>           <span class="jive-xml-tag"><servlet-class></span>com.securityWs.SecureWs<span class="jive-xml-tag"></servlet-class></span>           <span class="jive-xml-tag"><load-on-startup></span>1<span class="jive-xml-tag"></load-on-startup></span>      <span class="jive-xml-tag"></servlet></span>      <span class="jive-xml-tag"><servlet-mapping></span>           <span class="jive-xml-tag"><servlet-name></span>secureWs<span class="jive-xml-tag"></servlet-name></span>           <span class="jive-xml-tag"><url-pattern></span>/secureWs<span class="jive-xml-tag"></url-pattern></span>      <span class="jive-xml-tag"></servlet-mapping></span>      <span class="jive-xml-tag"><welcome-file-list></span>           <span class="jive-xml-tag"><welcome-file></span>index.html<span class="jive-xml-tag"></welcome-file></span>           <span class="jive-xml-tag"><welcome-file></span>index.htm<span class="jive-xml-tag"></welcome-file></span>           <span class="jive-xml-tag"><welcome-file></span>index.jsp<span class="jive-xml-tag"></welcome-file></span>           <span class="jive-xml-tag"><welcome-file></span>default.html<span class="jive-xml-tag"></welcome-file></span>           <span class="jive-xml-tag"><welcome-file></span>default.htm<span class="jive-xml-tag"></welcome-file></span>           <span class="jive-xml-tag"><welcome-file></span>default.jsp<span class="jive-xml-tag"></welcome-file></span>      <span class="jive-xml-tag"></welcome-file-list></span>
     <span class="jive-xml-comment"><!-- Security -->      <span class="jive-xml-tag"><security-constraint></span>
          <span class="jive-xml-tag"><web-resource-collection></span>                <span class="jive-xml-tag"><web-resource-name></span>All resources<span class="jive-xml-tag"></web-resource-name></span>                <span class="jive-xml-tag"><url-pattern></span>/*<span class="jive-xml-tag"></url-pattern></span>                <!-- <span class="jive-xml-tag"><http-method></span>POST<span class="jive-xml-tag"></http-method></span> --></span>           <span class="jive-xml-tag"></web-resource-collection></span>           <span class="jive-xml-tag"><auth-constraint></span>                <span class="jive-xml-tag"><role-name></span>friend<span class="jive-xml-tag"></role-name></span>           <span class="jive-xml-tag"></auth-constraint></span>      <span class="jive-xml-tag"></security-constraint></span>      <span class="jive-xml-tag"><security-role></span>           <span class="jive-xml-tag"><role-name></span>friend<span class="jive-xml-tag"></role-name></span>      <span class="jive-xml-tag"></security-role></span>      <span class="jive-xml-tag"><login-config></span>           <span class="jive-xml-tag"><auth-method></span>BASIC<span class="jive-xml-tag"></auth-method></span>           <span class="jive-xml-tag"><realm-name></span>JBossWS<span class="jive-xml-tag"></realm-name></span>      <span class="jive-xml-tag"></login-config></span> <span class="jive-xml-tag"></web-app></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"><jboss-web></span>
     <span class="jive-xml-tag"><security-domain></span>java:/jaas/JBossWS<span class="jive-xml-tag"></security-domain></span>
<span class="jive-xml-tag"></jboss-web></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;">  </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </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;
 
<font color="navy"><b>import</b></font> javax.jws.WebService;
 
 
@WebService
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> SecureWs <font color="navy">{</font>
 
 
 
     <font color="navy"><b>public</b></font> String echo(String word)<font color="navy">{</font>           <font color="navy"><b>return</b></font> word+<font color="red">" "</font>+word;      <font color="navy">}</font>
 
<font color="navy">}</font>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
</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;
 
<font color="navy"><b>import</b></font> <font color="navy"><b>static</b></font> org.junit.Assert.assertEquals;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
</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>