You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by pratibhaG <pr...@in2m.com> on 2008/06/11 09:05:26 UTC

How to handle unauthorized user

I have a user with username "smx" and password "smx".
The user is athenticated but not authorized on the bus to use any service.
When I make a request using this user, I get following error on servicemix
logs:

DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
DEBUG - ConsumerProcessor              - Receiving HTTP request: POST
/example/ HTTP/1.1
Authorization: Basic c214OnNteA==
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8192
Content-Length: 179


DEBUG - HttpComponent                  - Created correlation id:
ID:192.168.2.64-11a7656b905-17:7
DEBUG - DeliveryChannelImpl            - Send
ID:192.168.2.64-11a7656b905-17:7 in DeliveryChannel{servicemix-http}
WARN  - jetty                          - /example/
java.lang.IllegalStateException: Cannot write non xml faults for non soap
messages
        at
org.apache.servicemix.soap.marshalers.SoapWriter.writeSimpleMessage(SoapWriter.java:124)
        at
org.apache.servicemix.soap.marshalers.SoapWriter.write(SoapWriter.java:92)
        at
org.apache.servicemix.http.processors.ConsumerProcessor.sendFault(ConsumerProcessor.java:277)
        at
org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:176)
        at
org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:71)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
        at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
        at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
        at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:313)
        at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
        at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
        at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
        at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

Everything goes fine for the user who is both authenticated as well as
authorized. Now how to handle this error when user is authenticated but not
authorized.

Pratibha

 
-- 
View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17771342.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to handle unauthorized user

Posted by Guillaume Nodet <gn...@gmail.com>.
We may be missing a few log statements there.
Anyway, to handle the error in a specific way, you can implement your
own marshaler and configure it instead of the default one.  You will
be able to override the code used to send the error.

On Wed, Jun 11, 2008 at 10:54 AM, pratibhaG <pr...@in2m.com> wrote:
>
> I modified the configuration as per your suggestion. Now I get following on
> the SMX log:
>
> DEBUG - JettyContextManager            - Dispatching job:
> SCEP@30400341[d=true,io=0,w=true,b=false|false]
> DEBUG - JettyContextManager            - Dispatching job:
> SCEP@30400341[d=true,io=1,w=true,b=false|false]
> DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
> DEBUG - HttpComponent                  - Receiving HTTP request: POST
> /example/ HTTP/1.1
> Authorization: Basic c214OnNteA==
> User-Agent: Jakarta Commons-HttpClient/3.1
> Host: localhost:8192
> Content-Length: 179
>
>
> DEBUG - HttpComponent                  - Created correlation id:
> ID:192.168.2.64-11a7656b905-17:9
> DEBUG - DeliveryChannelImpl            - Send
> ID:192.168.2.64-11a7656b905-17:9 in DeliveryChannel{servicemix-http}
> DEBUG - JettyContextManager            - Dispatching job:
> SCEP@30400341[d=true,io=1,w=true,b=false|false]
> DEBUG - JettyContextManager            - Dispatching job:
> SCEP@30400341[d=true,io=1,w=true,b=false|false]
>
> What is parameter in the logs which says that the user is not authorized?
> Now how can I take any action. Suppose I want to send some meaningfull
> message to user. Then how can I do that.
>
> -Pratibha
> --
> View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17773046.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: How to handle unauthorized user

Posted by pratibhaG <pr...@in2m.com>.
I modified the configuration as per your suggestion. Now I get following on
the SMX log:

DEBUG - JettyContextManager            - Dispatching job:
SCEP@30400341[d=true,io=0,w=true,b=false|false]
DEBUG - JettyContextManager            - Dispatching job:
SCEP@30400341[d=true,io=1,w=true,b=false|false]
DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
DEBUG - HttpComponent                  - Receiving HTTP request: POST
/example/ HTTP/1.1
Authorization: Basic c214OnNteA==
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8192
Content-Length: 179


DEBUG - HttpComponent                  - Created correlation id:
ID:192.168.2.64-11a7656b905-17:9
DEBUG - DeliveryChannelImpl            - Send
ID:192.168.2.64-11a7656b905-17:9 in DeliveryChannel{servicemix-http}
DEBUG - JettyContextManager            - Dispatching job:
SCEP@30400341[d=true,io=1,w=true,b=false|false]
DEBUG - JettyContextManager            - Dispatching job:
SCEP@30400341[d=true,io=1,w=true,b=false|false]

What is parameter in the logs which says that the user is not authorized?
Now how can I take any action. Suppose I want to send some meaningfull
message to user. Then how can I do that. 

-Pratibha
-- 
View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17773046.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to handle unauthorized user

Posted by Guillaume Nodet <gn...@gmail.com>.
Yeah, but try instead:
  <http:consumer service="hello:MyConsumerService"
endpoint="providerEndpoint" targetService="xxx" ... />

On Wed, Jun 11, 2008 at 10:34 AM, pratibhaG <pr...@in2m.com> wrote:
>
> I am using the http-consumer. this is the configuration:
> <beans xmlns:http="http://servicemix.apache.org/http/1.0"
>       xmlns:hello="http://servicemix.in2m.com/samples/http">
>
>  <http:endpoint service="hello:MyConsumerService"
>                 endpoint="providerEndpoint"
>                     role="consumer"
>                         targetService="hello:MyProviderService"
>                 locationURI="http://0.0.0.0:8192/example/"
>                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>          authMethod="BASIC">
>          </http:endpoint>
>
> </beans>
>
> Pratibha
>
> --
> View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17772719.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: How to handle unauthorized user

Posted by pratibhaG <pr...@in2m.com>.
I am using the http-consumer. this is the configuration:
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:hello="http://servicemix.in2m.com/samples/http">

  <http:endpoint service="hello:MyConsumerService"
                 endpoint="providerEndpoint"
	             role="consumer"
	  	         targetService="hello:MyProviderService"
                 locationURI="http://0.0.0.0:8192/example/"
                 defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
	  authMethod="BASIC">
	  </http:endpoint>

</beans>

Pratibha

-- 
View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17772719.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to handle unauthorized user

Posted by Guillaume Nodet <gn...@gmail.com>.
Could you try using the <http:consumer /> endpoint instead, I think
the default marshaler will handle the error better.

On Wed, Jun 11, 2008 at 9:12 AM, Guillaume Nodet <gn...@gmail.com> wrote:
> Could you provide the log ebfore this error ? I'd like to see the
> exchange and understand what happens.
>
> On Wed, Jun 11, 2008 at 9:05 AM, pratibhaG <pr...@in2m.com> wrote:
>>
>> I have a user with username "smx" and password "smx".
>> The user is athenticated but not authorized on the bus to use any service.
>> When I make a request using this user, I get following error on servicemix
>> logs:
>>
>> DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
>> DEBUG - ConsumerProcessor              - Receiving HTTP request: POST
>> /example/ HTTP/1.1
>> Authorization: Basic c214OnNteA==
>> User-Agent: Jakarta Commons-HttpClient/3.1
>> Host: localhost:8192
>> Content-Length: 179
>>
>>
>> DEBUG - HttpComponent                  - Created correlation id:
>> ID:192.168.2.64-11a7656b905-17:7
>> DEBUG - DeliveryChannelImpl            - Send
>> ID:192.168.2.64-11a7656b905-17:7 in DeliveryChannel{servicemix-http}
>> WARN  - jetty                          - /example/
>> java.lang.IllegalStateException: Cannot write non xml faults for non soap
>> messages
>>        at
>> org.apache.servicemix.soap.marshalers.SoapWriter.writeSimpleMessage(SoapWriter.java:124)
>>        at
>> org.apache.servicemix.soap.marshalers.SoapWriter.write(SoapWriter.java:92)
>>        at
>> org.apache.servicemix.http.processors.ConsumerProcessor.sendFault(ConsumerProcessor.java:277)
>>        at
>> org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:176)
>>        at
>> org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:71)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>        at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>>        at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
>>        at
>> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>>        at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>        at
>> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
>>        at
>> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>>        at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>        at org.mortbay.jetty.Server.handle(Server.java:313)
>>        at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>>        at
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
>>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
>>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>>        at
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
>>        at
>> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
>>
>> Everything goes fine for the user who is both authenticated as well as
>> authorized. Now how to handle this error when user is authenticated but not
>> authorized.
>>
>> Pratibha
>>
>>
>> --
>> View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17771342.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/

Re: How to handle unauthorized user

Posted by pratibhaG <pr...@in2m.com>.
This is all that I get:
DEBUG - JettyContextManager            - Dispatching job:
SCEP@15977142[d=true,io=0,w=true,b=false|false]
DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
DEBUG - ConsumerProcessor              - Receiving HTTP request: POST
/example/ HTTP/1.1
Authorization: Basic c214OnNteA==
User-Agent: Jakarta Commons-HttpClient/3.1
Host: localhost:8192
Content-Length: 179


DEBUG - HttpComponent                  - Created correlation id:
ID:192.168.2.64-11a7656b905-17:8
DEBUG - DeliveryChannelImpl            - Send
ID:192.168.2.64-11a7656b905-17:8 in DeliveryChannel{servicemix-http}
WARN  - jetty                          - /example/
java.lang.IllegalStateException: Cannot write non xml faults for non soap
messages
        at
org.apache.servicemix.soap.marshalers.SoapWriter.writeSimpleMessage(SoapWriter.java:124)
        at
org.apache.servicemix.soap.marshalers.SoapWriter.write(SoapWriter.java:92)
        at
org.apache.servicemix.http.processors.ConsumerProcessor.sendFault(ConsumerProcessor.java:277)
        at
org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:176)
        at
org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:71)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
        at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
        at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
        at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:313)
        at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
        at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
        at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
        at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
DEBUG - JettyContextManager            - Dispatching job:
SCEP@15977142[d=true,io=1,w=true,b=false|false]
DEBUG - JettyContextManager            - Dispatching job:
SCEP@15977142[d=true,io=1,w=true,b=false|false]

here is the configuration:
1)security.xml:
<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
	xmlns:hello="http://servicemix.in2m.com/samples/http">

  <!-- Authentication service -->
  <sm:authenticationService id="authenticationService" />
  
  <!-- KeyStore manager -->
  <sm:keystoreManager id="keystoreManager">
    <sm:keystores>
      <sm:keystore name="default"
                   path="classpath:keystore.jks"
                   keystorePassword="servicemix"
                   keyPasswords="smx=smx" />
    </sm:keystores>
  </sm:keystoreManager>

  <!-- ServiceMix authorization map -->
  <sm:authorizationMap id="authorizationMap">
    <sm:authorizationEntries>
      <!--sm:authorizationEntry service="*:*" roles="*" /-->
	  <sm:authorizationEntry service="*:*" roles="dev" />
    </sm:authorizationEntries>
  </sm:authorizationMap>

</beans>

2)user-password.properties:

smx=smx
smx1=smx1

3)groups.properties:
admin=smx
dev=smx1
-- 
View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17771876.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to handle unauthorized user

Posted by Guillaume Nodet <gn...@gmail.com>.
Could you provide the log ebfore this error ? I'd like to see the
exchange and understand what happens.

On Wed, Jun 11, 2008 at 9:05 AM, pratibhaG <pr...@in2m.com> wrote:
>
> I have a user with username "smx" and password "smx".
> The user is athenticated but not authorized on the bus to use any service.
> When I make a request using this user, I get following error on servicemix
> logs:
>
> DEBUG - JAASAuthenticationService      - Authenticating 'smx' with 'smx'
> DEBUG - ConsumerProcessor              - Receiving HTTP request: POST
> /example/ HTTP/1.1
> Authorization: Basic c214OnNteA==
> User-Agent: Jakarta Commons-HttpClient/3.1
> Host: localhost:8192
> Content-Length: 179
>
>
> DEBUG - HttpComponent                  - Created correlation id:
> ID:192.168.2.64-11a7656b905-17:7
> DEBUG - DeliveryChannelImpl            - Send
> ID:192.168.2.64-11a7656b905-17:7 in DeliveryChannel{servicemix-http}
> WARN  - jetty                          - /example/
> java.lang.IllegalStateException: Cannot write non xml faults for non soap
> messages
>        at
> org.apache.servicemix.soap.marshalers.SoapWriter.writeSimpleMessage(SoapWriter.java:124)
>        at
> org.apache.servicemix.soap.marshalers.SoapWriter.write(SoapWriter.java:92)
>        at
> org.apache.servicemix.http.processors.ConsumerProcessor.sendFault(ConsumerProcessor.java:277)
>        at
> org.apache.servicemix.http.processors.ConsumerProcessor.process(ConsumerProcessor.java:176)
>        at
> org.apache.servicemix.http.HttpBridgeServlet.doPost(HttpBridgeServlet.java:71)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>        at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
>        at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>        at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>        at
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
>        at
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>        at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>        at org.mortbay.jetty.Server.handle(Server.java:313)
>        at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
>        at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
>        at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
>        at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
>
> Everything goes fine for the user who is both authenticated as well as
> authorized. Now how to handle this error when user is authenticated but not
> authorized.
>
> Pratibha
>
>
> --
> View this message in context: http://www.nabble.com/How-to-handle-unauthorized-user-tp17771342p17771342.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/