<!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="https://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;">
    My ws-security setting doesn't work.
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/aupres">Joseph Hwang</a> in <i>JBoss Web Services</i> - <a href="https://community.jboss.org/message/817924#817924">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>My WS-security reference site is <a class="jive-link-external-small" href="https://docs.jboss.org/author/display/JBWS/WS-Security">https://docs.jboss.org/author/display/JBWS/WS-Security</a>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I coded interface and bean like below :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService<br/>public interface IHelloPort {<br/> <br/> @WebMethod<br/> @WebResult<br/> public String sayHello(@WebParam String name);<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@WebService<br/><a class="jive-link-anchor-small" rel="nofollow">@EndpointConfig(configFile</a> = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")<br/>public class HelloBean implements IHelloPort {</p><p> @Override<br/> @WebMethod<br/> @WebResult<br/> public String sayHello(@WebParam String name) {<br/>&#160; // TODO Auto-generated method stub<br/>&#160; return "Hello " + name;<br/> }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Then I generated WEB-INF/jaxws-endpoint-config.xml</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="<a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance</a>"&#160; <br/> xmlns:javaee="<a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" rel="nofollow">http://java.sun.com/xml/ns/javaee</a>" <br/> xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd"&gt;</p><p>&#160; &lt;endpoint-config&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;config-name&gt;Custom WS-Security Endpoint&lt;/config-name&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;property&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-name&gt;ws-security.signature.properties&lt;/property-name&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-value&gt;${jboss.server.config.dir}/wssecurity.properties&lt;/property-value&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;/property&gt;&#160;&#160;&#160; <br/>&#160;&#160; <br/>&#160;&#160; &lt;property&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-name&gt;ws-security.encryption.properties&lt;/property-name&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-value&gt;${jboss.server.config.dir}/wssecurity.properties&lt;/property-value&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;/property&gt;&#160;&#160;&#160; <br/>&#160;&#160; <br/>&#160;&#160; &lt;property&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-name&gt;ws-security.signature.username&lt;/property-name&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-value&gt;joseph&lt;/property-value&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;/property&gt;&#160;&#160;&#160; <br/>&#160;&#160; <br/>&#160;&#160; &lt;property&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-name&gt;ws-security.encryption.username&lt;/property-name&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-value&gt;joseph&lt;/property-value&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;/property&gt;&#160;&#160;&#160; <br/>&#160;&#160; <br/>&#160;&#160; &lt;property&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-name&gt;ws-security.callback-handler&lt;/property-name&gt;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160; &lt;property-value&gt;com.aaa.ws.KeystorePasswordCallback&lt;/property-value&gt;&#160;&#160;&#160; <br/>&#160;&#160; &lt;/property&gt;&#160; <br/>&#160; &lt;/endpoint-config&gt;<br/> &lt;/jaxws-config&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Next I made ${jboss.server.config.dir}/wssecurity.properties and KeystorePasswordCallback.java like below</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>-- wssecurity.properties</p><p>org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin</p><p>org.apache.ws.security.crypto.merlin.keystore.type=jks</p><p>org.apache.ws.security.crypto.merlin.keystore.password=111111</p><p>org.apache.ws.security.crypto.merlin.keystore.alias=testWSssl</p><p>org.apache.ws.security.crypto.merlin.keystore.file=${jboss.server.config.dir}/jboss7ssl.jks</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>-- KeystorePasswordCallback.java</p><p>public class KeystorePasswordCallback implements CallbackHandler {<br/> <br/> private Map&lt;String, String&gt; passwords = new HashMap&lt;String, String&gt;();<br/> <br/> public KeystorePasswordCallback() {<br/>&#160; passwords.put("joseph", "11111"); </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> @Override<br/> public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {<br/>&#160; // TODO Auto-generated method stub<br/>&#160;&#160; for (int i = 0; i &lt; callbacks.length; i++) {<br/>&#160;&#160;&#160; WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];<br/>&#160;&#160;&#160; String pass = passwords.get(pc.getIdentifier());<br/>&#160;&#160;&#160; <br/>&#160;&#160; if (pass != null) {&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br/>&#160;&#160;&#160;&#160; pc.setPassword(pass);<br/>&#160;&#160;&#160;&#160; return;<br/>&#160;&#160; }<br/>&#160; }<br/> }</p><p> <br/> public void setAliasPassword(String alias, String password) {<br/>&#160; passwords.put(alias, password);<br/> }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Last I generated jboss7ssl.jks file with keytool command</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>keytool -genkey -alias testWSssl -keystore jboss7ssl.jks -keyalg RSA -validity 180</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Deployment threw no exception. But WS-security encryption was not applied to wsdl. Generated soap file was just plain xml file.</p><p>WS-security encryption setting doesn't work. Did i miss anything?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I need your advice. Thanks in advanced !</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/817924#817924">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss Web Services at <a href="https://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>