FileDocCategorySizeDatePackage
HTTPAuthHandler.javaAPI DocApache Axis 1.42591Sat Apr 22 18:57:26 BST 2006org.apache.axis.handlers.http

HTTPAuthHandler

public class HTTPAuthHandler extends org.apache.axis.handlers.BasicHandler
An HTTPAuthHandler simply sets the context's username and password properties from the HTTP auth headers.
author
Glen Daniels (gdaniels@allaire.com)
author
Doug Davis (dug@us.ibm.com)

Fields Summary
protected static Log
log
Constructors Summary
Methods Summary
public voidinvoke(org.apache.axis.MessageContext msgContext)


         
    
        log.debug("Enter: HTTPAuthHandler::invoke");
        
        /* Process the Basic Auth stuff in the headers */
        /***********************************************/
        String tmp = (String)msgContext.getProperty(HTTPConstants.HEADER_AUTHORIZATION);
        if ( tmp != null ) tmp = tmp.trim();
        if ( tmp != null && tmp.startsWith("Basic ") ) {
            String user=null ;
            int  i ;

            tmp = new String( Base64.decode( tmp.substring(6) ) );
            i = tmp.indexOf( ':" );
            if ( i == -1 ) user = tmp ;
            else           user = tmp.substring( 0, i);
            msgContext.setUsername( user );
            log.debug( Messages.getMessage("httpUser00", user) );
            if ( i != -1 )  {
                String pwd = tmp.substring(i+1);
                if ( pwd != null && pwd.equals("") ) pwd = null ;
                if ( pwd != null ) {
                    msgContext.setPassword( pwd );
                    log.debug( Messages.getMessage("httpPassword00", pwd) );
                }
            }
        }

        log.debug("Exit: HTTPAuthHandler::invoke");