Hello,

I am working on annotation base ws-securityPolicy and have the following
annotation on the service bean.
Note: using cxf version of 2.7.5

@WebService(endpointInterface = "com.apachecxf.services.HelloWorldService")
@Policy(uri = "policies/TestImplPolicy.xml")
@EndpointProperty(key="ws-security.ut.validator",
value="com.apachecxf.services.CustomUserTokenValidator")
public class HelloWorldServiceBean implements HelloWorldService {

        public String sayHello() {
                System.out.println("Hello World!!!");
                return "Hello my service is working";
        }

}

The bean configuration file have just the bean definition of the above bean.
Rest all required data is in place.

When I run this i get following exception
java.lang.ClassCastException: java.lang.String cannot be cast to
org.apache.ws.security.validate.Validator
from UsernameTokenProcessor at line

Validator validator = data.getValidator(WSSecurityEngine.USERNAME_TOKEN);

which gets the validator from UsernameTokenInterceptor.getPrincipal() method

On debugging, it seems that the CustomUserTokenValidator is not loaded via
annotation.

If the same example i did with bean configuration it works fine. Bean
configuration as follows
<bean id="helloWorldService"
class="com.apachecxf.services.HelloWorldServiceBean" />

        <jaxws:endpoint id="helloWorld" 
                                 implementor="#helloWorldService" 
                                 address="/HelloWorld"> 
                
        <jaxws:properties>
    <entry key="ws-security.ut.validator" 
           value-ref="customUserTokenValidator" />
    </jaxws:properties>
    
    <jaxws:inInterceptors>
        <ref bean="loggingInInterceptor" />     
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>         
                <ref bean="logOutInterceptor" />
        </jaxws:outInterceptors> 
                                
 </jaxws:endpoint> 

Please advise for any missing step.



--
View this message in context: 
http://cxf.547215.n5.nabble.com/Annotation-based-WS-SecurityPolicy-throwing-exception-tp5729540.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to