0

私はSpring Web Servicesプロジェクト(春の例:https://spring.io/guides/gs/producing-web-service/)を持っており、セキュリティを設定したいと考えています。コンパイルでクラスが見つからないため、XwsSecurityInterceptorを追加するとエラーが発生します。com/sun/xml/wss/XWSSecurityExceptionSpring WSセキュリティに関する問題

以下、私のpom.xml、Webサービスの設定、およびエラートレースが見つかります。

のpom.xml

... 
    <parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.5.RELEASE</version> 

<!-- Dependencia Proyecto Web de Spring Boot --> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 

    <!-- Dependencia para Web Services de Spring Boot --> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-ws</artifactId> 
    </dependency> 

<dependency> 
    <groupId>org.springframework.ws</groupId> 
    <artifactId>spring-ws-security</artifactId> 
    <version>2.3.0.RELEASE</version> 
</dependency> 


    <dependency> 
     <groupId>wsdl4j</groupId> 
     <artifactId>wsdl4j</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.ws.security</groupId> 
     <artifactId>wss4j</artifactId> 
     <version>1.6.19</version> 
    </dependency> 

...

@EnableWs 
@Configuration 
public class WebServiceConfig extends WsConfigurerAdapter { 
    @Bean 
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { 
     MessageDispatcherServlet servlet = new MessageDispatcherServlet(); 
     servlet.setApplicationContext(applicationContext); 
     servlet.setTransformWsdlLocations(true); 
     return new ServletRegistrationBean(servlet, "/ws/*"); 
    } 
@Bean(name = "countries") 
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { 
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); 
    wsdl11Definition.setPortTypeName("CountriesPort"); 
    wsdl11Definition.setLocationUri("/ws"); 
    wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); 
    wsdl11Definition.setSchema(countriesSchema); 
    return wsdl11Definition; 
} 

@Bean 
public XsdSchema countriesSchema() { 
    return new SimpleXsdSchema(new ClassPathResource("ws/countries.xsd")); 
} 


@Bean(name= "wsSecurityInterceptor") 
public XwsSecurityInterceptor xwsSecurityInterceptor(){ 

    Resource securityPolicy = new ClassPathResource("ws/resources/SecurityPolicy.xml"); 

    XwsSecurityInterceptor xwsSI = new XwsSecurityInterceptor(); 

    xwsSI.setPolicyConfiguration(securityPolicy); 
    xwsSI.setCallbackHandler(simplePasswordValidationCallbackHandler()); 

    return xwsSI; 

} 


@Bean(name = "passwordValidationHandler") 
public SimplePasswordValidationCallbackHandler simplePasswordValidationCallbackHandler(){ 

    HashMap<String, String> user = new HashMap<String, String>(); 
    user.put("Bert", "Ernie"); 

    SimplePasswordValidationCallbackHandler spvch = new SimplePasswordValidationCallbackHandler(); 
    spvch.setUsersMap(user); 

    return spvch;  
} 

}

エラートレース

Caused by: java.lang.ClassNotFoundException: com.sun.xml.wss.XWSSecurityException 
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_20] 
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.8.0_20] 
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_20] 
    at java.net.URLClassLoader.findClass(Unknown Source) ~[na:1.8.0_20] 
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_20] 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) ~[na:1.8.0_20] 
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[na:1.8.0_20] 
    ... 30 common frames omitted 

ありがとう!

答えて

0

私は問題を解決してきた、私はちょうど私のPOMに次の依存関係を追加しました:

<dependency> 
     <groupId>com.sun.xml.wss</groupId> 
     <artifactId>xws-security</artifactId> 
     <version>3.0</version> 
     <exclusions> 
      <exclusion> 
       <groupId>javax.xml.crypto</groupId> 
       <artifactId>xmldsig</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

感謝を!

関連する問題