<!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;">
    Problem implementing WS-Security X509 Token in JBoss 5.x
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/soulshunter">Andrea De Angelis</a> in <i>JBoss Web Services</i> - <a href="https://community.jboss.org/message/771678#771678">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi all,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p> i'm re-writing an application developped for JBoss 4.3 fro a new environment in JBoss 5.1.</p><p>In this application (EAR) we've a WAR with some Web Services with WS-Security and X509 Token.</p><p>In the first environment (Jboss 4.3) my jboss-wsse-server.xml look as:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p>&lt;jboss-ws-security</p><p><span>&#160;&#160; 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>"</span></p><p><span>&#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>"</span></p><p><span>&#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></p><p><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#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></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&lt;!-- PRODUCTION&#160;&#160;&#160; --&gt;</p><p>&#160;&#160;&#160; &lt;key-store-file&gt;<span style="color: #ff0000;">/mydirectory/keystore/server.keystore</span>&lt;/key-store-file&gt;</p><p>&#160;&#160;&#160; &lt;key-store-password&gt;xxx&lt;/key-store-password&gt;</p><p>&#160;&#160;&#160; &lt;key-store-type&gt;jks&lt;/key-store-type&gt;</p><p>&#160;&#160;&#160; &lt;trust-store-file&gt;<span style="color: #ff0000;">/mydirectory/keystore/server.truststore</span>&lt;/trust-store-file&gt;</p><p>&#160;&#160;&#160; &lt;trust-store-password&gt;xxx&lt;/trust-store-password&gt;</p><p>&#160;&#160;&#160; &lt;trust-store-type&gt;jks&lt;/trust-store-type&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160; &lt;!-- timestamp tolerance --&gt;</p><p>&#160;&#160;&#160; &lt;timestamp-verification createdTolerance="600" warnCreated="true" expiresTolerance="600" warnExpires="true" /&gt;</p><p>&#160;&#160;&#160; </p><p>&#160;&#160;&#160; &lt;config&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!-- &lt;timestamp ttl="1000"/&gt;&#160; --&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;sign type="x509v3" alias="server" /&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;requires&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;signature/&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/requires&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;authenticate&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;signatureCertAuth certificatePrincipal="com.examples.service.jbossws.MyCertificatePrincipal"/&gt;</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/authenticate&gt;</p><p>&#160;&#160;&#160; &lt;/config&gt;</p><p>&lt;/jboss-ws-security&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>And my Jboss-service.xml as:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code:xml}</p><p>&lt;mbean code="org.jboss.security.plugins.JaasSecurityDomain"</p><p>&#160;&#160;&#160;&#160;&#160;&#160; name="jboss.security:service=SanferSecurityDomain"&gt;</p><p>&#160;&#160;&#160; &lt;constructor&gt;</p><p>&#160;&#160;&#160;&#160; &lt;arg type="java.lang.String" value="SanferWSCert"/&gt;</p><p>&#160;&#160;&#160; &lt;/constructor&gt;</p><p>&#160;&#160;&#160; &lt;attribute name="KeyStoreURL"&gt;<span style="color: #ff0000;">/mydirectory/keystore/server.keystore</span>&lt;/attribute&gt;</p><p>&#160;&#160;&#160; &lt;attribute name="KeyStorePass"&gt;xxx&lt;/attribute&gt;</p><p>&#160;&#160;&#160; &lt;attribute name="KeyStoreType"&gt;jks&lt;/attribute&gt;</p><p>&#160;&#160;&#160; &lt;depends&gt;jboss.security:service=JaasSecurityManager&lt;/depends&gt;</p><p>&#160; &lt;/mbean&gt;</p><p>&#160; </p><p>&#160; &lt;mbean code="org.jboss.security.auth.login.DynamicLoginConfig"</p><p>&#160;&#160;&#160; name="whatever:service=SanferLogin"&gt;</p><p>&#160;&#160;&#160; &lt;attribute name="AuthConfig"&gt;my-login-config.xml&lt;/attribute&gt;</p><p>&#160;&#160;&#160; &lt;depends optional-attribute-name="LoginConfigService"&gt;</p><p>&#160;&#160;&#160;&#160;&#160; jboss.security:service=XMLLoginConfig&lt;/depends&gt;</p><p>&#160;&#160;&#160; &lt;depends optional-attribute-name="SecurityManagerService"&gt;</p><p>&#160;&#160;&#160;&#160;&#160; jboss.security:service=JaasSecurityManager&lt;/depends&gt;</p><p>&#160; &lt;/mbean&gt;</p><p>&lt;/server&gt;</p><p>{code}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I highlighted in red the absolute path of my keystore and truststore.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When i deploy this EAR in Jboss 4.3 everything it's ok, but in Jboss 5.1 i've the error message above:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>{code}</p><p>Caused by: org.jboss.ws.WSException: Cannot find required security resource: /opt/sanfer/keystore/server.keystore</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.wsse.WSSecurityConfigFactory.getResource(WSSecurityConfigFactory.java:114)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.wsse.WSSecurityConfigFactory.initKeystorePath(WSSecurityConfigFactory.java:89)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.wsse.WSSecurityConfigFactory.createConfiguration(WSSecurityConfigFactory.java:72)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.buildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:132)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.builder.jaxws.JAXWSServerMetaDataBuilder.setupProviderOrWebService(JAXWSServerMetaDataBuilder.java:52)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.ws.metadata.builder.jaxws.JAXWSMetaDataBuilderJSE.buildMetaData(JAXWSMetaDataBuilderJSE.java:61)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.wsf.stack.jbws.UnifiedMetaDataDeploymentAspect.start(UnifiedMetaDataDeploymentAspect.java:64)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.wsf.framework.deployment.DeploymentAspectManagerImpl.deploy(DeploymentAspectManagerImpl.java:129)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.wsf.container.jboss50.deployer.ArchiveDeployerHook.deploy(ArchiveDeployerHook.java:76)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.wsf.container.jboss50.deployer.AbstractWebServiceDeployer.internalDeploy(AbstractWebServiceDeployer.java:60)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)</p><p>&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;... 30 more</p><p>{code}</p><p>The WSSecurityConfig can't locate the keystore from the absolute path, but the JaasSecurityDomain however locate it.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've tried another different way putting the Keystore and Trustore inside the WEB-INF folder of WAR, and i've a similar scenario.</p><p>In this case the WSSecurityConfig locate the Kesytsore/Trustore but the JaasSecurityDomain throw the error "Can't locate resource: WEB-INF/server.keystore".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I think i've some Class Loading issue, can you help me to fix it?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks for the help.</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/771678#771678">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>