<!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">JBoss 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;">
    Problem with securing web service with ws security ( username token )
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/lmarczuk">Ɓukasz Marczuk</a> in <i>JBoss Web Services</i> - <a href="http://community.jboss.org/message/560597#560597">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'am trying to secure web service ( from ejb 3.0 stateless bean) and it is not working.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>here is my code :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Bean : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@Stateless</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@SOAPBinding(style=SOAPBinding.Style.RPC)</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@SecurityDomain("JBossWS")</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@EndpointConfig(configName = "Standard WSSecurity Endpoint")</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span>@WebService(name="Hello",targetNamespace = "</span><a class="jive-link-external-small" href="http://test" target="_blank">http://test</a><span>",serviceName = "HelloWSSService")</span></div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class HelloBean implements IHello {</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">@WebMethod</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public String sayHello(String aName) {</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">return "siemanko " + aName;</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div></p><pre class="jive-pre"><code class="jive-code jive-java"><font color="darkgreen">// ... some imports</font>
&#160;
@Stateless
@SOAPBinding(style=SOAPBinding.Style.RPC)
@SecurityDomain(<font color="red">"JBossWS"</font>)
@EndpointConfig(configName = <font color="red">"Standard WSSecurity Endpoint"</font>)
@WebService(name=<font color="red">"Hello"</font>,targetNamespace = <font color="red">"http://test"</font>,serviceName = <font color="red">"HelloWSSService"</font>)
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> HelloBean <font color="navy"><b>implements</b></font> IHello <font color="navy">{</font>
&#160;
&#160;&#160;&#160;&#160;&#160;@WebMethod
&#160;&#160;&#160;&#160;&#160;<font color="navy"><b>public</b></font> String sayHello(String aName) <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<font color="navy"><b>return</b></font> <font color="red">"siemanko "</font> + aName;
&#160;&#160;&#160;&#160;&#160;<font color="navy">}</font>
&#160;
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>interface : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@EndpointConfig(configName = <font color="red">"Standard WSSecurity Endpoint"</font>)
@WebService(name=<font color="red">"Hello"</font>,targetNamespace = <font color="red">"http://test"</font>,serviceName = <font color="red">"HelloWSSService"</font>)
<font color="navy"><b>public</b></font> <font color="navy"><b>interface</b></font> IHello&#160; <font color="navy">{</font>
&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;String sayHello( String name);
<font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In my META-INF folder i put jboss-wsse-server.xml file :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><span>&lt;jboss-ws-security xmlns="</span><a class="jive-link-external-small" href="http://www.jboss.com/ws-security/config" target="_blank">http://www.jboss.com/ws-security/config</a><span>"
&#160;&#160;&#160;&#160;&#160;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>"
&#160;&#160;&#160;&#160;&#160;xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.jboss.com/ws-security/config" target="_blank">http://www.jboss.com/ws-security/config</a><span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><a class="jive-link-external-small" href="http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd" target="_blank">http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd</a><span>"&gt;</span></span>
&#160;&#160;&#160;&#160;&#160;<span class="jive-xml-tag">&lt;config&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span class="jive-xml-tag">&lt;timestamp ttl="300"/&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;requires/&gt;</span>
&#160;&#160;&#160;&#160;&#160;<span class="jive-xml-tag">&lt;/config&gt;</span>
<span class="jive-xml-tag">&lt;/jboss-ws-security&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Now i deploy my app on server and i test it from SoapUI. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&lt;soapenv:Envelope xmlns:soapenv=<font color="red">"http://schemas.xmlsoap.org/soap/envelope/"</font> xmlns:test=<font color="red">"http://test"</font>&gt;
&#160;&#160; &lt;soapenv:Header/&gt;
&#160;&#160; &lt;soapenv:Body&gt;
&#160;&#160;&#160;&#160;&#160; &lt;test:sayHello&gt;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;arg0&gt;?&lt;/arg0&gt;
&#160;&#160;&#160;&#160;&#160; &lt;/test:sayHello&gt;
&#160;&#160; &lt;/soapenv:Body&gt;
&lt;/soapenv:Envelope&gt;
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And anser : </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><span>&lt;env:Envelope xmlns:env="</span><a class="jive-link-external-small" href="http://schemas.xmlsoap.org/soap/envelope/" target="_blank">http://schemas.xmlsoap.org/soap/envelope/</a><span>"&gt;</span></span>
&#160;&#160; <span class="jive-xml-tag">&lt;env:Header&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag"><span>&lt;wsse:Security env:mustUnderstand="1" xmlns:ds="</span><a class="jive-link-external-small" href="http://www.w3.org/2000/09/xmldsig#" target="_blank">http://www.w3.org/2000/09/xmldsig#</a><span>" xmlns:wsse="</span><a class="jive-link-external-small" href="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" target="_blank">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</a><span>" xmlns:wsu="</span><a class="jive-link-external-small" href="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" target="_blank">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd</a><span>"&gt;</span></span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;wsu:Timestamp wsu:Id="timestamp"&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;wsu:Created&gt;</span>2010-09-06T11:41:38.621Z<span class="jive-xml-tag">&lt;/wsu:Created&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;wsu:Expires&gt;</span>2010-09-06T11:46:38.621Z<span class="jive-xml-tag">&lt;/wsu:Expires&gt;</span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/wsu:Timestamp&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/wsse:Security&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/env:Header&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;env:Body&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag"><span>&lt;test:sayHelloResponse xmlns:test="</span><a class="jive-link-external-small" href="http://test" target="_blank">http://test</a><span>"&gt;</span></span>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;return&gt;</span>siemanko ?<span class="jive-xml-tag">&lt;/return&gt;</span>
&#160;&#160;&#160;&#160;&#160; <span class="jive-xml-tag">&lt;/test:sayHelloResponse&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;/env:Body&gt;</span>
<span class="jive-xml-tag">&lt;/env:Envelope&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Got any idea why i can't secure my web service like that? i tryid it on jboss 4.2.3&#160; , 5.01, 5.1, and 6 actually i work on 5.0.1 with JBoss Web Services - Native Server 3.3.1.GA. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Mayby i'm skipping some step or jboss-wsse-server.xml is incorect ? </p><p>when i put to jboss-wsse-server.xml this :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">&lt;jboss-ws-security xmlns=<font color="red">"http://www.jboss.com/ws-security/config"</font>
&#160; xmlns:xsi=<font color="red">"http://www.w3.org/2001/XMLSchema-instance"</font>
&#160; xsi:schemaLocation=<font color="red">"http://www.jboss.com/ws-security/config</font>
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; http:<font color="darkgreen">//www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd"&gt;</font>
&#160; &lt;config&gt;
&#160;&#160;&#160; &lt;username/&gt;
&#160;&#160;&#160; &lt;authenticate&gt;
&#160;&#160;&#160;&#160;&#160; &lt;usernameAuth/&gt;
&#160;&#160;&#160; &lt;/authenticate&gt;
&#160; &lt;/config&gt;
&lt;/jboss-ws-security&gt;
&#160;
&#160;
&#160;
</code></pre><p>Also nothing happend and i'am albe to get response without puting principals in header.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>JBossWS is good configured in login-config.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Please help.</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/560597#560597">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>