Password Callback Class is required for the UsernameToken security function to specify password for username as well as for private keys in keystore for using Encryption security function. Private keys will be used to sign and/or decrypt a message.

Password callback classes are used to:

  • set password for user in UsernameToken while using while using UsernameToken security action
  • set password for private key used to decrypt SOAP message while using Encryption security action
  • set password for private key used to sign SOAP message  while using Signature security action

To specify password, an implementation of javax.security.auth.callback.CallbackHandler is needed. A fully qualified class name of this implementation should be provided in Component Property Sheet (CPS).

Follow the below sections to understand how to create a Password Callback Class and to attach the resulting jar files to Web Service components and thereby used for UsernameToken security action as well as Encryption security action.

Create the Class file

Copy the below sample Java program and paste it in .java file and save it (save the password callback class with name 'PWCallback' as an example)

PWCallback class

Explanation of script in the class

Icon
  • Callback classes used for WS-Security should be instances of WSPasswordCallback.
    The below part is used in the class to define the same:

    if ((callback instanceof WSPasswordCallback)) {
    WSPasswordCallback passCallback = (WSPasswordCallback) callback;
     
  • Passwords can be set in three different ways, as explained earlier, using the above class:
    • By checking the username in case of UsernameToken WS-Security action.
    • By checking the WS-Security action where the password is needed for Decryption
    • By checking the WS-Security action where the password is needed for Signature
      The part of the class that starts from the below line defines this condition:
      From
      if ("User1".equals(passCallback.getIdentifier
      till
      passCallback.setPassword("SignaturePasswd");

Compile the Class and archive

Compile the class and archive it into a JAR file (PWCallback.jar).

Icon
  • wss4j.jar file present at the location %FIORANO_HOME%\extlib\wss4j\wss4j.jar needs to be placed in classpath while compiling.
  • This JAR file will be used by WSStub and WebserviceConsumer components to set username and password in SOAP message header.

Use the implementation in WebService components

Implementation in WSStub

To use PWCallback implementation in WSStub, stop the Peer server on which WSStub is running and copy the JAR which contains Password Callback Class into the location:
%FIORANO_HOME%\esb\server\jetty\fps\webapps\bcwsgateway\WEB-INF\classes

Icon
  • If the class file has any package, the jar file should be created to include that class and placed in the following location: %FIORANO_HOME%\esb\server\jetty\fps\webapps\bcwsgateway\WEB-INF\lib
  • For UsernameToken, restart the Peer server on which WSStub is running.
  • For Encryption, restart the Peer server on which WSStub is running only after the following:

Implementation in WedServiceConsumer

To use PWCallback implementation in WebserviceConsumer 4.0 component, add the JAR as resource by editing properties in the ServiceDescriptor.xml section in eStudio.

Adaptavist ThemeBuilder EngineAtlassian Confluence