1

我正在尝试将我的 Java EE 5(GlassFish v2,Metro 2.1.1)应用程序转换为 Java EE 6(GlassFish 3.1.2,Metro 2.2.1-1)。我的 web 服务客户端有问题,它的安全性基于 JAXRPCSecuirty。JAXRPCSecurity 配置:

private final static String SECURITY_CONFIG =
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?> "+
    "<xwss:JAXRPCSecurity xmlns:xwss=\"http://java.sun.com/xml/ns/xwss/config\">                " +
    "   <xwss:Service>                                                                          " +
    "       <xwss:SecurityConfiguration dumpMessages=\"true\">                      " +
    "           <xwss:Sign includeTimestamp=\"false\">                                          " +
    "               <xwss:X509Token certificateAlias=\"certificate_alias\" />                       " +
    "               <xwss:CanonicalizationMethod disableInclusivePrefix=\"true\" />             " + 
    "               <xwss:SignatureTarget type=\"xpath\" value=\"//SOAP-ENV:Body\">             " +
    "                 <xwss:Transform algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"     " +
    "                                 disableInclusivePrefix=\"true\" />                        " +
    "               </xwss:SignatureTarget>                                                     " +
    "           </xwss:Sign>                                                                    " +
    "       </xwss:SecurityConfiguration>                                                       " +
    "   </xwss:Service>                                                                         " +
    "   <xwss:SecurityEnvironmentHandler>                                                       " +
    "      SecurityCallbackHandler                                                              " +
    "   </xwss:SecurityEnvironmentHandler>                                                      " +
    "</xwss:JAXRPCSecurity>";

以及我如何将此配置设置为 web 服务客户端:

public void configureSecurity() throws SITAWebServiceException {        
    String JAXRPCSecurityXML = completeJAXRPCSecurityXML(alias, keyStore, callbackHandler, dumpMessage);

    byte[] JAXRPCSecurityXMLBytes = convertJAXRPSecurityXMLToBytes(JAXRPCSecurityXML);

    XWSSecurityConfiguration sc = createXWSSecurityConfiguration(JAXRPCSecurityXMLBytes);

    ((BindingProvider) port).getRequestContext().put(XWSSecurityConfiguration.MESSAGE_SECURITY_CONFIGURATION, sc);      
}

private XWSSecurityConfiguration createXWSSecurityConfiguration(final byte[] JAXRPCSecurityXML) throws SITAWebServiceException {
    InputStream is = new ByteArrayInputStream(JAXRPCSecurityXML);
    try {
        return new SecurityConfiguration(is);
    } catch (XWSSecurityException e) {
        throw new SITAWebServiceException("XWSSecurityConfiguration problem.", e);
    } finally {
        closeInputStream(is);
    }
}

使用 GlassFish v2 和 Metro 2.1.1,一切正常。但是 GlassFish 3 使用基于 OSGi 的 Metro(webservices-api-osgi 和 webservice-osgi),并且com.sun.xml.xwss包中的类不再可见(未导出),因此我经常收到此异常:

java.lang.NoClassDefFoundError: com/sun/xml/xwss/XWSSecurityConfiguration

是否有一些解决方案如何导出包com.sun.xml.xwss或如何将 JAXRPCSecurity 更改为其他/更好的东西?

谢谢。

4

0 回答 0