axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerhard presser <gpres...@groiss.com>
Subject Re: Wrong response when authentication fails with Rampart (not SOAP but HTML)
Date Wed, 16 Sep 2009 12:39:31 GMT

Hi!
I'm using Axis2 1.5 and Rampart 1.4 --> same problem :-(
regards,
Gerhard


Nunny wrote:
> 
> Hi Giuseppe,
>               Are you using Axis2 1.4.1 and  Rampart 1.3 ? Can you try
> with
> Rampart 1.4 ?
> 
> regards,
> Nandana
> 
> On Fri, Jul 3, 2009 at 4:51 PM, Giuseppe Gortan
> <superbeppe@gmail.com>wrote:
> 
>> Hi everybody.
>>
>> I have a problem with axis2 (1.4.1) and rampart (1.3).
>> I put a simple policy in services.xml [1] and I wrote a
>> PasswordHandler [2]. Everything works fine if user and password are
>> correct. When the user doesn't exist (getUser returns
>> UserNotFoundException), the authentication process (correctly) fails,
>> but returning a HTML error page [5] instead of a SOAP response
>> message. The servlet engine logs an error message coming from the Axis
>> Servlet [4], and the SOAP client, that uses a library generated by
>> WSDL2Java, logs the error "First Element must contain the local name,
>> Envelope , but found html" [3].
>>
>> I want to return to the client a custom SOAP error message if
>> authentication process fails. How can I do it?
>>
>> Thanks,
>>
>> Giuseppe
>>
>>
>> [1] Policy
>> <parameter name="InflowSecurity">
>>                        <action>
>>                                <items>UsernameToken</items>
>>                                <passwordCallbackClass>
>>                                        mypackage.myapp.PasswordHandler
>>                                </passwordCallbackClass>
>>                        </action>
>>        </parameter>
>>
>> [2] PasswordHandler
>> public class PasswordHandler implements CallbackHandler {
>>        public void handle(Callback[] callbacks) throws IOException,
>> UnsupportedCallbackException {
>>                for (int i = 0; i < callbacks.length; i++) {
>>                        if (callbacks[i] instanceof WSPasswordCallback) {
>>                            try{
>>                                        WSPasswordCallback pwcb =
>> (WSPasswordCallback) callbacks[i];
>>                                        String username =
>> pwcb.getIdentifer();
>>                                        String user = getUser(username);
>>                                        String password =
>> getPlainPassword(user);
>>
>>                                        int passwordType =
>> pwcb.getUsage();
>>                                        if (passwordType ==
>> WSPasswordCallback.USERNAME_TOKEN) {
>>                                               
>> pwcb.setPassword(password);
>>                                        } else {
>>                                                throw new
>> UnsupportedCallbackException(callbacks[i],
>> "Unrecognized Callback");
>>                                        }
>>                        } catch (UserNotFoundException e){
>>                                  throw new AxisFault("No user found",
>> e.getCause());
>>                       }
>>                }
>>        }
>> }
>>
>> [3] First Element must contain the local name, Envelope , but found html
>> org.apache.axis2.AxisFault: First Element must contain the local name,
>> Envelope , but found html
>>        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>>        at
>> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:90)
>>        at
>> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:353)
>>        at
>> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
>>        at
>> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
>>        at
>> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>>        at
>> mypackage.myapp.WebservicesStub.myRemoteWS(WebservicesStub.java:6642)
>>        at mypackage.myapp.client.Client.main(Client.java:63)
>> Caused by: org.apache.axiom.soap.SOAPProcessingException: First
>> Element must contain the local name, Envelope , but found html
>>        at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:251)
>>        at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:209)
>>        at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:191)
>>        at
>> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:172)
>>        at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:156)
>>        at
>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:105)
>>        at
>> org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:677)
>>        at
>> org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:182)
>>        at
>> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:112)
>>        at
>> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:88)
>>        ... 6 more
>>
>> [4] Error log
>> GRAVE: Servlet.service() for servlet AxisServlet threw exception
>> java.lang.NullPointerException
>>        at
>> org.apache.rampart.RampartMessageData.<init>(RampartMessageData.java:308)
>>        at org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
>>        at
>> org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
>>        at org.apache.axis2.engine.Phase.invoke(Phase.java:317)
>>        at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
>>        at
>> org.apache.axis2.engine.AxisEngine.sendFault(AxisEngine.java:520)
>>        at
>> org.apache.axis2.transport.http.AxisServlet.handleFault(AxisServlet.java:416)
>>        at
>> org.apache.axis2.transport.http.AxisServlet.processAxisFault(AxisServlet.java:379)
>>        at
>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:167)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>>
>> [5]
>> HTTP/1.1 500 Internal Server Error
>>
>> Server: Apache-Coyote/1.1
>>
>> Content-Type: text/html;charset=utf-8
>>
>> Content-Length: 2154
>>
>> Date: Fri, 03 Jul 2009 10:47:04 GMT
>>
>> Connection: close
>>
>>
>>
>> <html>
>>   <head>
>>      <title>Apache Tomcat/6.0.18 - Error report</title>
>>      <style>
>>         <!--H1
>>
>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
>> H2
>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
>> H3
>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
>> BODY
>> {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
>> B
>> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
>> P
>> {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
>> {color : black;}A.name {color : black;}HR {color :
>> #525D76;}--></style>
>>      </head>
>>      <body>
>>         <h1>HTTP Status 500 - </h1>
>>         <HR size="1" noshade="noshade">
>>            <p>
>>               type Exception report
>>            </p>
>>            <p>
>>               message
>>               <u></u>
>>            </p>
>>            <p>
>>               description
>>               <u>The server encountered an internal error () that
>> prevented it from fulfilling this request.</u>
>>            </p>
>>            <p>
>>               exception
>>               <pre>java.lang.NullPointerException
>> 
>> org.apache.rampart.RampartMessageData.&lt;init&gt;(RampartMessageData.java:308)
>> org.apache.rampart.MessageBuilder.build(MessageBuilder.java:61)
>> org.apache.rampart.handler.RampartSender.invoke(RampartSender.java:64)
>>  org.apache.axis2.engine.Phase.invoke(Phase.java:317)
>>  org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:264)
>>  org.apache.axis2.engine.AxisEngine.sendFault(AxisEngine.java:520)
>> org.apache.axis2.transport.http.AxisServlet.handleFault(AxisServlet.java:416)
>>
>> org.apache.axis2.transport.http.AxisServlet.processAxisFault(AxisServlet.java:379)
>>
>>  org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:167)
>>      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>>  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)</pre>
>>            </p>
>>            <p>
>>               note
>>               <u>The full stack trace of the root cause is available
>> in the Apache Tomcat/6.0.18 logs.</u>
>>            </p>
>>            <HR size="1" noshade="noshade">
>>               <h3>Apache Tomcat/6.0.18</h3>
>>            </body>
>>         </html>
>> --
>> «The phonograph has no commercial value at all.»
>>  Thomas Edison, American inventor, 1880s.
>>
> 
> 
> 
> -- 
> Nandana Mihindukulasooriya
> WSO2 inc.
> 
> http://nandana83.blogspot.com/
> http://www.wso2.org
> 
> 

-- 
View this message in context: http://www.nabble.com/Wrong-response-when-authentication-fails-with-Rampart-%28not-SOAP-but--HTML%29-tp24321586p25471523.html
Sent from the Axis - User mailing list archive at Nabble.com.


Mime
View raw message