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 Belunek Karel <be...@vegacom.cz> on 2007/04/11 14:52:57 UTC

AXIS2 1.1.1 problem with BASIC AUTH

Hello everyone,

I'm new to AXIS and I would like to ask for help.

I have Axis2 1.1.1 under Tomcat 5.5.9 and I have correctly working Axis 
service generated from WSDL file.

Now I'm trying to implement BASIC authenticacion.

On server side I'have se security constraint on the Tomcat level, it 
works fine. I have tried it via WWW browser http://user:pass@URI

But I'm not able to write client with BASIC authentication.
Example from documentation does not work because 
org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE 
constant simply does not exist.
Example from documentation:
...
Options options = new Options();
HttpTransportProperties.Authenticator auth = new 
HttpTransportProperties.Authenticator();
             auth.setUsername("username");
             auth.setPassword("password");
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE,auth);
  ...

I have tried to replace the constant by 
HttpTransportProperties.Authenticator.BASIC but it does not work.

Here is my client code:
---------------------------------------
public Calendar getTtT2(OcTtStub stub)
     throws RemoteException
   {
     Options options = new Options();
     HttpTransportProperties.Authenticator  auth = new 
HttpTransportProperties.Authenticator();
     auth.setUsername("ide");
     auth.setPassword("ide");
     options.setProperty(HttpTransportProperties.Authenticator.BASIC,auth);

     GetTtT2RequestDocument reqDoc = 
GetTtT2RequestDocument.Factory.newInstance();
     GetTtT2RequestDocument.GetTtT2Request req = 
reqDoc.addNewGetTtT2Request();
     req.setTtId(new BigInteger(m_Args[1]));

     GetTtT2ResponseDocument resDoc = stub.getTtT2(reqDoc);
     Calendar retVal = resDoc.getGetTtT2Response().getT2();

     return retVal;
   }
-------------------------------------

It does not work:
======================
Apr 11, 2007 2:26:20 PM 
org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme
INFO: basic authentication scheme selected
Apr 11, 2007 2:26:20 PM org.apache.commons.httpclient.HttpMethodDirector 
processWWWAuthChallenge
INFO: No credentials available for BASIC 'Axis2 Application'@localhost:8084
Exception in thread "main" org.apache.axis2.AxisFault: HTTP Transport 
error : '401' - 'Unauthorized'; nested exception is:
         org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'; nested exception is:
         org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'; nested exception is:
         org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'
         at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:227)
         at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:674)
         at 
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:237)
         at 
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java:202)
         at cz.gts.client.OcTtStub.getTtT2(OcTtStub.java:380)
         at cz.gts.client.GTSClient.getTtT2(GTSClient.java:184)
         at cz.gts.client.GTSClient.go(GTSClient.java:64)
         at cz.gts.client.GTSClient.main(GTSClient.java:51)
Caused by: org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'; nested exception is:
         org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'
         at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:344)
         at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:204)
         ... 7 more
Caused by: org.apache.axis2.AxisFault: HTTP Transport error : '401' - 
'Unauthorized'
         at 
org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:144)
         at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:335)
         ... 8 more
=============================

I'm really stuck in, could please anyone help?

Karel Belunek

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Hi,

   Thank you for your reply. I will try again today, but yesterday when I
tried with different set of options the HTTP Header remained the same for
each Web Service call. I assume that I must be missing something. 

Thank you for the help.

Cheers
Asif
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10139025
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: [AXIS2] Problem with MessageContext

Posted by Shaoguang Cong <sc...@yahoo.com>.
Thanks, Deepal.  I changed to set the property in OperationConetxt and it works.
  I noticed the OperationContext is copied from the in to the out memssageContext.
   
  Shaoguang

Deepal Jayasinghe <de...@opensource.lk> wrote:
  Hi Shaoguang ,

Yes , you can not store property in req message context and access them
using response message context. If you want to do so , then you need to
store the property in OperationConetxt not in the message context.

There will be two fresh message context for one in-out mep.

Thanks
Deepal

> On server side, I use a request and a response handler to log some data.
> In the request handler, I called
> messageContext.setProperty("myProperty", "xyz").
> In the response handler, messageContext.getProperty("myProperty")
> returns null.
> It looks the properties in MessageContext (Options) are reset after
> invoking the web service.
> 
> Should the messageContext carry around the custom properties through
> all server-side handlers?
> 
> Shaoguang
>
> ------------------------------------------------------------------------
> Ahhh...imagining that irresistible "new car" smell?
> Check out new cars at Yahoo! Autos.
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org



       
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.

Re: [AXIS2] Problem with MessageContext

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi  Shaoguang ,

Yes , you can not store property in req message context and access them
using response message context. If you want to do so , then you need to
store the property in OperationConetxt not in the message context.

There will be two fresh message context for one in-out mep.

Thanks
Deepal

> On server side, I use a request and a response handler to log some data.
> In the request handler, I called
> messageContext.setProperty("myProperty", "xyz").
> In the response handler, messageContext.getProperty("myProperty")
> returns null.
> It looks the properties in MessageContext (Options) are reset after
> invoking the web service.
>  
> Should the messageContext carry around the custom properties through
> all server-side handlers?
>  
> Shaoguang
>
> ------------------------------------------------------------------------
> Ahhh...imagining that irresistible "new car" smell?
> Check out new cars at Yahoo! Autos.
> <http://us.rd.yahoo.com/evt=48245/*http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE1YW1jcXJ2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3LWNhcnM->




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


[AXIS2] Problem with MessageContext

Posted by Shaoguang Cong <sc...@yahoo.com>.
  On server side, I use a request and a response handler to log some data. 
  In the request handler, I called messageContext.setProperty("myProperty", "xyz"). 
  In the response handler, messageContext.getProperty("myProperty") returns null. 
  It looks the properties in MessageContext (Options) are reset after invoking the web service.
   
  Should the messageContext carry around the custom properties through all server-side handlers?
   
  Shaoguang

       
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
 Check outnew cars at Yahoo! Autos.

Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Dear  Geir,

    Thank you for your reply. Your solution for OC4J was not working with
Tomcat. I managed to make it work after getting ideas from your last reply
which was using HttpServletRequest. Below is the working solution, which may
help other readers.

        // acquire the active HTTP Request
        HttpServletRequest req =
            (HttpServletRequest)
inMesasgeContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);

        // Acquiring Authorization Header from servlet request
        String             auth = req.getHeader("Authorization");

        auth = auth.substring(auth.indexOf(" "));

        // Decoding the authorization header...
        String decoded = new String(Base64.decode(auth));

        // decoded now contains username:password in plain text.
        int i = decoded.indexOf(":");

        // so we take the username from it ( everything until the ':' )
        String username = decoded.substring(0, i);

        // and the password
        String pwd = decoded.substring(i + 1, decoded.length());
        
       // Printing it for confirmation.
        System.out.println(username + "   " + pwd);

Once again thank you for your help.

Cheers
Asif


-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10163886
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Geir Amdal <ge...@usit.uio.no>.

aassif wrote:
> 
> Now moving to the Server side implementation, I was expecting retrieving
> the result will be simple so I tried on the lines similar to Axis 1.X,
> below is the code listing:
> 
> [znip code]
> 


I don't know which is the preferred procedure for extracting authentication
data from incoming SOAP requests. I ended up acquiring the Principal object
(created by the servlet container upon a successful login since I let the
container handle the authentication) from the HTTP request. But then -
platform differences might come into play here. (As stated earlier, I use
OC4J 10.1.3.1.2.)

Here's an example of Principal extraction from the request:

    //
    :
    import java.security.Principal;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.axis2.context.MessageContext;
    import org.apache.axis2.transport.http.HTTPConstants;
    :

    :
    // acquire the active MessageContext
    MessageContext mc = MessageContext.getCurrentMessageContext();
		
    // acquire the active HTTP Request
    HttpServletRequest req = (HttpServletRequest)
mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
    
    Principal principal = req.getUserPrincipal();
    if (principal == null) {
        System.out.println("HTTP Request held no principal - user is not
logged in.");
    } else {
        System.out.println("UserName: " + principal.getName());
    }
    // 


Sincerely,

  Geir
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10159661
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Dear Geir,
   Thank you for your help. I was doing exactly the same what was mentioned
in the Thread and what you suggested today but yesterday I failed to notice
the HTTP headers regarding Authorization: Basic. But today when I executed
the client without any change it was working as required.  I assume that it
must be my mistake. I was hoping that Authorization: Basic will be the last
thing in the HTTP Header just before SOAP Message as normally it is the case
for Axis 1.X but infact it was somewhere in the middle of HTTP header for
Axis2.

Now moving to the Server side implementation, I was expecting retrieving the
result will be simple so I tried on the lines similar to Axis 1.X, below is
the code listing:

        inMesasgeContext = MessageContext.getCurrentMessageContext();

        if(inMesasgeContext == null)
            System.out.println("inMesasgeContext is null");
        else System.out.println("inMesasgeContext is NOT null"); //
MessageContext is not NULL

        Options options = inMesasgeContext.getOptions();

       HttpTransportProperties.Authenticator authProperties = (
          HttpTransportProperties.Authenticator)
options.getProperty(HTTPConstants.AUTHENTICATE);
        
        if(authProperties != null){
            System.out.println("UserName: " + authProperties.getUsername());
        }else {
            System.out.println("authProperties is null");
        }

But it always print "authProperties is null". Once again I must be making
error in casting i.e. casting the Object in wrong class. 

Your help is appreciated.

Cheers
Asif
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10146297
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Dear Geir,
   Thank you for your help. I was doing exactly the same what was mentioned
in the Thread and what you suggested today but yesterday I failed to notice
the HTTP headers regarding Authorization: Basic. But today when I executed
the client without any change it was working as required.  I assume that it
must be my mistake. I was hoping that Authorization: Basic will be the last
thing in the HTTP Header just before SOAP Message as normally it is the case
for Axis 1.X but infact it was somewhere in the middle of HTTP header for
Axis2.

Now moving to the Server side implementation, I was expecting retrieving the
result will be simple so I tried on the lines similar to Axis 1.X, below is
the code listing:

        inMesasgeContext = MessageContext.getCurrentMessageContext();

        if(inMesasgeContext == null)
            System.out.println("inMesasgeContext is null");
        else System.out.println("inMesasgeContext is NOT null"); //
MessageContext is not NULL

        Options options = inMesasgeContext.getOptions();

       HttpTransportProperties.Authenticator authProperties = (
          HttpTransportProperties.Authenticator)
options.getProperty(HTTPConstants.AUTHENTICATE);
        
        if(authProperties != null){
            System.out.println("UserName: " + authProperties.getUsername());
        }else {
            System.out.println("authProperties is null");
        }

But it always print "authProperties is null". Once again I must be making
error in casting i.e. casting the Object in wrong class. 

Your help is appreciated.

Cheers
Asif
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10146272
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Geir Amdal <ge...@usit.uio.no>.

aassif wrote:
> 
>     [...] do I need to manually configure ServiceClient to use Basic
> Authorization.
> 
I might be missing the mark here, but are you asking whether you have to
instanciate a new ServiceClient or whether you can configure one retrieved
from the stub? If so, take a look at Belunek Karel's second post in this
thread (April 12th), where the ServiceClient from the stub is retrieved and
configured:

    Options opt = stub._getServiceClient().getOptions(); 
    :
    :
    opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);

http://www.nabble.com/forum/ViewPost.jtp?post=9961378

Sincerely, 

  Geir
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10141309
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Dear  Geir,

      " If no Authorization header is present among the HTTP headers, I'd
suspect the ServiceClient used by the stub was not configured correctly... "

     One stupid question, do I need to manually configure ServiceClient to
use Basic Authorization.

Cheers 
Asif
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10139031
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Geir Amdal <ge...@usit.uio.no>.

aassif wrote:
> 
> I have one query regarding Basic Authentication. I Axis 1.X, when we use
> Call.setUserName() or call.setPassword(), the details are encoded and sent
> to the server as HTTP Headers and which can be seen through TCP monitor.
> The username and password can be retrieved in the Web Service Handler or
> Web Service implementation through Message Context.  In the case of Axis2
> I can't see and difference in the SOAP request with or without BASIC
> Authentication.
> 

I just tested TCPMon for my own setup, and verified that an "Authorization:
Basic (...)" header was generated and sent. While the Soap Envelope is not
different, the HTTP headers should be.


aassif wrote:
> 
> I am not creating ServiceClient from scratch rather I am using the Stub
> generated as result of WSDL2Java and then from the stub I am retrieving
> the ServiceClient and Options. But I don't think this should make any
> difference. I believe it has more to do with my poor understanding of
> Basic Authentication in Axis2. 
> 
> Question is how I can send username and password to the Web Service as
> HTTP Header rather than SOAP Header in Axis2 similar to Axis 1.X. Reason I
> am looking for this functionality is for back compatibility.
> 

If you are using code parallell to what I suggested, you are sending the
authorization data as a HTTP (Authorization:) header. If no Authorization
header is present among the HTTP headers, I'd suspect the ServiceClient used
by the stub was not configured correctly... 

Like you, I think that your retrieving the ServiceClient and Options from
the stub should not make any significant difference. From what I understood,
that was the same approach Belunek Karel was (successfully) using.


Sincerely,

  Geir
-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10138964
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Dear Geir Amdal,

  Thank you for reply. I have one query regarding Basic Authentication. I
Axis 1.X, when we use Call.setUserName() or call.setPassword(), the details
are encoded and sent to the server as HTTP Headers and which can be seen
through TCP monitor. The username and password can be retrieved in the Web
Service Handler or Web Service implementation through Message Context.  In
the case of Axis2 I can't see and difference in the SOAP request with or
without BASIC Authentication.

I am not creating ServiceClient from scratch rather I am using the Stub
generated as result of WSDL2Java and then from the stub I am retrieving the
ServiceClient and Options. But I don't think this should make any
difference. I believe it has more to do with my poor understanding of Basic
Authentication in Axis2. 

Question is how I can send username and password to the Web Service as HTTP
Header rather than SOAP Header in Axis2 similar to Axis 1.X. Reason I am
looking for this functionality is for back compatibility. 

Cheers.
Asif

-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10137496
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by gAm <ge...@usit.uio.no>.

aassif wrote:
> 
> I went through the whole discussion and when tried to implement BASIC
> Authentication I can't find the Authenticator class, the one which I can
> locate is only HttpTransportProperties.Authenticator.
> 

It was HttpTransportProperties.Authenticator that was used. My apologies for
causing confusion - I should absolutely have used the full notation for the
inner class.

        // Strings 'username' and 'password' presupposed, 
        // as well as an Options object 'options'
        :
 
        HttpTransportProperties.Authenticator authenticator =
    	    new HttpTransportProperties.Authenticator();
    	
        List<String> auth = new ArrayList<String>();
        auth.add(HttpTransportProperties.Authenticator.BASIC);
        authenticator.setAuthSchemes(auth);

        authenticator.setUsername(username);
        authenticator.setPassword(password);
        authenticator.setPreemptiveAuthentication(true);

        options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);

        :
        //


aassif wrote:
> 
> But HttpTransportProperties.Authenticator doesn't have any property BASIC
> and seems to be different from Authenticator class used in the thread. 
> 

I believe 'BASIC' is a static field of HttpTransportProperties.Authenticator
in Axis2 v1.1.1, at least.
See 
http://ws.apache.org/axis2/1_1_1/api/org/apache/axis2/transport/http/HttpTransportProperties.Authenticator.html#field_detail
HttpTransportProperties.Authenticator Field Detail .

Sincerely,
  Geir Amdal

-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10128688
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by aassif <as...@hotmail.com>.
Hi,
   
I went through the whole discussion and when tried to implement BASIC
Authentication I can't find the Authenticator class, the one which I can
locate is only HttpTransportProperties.Authenticator. But
HttpTransportProperties.Authenticator doesn't have any property BASIC and
seems to be different from Authenticator class used in the thread. 

Cheers
Asif


Belunek Karel wrote:
> 
> Geir Amdal napsal(a):
>> On 11. apr. 2007, at 14:52, Belunek Karel wrote:
>>> I have Axis2 1.1.1 under Tomcat 5.5.9 and I have correctly working 
>>> Axis service generated from WSDL file.
>>>
>>> Now I'm trying to implement BASIC authenticacion.
>>>
>>> On server side I'have se security constraint on the Tomcat level, it 
>>> works fine. I have tried it via WWW browser http://user:pass@URI
>>>
>>> But I'm not able to write client with BASIC authentication.
>>> Example from documentation does not work because 
>>> org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE 
>>> constant simply does not exist.
>> (...)
>>> I have tried to replace the constant by 
>>> HttpTransportProperties.Authenticator.BASIC but it does not work.
>> 
>> I configure the Options object as follows in my own ServiceClient-based 
>> client implementation (also using Axis2 1.1.1, but on OC4J, not Tomcat):
>> 
>>     //(...)
>>         Authenticator authenticator = new Authenticator();
>> 
>>         List<String> auth = new ArrayList<String>();
>>         auth.add(Authenticator.BASIC);
>> 
>>         authenticator.setAuthSchemes(auth);
>>         authenticator.setUsername(username);
>>         authenticator.setPassword(password);
>> 
>>         options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
>>     //(...)
>> 
>> 
>> 
>> 
> 
> Thanks guys, it solves the problem.
> Your code snippet with Jarek's modification works.
> Here is my code snippet:
> 
> ...
>      //set authentication param
>      Options opt = stub._getServiceClient().getOptions();
>      Authenticator authenticator = new Authenticator();
>      List<String> auth = new ArrayList<String>();
>      auth.add(Authenticator.BASIC);
>      authenticator.setAuthSchemes(auth);
>      authenticator.setUsername(user);
>      authenticator.setPassword(pass);
>      authenticator.setPreemptiveAuthentication(true);
>      opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
> ...
> 
> 
> Regards
> Karel Belunek
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AXIS2-1.1.1-problem-with-BASIC-AUTH-tf3559184.html#a10125068
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Belunek Karel <be...@vegacom.cz>.
Geir Amdal napsal(a):
> On 11. apr. 2007, at 14:52, Belunek Karel wrote:
>> I have Axis2 1.1.1 under Tomcat 5.5.9 and I have correctly working 
>> Axis service generated from WSDL file.
>>
>> Now I'm trying to implement BASIC authenticacion.
>>
>> On server side I'have se security constraint on the Tomcat level, it 
>> works fine. I have tried it via WWW browser http://user:pass@URI
>>
>> But I'm not able to write client with BASIC authentication.
>> Example from documentation does not work because 
>> org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE 
>> constant simply does not exist.
> (...)
>> I have tried to replace the constant by 
>> HttpTransportProperties.Authenticator.BASIC but it does not work.
> 
> I configure the Options object as follows in my own ServiceClient-based 
> client implementation (also using Axis2 1.1.1, but on OC4J, not Tomcat):
> 
>     //(...)
>         Authenticator authenticator = new Authenticator();
> 
>         List<String> auth = new ArrayList<String>();
>         auth.add(Authenticator.BASIC);
> 
>         authenticator.setAuthSchemes(auth);
>         authenticator.setUsername(username);
>         authenticator.setPassword(password);
> 
>         options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
>     //(...)
> 
> 
> 
> 

Thanks guys, it solves the problem.
Your code snippet with Jarek's modification works.
Here is my code snippet:

...
     //set authentication param
     Options opt = stub._getServiceClient().getOptions();
     Authenticator authenticator = new Authenticator();
     List<String> auth = new ArrayList<String>();
     auth.add(Authenticator.BASIC);
     authenticator.setAuthSchemes(auth);
     authenticator.setUsername(user);
     authenticator.setPassword(pass);
     authenticator.setPreemptiveAuthentication(true);
     opt.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
...


Regards
Karel Belunek


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Geir Amdal <ge...@usit.uio.no>.
On 12. apr. 2007, at 13:25, Jarek Kucypera wrote:

> Don't you also need to set the 'preemtive' flag, like this:
> authenticator.setPreemptiveAuthentication(true);
> ?

Ahh. Valid point. Though I am not sure a 'need' can be generalized  
for this setting.

 From what I can tell, setting this flag activates sending of the  
authentication response even before the server gives an  
"unauthorized" response.
While it might serve to reduce the overhead of making the connection,  
I can only assume it also has some security related issues? Or have I  
misunderstood how the flag works?

In the configuration I quoted, using the Authenticator and  
ServiceClient without preemptive authentication works fine.

I'm very interested in the experiences of others on the matter, though.



Regards,

  .gAm

--
Geir Amdal
Java Developer, Center for Information Technology Services
University of Oslo
                               - there is no spool -



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Jarek Kucypera <jk...@mikrozet.wroc.pl>.
Don't you also need to set the 'preemtive' flag, like this:
authenticator.setPreemptiveAuthentication(true);
?

J.K.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: AXIS2 1.1.1 problem with BASIC AUTH

Posted by Geir Amdal <ge...@usit.uio.no>.
On 11. apr. 2007, at 14:52, Belunek Karel wrote:
> I have Axis2 1.1.1 under Tomcat 5.5.9 and I have correctly working  
> Axis service generated from WSDL file.
>
> Now I'm trying to implement BASIC authenticacion.
>
> On server side I'have se security constraint on the Tomcat level,  
> it works fine. I have tried it via WWW browser http://user:pass@URI
>
> But I'm not able to write client with BASIC authentication.
> Example from documentation does not work because  
> org.apache.axis2.transport.http.HTTPConstants.BASIC_AUTHENTICATE  
> constant simply does not exist.
(...)
> I have tried to replace the constant by  
> HttpTransportProperties.Authenticator.BASIC but it does not work.

I configure the Options object as follows in my own ServiceClient- 
based client implementation (also using Axis2 1.1.1, but on OC4J, not  
Tomcat):

	//(...)
         Authenticator authenticator = new Authenticator();

         List<String> auth = new ArrayList<String>();
         auth.add(Authenticator.BASIC);

         authenticator.setAuthSchemes(auth);
         authenticator.setUsername(username);
         authenticator.setPassword(password);

         options.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
	//(...)




Regards,

  .gAm

--
Geir Amdal
Java Developer, Center for Information Technology Services
The University of Oslo
                                                           - there is  
no spool -



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org