Michael
That is kind of tricky :-)
I was expecting that you would have programmed your service client to
send user-auth headers. It is possible to force Axis2 to ask for user
auth but its not easy. But that is usually a trick you need to play
with browsers/human clients. For service clients there it is usually
programmed. For example with Axis2 its very easy to get it to pass
HTTP uid/pw.
As for the property, I made a mistake. You need to do this:
org.apache.axis2.context.MessageContext mc =
((Axis2MessageContext)msgCtx).getAxis2MessageContext();
and then look in there.
Paul
On 1/6/07, Michael Buchholz <[EMAIL PROTECTED]> wrote:
Hi Paul,
I sucessfully wrote a mediator and remote debugged it. The mediator is
called with:
<class name="de.subnatural.synapse.SimpleAuthenticationMediator"/>
in a <sequence> that is referred by a <proxy> entry.
Now come the problems:
> The uid/pw can be extracted like this:
> Map map = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
1) The Hashmap "properties" in msgCtx is empty so I can´t retrieve any
headers from it.
2) First problem might be an result of the second one. A HTTP client
only sends basic auth username/pw when the server requests them. Synapse
doesn´t request any and so the client sends no authorization headers.
Can I somehow tell Synapse to force basic authentication on the Proxy
Service Endpoint?
Michael
Paul Fremantle schrieb:
> Michael
>
> Good question!
>
> So you need to basically write a mediator that grabs the Username from
> the MessageContext and then checks it. If it succeeds you can pass the
> message on, otherwise you can fault back.
>
> The uid/pw can be extracted like this:
>
> Map map = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
> String tmp = (String) map.get("Authorization");
> String username = null;
> String password = null;
>
> if (tmp != null) {
> tmp = tmp.trim();
> }
> if (tmp != null && tmp.startsWith("Basic ")) {
> tmp = new String(Base64.decode(tmp.substring(6)));
> int i = tmp.indexOf(':');
> if (i == -1) {
> username = tmp;
> } else {
> username = tmp.substring(0, i);
> }
>
> if (i != -1) {
> password = tmp.substring(i + 1);
> if (password != null && password.equals("")) {
> password = null;
> }
> }
> }
>
> You can see how to fault by looking at the fault mediator.
>
> If you've written a mediator before -- or want the challenge -- it
> should be pretty straightforward. Would you like to contribute it
> back?
>
> If you need help I'll be happy to help out.
>
> Paul
>
> On 1/5/07, Michael Buchholz <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> first: congratulations to the synapse dev-team for graduating from the
>> incubator!
>>
>> second: I´m a little stuck with a feature I need...
>> I would like to use synapse as a proxy for internal web-services. The
>> samples show how to achieve this. But in addition to the proxy
>> functionality I need that all proxy-services require the clients to
>> authenticate with a username (password is not required...).
>>
>> Also the authentication if the username is correct or not must be done
>> by a java class I provide.
>>
>> Any idea how this can be achieved? HTTPS with basic authentication by a
>> self written username check java class would be sufficient...
>>
>> Michael
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair
http://bloglines.com/blog/paulfremantle
[EMAIL PROTECTED]
"Oxygenating the Web Service Platform", www.wso2.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]