[JBossWS] - Authorization failure .NET client to secured Webservices
by marcelvanvelzen
Hi,
I am sorry for this posting, since I think this has been asked many many times. I have read all the related topics and tried many things, but still I cannot make my .NET client connect to my JBoss 4.0.5GA Webservices. My Visual Basic 2005 .NET client gives the error 'Authorization failed'. When I use @PermitAll it works fine. I really hope somebody can help me, since I have an idea what to do next.
What have I done:
1) Specified @SecurityDomain("AthenaWS") in the Webservice and added @RolesAllowed("RegularUser") for all methods. The annotations of the class start with:
@WebService (name="ApplicationEndPoint", serviceName="Application", targetNamespace = "http://address:8080/athenaserver")
@SOAPBinding (style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@Stateless
@Remote(ApplicationRemote.class)
@RemoteBinding(jndiBinding = "/ejb3/ApplicationEndPoint")
@SecurityDomain("AthenaWS")
public class etc
2) Added the following text to JBOSS_HOME/server/default/conf/login-config.xml:
<!-- A template configuration for the AthenaWS web application (and transport layer!).
This defaults to the UsersRolesLoginModule the same as other and should be
changed to a stronger authentication mechanism as required.
-->
<application-policy name="AthenaWS">
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
<module-option name="usersProperties">props/athenaws-users.properties</module-option>
<module-option name="rolesProperties">props/athenaws-roles.properties</module-option>
<module-option name="unauthenticatedIdentity">anonymous</module-option>
<module-option name="hashEncoding">base64</module-option>
<!--
<module-option name="hashAlgorithm">MD5</module-option> (when basic works, I want to use digest authentication)
-->
</login-module>
</application-policy>
3) Placed athenaws-users.properties in the JBOSS_HOME/server/default/conf/props, this has the following contents:
velzm=secret
4) Placed athenaws-roles.properties in the JBOSS_HOME/server/default/conf/props, this has the following contents:
velzm=RegularUser
5) Downloaded Visual Basic 2005 Express Edition and SDK 2.0. I am using InfoPath 2007 but this cannot work with JBoss secured webservices directly, only using SharePoint Server this should be possible using UDC reading the documentation. However, I don't want this additional layer, so I am trying to make a work-a-round. I am using the tool wsdl.exe to generate a Visual Basic class for the webservice. Later when this works, I want to see if it possible to generate JavaScript code and embed this in the InfoPath form, so distribution no problem. With VB I must distribute the dll, which would suck.
6) Extended the generated VB webservice class, since preAuthenticate according to the topics gives problem. The VB code is:
Option Explicit On
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Public Class ApplicationWS
Inherits Application
Private nc As NetworkCredential = Nothing
Protected Overrides Function GetWebRequest(ByVal Uri As Uri) As System.Net.WebRequest
Dim request As System.Net.HttpWebRequest = MyBase.GetWebRequest(Uri)
If (MyBase.PreAuthenticate) Then
Dim nc As System.Net.NetworkCredential = MyBase.Credentials.GetCredential(Uri, "Basic")
Dim credBuf() As Byte = New System.Text.UTF8Encoding().GetBytes(nc.Domain + "\" + nc.UserName + ":" + nc.Password)
If Not credBuf Is Nothing Then
request.Headers("Authorization") = "Basic " + Convert.ToBase64String(credBuf)
End If
End If
GetWebRequest = request
End Function
Public Overloads Function getExchanges() As String()
Dim parms As New getExchanges
Return MyBase.getExchanges(parms)
End Function
Public Sub New()
MyBase.New()
MyBase.PreAuthenticate = False
End Sub
Public Sub New(ByVal domain As String, ByVal user As String, ByVal password As String)
MyBase.New()
MyBase.Credentials = New NetworkCredential(user, password, domain)
MyBase.PreAuthenticate = True
End Sub
End Class
7) Testing the stuff, by the following VB code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim application As New ApplicationWS("AthenaWS", "velzm", "secret")
Dim count As Integer
Try
Dim exchanges() As String = application.getExchanges()
For count = 0 To exchanges.Length - 1
Console.WriteLine(exchanges(count))
Next count
Console.Beep()
Catch ex As Exception
MsgBox("ex=" + ex.Message)
End Try
End Sub
This results in the message 'Authorization failure'. What's wrong ?
- In JBoss 4.0.5GA I don't see an annotation of validateUnauthorizedTrue, so I cannot set this to true.
Question which I have, is this option still necessary to set in JBoss 4.0.5GA ?
- JBOSS_HOME/server/default/logs/server.log shows the following line:
2006-12-02 09:18:20,062 DEBUG [jbossws.SOAPMessage] Incomming SOAPMessage
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<soap:Header/>
<soap:Body>
</soap:Body></soap:Envelope>
Question which I have, where is the authentication header ?? I have used the debugger for overridded function GetWebRequest and this is called correctly, but is it not sending the information ? Or is it sending the information, but not showing up in the log ?
I really need some suggestions, since I am stuck.
Thanks in advance,
Marcel van Velzen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990739#3990739
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990739
18 years, 1 month
[JBossWS] - Second parameter missing from generated WSDL
by cpmcda01
I have the following interface that I am exposing via web service:
| public interface StandardWebService {
| public PurchaseResult purchaseNew(PurchaseTransactionEntity e, Collection<PurchaseTransactionDetailEntity> c);
| public ReturnResult purchaseReturn(PurchaseTransactionEntity e, Collection<PurchaseTransactionDetailEntity> c);
| public VoidResult purchaseVoid(PurchaseTransactionEntity e);
| }
|
When I deploy my WAR file to JBoss, it creates the following WSDL. Notice that the purchaseNew and purchaseReturn methods only have the first parameter (PurchaseTransactionEntity). Perhaps it does not want to deal with collections as parameters? This is on JBoss 4.0.4GA with JBossWS 1.0.4GA and JBossEJB 3.0-rc9fd.
| <definitions name="StandardWebServiceService"
| targetNamespace="http://webservice.ejb.mc.foo.com/jaws"
| xmlns="http://schemas.xmlsoap.org/wsdl/"
| xmlns:ns1="http://sql.java/jaws"
| xmlns:ns2="http://entity.ejb.mc.foo.com/jaws"
| xmlns:ns3="http://result.ejb.mc.foo.com/jaws"
| xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
| xmlns:tns="http://webservice.ejb.mc.foo.com/jaws"
| xmlns:xsd="http://www.w3.org/2001/XMLSchema">
| <types>
| <schema elementFormDefault="qualified"
| targetNamespace="http://sql.java/jaws"
| xmlns="http://www.w3.org/2001/XMLSchema"
| xmlns:ns1="http://webservice.ejb.mc.foo.com/jaws"
| xmlns:ns2="http://entity.ejb.mc.foo.com/jaws"
| xmlns:ns4="http://result.ejb.mc.foo.com/jaws"
| xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
| xmlns:tns="http://sql.java/jaws"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
| <import namespace="http://result.ejb.mc.foo.com/jaws"/>
| <import namespace="http://entity.ejb.mc.foo.com/jaws"/>
| <import namespace="http://webservice.ejb.mc.foo.com/jaws"/>
| <complexType name="Date">
| <sequence>
| <element name="hours" type="int"/>
| <element name="minutes" type="int"/>
| <element name="seconds" type="int"/>
| <element name="time" type="long"/>
| </sequence>
| </complexType>
| <complexType name="Timestamp">
| <sequence>
| <element name="nanos" type="int"/>
| <element name="time" type="long"/>
| </sequence>
| </complexType>
| </schema>
| <schema elementFormDefault="qualified"
| targetNamespace="http://result.ejb.mc.foo.com/jaws"
| xmlns="http://www.w3.org/2001/XMLSchema"
| xmlns:ns1="http://webservice.ejb.mc.foo.com/jaws"
| xmlns:ns2="http://entity.ejb.mc.foo.com/jaws"
| xmlns:ns3="http://sql.java/jaws"
| xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
| xmlns:tns="http://result.ejb.mc.foo.com/jaws"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
| <import namespace="http://sql.java/jaws"/>
| <import namespace="http://entity.ejb.mc.foo.com/jaws"/>
| <import namespace="http://webservice.ejb.mc.foo.com/jaws"/>
| <complexType name="PurchaseResult">
| <sequence>
| <element name="failMsg" nillable="true" type="string"/>
| <element name="status" nillable="true" type="tns:ResultStatus"/>
| <element name="transaction" nillable="true"
| type="ns2:PurchaseTransactionEntity"/>
| </sequence>
| </complexType>
| <complexType name="ResultStatus">
| <sequence/>
| </complexType>
| <complexType name="ReturnResult">
| <sequence>
| <element name="status" nillable="true" type="tns:ResultStatus"/>
| <element name="transaction" nillable="true"
| type="ns2:PurchaseTransactionEntity"/>
| </sequence>
| </complexType>
| <complexType name="VoidResult">
| <sequence>
| <element name="purchaseTransactionEntity" nillable="true"
| type="ns2:PurchaseTransactionEntity"/>
| <element name="status" nillable="true" type="tns:ResultStatus"/>
| </sequence>
| </complexType>
| </schema>
| <schema elementFormDefault="qualified"
| targetNamespace="http://entity.ejb.mc.foo.com/jaws"
| xmlns="http://www.w3.org/2001/XMLSchema"
| xmlns:ns1="http://webservice.ejb.mc.foo.com/jaws"
| xmlns:ns3="http://sql.java/jaws"
| xmlns:ns4="http://result.ejb.mc.foo.com/jaws"
| xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
| xmlns:tns="http://entity.ejb.mc.foo.com/jaws"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
| <import namespace="http://sql.java/jaws"/>
| <import namespace="http://result.ejb.mc.foo.com/jaws"/>
| <import namespace="http://webservice.ejb.mc.foo.com/jaws"/>
| <complexType name="PurchaseTransactionEntity">
| <sequence>
| <element name="address1" nillable="true" type="string"/>
| <element name="address2" nillable="true" type="string"/>
| <element name="agentResultCd" nillable="true" type="string"/>
| <element name="birthDt" nillable="true" type="ns3:Date"/>
| <element name="city" nillable="true" type="string"/>
| <element name="comments" nillable="true" type="string"/>
| <element name="creationSourceCd" nillable="true" type="string"/>
| <element name="creationTs" nillable="true" type="ns3:Timestamp"/>
| <element name="creationUser" nillable="true" type="string"/>
| <element name="delayedInd" nillable="true" type="string"/>
| <element name="deniedInd" nillable="true" type="string"/>
| <element name="firstName" nillable="true" type="string"/>
| <element name="fraudInd" nillable="true" type="string"/>
| <element name="idExpDt" nillable="true" type="ns3:Date"/>
| <element name="idNbr" nillable="true" type="string"/>
| <element name="idStateCd" nillable="true" type="string"/>
| <element name="idTypeCd" nillable="true" type="string"/>
| <element name="lastChangeSourceCd" nillable="true" type="string"/>
| <element name="lastChangeTs" nillable="true" type="ns3:Timestamp"/>
| <element name="lastChangeUser" nillable="true" type="string"/>
| <element name="lastName" nillable="true" type="string"/>
| <element name="manualInd" nillable="true" type="string"/>
| <element name="middleName" nillable="true" type="string"/>
| <element name="pharmacySid" nillable="true" type="string"/>
| <element name="pharmacyTrxId" nillable="true" type="string"/>
| <element name="postalCd" nillable="true" type="string"/>
| <element name="processTime" nillable="true" type="int"/>
| <element name="sessionId" nillable="true" type="string"/>
| <element name="siteId" nillable="true" type="int"/>
| <element name="soldInd" nillable="true" type="string"/>
| <element name="stateCd" nillable="true" type="string"/>
| <element name="suffixName" nillable="true" type="string"/>
| <element name="suspicionCd" nillable="true" type="string"/>
| <element name="transactionCd" nillable="true" type="string"/>
| <element name="transactionDt" nillable="true" type="ns3:Timestamp"/>
| <element name="transactionSid" nillable="true" type="string"/>
| <element name="voidAuthUser" nillable="true" type="string"/>
| <element name="voidTs" nillable="true" type="ns3:Timestamp"/>
| <element name="voidUser" nillable="true" type="string"/>
| </sequence>
| </complexType>
| </schema>
| <schema elementFormDefault="qualified"
| targetNamespace="http://webservice.ejb.mc.foo.com/jaws"
| xmlns="http://www.w3.org/2001/XMLSchema"
| xmlns:ns2="http://entity.ejb.mc.foo.com/jaws"
| xmlns:ns3="http://sql.java/jaws"
| xmlns:ns4="http://result.ejb.mc.foo.com/jaws"
| xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"
| xmlns:tns="http://webservice.ejb.mc.foo.com/jaws"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
| <import namespace="http://sql.java/jaws"/>
| <import namespace="http://result.ejb.mc.foo.com/jaws"/>
| <import namespace="http://entity.ejb.mc.foo.com/jaws"/>
| <complexType name="purchaseNew">
| <sequence>
| <element name="PurchaseTransactionEntity_1" nillable="true" type="ns2:PurchaseTransactionEntity"/>
| </sequence>
| </complexType>
| <complexType name="purchaseNewResponse">
| <sequence>
| <element name="result" nillable="true" type="ns4:PurchaseResult"/>
| </sequence>
| </complexType>
| <complexType name="purchaseReturn">
| <sequence>
| <element name="PurchaseTransactionEntity_1" nillable="true" type="ns2:PurchaseTransactionEntity"/>
| </sequence>
| </complexType>
| <complexType name="purchaseReturnResponse">
| <sequence>
| <element name="result" nillable="true" type="ns4:ReturnResult"/>
| </sequence>
| </complexType>
| <complexType name="purchaseVoid">
| <sequence>
| <element name="PurchaseTransactionEntity_1" nillable="true" type="ns2:PurchaseTransactionEntity"/>
| </sequence>
| </complexType>
| <complexType name="purchaseVoidResponse">
| <sequence>
| <element name="result" nillable="true" type="ns4:VoidResult"/>
| </sequence>
| </complexType>
| <element name="purchaseNew" type="tns:purchaseNew"/>
| <element name="purchaseNewResponse" type="tns:purchaseNewResponse"/>
| <element name="purchaseReturn" type="tns:purchaseReturn"/>
| <element name="purchaseReturnResponse" type="tns:purchaseReturnResponse"/>
| <element name="purchaseVoid" type="tns:purchaseVoid"/>
| <element name="purchaseVoidResponse" type="tns:purchaseVoidResponse"/>
| </schema>
| </types>
| <message name="StandardWebService_purchaseReturn">
| <part element="tns:purchaseReturn" name="parameters"/>
| </message>
| <message name="StandardWebService_purchaseVoidResponse">
| <part element="tns:purchaseVoidResponse" name="result"/>
| </message>
| <message name="StandardWebService_purchaseReturnResponse">
| <part element="tns:purchaseReturnResponse" name="result"/>
| </message>
| <message name="StandardWebService_purchaseVoid">
| <part element="tns:purchaseVoid" name="parameters"/>
| </message>
| <message name="StandardWebService_purchaseNew">
| <part element="tns:purchaseNew" name="parameters"/>
| </message>
| <message name="StandardWebService_purchaseNewResponse">
| <part element="tns:purchaseNewResponse" name="result"/>
| </message>
| <portType name="StandardWebService">
| <operation name="purchaseNew">
| <input message="tns:StandardWebService_purchaseNew"/>
| <output message="tns:StandardWebService_purchaseNewResponse"/>
| </operation>
| <operation name="purchaseReturn">
| <input message="tns:StandardWebService_purchaseReturn"/>
| <output message="tns:StandardWebService_purchaseReturnResponse"/>
| </operation>
| <operation name="purchaseVoid">
| <input message="tns:StandardWebService_purchaseVoid"/>
| <output message="tns:StandardWebService_purchaseVoidResponse"/>
| </operation>
| </portType>
| <binding name="StandardWebServiceBinding" type="tns:StandardWebService">
| <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
| <operation name="purchaseNew">
| <soap:operation soapAction=""/>
| <input>
| <soap:body use="literal"/>
| </input>
| <output>
| <soap:body use="literal"/>
| </output>
| </operation>
| <operation name="purchaseReturn">
| <soap:operation soapAction=""/>
| <input>
| <soap:body use="literal"/>
| </input>
| <output>
| <soap:body use="literal"/>
| </output>
| </operation>
| <operation name="purchaseVoid">
| <soap:operation soapAction=""/>
| <input>
| <soap:body use="literal"/>
| </input>
| <output>
| <soap:body use="literal"/>
| </output>
| </operation>
| </binding>
| <service name="StandardWebServiceService">
| <port binding="tns:StandardWebServiceBinding" name="StandardWebServicePort">
| <soap:address location="http://10.11.20.18:8080/mcWS"/>
| </port>
| </service>
| </definitions>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990569#3990569
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3990569
18 years, 1 month