try
{
// convert password to byte data
byte[] passBytes = password.getBytes("UTF-8");
// prepare the username token digest callback
UsernameTokenCallback callback = new UsernameTokenCallback();
Map options = new HashMap();
callback.init(options);
// add the username token callback handler to provide the parameters
CallbackHandler handler = new UsernameTokenCallbackHandler(nonce, created);
handler.handle((Callback[])options.get("callbacks"));
// calculate the hash and apply the encoding.
MessageDigest md = MessageDigest.getInstance("SHA");
callback.preDigest(md);
md.update(passBytes);
callback.postDigest(md);
byte[] hash = md.digest();
passwordHash = Base64Encoder.encode(hash);
}
catch(Exception e)
{