else if ( ctx.getEnvironment().containsKey( CREDS ) ) {  doAuthSimple( ctx ); } else {  doAuthNone( ctx ); }
    public void invoke( Invocation invocation ) throws NamingException    {        // only handle preinvocation state        if ( invocation.getState() != InvocationStateEnum.PREINVOCATION )        {            return;        }        // check if we are already authenticated and if so we return making        // sure first that the credentials are not exposed within context        ServerContext ctx = ( ServerLdapContext ) invocation.getContextStack().peek();        if ( ctx.getPrincipal() != null )        {            if ( ctx.getEnvironment().containsKey( CREDS ) )            {                ctx.removeFromEnvironment( CREDS );            }            return;        }        // check the kind of authentication being performed        if ( ctx.getEnvironment().containsKey( AUTH_TYPE ) )        {            // authentication type can be anything            String auth = ( String ) ctx.getEnvironment().get( AUTH_TYPE );            if ( auth.equalsIgnoreCase( "none" ) )            {                doAuthNone( ctx );            }            else if ( auth.equalsIgnoreCase( "simple" ) )            {                doAuthSimple( ctx );            }            else            {                doAuthSasl( ctx );            }        }        else if ( ctx.getEnvironment().containsKey( CREDS ) )        {            // authentication type is simple here            doAuthSimple( ctx );        }        else        {            // authentication type is anonymous            doAuthNone( ctx );        }        // remove creds so there is no security risk        ctx.removeFromEnvironment( CREDS );    }