views:

21

answers:

0

I'm trying to use an AES 256 encrypted password instead of a plain text password. I'm not sure how to configure the server to use an AES encrypted password.

When I try to run the client code it gets an exception org.apache.ws.security.WSSecurityException: Unknown password type encoding: http://www.w3.org/2001/04/xmlenc#aes256-cbc

If anyone has any suggestions or can point me to a website with more information. I'd really appreciate it.

Client Code

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(TestService.class);
factory.setAddress(serviceLocation);

Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.TIMESTAMP);

outProps.put(WSHandlerConstants.USER, serviceUserName);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.AES_256);

// set our password callback class this is used to lookup the password for a user.
outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new ClientPasswordCallback(servicePassword));

WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
factory.getOutInterceptors().add(wssOut);
service = (TestService) factory.create();

Server Configuration

<bean id="webServiceSecurity" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
  <constructor-arg>
    <map>
      <entry key="action" value="UsernameToken Timestamp"/>
      <entry key="passwordType" value="PasswordText"/>
      <entry key="passwordCallbackRef">
        <ref bean="myPasswordCallback"/>
      </entry>
    </map>
  </constructor-arg>
</bean>
<jaxws:endpoint id="testServiceWs" implementor="#service.test" address="/TestService">
  <jaxws:inInterceptors>
    <ref bean="webServiceSecurity"/>
  </jaxws:inInterceptors>
</jaxws:endpoint>