FileDocCategorySizeDatePackage
WebCallbackHandler.javaAPI DocExample1281Tue Aug 05 08:34:10 BST 2003com.jspservletcookbook

WebCallbackHandler

public class WebCallbackHandler extends Object implements CallbackHandler

Fields Summary
private String
userName
private String
password
Constructors Summary
public WebCallbackHandler(ServletRequest request)

    
        userName = request.getParameter("userName");
        password = request.getParameter("password");
        
    
Methods Summary
public voidhandle(javax.security.auth.callback.Callback[] callbacks)

				   
		for (int i = 0; i < callbacks.length; i++){
         
            if (callbacks[i] instanceof NameCallback){
            
                NameCallback nameCall = (NameCallback) callbacks[i];
                nameCall.setName(userName);
            
            } else if (callbacks[i] instanceof PasswordCallback){
            
                PasswordCallback passCall = (PasswordCallback) callbacks[i];
                passCall.setPassword(password.toCharArray());
            
            } else{
            
                throw new UnsupportedCallbackException (callbacks[i],
                  "The CallBacks are unrecognized in class: "+getClass().getName());
            
            }
        
        }//for