/**
 * (c) Microsoft Corporation.  All rights reserved
 */
package org.ogf.hpcbp;

import org.apache.ws.security.WSPasswordCallback;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;

import java.io.IOException;

public class PWHandlerClass implements CallbackHandler {

    public void handle (Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        for (int i = 0; i < callbacks.length; i++) {
            WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[i];
            String id = pwcb.getIdentifer();
            if (Client.WSSUsername.equals(id)) {
                pwcb.setPassword(Client.WSSPassword);
            } else {
                pwcb.setPassword("User not recognized within PWHandlerClass.");
			}
        }
    }
}
