You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by John McCosker <J....@andronics.com> on 2005/03/24 09:51:51 UTC

Handlers and authentication

Hi, I have a simple question.

If a handler authenticates a request and the username and password is not
set or invalid,
how do I stop the request getting through to the actual service and send a
response back?

Thanks for all advice.

RES: Handlers and authentication

Posted by Flávio, "M.Sc." <fl...@uniminas.br>.
Handlers and authenticationDear John,

This is reallly simple.

The only think you have to do is to "throw" a AxisFault wihtin the invoke
method as shown in the code below:


public class MyHandler extends BasicHandler {

 //member variables

  public void invoke(MessageContext msgContext) throws AxisFault
    {
        // Log an access each time we get invoked.
        try {
            Handler serviceHandler = msgContext.getService();
            String sUser = msgContext.getUsername();
            String sPassword = msgContext.getPassword();


            //....
            if (sUser.equals("") || sPassword.equals("")){
                  throw new AxisFault("Blank Passsword and user!", "Invalide
values!", null, null);

            }

        } catch (Exception e) {
            e.printStackTrace();
            throw AxisFault.makeFault(e);
        }
    }
}


I hope this helps.

Regards,


FLÁVIO DE OLIVEIRA SILVA

UNIMINAS

Uberlândia, MG      Brazil



  -----Mensagem original-----
  De: John McCosker [mailto:J.McCosker@andronics.com]
  Enviada em: quinta-feira, 24 de março de 2005 05:52
  Para: 'axis-user@ws.apache.org'
  Assunto: Handlers and authentication


  Hi, I have a simple question.

  If a handler authenticates a request and the username and password is not
set or invalid,
  how do I stop the request getting through to the actual service and send a
response back?

  Thanks for all advice.


  --
  Esta mensagem foi verificada pelo sistema de antivírus e
  acredita-se estar livre de perigo.

RES: Handlers and authentication

Posted by Flávio, "M.Sc." <fl...@uniminas.br>.
Handlers and authenticationDear John,

This is reallly simple.

The only think you have to do is to "throw" a AxisFault wihtin the invoke
method as shown in the code below:


public class MyHandler extends BasicHandler {

 //member variables

  public void invoke(MessageContext msgContext) throws AxisFault
    {
        // Log an access each time we get invoked.
        try {
            Handler serviceHandler = msgContext.getService();
            String sUser = msgContext.getUsername();
            String sPassword = msgContext.getPassword();


            //....
            if (sUser.equals("") || sPassword.equals("")){
                  throw new AxisFault("Blank Passsword and user!", "Invalide
values!", null, null);

            }

        } catch (Exception e) {
            e.printStackTrace();
            throw AxisFault.makeFault(e);
        }
    }
}


I hope this helps.

Regards,


FLÁVIO DE OLIVEIRA SILVA

UNIMINAS

Uberlândia, MG      Brazil



  -----Mensagem original-----
  De: John McCosker [mailto:J.McCosker@andronics.com]
  Enviada em: quinta-feira, 24 de março de 2005 05:52
  Para: 'axis-user@ws.apache.org'
  Assunto: Handlers and authentication


  Hi, I have a simple question.

  If a handler authenticates a request and the username and password is not
set or invalid,
  how do I stop the request getting through to the actual service and send a
response back?

  Thanks for all advice.


  --
  Esta mensagem foi verificada pelo sistema de antivírus e
  acredita-se estar livre de perigo.